/* -1 don't continue, it's done */ int user_message_parse(struct user_list_t *user_list, char *buf, int fromsfd) { /* socket fd to whom the message should be send */ char *str_p; /* did user wrote command? */ if (buf[0]=='!') { /* list users connected to server */ if (strcmp(buf,"!ls\n")==0) { user_print(user_list, fromsfd); } if (strcmp(buf,"!logout\n")==0) { } return -1; } else if ((str_p = strstr(buf, str2))!=NULL) { /* length of nick*/ int length=str_p-buf; char name[MAXNAME+1]; memset(name,0,sizeof(name)); for (int i=0;i<length;i++) { name[i]=buf[i]; } /* name match */ struct user_t *p; if ((p=user_find_name(user_list, name))!=NULL) { return p->sfd; } else /* no name match */ { /* the message is for all users */ if (strcmp(name,"all")==0) { return 0; } else return -2; } } return -2; }
static void m_dump_user(char *arg) { struct user *uptr = NULL; if(arg) { if(chars_isdigit(*arg)) uptr = user_find_id(atoi(arg)); else uptr = user_find_name(arg); if(uptr == NULL) uptr = user_find_uid(arg); } user_dump(uptr); }