eNextState POP3_C_DNSFail(AsyncIO *IO) { pop3aggr *pMsg = (pop3aggr *)IO->Data; EVP3CCS_syslog(LOG_DEBUG, "POP3: %s\n", __FUNCTION__); StrBufPlain(IO->ErrMsg, CKEY(POP3C_ReadErrors[pMsg->State])); return FailAggregationRun(IO); }
void parse_args(int argc, char *argv[]) { int r; static struct option longOptions[] = { {"receive-cmd", required_argument, 0, 'v'}, {"send-cmd", required_argument, 0, 's'}, {"imap", required_argument, 0, 'I' }, {"omap", required_argument, 0, 'O' }, {"emap", required_argument, 0, 'E' }, {"escape", required_argument, 0, 'e'}, {"echo", no_argument, 0, 'c'}, {"noinit", no_argument, 0, 'i'}, {"noreset", no_argument, 0, 'r'}, {"nolock", no_argument, 0, 'l'}, {"flow", required_argument, 0, 'f'}, {"baud", required_argument, 0, 'b'}, {"parity", required_argument, 0, 'y'}, {"databits", required_argument, 0, 'd'}, {"stopbits", required_argument, 0, 'p'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; r = 0; while (1) { int optionIndex = 0; int c; int map; /* no default error messages printed. */ opterr = 0; c = getopt_long(argc, argv, "hirlcv:s:r:e:f:b:y:d:p:", longOptions, &optionIndex); if (c < 0) break; switch (c) { case 's': strncpy(opts.send_cmd, optarg, sizeof(opts.send_cmd)); opts.send_cmd[sizeof(opts.send_cmd) - 1] = '\0'; break; case 'v': strncpy(opts.receive_cmd, optarg, sizeof(opts.receive_cmd)); opts.receive_cmd[sizeof(opts.receive_cmd) - 1] = '\0'; break; case 'I': map = parse_map(optarg); if (map >= 0) opts.imap = map; else { fprintf(stderr, "Invalid --imap\n"); r = -1; } break; case 'O': map = parse_map(optarg); if (map >= 0) opts.omap = map; else { fprintf(stderr, "Invalid --omap\n"); r = -1; } break; case 'E': map = parse_map(optarg); if (map >= 0) opts.emap = map; else { fprintf(stderr, "Invalid --emap\n"); r = -1; } break; case 'c': opts.lecho = 1; break; case 'i': opts.noinit = 1; break; case 'r': opts.noreset = 1; break; case 'l': #if defined (UUCP_LOCK_DIR) || defined (USE_FLOCK) opts.nolock = 1; #endif break; case 'e': opts.escape = CKEY(optarg[0]); break; case 'f': switch (optarg[0]) { case 'X': case 'x': opts.flow = FC_XONXOFF; break; case 'H': case 'h': opts.flow = FC_RTSCTS; break; case 'N': case 'n': opts.flow = FC_NONE; break; default: fprintf(stderr, "Invalid --flow: %c\n", optarg[0]); r = -1; break; } break; case 'b': opts.baud = atoi(optarg); if ( opts.baud == 0 || ! term_baud_ok(opts.baud) ) { fprintf(stderr, "Invalid --baud: %d\n", opts.baud); r = -1; } break; case 'y': switch (optarg[0]) { case 'e': opts.parity = P_EVEN; break; case 'o': opts.parity = P_ODD; break; case 'n': opts.parity = P_NONE; break; default: fprintf(stderr, "Invalid --parity: %c\n", optarg[0]); r = -1; break; } break; case 'd': switch (optarg[0]) { case '5': opts.databits = 5; break; case '6': opts.databits = 6; break; case '7': opts.databits = 7; break; case '8': opts.databits = 8; break; default: fprintf(stderr, "Invalid --databits: %c\n", optarg[0]); r = -1; break; } break; case 'p': switch (optarg[0]) { case '1': opts.stopbits = 1; break; case '2': opts.stopbits = 2; break; default: fprintf(stderr, "Invalid --stopbits: %c\n", optarg[0]); r = -1; break; } break; case 'h': show_usage(argv[0]); exit(EXIT_SUCCESS); case '?': default: fprintf(stderr, "Unrecognized option(s)\n"); r = -1; break; } if ( r < 0 ) { fprintf(stderr, "Run with '--help'.\n"); exit(EXIT_FAILURE); } } /* while */ if ( (argc - optind) < 1) { fprintf(stderr, "No port given\n"); fprintf(stderr, "Run with '--help'.\n"); exit(EXIT_FAILURE); } strncpy(opts.port, argv[optind], sizeof(opts.port) - 1); opts.port[sizeof(opts.port) - 1] = '\0'; #ifndef NO_HELP printf("picocom v%s\n", VERSION_STR); printf("\n"); printf("port is : %s\n", opts.port); printf("flowcontrol : %s\n", flow_str[opts.flow]); printf("baudrate is : %d\n", opts.baud); printf("parity is : %s\n", parity_str[opts.parity]); printf("databits are : %d\n", opts.databits); printf("stopbits are : %d\n", opts.stopbits); printf("escape is : C-%c\n", KEYC(opts.escape)); printf("local echo is : %s\n", opts.lecho ? "yes" : "no"); printf("noinit is : %s\n", opts.noinit ? "yes" : "no"); printf("noreset is : %s\n", opts.noreset ? "yes" : "no"); #if defined (UUCP_LOCK_DIR) || defined (USE_FLOCK) printf("nolock is : %s\n", opts.nolock ? "yes" : "no"); #endif printf("send_cmd is : %s\n", (opts.send_cmd[0] == '\0') ? "disabled" : opts.send_cmd); printf("receive_cmd is : %s\n", (opts.receive_cmd[0] == '\0') ? "disabled" : opts.receive_cmd); printf("imap is : "); print_map(opts.imap); printf("omap is : "); print_map(opts.omap); printf("emap is : "); print_map(opts.emap); printf("\n"); #endif /* of NO_HELP */ }
static long parse_MimeHeaders(interesting_mime_headers *m, char** pcontent_start, char *content_end) { char buf[SIZ]; char header[SIZ]; long headerlen; char *ptr, *pch; int buflen = 0; int i; /* Learn interesting things from the headers */ ptr = *pcontent_start; *header = '\0'; headerlen = 0; do { ptr = memreadlinelen(ptr, buf, SIZ, &buflen); for (i = 0; i < buflen; ++i) { if (isspace(buf[i])) { buf[i] = ' '; } } if (!isspace(buf[0]) && (headerlen > 0)) { if (!strncasecmp(header, "Content-type:", 13)) { memcpy (m->b[content_type].Key, &header[13], headerlen - 12); m->b[content_type].Key[headerlen - 12] = '\0'; m->b[content_type].len = striplt (m->b[content_type].Key); m->b[content_type_name].len = extract_key(m->b[content_type_name].Key, CKEY(m->b[content_type]), HKEY("name"), '='); m->b[charset].len = extract_key(m->b[charset].Key, CKEY(m->b[content_type]), HKEY("charset"), '='); m->b[boundary].len = extract_key(m->b[boundary].Key, header, headerlen, HKEY("boundary"), '='); /* Deal with weird headers */ pch = strchr(m->b[content_type].Key, ' '); if (pch != NULL) { *pch = '\0'; m->b[content_type].len = m->b[content_type].Key - pch; } pch = strchr(m->b[content_type].Key, ';'); if (pch != NULL) { *pch = '\0'; m->b[content_type].len = m->b[content_type].Key - pch; } } else if (!strncasecmp(header, "Content-Disposition:", 20)) { memcpy (m->b[disposition].Key, &header[20], headerlen - 19); m->b[disposition].Key[headerlen - 19] = '\0'; m->b[disposition].len = striplt(m->b[disposition].Key); m->b[content_disposition_name].len = extract_key(m->b[content_disposition_name].Key, CKEY(m->b[disposition]), HKEY("name"), '='); m->b[filename].len = extract_key(m->b[filename].Key, CKEY(m->b[disposition]), HKEY("filename"), '='); pch = strchr(m->b[disposition].Key, ';'); if (pch != NULL) *pch = '\0'; m->b[disposition].len = striplt(m->b[disposition].Key); } else if (!strncasecmp(header, "Content-ID:", 11)) { memcpy(m->b[id].Key, &header[11], headerlen - 11); m->b[id].Key[headerlen - 11] = '\0'; striplt(m->b[id].Key); m->b[id].len = stripallbut(m->b[id].Key, '<', '>'); } else if (!strncasecmp(header, "Content-length: ", 15)) { char *clbuf; clbuf = &header[15]; while (isspace(*clbuf)) clbuf ++; m->content_length = (size_t) atol(clbuf); } else if (!strncasecmp(header, "Content-transfer-encoding: ", 26)) { memcpy(m->b[encoding].Key, &header[26], headerlen - 26); m->b[encoding].Key[headerlen - 26] = '\0'; m->b[encoding].len = striplt(m->b[encoding].Key); } *header = '\0'; headerlen = 0; } if ((headerlen + buflen + 2) < SIZ) { memcpy(&header[headerlen], buf, buflen); headerlen += buflen; header[headerlen] = '\0'; } if (ptr >= content_end) { return -1; } } while ((!IsEmptyStr(buf)) && (*ptr != 0)); m->is_multipart = m->b[boundary].len != 0; *pcontent_start = ptr; return 0; }
int omap; int emap; } opts = { .port = "", .baud = 9600, .flow = FC_NONE, .parity = P_NONE, .databits = 8, .stopbits = 1, .lecho = 0, .noinit = 0, .noreset = 0, #if defined (UUCP_LOCK_DIR) || defined (USE_FLOCK) .nolock = 0, #endif .escape = CKEY('a'), .send_cmd = "sz -vv", .receive_cmd = "rz -vv -E", .imap = M_I_DFL, .omap = M_O_DFL, .emap = M_E_DFL }; int sig_exit = 0; #define STO STDOUT_FILENO #define STI STDIN_FILENO int tty_fd; #ifndef TTY_Q_SZ