Revision: 5616 http://ipcop.svn.sourceforge.net/ipcop/?rev=5616&view=rev Author: dotzball Date: 2011-04-15 11:20:52 +0000 (Fri, 15 Apr 2011)
Log Message: ----------- Change fprint error output from stderr to stdout. So the webgui is able to show errors. Modified Paths: -------------- ipcop/trunk/src/misc-progs/emailhelper.c Modified: ipcop/trunk/src/misc-progs/emailhelper.c =================================================================== --- ipcop/trunk/src/misc-progs/emailhelper.c 2011-04-14 06:16:10 UTC (rev 5615) +++ ipcop/trunk/src/misc-progs/emailhelper.c 2011-04-15 11:20:52 UTC (rev 5616) @@ -129,12 +129,12 @@ int len = 0; len = strlen(optarg); if (len > STRING_SIZE - 1) { - fprintf(stderr, "Subject too long: %s\n", optarg); + fprintf(stdout, "Subject too long: %s\n", optarg); exit(EMAIL_ERR_SUBJECT); } if (strspn(optarg, LETTERS_NUMBERS "-_:.+, ") != len) { - fprintf(stderr, "Invalid character in subject (%s)\n", optarg); + fprintf(stdout, "Invalid character in subject (%s)\n", optarg); exit(EMAIL_ERR_SUBJECT); } opt_subject = strdup(optarg); @@ -159,35 +159,35 @@ case 'h': usage(argv[0], EMAIL_SUCCESS); default: - fprintf(stderr, "unknown option\n"); + fprintf(stdout, "unknown option\n"); usage(argv[0], EMAIL_ERR_ANY); } } verbose_printf(1, "Reading email settings ... \n"); if (read_kv_from_file(&kv, "/var/ipcop/email/settings") != SUCCESS) { - fprintf(stderr, "Cannot read email settings\n"); + fprintf(stdout, "Cannot read email settings\n"); exit(EMAIL_ERR_ANY); } strcpy(server, ""); verbose_printf(2, "Reading EMAIL_SERVER ... \n"); if (find_kv_default(kv, "EMAIL_SERVER", server) != SUCCESS) { - fprintf(stderr, "Cannot read EMAIL_SERVER\n"); + fprintf(stdout, "Cannot read EMAIL_SERVER\n"); exit(EMAIL_ERR_SERVER); } verbose_printf(2, "Validate EMAIL_SERVER ... \n"); if (!(strlen(server))) { - fprintf(stderr, "Email server cannot be empty\n"); + fprintf(stdout, "Email server cannot be empty\n"); exit(EMAIL_ERR_SERVER); } else if (strchr(server, ' ')) { - fprintf(stderr, "Email server cannot contain spaces\n"); + fprintf(stdout, "Email server cannot contain spaces\n"); exit(EMAIL_ERR_SERVER); } else if (strlen(server) != strspn(server, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.")) { - fprintf(stderr, "Email server contains non valid chars\n"); + fprintf(stdout, "Email server contains non valid chars\n"); exit(EMAIL_ERR_SERVER); } @@ -195,17 +195,17 @@ strcpy(opt_port, ""); verbose_printf(2, "Reading EMAIL_SERVER_PORT ... \n"); if (find_kv_default(kv, "EMAIL_SERVER_PORT", opt_port) != SUCCESS) { - fprintf(stderr, "Cannot read EMAIL_SERVER_PORT\n"); + fprintf(stdout, "Cannot read EMAIL_SERVER_PORT\n"); exit(EMAIL_ERR_PORT); } verbose_printf(2, "Validate EMAIL_SERVER_PORT ... \n"); if (strchr(opt_port, ' ')) { - fprintf(stderr, "Email server port cannot contain spaces\n"); + fprintf(stdout, "Email server port cannot contain spaces\n"); exit(EMAIL_ERR_PORT); } else if (strlen(opt_port) != strspn(opt_port, NUMBERS)) { - fprintf(stderr, "Email server port contains non valid chars\n"); + fprintf(stdout, "Email server port contains non valid chars\n"); exit(EMAIL_ERR_PORT); } else if (strlen(opt_port)) { @@ -221,17 +221,17 @@ strcpy(opt_user, ""); verbose_printf(2, "Reading EMAIL_USR ... \n"); if (find_kv_default(kv, "EMAIL_USR", opt_user) != SUCCESS) { - fprintf(stderr, "Cannot read EMAIL_USR\n"); + fprintf(stdout, "Cannot read EMAIL_USR\n"); exit(EMAIL_ERR_USR); } verbose_printf(2, "Validate EMAIL_USR ... \n"); if (strchr(opt_user, ' ')) { - fprintf(stderr, "Username cannot contain spaces\n"); + fprintf(stdout, "Username cannot contain spaces\n"); exit(EMAIL_ERR_USR); } else if (strlen(opt_user) != strspn(opt_user, LETTERS_NUMBERS "-_.@")) { - fprintf(stderr, "Username contains non valid chars\n"); + fprintf(stdout, "Username contains non valid chars\n"); exit(EMAIL_ERR_USR); } else if (strlen(opt_user)) { @@ -247,17 +247,17 @@ strcpy(opt_password, ""); verbose_printf(2, "Reading EMAIL_PW ... \n"); if (find_kv_default(kv, "EMAIL_PW", opt_password) != SUCCESS) { - fprintf(stderr, "Cannot read EMAIL_PW\n"); + fprintf(stdout, "Cannot read EMAIL_PW\n"); exit(EMAIL_ERR_PW); } verbose_printf(2, "Validate EMAIL_PW ... \n"); if (strchr(opt_password, ' ')) { - fprintf(stderr, "Password cannot contain spaces\n"); + fprintf(stdout, "Password cannot contain spaces\n"); exit(EMAIL_ERR_PW); } else if (strchr(opt_password, '"') || strstr(opt_password, "'")) { - fprintf(stderr, "Password cannot contain single or double quotes\n"); + fprintf(stdout, "Password cannot contain single or double quotes\n"); exit(EMAIL_ERR_PW); } else if (strlen(opt_password)) { @@ -273,21 +273,21 @@ strcpy(from, ""); verbose_printf(2, "Reading EMAIL_FROM ... \n"); if (find_kv_default(kv, "EMAIL_FROM", from) != SUCCESS) { - fprintf(stderr, "Cannot read EMAIL_FROM\n"); + fprintf(stdout, "Cannot read EMAIL_FROM\n"); exit(EMAIL_ERR_FROM); } verbose_printf(2, "Validate EMAIL_FROM ... \n"); if (!(strlen(from))) { - fprintf(stderr, "From email cannot be empty\n"); + fprintf(stdout, "From email cannot be empty\n"); exit(EMAIL_ERR_FROM); } else if (strchr(from, ' ')) { - fprintf(stderr, "From email cannot contain spaces\n"); + fprintf(stdout, "From email cannot contain spaces\n"); exit(EMAIL_ERR_FROM); } else if (strlen(from) != strspn(from, LETTERS_NUMBERS "-_.@")) { - fprintf(stderr, "From email contains non valid chars\n"); + fprintf(stdout, "From email contains non valid chars\n"); exit(EMAIL_ERR_FROM); } @@ -295,28 +295,28 @@ strcpy(to, ""); verbose_printf(2, "Reading EMAIL_TO ... \n"); if (find_kv_default(kv, "EMAIL_TO", to) != SUCCESS) { - fprintf(stderr, "Cannot read EMAIL_TO\n"); + fprintf(stdout, "Cannot read EMAIL_TO\n"); exit(EMAIL_ERR_TO); } verbose_printf(2, "Validate EMAIL_TO ... \n"); if (!(strlen(to))) { - fprintf(stderr, "To email cannot be empty\n"); + fprintf(stdout, "To email cannot be empty\n"); exit(EMAIL_ERR_TO); } else if (strchr(to, ' ')) { - fprintf(stderr, "To email cannot contain spaces\n"); + fprintf(stdout, "To email cannot contain spaces\n"); exit(EMAIL_ERR_TO); } else if (strlen(to) != strspn(to, LETTERS_NUMBERS "-_.@")) { - fprintf(stderr, "To email contains non valid chars\n"); + fprintf(stdout, "To email contains non valid chars\n"); exit(EMAIL_ERR_TO); } verbose_printf(1, "Reading main settings ... \n"); if (read_kv_from_file(&main_kv, "/var/ipcop/main/settings") != SUCCESS) { - fprintf(stderr, "Cannot read main settings\n"); + fprintf(stdout, "Cannot read main settings\n"); exit(EMAIL_ERR_ANY); } @@ -324,7 +324,7 @@ strcpy(hostname, ""); verbose_printf(2, "Reading HOSTNAME ... \n"); if (find_kv_default(main_kv, "HOSTNAME", hostname) != SUCCESS) { - fprintf(stderr, "Cannot read HOSTNAME\n"); + fprintf(stdout, "Cannot read HOSTNAME\n"); exit(EMAIL_ERR_HOSTNAME); } @@ -332,7 +332,7 @@ strcpy(domainname, ""); verbose_printf(2, "Reading DOMAINNAME ... \n"); if (find_kv_default(main_kv, "DOMAINNAME", domainname) != SUCCESS) { - fprintf(stderr, "Cannot read DOMAINNAME\n"); + fprintf(stdout, "Cannot read DOMAINNAME\n"); exit(EMAIL_ERR_DOMAINNAME); } @@ -369,7 +369,7 @@ verbose_printf(2, "sed: %s\n", sed); rc = safe_system(sed); if (rc) { - fprintf(stderr, "Couldn't replace placeholders in messagefile: %d\n", rc); + fprintf(stdout, "Couldn't replace placeholders in messagefile: %d\n", rc); exit(EMAIL_ERR_SED); } } @@ -401,7 +401,7 @@ verbose_printf(2, "Command: %s\n", command); rc = safe_system(command); if (rc) { - fprintf(stderr, "Couldn't send Email, sendEmail exitcode: %d\n", rc); + fprintf(stdout, "Couldn't send Email, sendEmail exitcode: %d\n", rc); exit(EMAIL_ERR_SENDEMAIL); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev _______________________________________________ Ipcop-svn mailing list Ipcop-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ipcop-svn