|
|
@@ -45,7 +45,8 @@ int do_cmd_quit(char *);
|
|
|
int do_cmd_ls(char *);
|
|
|
int do_cmd_ls_bh(struct vcc_request *);
|
|
|
|
|
|
-extern int pid;
|
|
|
+int read_msg(struct vcc_request *);
|
|
|
+
|
|
|
extern char usrname[];
|
|
|
|
|
|
int get_users(void);
|
|
|
@@ -61,8 +62,6 @@ struct cmdtable {
|
|
|
{ NULL, NULL, NULL }
|
|
|
};
|
|
|
|
|
|
-void *bh_list[] = {do_cmd_ls_bh};
|
|
|
-
|
|
|
|
|
|
int do_cmd(char *s) {
|
|
|
struct cmdtable *t;
|
|
|
@@ -77,25 +76,6 @@ int do_cmd(char *s) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-/* bottom half */
|
|
|
-
|
|
|
-int do_cmd_bh(struct vcc_request *req) {
|
|
|
- int i;
|
|
|
- int (* fn) (struct vcc_request *);
|
|
|
-
|
|
|
- for (i = 0; bh_list[i]; i++)
|
|
|
- if (!(fn = bh_list[i])(req)) {
|
|
|
- pretty_prompt(usrname);
|
|
|
-
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- fprintf(stderr, "--- unexpected bh\n");
|
|
|
-
|
|
|
- return 1;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
int do_cmd_help(char *s) {
|
|
|
struct cmdtable *t;
|
|
|
|
|
|
@@ -114,28 +94,26 @@ int do_cmd_quit(char *s) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-int do_cmd_ls_bh(struct vcc_request *req) {
|
|
|
- int i, n = ntohl(req->uid);
|
|
|
+int do_cmd_ls(char *s) {
|
|
|
+ struct vcc_request req;
|
|
|
+ int i, n;
|
|
|
+
|
|
|
+ get_users();
|
|
|
+
|
|
|
+ read_msg(&req);
|
|
|
+ n = ntohl(req.uid);
|
|
|
|
|
|
/* clear current line */
|
|
|
- printf("\033[2K\r");
|
|
|
|
|
|
- if (unlikely(ntohl(req->reqtype) != REQ_CTL_USRS)) {
|
|
|
+ if (unlikely(ntohl(req.reqtype) != REQ_CTL_USRS)) {
|
|
|
fprintf(stderr, "--- do_cmd_ls_bh: bad package. \n");
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
- printf("%s\n", req->msg + i * USRNAME_SIZE);
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
+ printf("%s\n", req.msg + i * USRNAME_SIZE);
|
|
|
|
|
|
-int do_cmd_ls(char *s) {
|
|
|
- get_users();
|
|
|
-
|
|
|
return 0;
|
|
|
}
|
|
|
|