extern int handle_mail_command(t_connection * c, char const * text) { if (!prefs_get_mail_support()) { message_send_text(c,message_type_error,c,"This server has NO mail support."); return -1; } std::istringstream istr(text); std::string token; /* stkip "/mail" */ istr >> token; /* get the mail function */ token.clear(); istr >> token; switch (identify_mail_function(token.c_str())) { case MAIL_FUNC_SEND: mail_func_send(c, istr); break; case MAIL_FUNC_READ: mail_func_read(c, istr); break; case MAIL_FUNC_DELETE: mail_func_delete(c, istr); break; case MAIL_FUNC_HELP: message_send_text(c, message_type_info, c, "The mail command supports the following patterns."); mail_usage(c); break; default: message_send_text(c, message_type_error, c, "The command its incorrect. Use one of the following patterns."); mail_usage(c); } return 0; }
extern int handle_mail_command(t_connection * c, char const * text) { unsigned int i,j; char comm[MAX_FUNC_LEN]; if (!prefs_get_mail_support()) { message_send_text(c,message_type_error,c,"This server has NO mail support."); return -1; } for (i=0; text[i]!=' ' && text[i]!='\0'; i++); /* skip /mail command */ for (; text[i]==' '; i++); /* skip any spaces after it */ for (j=0; text[i]!=' ' && text[i]!='\0' && j<sizeof(comm)-1; i++) /* get function */ if (j<sizeof(comm)-1) comm[j++] = text[i]; comm[j] = '\0'; switch (identify_mail_function(comm)) { case MAIL_FUNC_SEND: mail_func_send(c,text+i); break; case MAIL_FUNC_READ: mail_func_read(c,text+i); break; case MAIL_FUNC_DELETE: mail_func_delete(c,text+i); break; case MAIL_FUNC_HELP: message_send_text(c,message_type_info,c,"The mail command supports the following patterns."); mail_usage(c); break; default: message_send_text(c,message_type_error,c,"The command its incorrect. Use one of the following patterns."); mail_usage(c); } return 0; }