// move backwards a word int back_word(int big_word) { int c, cpos = inputline_pos; if (inputline[cpos-1] == ' ' ) cpos--; while (cpos) if ((c = inputline[--cpos]) && c == ' ' ) return cpos+1; else if ( istext( inputline [cpos] ) && ! istext( inputline[cpos - 1] ) && ! big_word ) return cpos; else if ( ! istext( inputline [cpos] ) && istext( inputline[cpos - 1] ) && ! big_word ) return cpos; return cpos; }
int main(void) { int mode; unsigned char old[MINTEXT - 1]; int c; mode = 0; while ((c = getchar()) != EOF) { if (isbinary(c)) { if (mode == 0) putchar('\n'); mode = MINTEXT; } else { if (mode > 0) { if (istext(c)) { mode--; if (mode == 0) { int j; for (j = 0; j < MINTEXT-1; j++) putchar(old[j]); putchar(c); } else old[MINTEXT - mode - 1] = c; } else mode = MINTEXT; } else putchar(c); } } if (mode == 0) putchar('\n'); return 0; }
commandstruct::commandstruct(guidtype gid, indx tgid, indx grp, num64 val_b, num64 val_s, guidtype clid, tagtype tp) { guid_ = static_cast<unum64> (gid); tagid_ = static_cast<num64> (tgid); type(tp); clientid(clid); executed(false); group(grp); value_before<num64 > (val_b); value_set<num64 > (val_s); istext(false); }
VOID hndl_spbut(WORD ob) { BYTE *pstr; WORD isok; WORD i, j, k, remvd_1st, isgrafic; WORD exists; BYTE dir[ 80 ]; BYTE new_wc[ 14 ]; BYTE new_file[ 14 ]; BYTE dir_wc[ 80 ]; if ( ob == ADDNAME ) { strcpy(&gl_fname[0], ""); fsel_input(ADDR(&gl_fspec[0]), ADDR(&gl_fname[0]), &isok); strcpy( dir_wc, gl_fspec ); strcpy( new_file, gl_fname ); splt_dir( dir_wc, dir, new_wc ); exists = file_exists( dir, new_file ); if ( exists ) { if ( (isok) && (gl_fname[0]) && (gl_fspec[0]) ) { strcpy(&gl_fspol[0], &gl_fspec[0]); pstr = &gl_fspol[0]; while (*pstr) pstr++; pstr--; while ( (*pstr) && (*pstr != '\\') && (*pstr != ':') ) pstr--; if (*pstr) pstr++; strcpy(pstr, &gl_fname[0]); if ( istext( &gl_fname[0] ) ) hndl_spmsg((WORD)strlen(&gl_fspol[0]), (LONG)ADDR(&gl_fspol[0]), 1, FALSE, 0); else { form_alert(1, ADDR("[1][The Print Spooler is only able to|\ directly print text files. If you wish|\ to print a graphic file in background,|\ go to the OUTPUT application, and select|\ the Print in Background option.][ OK ]") ); } } }
commandstruct::commandstruct(guidtype gid, indx tgid, indx grp, const std::string& vl, guidtype clid) { guid_ = static_cast<unum64> (gid); tagid_ = static_cast<num64> (tgid); clientid(clid); type(TYPE_TEXT); executed(false); group(grp); value_before<num64 > (0); value_set<num64 > (0); strvalue(vl); istext(true); }
void process_modules(int mods_count, DWORD mods_addr) { DWORD i, j; struct read_funcs rf; struct bin_format *binfmt; char *command_line; char *args; /* Initialize the Modules Pseudo-FS... */ modfs_init(&kf, mods_addr, mods_count); /* Now module #n is accesible as file n... */ /* kf.file_read = mod_read; kf.file_seek = mod_seek; */ kf.mem_alloc = mem_get; kf.mem_alloc_region = mem_get_region; kf.mem_free = mem_free; kf.message = message; kf.log = fd32_log_printf; kf.error = message; kf.get_dll_table = get_dll_table; kf.add_dll_table = add_dll_table; kf.seek_set = 0; kf.seek_cur = 1; /* Get the binary format object table, ending with NULL name */ binfmt = fd32_get_binfmt(); for (i = 0; i < mods_count; i++) { #ifdef __MOD_DEBUG__ fd32_log_printf("[BOOT] Processing module #%d\n", i); #endif message("Processing module #%d", (int)i); /* Pseudo-FS open */ modfs_open(mods_addr, i); command_line = module_cl(mods_addr, i); /* Reset the file status in kf */ kf.file_offset = 0; for (args = command_line; ; args++) { if (*args == 0) { args = NULL; break; } else if (*args == ' ') { *args++ = 0; break; } } message(": %s\n", command_line); if (command_line[0] == '(' && isalpha(command_line[1]) && command_line[2] == 'd' && isdigit(command_line[3])) { /* TODO: move out the DOS drive name conversion */ if (command_line[4] == ',' && isdigit(command_line[5]) && command_line[6] == ')') { /* (?dN,N) */ command_line[3] += 'a'-'0'; command_line[4] = command_line[5]+1; command_line[5] = '\0'; command_line[5] = fd32_get_drive_letter(command_line+1); command_line[6] = ':'; command_line += 5; } else if (command_line[4] == ')') { /* (?dN) */ command_line[4] = '\0'; command_line[3] = fd32_get_drive_letter(command_line+1); command_line[4] = ':'; command_line += 3; } } /* Load different modules in various binary format */ for (j = 0; binfmt[j].name != NULL; j++) { if (binfmt[j].check(&kf, i, &rf)) { binfmt[j].exec(&kf, i, &rf, command_line, args); break; } else { fd32_log_printf("[MOD] Not '%s' format\n", binfmt[j].name); } /* p->file_seek(file, p->file_offset, p->seek_set); */ } if (binfmt[j].name == NULL && istext(&kf, i)) process_ascii_module(&kf, i); mem_release_module(mods_addr, i, mods_count); } }
int MyRequest::Lexer(char *buf, int length) { int consumed = 0; if(length == 0) { valid = methodValid && urlValid && httpVersionValid; if(data.size() == contentLength) done = lexerState != LEXER_init; return 0; } if(parserState == PARSER_body) { consumed = AppendData(buf, length); return consumed; } for(int i = 0; i < length; i++, consumed++) { if(parserState == PARSER_body) { consumed += AppendData(buf + i, length - i); break; } char ch = buf[i]; rawHeader.push_back(ch); again: if(parserState == PARSER_body) { consumed += AppendData(buf + i, length - i); break; } if(lexerState > LEXER_error) { aborted = true; break; } switch(lexerState) { case LEXER_init: if((isctl(ch) || isseparator(ch) || ch == ' ' || ch == '\t') && !lexerToken.empty()) { ProcessTokenIfAvailable(); goto again; } if(ch == '\r') lexerState = LEXER_cr_read; else if(ch == '\n') ProcessLF(); else if(opaqueEnabled) { lexerOpaqueString.clear(); lexerState = LEXER_opaque; goto again; } else if(parseURLEnabled && !isspace(ch)) { lexerUrl.clear(); lexerState = LEXER_url; goto again; } else if(ch == '"' && quotedStringsEnabled) { lexerQuotedString.clear(); lexerState = LEXER_quoted_string; } else if(ch == '(' && commentsEnabled) { lexerComment.clear(); lexerComment.push_back(ch); lexerState = LEXER_comment; lexerCommentNesting = 1; } else if(ch == ' ' || ch == '\t') lexerState = LEXER_LWS_read; else if(isseparator(ch)) ProcessSeparator(ch); else if(!isctl(ch)) lexerToken.push_back(ch); else lexerState = LEXER_token_text_error; break; case LEXER_opaque: ProcessTokenIfAvailable(); if(ch == '\r') { if(foldingEnabled) lexerState = LEXER_opaque_cr_read; else { ProcessOpaque(lexerOpaqueString); lexerState = LEXER_init; goto again; } } else lexerOpaqueString.push_back(ch); break; case LEXER_opaque_cr_read: ProcessTokenIfAvailable(); if(ch == '\n') lexerState = LEXER_opaque_newline_read; else { ProcessOpaque(lexerOpaqueString); lexerState = LEXER_init; goto again; } break; case LEXER_opaque_newline_read: if(ch == ' ' || ch == '\t') { lexerOpaqueString.push_back(' '); lexerState = LEXER_opaque; } else { ProcessOpaque(lexerOpaqueString); ProcessNewline(); lexerState = LEXER_init; goto again; } break; case LEXER_url: ProcessTokenIfAvailable(); if(isspace(ch)) { ProcessURL(lexerUrl); lexerState = LEXER_init; goto again; } else { if(ch == '%') lexerState = LEXER_url_encoded_1; else if(ch == '+') lexerUrl.push_back(' '); else lexerUrl.push_back(ch); } break; case LEXER_url_encoded_1: if(ch == '%') { lexerUrl.push_back('%'); lexerState = LEXER_url; } else if(isxdigit(ch)) { lexerTmpHex[0] = ch; lexerTmpHex[2] = '\0'; lexerState = LEXER_url_encoded_2; } else lexerState = LEXER_url_error; break; case LEXER_url_encoded_2: if(isxdigit(ch)) { lexerTmpHex[1] = ch; char newch = strtol(lexerTmpHex, NULL, 16); lexerUrl.push_back(newch); lexerState = LEXER_url; } else lexerState = LEXER_url_error; break; case LEXER_comment: ProcessTokenIfAvailable(); if(ch == '\\') lexerState = LEXER_quoted_pair_comment; else if(ch == '(') { lexerCommentNesting++; lexerComment.push_back(ch); } else if(ch == ')') { lexerCommentNesting--; lexerComment.push_back(ch); if(lexerCommentNesting == 0) { ProcessComment(lexerComment); lexerState = LEXER_init; } } else if(istext(ch)) { lexerComment.push_back(ch); } else lexerState = LEXER_comment_text_error; break; case LEXER_quoted_pair_comment: ProcessTokenIfAvailable(); lexerComment.push_back(ch); lexerState = LEXER_comment; break; case LEXER_quoted_string: ProcessTokenIfAvailable(); if(ch == '\\') lexerState = LEXER_quoted_pair; else if(ch == '"') { ProcessQuotedString(lexerQuotedString); lexerState = LEXER_init; } else if(istext(ch)) { lexerQuotedString.push_back(ch); } else lexerState = LEXER_quoted_string_text_error; break; case LEXER_quoted_pair: ProcessTokenIfAvailable(); lexerQuotedString.push_back(ch); lexerState = LEXER_quoted_string; break; case LEXER_cr_read: ProcessTokenIfAvailable(); if(ch == '\n') { if(foldingEnabled) lexerState = LEXER_newline_read; else { ProcessNewline(); lexerState = LEXER_init; } } else { ProcessCR(); lexerState = LEXER_init; goto again; } break; case LEXER_newline_read: // LWS folding state ProcessTokenIfAvailable(); if(ch == ' ' || ch == '\t') lexerState = LEXER_LWS_read; else { ProcessNewline(); lexerState = LEXER_init; goto again; } break; case LEXER_LWS_read: // partial LWS ProcessTokenIfAvailable(); if(ch == '\r') lexerState = LEXER_LWS_cr_read; else if(ch != ' ' && ch != '\t') { lexerState = LEXER_init; ProcessLWS(); goto again; } break; case LEXER_LWS_cr_read: ProcessTokenIfAvailable(); if(ch == '\n') { if(foldingEnabled) lexerState = LEXER_LWS_newline_read; else { ProcessLWS(); ProcessNewline(); lexerState = LEXER_init; } } else { ProcessCR(); lexerState = LEXER_init; goto again; } break; case LEXER_LWS_newline_read: ProcessTokenIfAvailable(); if(ch == ' ' || ch == '\t') lexerState = LEXER_LWS_read; else { ProcessLWS(); ProcessNewline(); lexerState = LEXER_init; goto again; } break; } } if(parserState == PARSER_body) { valid = methodValid && urlValid && httpVersionValid; if(data.size() == contentLength) done = true; } return consumed; }
void commandstruct::reset_commandstruct(const std::string& vl, guidtype clid) { istext(true); strvalue(vl); if (clid != NULL_CLIENT) clientid(clid); executed(false); }
void commandstruct::reset_commandstruct(num64 val_s, guidtype clid) { value_set<num64 > (val_s); istext(false); if (clid != NULL_CLIENT) clientid(clid); executed(false); }
void iprofile() { char sbuf[1000]; nialptr z; FILE *prf = STDOUT; int c1, c2; int i; double real_total_time = 0; double profile_duration_time; int NMWIDTH = 30; /* grab the argument */ z = apop(); if (newprofile) { buildfault("no profile available"); freeup(z); return; } /* handle input argument */ if (kind(z) == phrasetype) { apush(z); istring(); z = apop(); } if (tally(z) != 0) { if (!istext(z)) { buildfault("profile file name arg is not text"); freeup(z); return; } else { prf = openfile(pfirstchar(z), 'w', 't'); if (prf == OPENFAILED) { buildfault("unable to open specified file to write profile to"); freeup(z); return; /* exit_cover(NC_PROFILE_FILE_W); removed Nov 22/95 because this * cleared profile information */ } } } freeup(z); /* If profiling is still on, then turn it off */ if (profile == true) { apush(createbool(0)); isetprofile(); apop(); } #ifndef OLD_BUILD_SYMBOL_TABLE if (symtab) free_symtab(); symtab = NULL; build_symbol_table(); #endif profile_duration_time = (calltree->total_time); for (i = 0;i <calltree->num_children;i++) { real_total_time += calltree->children[i]->total_time; } /* traverse the call tree placing nodes in the symbol table entries */ if (!traversed) { traverse_tree(calltree); traversed = true; } /* generate the output and place it in the output file or stdout */ /* if a filename has been specified then write that out */ if (tally(z)) { sprintf(sbuf,"Profile output file: \"%s\"\n\n",pfirstchar(z)); writechars(prf, sbuf, strlen(sbuf), false); } sprintf(sbuf, "\nTotal execution time of profile session: \t%f\n", profile_duration_time); writechars(prf, sbuf, strlen(sbuf), false); sprintf(sbuf, "Total execution time in top level calls: \t%f\n\n",real_total_time); writechars(prf, sbuf, strlen(sbuf), false); /* header line for all data */ sprintf(sbuf, "op name[.tr arg] calls[rec] "); writechars(prf, sbuf, strlen(sbuf), false); sprintf(sbuf, "time time/call %% time\n"); writechars(prf, sbuf, strlen(sbuf), false); for (c1 = 0; c1 < symtabsize; c1++) { if ((symtab[c1]->num_locs > 0) || (symtab[c1]->num_rcalls > 0)) { double totaloptime = 0; int totalopcalls = 0; int totalropcalls; char *tmp; for (c2 = 0; c2 < symtab[c1]->num_locs; c2++) { if (symtab[c1]->id != symtab[c1]->locations[c2]->parent->opid) /* omit adding calls and time for direct recursions */ { totaloptime += symtab[c1]->locations[c2]->total_time; totalopcalls += symtab[c1]->locations[c2]->total_calls; } } totalropcalls = symtab[c1]->num_rcalls; sprintf(sbuf, "%s%5d", (tmp = padright(NMWIDTH, (char *) symtab[c1]->name)), totalopcalls); writechars(prf, sbuf, strlen(sbuf), false); free(tmp); if (totalropcalls != 0) { sprintf(sbuf, "[%5d]", totalropcalls); writechars(prf, sbuf, strlen(sbuf), false); } else { sprintf(sbuf, " "); writechars(prf, sbuf, strlen(sbuf), false); } /* details for each definition */ sprintf(sbuf, "%8.2f %8.4f %8.1f%s\n", totaloptime, (totaloptime / totalopcalls), 100 * (totaloptime / real_total_time), ((symtab[c1]->toplevel_call == true)?"<":"")); writechars(prf, sbuf, strlen(sbuf), false); { struct node **chlist; int c, used; char tname[40]; chlist = merge_children(symtab[c1], &used); for (c = 0; c < used; c++) { char *tmp; if (chlist[c]->opid == symtab[c1]->id) /* recursions only counted */ break; strcpy(tname, num_to_name(chlist[c]->opid)); /* details for each definition it calls */ if (chlist[c]->total_time > 0.0) sprintf(sbuf, " %s%5d %8.2f %8.4f %8.2f\n", (tmp = padright(NMWIDTH - 1, tname)), chlist[c]->total_calls, chlist[c]->total_time, chlist[c]->total_time / chlist[c]->total_calls, 100 * (chlist[c]->total_time / totaloptime)); else sprintf(sbuf, " %s%5d %8.2f %8.4f %8.2f\n", (tmp = padright(NMWIDTH - 1, tname)), chlist[c]->total_calls, chlist[c]->total_time, 0.0, 0.0); writechars(prf, sbuf, strlen(sbuf), false); free(tmp); } free_merge_list(chlist, used); } sprintf(sbuf, "\n"); writechars(prf, sbuf, strlen(sbuf), false); } } if (prf != STDOUT) closefile(prf); apush(Nullexpr); return; }
/* Send mail - High level sending routine */ void sendmail(int argc, char **argv) { char **args; char *tp, *zp; char *buf = NULL; size_t bufsize = 0; char last1c; FILE *input; struct stat sbuf; int aret; int i, n; int oldn = 1; int ttyf = 0; int pushrest = 0; int hdrtyp = 0; int ctf = FALSE; int binflg = 0; long count = 0L; struct tm *bp; struct hdrs *hptr; static char pn[] = "sendmail"; reciplist list; buf = smalloc(bufsize = 2048); Dout(pn, 0, "entered\n"); new_reciplist(&list); for (i = 1; i < argc; ++i) { if (argv[i][0] == '-') { if (argv[i][1] == '\0') { errmsg(E_SYNTAX,"Hyphens MAY NOT be followed by spaces"); } if (i > 1) { errmsg(E_SYNTAX,"Options MUST PRECEDE persons"); } done(0); } /* Ensure no NULL names in list */ if (argv[i][0] == '\0' || argv[i][strlen(argv[i])-1] == '!') { errmsg(E_SYNTAX,"Null names are not allowed"); done(0); } add_recip(&list, argv[i], FALSE); /* Don't check for duplication */ } mktmp(); /* Format time */ time(&iop); bp = localtime(&iop); tp = asctime(bp); zp = tzname[bp->tm_isdst]; sprintf(datestring, "%.16s %.4s %.5s", tp, zp, tp+20); trimnl (datestring); /* asctime: Fri Sep 30 00:00:00 1986\n */ /* 0123456789012345678901234 */ /* RFCtime: Fri, 28 Jul 89 10:30 EDT */ sprintf(RFC822datestring, "%.3s, %.2s %.3s %.4s %.5s %.3s", tp, tp+8, tp+4, tp+20, tp+11, zp); /* Write out the from line header for the letter */ if (fromflag && deliverflag && from_user[0] != '\0') { snprintf(buf, bufsize, "%s%s %s\n", header[H_FROM].tag, from_user, datestring); } else { snprintf(buf, bufsize, "%s%s %s\n", header[H_FROM].tag, my_name, datestring); } if (!wtmpf(buf, strlen(buf))) { done(0); } savehdrs(buf, H_FROM); /* Copy to list in mail entry? */ if (flgt == 1 && argc > 1) { aret = argc; args = argv; while (--aret > 0) { snprintf(buf, bufsize, "%s %s\n", header[H_TO].tag, *++args); if (!wtmpf(buf, strlen(buf))) { done(0); } savehdrs(buf, H_TO); } } flgf = 1; /* reset when first read of message body succeeds */ /* Read mail message, allowing for lines of infinite length. This is tricky, have to watch for newlines. */ saveint = setsig(SIGINT, savdead); last1c = ' '; /* anything other than newline */ ttyf = isatty (fileno(stdin)); pushrest = 0; /* * scan header & save relevant info. */ cpy(&fromU, &fromUsize, my_name); cpy(&fromS, &fromSsize, ""); input = stdin; if (fstat(fileno(input), &sbuf) < 0) { #ifdef EOVERFLOW if (errno == EOVERFLOW) { perror("stdin"); exit(1); } #endif } while ((n = getline (&line, &linesize, stdin)) > 0) { last1c = line[n-1]; if (pushrest) { if (!wtmpf(line,n)) { done(0); } pushrest = (last1c != '\n'); continue; } pushrest = (last1c != '\n'); if ((hdrtyp = isheader (line, &ctf)) == FALSE) { break; } flgf = 0; switch (hdrtyp) { case H_RVERS: /* Are we dealing with a delivery report? */ /* dflag = 9 ==> do not return on failure */ dflag = 9; Dout(pn, 0, "dflag = 9\n"); break; case H_FROM: if (!wtmpf(">", 1)) { done(0); } /* note dropthru */ hdrtyp = H_FROM1; case H_FROM1: if (substr(line, "forwarded by") > -1) { break; } pickFrom (line); if (Rpath[0] != '\0') concat(&Rpath, &Rpathsize, "!"); concat(&Rpath, &Rpathsize, fromS); n = 0; /* don't copy remote from's into mesg. */ break; case H_CTYPE: /* suppress it: only generated if needed */ n = 0; /* suppress */ break; case H_TCOPY: /* Write out placeholder for later */ snprintf(buf, bufsize, "%s \n", header[H_TCOPY].tag); if (!wtmpf(buf, strlen(buf))) { done(0); } n = 0; /* suppress */ break; case H_MTYPE: if (flgm) { /* suppress if message-type argument */ n = 0; } break; case H_CONT: if (oldn == 0) { /* suppress continuation line also */ n = 0; } break; } oldn = n; /* remember if this line was suppressed */ if (n && !wtmpf(line,n)) { done(0); } if (!n) savehdrs(line, hdrtyp); } if (Rpath != NULL && Rpath[0] != '\0') concat(&Rpath, &Rpathsize, "!"); concat(&Rpath, &Rpathsize, fromU); /* push out message type if so requested */ if (flgm) { /* message-type */ snprintf(buf, bufsize, "%s%s\n", header[H_MTYPE].tag, msgtype); if (!wtmpf(buf, strlen(buf))) { done(0); } } if (n > bufsize) { free(buf); buf = smalloc(bufsize = n); } memcpy (buf, line, n); if (n == 0 || (ttyf && !strncmp (buf, ".\n", 2)) ) { if (flgf) { /* no input */ return; } else { /* * no content: put content-type * only if explicitly present. * Write out 'place-holders' only. (see below....) */ if ((hptr = hdrlines[H_CTYPE].head) != (struct hdrs *)NULL) { snprintf(line, linesize, "%s \n", header[H_CTYPE].tag); if (!wtmpf(line, strlen(line))) { done(0); } } goto wrapsend; } } if (n == 1 && last1c == '\n') { /* blank line -- suppress */ n = getline (&buf, &bufsize, stdin); if (n == 0 || (ttyf && !strncmp (buf, ".\n", 2)) ) { /* * no content: put content-type * only if explicitly present. * Write out 'place-holder' only. (see below....) */ if ((hptr = hdrlines[H_CTYPE].head) != (struct hdrs *)NULL) { snprintf(line, linesize, "%s \n", header[H_CTYPE].tag); if (!wtmpf(line, strlen(line))) { done(0); } } goto wrapsend; } } if (debug > 0) { buf[n] = '\0'; Dout(pn, 0, "header scan complete, readahead %d = \"%s\"\n", n, buf); } /* * Write out H_CTYPE line. This is used only as * placeholders in the tmp file. When the 'real' message is sent, * the proper value will be put out by copylet(). */ snprintf(line, linesize, "%s \n", header[H_CTYPE].tag); if (!wtmpf(line, strlen(line))) { done(0); } if (hdrlines[H_CTYPE].head == (struct hdrs *)NULL) { savehdrs(line,H_CTYPE); } /* and a blank line */ if (!wtmpf("\n", 1)) { done(0); } Dout(pn, 0, "header out completed\n"); pushrest = 0; count = 0L; /* * Are we returning mail from a delivery failure of an old-style * (SVR3.1 or SVR3.0) rmail? If so, we won't return THIS on failure * [This line should occur as the FIRST non-blank non-header line] */ if (!strncmp("***** UNDELIVERABLE MAIL sent to",buf,32)) { dflag = 9; /* 9 says do not return on failure */ Dout(pn, 0, "found old-style UNDELIVERABLE line. dflag = 9\n"); } /* scan body of message */ while (n > 0) { if (ttyf && !strcmp (buf, ".\n")) break; if (!binflg) { binflg = !istext ((unsigned char *)buf, n); } if (!wtmpf(buf, n)) { done(0); } count += n; n = ttyf ? getline (&buf, &bufsize, stdin) : fread (buf, 1, bufsize, stdin); } setsig(SIGINT, saveint); wrapsend: /* * In order to use some of the subroutines that are used to * read mail, the let array must be set up */ nlet = 1; let[0].adr = 0; let[1].adr = ftell(tmpf); let[0].text = (binflg == 1 ? FALSE : TRUE); Dout(pn, 0, "body copy complete, count %ld\n", count); /* * Modify value of H_CTYPE if necessary. */ if ((hptr = hdrlines[H_CTYPE].head) != (struct hdrs *)NULL) { if (strlen(hptr->value) == 0) strcpy(hptr->value, binflg ? "binary" : "text"); } if (fclose(tmpf) == EOF) { tmpf = NULL; tmperr(); done(0); } tmpf = doopen(lettmp,"r+",E_TMP); /* Do not send mail on SIGINT */ if (dflag == 2) { done(0); } sendlist(&list, 0, 0); done(0); }
void do_editmode(struct block * sb) { if (sb->value == 'h' || sb->value == OKEY_LEFT) { // LEFT inputline_pos = back_char(); } else if (sb->value == 'l' || sb->value == OKEY_RIGHT) { // RIGHT inputline_pos = for_char(); } else if (sb->value == 'x') { // x del_back_char(); } else if (sb->value == 'X') { // X del_for_char(); } else if (sb->value == ' ' && ( strlen(inputline) < (COLS - 14) ) ) { // SPACE add_char(inputline, ' ', inputline_pos); } else if (sb->value == 'r') { // r curs_set(1); int c = get_key(); if (c != -1) inputline[inputline_pos] = c; curs_set(2); } else if (sb->value == 'R') { // R curs_set(1); int c = get_key(); while (c != OKEY_ENTER && c != -1) { if (isprint(c)) { inputline[inputline_pos] = c; ++inputline_pos; mvwprintw(input_win, 0, 1 + rescol, "%s", inputline); wmove(input_win, 0, inputline_pos + 1 + rescol); wrefresh(input_win); } c = get_key(); } curs_set(2); } else if (sb->value == 'f') { // f int c = get_key(); if (c != -1) inputline_pos = look_for(c); } else if (sb->value == 'd' || sb->value == 'c') { // d or c int c, d; if ( (c = get_key()) != -1 ) { switch (c) { case 'e': // de or ce del_range_chars(inputline, inputline_pos, for_word(1, 0, 0)); break; case 'E': // dE or cE del_range_chars(inputline, inputline_pos, for_word(1, 0, 1)); break; case 'w': // dw or cw del_range_chars(inputline, inputline_pos, for_word(0, 1, 0) - 1); if (inputline_pos == strlen(inputline) && inputline_pos) inputline_pos--; break; case 'W': // dW or cW del_range_chars(inputline, inputline_pos, for_word(0, 1, 1) - 1); if (inputline_pos == strlen(inputline) && inputline_pos) inputline_pos--; break; case 'b': // db or cb d = back_word(0); del_range_chars(inputline, d, inputline_pos-1); inputline_pos = d; break; case 'B': // dB or cB d = back_word(1); del_range_chars(inputline, d, inputline_pos-1); inputline_pos = d; break; case 'l': // dl or cl case OKEY_RIGHT: del_back_char(); break; case 'h': // dh or ch case OKEY_LEFT: del_for_char(); break; case 'a': if ( (d = get_key()) == 'W' ) { // daW or caW c = ( inputline_pos && inputline[inputline_pos-1] == ' ' ) ? inputline_pos : back_word(1); del_range_chars(inputline, c, for_word(0, 1, 1) - 1); inputline_pos = (strlen(inputline) > inputline_pos) ? c : strlen(inputline)-2; } else if ( d == 'w' ) { // daw or caw d = ( inputline_pos && ! istext( inputline[inputline_pos-1]) ) ? inputline_pos : back_word(0); del_range_chars(inputline, d, for_word(0, 1, 0) - 1); inputline_pos = (strlen(inputline) > inputline_pos) ? d : strlen(inputline)-2; } break; } if (sb->value == 'c') chg_mode(insert_edit_submode); } } else if (find_val(sb, OKEY_ENTER)) { // ENTER insert_or_edit_cell(); return; } else if (sb->value == '$') { // $ inputline_pos = strlen(inputline) - 1; } else if (sb->value == 'w') { // w inputline_pos = for_word(0, 0, 0); } else if (sb->value == 'W') { // W inputline_pos = for_word(0, 0, 1); } else if (sb->value == 'e') { // e inputline_pos = for_word(1, 0, 0); } else if (sb->value == 'E') { // E inputline_pos = for_word(1, 0, 1); } else if (sb->value == 'b') { // b inputline_pos = back_word(0); } else if (sb->value == 'B') { // B inputline_pos = back_word(1); } else if (sb->value == '0') { // 0 inputline_pos = 0; } else if (sb->value == 'a') { // a inputline_pos++; chg_mode(insert_edit_submode); } else if (sb->value == 'i' || sb->value == '=') { // i o = chg_mode(insert_edit_submode); } else if (sb->value == 's') { // s if (inputline_pos <= strlen(inputline)) del_char(inputline, inputline_pos); chg_mode(insert_edit_submode); } else if (sb->value == 'A') { // A inputline_pos = strlen(inputline); chg_mode(insert_edit_submode); } else if (sb->value == 'I') { // I inputline_pos = 0; chg_mode(insert_edit_submode); } else if (sb->value == 'D') { // D inputline_pos = 0; inputline[0] = '\0'; chg_mode(insert_edit_submode); } show_header(input_win); return; }