CORE_SIGTYPE sigs_sighandler (int sig) { int save_errno = errno; switch (sig) { case SIGTSTP: /* user requested a suspend */ #if 0 if (!option (OPTSUSPEND)) break; IsEndwin = isendwin (); curs_set (1); if (!IsEndwin) endwin (); #endif kill (0, SIGSTOP); case SIGCONT: #if 0 if (!IsEndwin) refresh (); mutt_curs_set (-1); #if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM) /* We don't receive SIGWINCH when suspended; however, no harm is done by * just assuming we received one, and triggering the 'resize' anyway. */ SigWinch = 1; #endif #endif break; #if 0 #if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM) case SIGWINCH: SigWinch = 1; break; #endif #endif case SIGINT: #if 0 SigInt = 1; #endif break; case SIGALRM: break; } errno = save_errno; }
/* Display a formatted message on stderr and exit cleanly. */ void die(char const *fmt, ...) { va_list args; if (!isendwin()) { endwin(); fputc('\n', stderr); } va_start(args, fmt); fprintf(stderr, "%s: ", programname); vfprintf(stderr, fmt, args); fputc('\n', stderr); va_end(args); exit(EXIT_FAILURE); }
/* Handle term resizing in X */ static void received_sigwinch(void) { if(curr_stats.save_msg != 2) curr_stats.save_msg = 0; if(!isendwin()) { schedule_redraw(); } else { curr_stats.need_update = UT_FULL; } }
static int curses_msgwin_generic(const char *msg, int (*validator)(int, void *), void *arg, nh_bool cursor_visible, enum keyreq_context context) { int rv; /* We don't know whether the window system is inited right now. So ask. isendwin() is one of the few uncursed functions that works no matter what. */ if (isendwin()) { fprintf(stderr, "%s\n", msg); return validator('\x1b', arg); } /* Don't try to render this on a very small terminal. */ if (COLS < COLNO || LINES < ROWNO) return validator('\x1b', arg); int prevcurs = nh_curs_set(cursor_visible); struct gamewin *gw = alloc_gamewin(sizeof (struct win_msgwin)); struct win_msgwin *wmw = (struct win_msgwin *)gw->extra; wmw->msg = msg; wmw->context = context; gw->draw = draw_curses_msgwin; gw->resize = resize_curses_msgwin; gw->win = 0; /* resize_curses_msgwin sets the layout_{width,height}, and because gw->win is 0, allocates gw->win. */ resize_curses_msgwin(gw); draw_curses_msgwin(gw); rv = -1; while (rv == -1) rv = validator(nh_wgetch(gw->win, context), arg); delete_gamewin(gw); nh_curs_set(prevcurs); redraw_game_windows(); return rv; }
void leave(int sig) { static char buf[BUFSIZ]; NOOP(sig); setbuf(stdout, buf); /* throw away pending output */ if (!isendwin()) { mvcur(0, COLS - 1, LINES - 1, 0); endwin(); } putchar('\n'); my_exit(0); }
int doupdate(void) { chtype *std_ptr, *cur_ptr, *std_end; ptrdiff_t offset; uint16_t y, x; if (isendwin()) { if (0 != screen_change_mode()) { return ERR; } } std_ptr = stdscr->lines; cur_ptr = curscr->lines; std_end = stdscr->lines + LINES * COLS; do { for (; (std_ptr < std_end) && (*std_ptr == *cur_ptr); ++std_ptr, ++cur_ptr) { } offset = std_ptr - stdscr->lines; y = offset / COLS; x = offset % COLS; fprintf(screen.out, "\x1b[%hu;%huH", y + 1, x + 1); for (; (std_ptr < std_end) && (*std_ptr != *cur_ptr); ++std_ptr, ++cur_ptr) { *cur_ptr = *std_ptr; fprintf(screen.out, "%c", (char)*std_ptr); if (++x == COLS) { fprintf(screen.out, "\n"); x = 0; } } } while (std_ptr < std_end); return OK; }
int endwin(void) { uint16_t y, x; if (isendwin()) { return ERR; } if (0 != screen_change_mode()) { return ERR; } fprintf(screen.out, "\x1b[1;1H"); for (y = 0; y < LINES; ++y) { for (x = 0; x < COLS; ++x) { window_setch(curscr, ' ', y, x); fprintf(screen.out, " "); } } fprintf(screen.out, "\x1b[1;1H"); return OK; }
/* Function to call when we're all done. Does a bit of clean-up. */ static void die(int sig) { if (!isendwin()) { /* Move the cursor to the bottom left corner. */ (void)mvcur(0, COLS - 1, LINES - 1, 0); /* Put input attributes back the way they were. */ (void)echo(); /* Done with curses. */ (void)endwin(); } /* We're done talking to gpsd. */ (void)gps_close(&gpsdata); switch (sig) { case CGPS_QUIT: break; case GPS_GONE: (void)fprintf(stderr, "cgps: GPS hung up.\n"); break; case GPS_ERROR: (void)fprintf(stderr, "cgps: GPS read returned error\n"); break; case GPS_TIMEOUT: (void)fprintf(stderr, "cgps: GPS timeout\n"); break; default: (void)fprintf(stderr, "cgps: caught signal %d\n", sig); break; } /* Bye! */ exit(EXIT_SUCCESS); }
void stop_curses() { if (curses_started && !isendwin()) endwin(); }
int mutt_protect (HEADER *msg, char *keylist) { BODY *pbody = NULL, *tmp_pbody = NULL; BODY *tmp_smime_pbody = NULL; BODY *tmp_pgp_pbody = NULL; int flags = (WithCrypto & APPLICATION_PGP)? msg->security: 0; int i; if (!WithCrypto) return -1; if (!(msg->security & (ENCRYPT | SIGN))) return 0; if ((msg->security & SIGN) && !crypt_valid_passphrase (msg->security)) return (-1); if ((WithCrypto & APPLICATION_PGP) && ((msg->security & PGPINLINE) == PGPINLINE)) { if ((msg->content->type != TYPETEXT) || ascii_strcasecmp (msg->content->subtype, "plain")) { if ((i = query_quadoption (OPT_PGPMIMEAUTO, _("Inline PGP can't be used with attachments. Revert to PGP/MIME?"))) != MUTT_YES) { mutt_error _("Mail not sent: inline PGP can't be used with attachments."); return -1; } } else { /* they really want to send it inline... go for it */ if (!isendwin ()) mutt_endwin _("Invoking PGP..."); pbody = crypt_pgp_traditional_encryptsign (msg->content, flags, keylist); if (pbody) { msg->content = pbody; return 0; } /* otherwise inline won't work...ask for revert */ if ((i = query_quadoption (OPT_PGPMIMEAUTO, _("Message can't be sent inline. Revert to using PGP/MIME?"))) != MUTT_YES) { mutt_error _("Mail not sent."); return -1; } } /* go ahead with PGP/MIME */ } if (!isendwin ()) mutt_endwin (NULL); if ((WithCrypto & APPLICATION_SMIME)) tmp_smime_pbody = msg->content; if ((WithCrypto & APPLICATION_PGP)) tmp_pgp_pbody = msg->content; if (option (OPTCRYPTUSEPKA) && (msg->security & SIGN)) { /* Set sender (necessary for e.g. PKA). */ if ((WithCrypto & APPLICATION_SMIME) && (msg->security & APPLICATION_SMIME)) crypt_smime_set_sender (msg->env->from->mailbox); else if ((WithCrypto & APPLICATION_PGP) && (msg->security & APPLICATION_PGP)) crypt_pgp_set_sender (msg->env->from->mailbox); } if (msg->security & SIGN) { if ((WithCrypto & APPLICATION_SMIME) && (msg->security & APPLICATION_SMIME)) { if (!(tmp_pbody = crypt_smime_sign_message (msg->content))) return -1; pbody = tmp_smime_pbody = tmp_pbody; } if ((WithCrypto & APPLICATION_PGP) && (msg->security & APPLICATION_PGP) && (!(flags & ENCRYPT) || option (OPTPGPRETAINABLESIG))) { if (!(tmp_pbody = crypt_pgp_sign_message (msg->content))) return -1; flags &= ~SIGN; pbody = tmp_pgp_pbody = tmp_pbody; } if (WithCrypto && (msg->security & APPLICATION_SMIME) && (msg->security & APPLICATION_PGP)) { /* here comes the draft ;-) */ } } if (msg->security & ENCRYPT) { if ((WithCrypto & APPLICATION_SMIME) && (msg->security & APPLICATION_SMIME)) { if (!(tmp_pbody = crypt_smime_build_smime_entity (tmp_smime_pbody, keylist))) { /* signed ? free it! */ return (-1); } /* free tmp_body if messages was signed AND encrypted ... */ if (tmp_smime_pbody != msg->content && tmp_smime_pbody != tmp_pbody) { /* detatch and don't delete msg->content, which tmp_smime_pbody->parts after signing. */ tmp_smime_pbody->parts = tmp_smime_pbody->parts->next; msg->content->next = NULL; mutt_free_body (&tmp_smime_pbody); } pbody = tmp_pbody; } if ((WithCrypto & APPLICATION_PGP) && (msg->security & APPLICATION_PGP)) { if (!(pbody = crypt_pgp_encrypt_message (tmp_pgp_pbody, keylist, flags & SIGN))) { /* did we perform a retainable signature? */ if (flags != msg->security) { /* remove the outer multipart layer */ tmp_pgp_pbody = mutt_remove_multipart (tmp_pgp_pbody); /* get rid of the signature */ mutt_free_body (&tmp_pgp_pbody->next); } return (-1); } /* destroy temporary signature envelope when doing retainable * signatures. */ if (flags != msg->security) { tmp_pgp_pbody = mutt_remove_multipart (tmp_pgp_pbody); mutt_free_body (&tmp_pgp_pbody->next); } } } if(pbody) msg->content = pbody; return 0; }
void Pantalla::endCurses(){ if (curses_ON && !isendwin()) clear(); endwin(); }
/* Called on program exit. */ static void shutdown(void) { if (!isendwin()) endwin(); }
/** * crypt_extract_keys_from_messages - Extract keys from a message * @param el List of Emails to process * * The extracted keys will be added to the user's keyring. */ void crypt_extract_keys_from_messages(struct EmailList *el) { char tempfname[PATH_MAX], *mbox = NULL; struct Address *tmp = NULL; if (!WithCrypto) return; mutt_mktemp(tempfname, sizeof(tempfname)); FILE *fp_out = mutt_file_fopen(tempfname, "w"); if (!fp_out) { mutt_perror(tempfname); return; } if (WithCrypto & APPLICATION_PGP) OptDontHandlePgpKeys = true; struct EmailNode *en = NULL; STAILQ_FOREACH(en, el, entries) { struct Email *e = en->email; mutt_parse_mime_message(Context->mailbox, e); if (e->security & SEC_ENCRYPT && !crypt_valid_passphrase(e->security)) { mutt_file_fclose(&fp_out); break; } if (((WithCrypto & APPLICATION_PGP) != 0) && (e->security & APPLICATION_PGP)) { mutt_copy_message_ctx(fp_out, Context->mailbox, e, MUTT_CM_DECODE | MUTT_CM_CHARCONV, 0); fflush(fp_out); mutt_endwin(); puts(_("Trying to extract PGP keys...\n")); crypt_pgp_invoke_import(tempfname); } if (((WithCrypto & APPLICATION_SMIME) != 0) && (e->security & APPLICATION_SMIME)) { if (e->security & SEC_ENCRYPT) { mutt_copy_message_ctx(fp_out, Context->mailbox, e, MUTT_CM_NOHEADER | MUTT_CM_DECODE_CRYPT | MUTT_CM_DECODE_SMIME, 0); } else mutt_copy_message_ctx(fp_out, Context->mailbox, e, 0, 0); fflush(fp_out); if (e->env->from) tmp = mutt_expand_aliases(e->env->from); else if (e->env->sender) tmp = mutt_expand_aliases(e->env->sender); mbox = tmp ? tmp->mailbox : NULL; if (mbox) { mutt_endwin(); puts(_("Trying to extract S/MIME certificates...")); crypt_smime_invoke_import(tempfname, mbox); tmp = NULL; } } rewind(fp_out); } mutt_file_fclose(&fp_out); if (isendwin()) mutt_any_key_to_continue(NULL); mutt_file_unlink(tempfname); if (WithCrypto & APPLICATION_PGP) OptDontHandlePgpKeys = false; }
/** * mutt_protect - Encrypt and/or sign a message * @param msg Header of the message * @param keylist List of keys to encrypt to (space-separated) * @retval 0 Success * @retval -1 Error */ int mutt_protect(struct Email *msg, char *keylist) { struct Body *pbody = NULL, *tmp_pbody = NULL; struct Body *tmp_smime_pbody = NULL; struct Body *tmp_pgp_pbody = NULL; int flags = (WithCrypto & APPLICATION_PGP) ? msg->security : 0; if (!WithCrypto) return -1; if (!(msg->security & (SEC_ENCRYPT | SEC_SIGN))) return 0; if ((msg->security & SEC_SIGN) && !crypt_valid_passphrase(msg->security)) return -1; if (((WithCrypto & APPLICATION_PGP) != 0) && ((msg->security & PGP_INLINE) == PGP_INLINE)) { if ((msg->content->type != TYPE_TEXT) || (mutt_str_strcasecmp(msg->content->subtype, "plain") != 0)) { if (query_quadoption(C_PgpMimeAuto, _("Inline PGP can't be used with attachments. " "Revert to PGP/MIME?")) != MUTT_YES) { mutt_error( _("Mail not sent: inline PGP can't be used with attachments")); return -1; } } else if (mutt_str_strcasecmp("flowed", mutt_param_get(&msg->content->parameter, "format")) == 0) { if ((query_quadoption(C_PgpMimeAuto, _("Inline PGP can't be used with format=flowed. " "Revert to PGP/MIME?"))) != MUTT_YES) { mutt_error( _("Mail not sent: inline PGP can't be used with format=flowed")); return -1; } } else { /* they really want to send it inline... go for it */ if (!isendwin()) { mutt_endwin(); puts(_("Invoking PGP...")); } pbody = crypt_pgp_traditional_encryptsign(msg->content, flags, keylist); if (pbody) { msg->content = pbody; return 0; } /* otherwise inline won't work...ask for revert */ if (query_quadoption( C_PgpMimeAuto, _("Message can't be sent inline. Revert to using PGP/MIME?")) != MUTT_YES) { mutt_error(_("Mail not sent")); return -1; } } /* go ahead with PGP/MIME */ } if (!isendwin()) mutt_endwin(); if (WithCrypto & APPLICATION_SMIME) tmp_smime_pbody = msg->content; if (WithCrypto & APPLICATION_PGP) tmp_pgp_pbody = msg->content; if (C_CryptUsePka && (msg->security & SEC_SIGN)) { /* Set sender (necessary for e.g. PKA). */ const char *mailbox = NULL; struct Address *from = msg->env->from; if (!from) from = mutt_default_from(); mailbox = from->mailbox; if (!mailbox && C_EnvelopeFromAddress) mailbox = C_EnvelopeFromAddress->mailbox; if (((WithCrypto & APPLICATION_SMIME) != 0) && (msg->security & APPLICATION_SMIME)) crypt_smime_set_sender(mailbox); else if (((WithCrypto & APPLICATION_PGP) != 0) && (msg->security & APPLICATION_PGP)) crypt_pgp_set_sender(mailbox); if (!msg->env->from) mutt_addr_free(&from); } if (C_CryptProtectedHeadersWrite) { struct Envelope *protected_headers = mutt_env_new(); mutt_str_replace(&protected_headers->subject, msg->env->subject); /* Note: if other headers get added, such as to, cc, then a call to * mutt_env_to_intl() will need to be added here too. */ mutt_prepare_envelope(protected_headers, 0); mutt_env_free(&msg->content->mime_headers); msg->content->mime_headers = protected_headers; } if (msg->security & SEC_SIGN) { if (((WithCrypto & APPLICATION_SMIME) != 0) && (msg->security & APPLICATION_SMIME)) { tmp_pbody = crypt_smime_sign_message(msg->content); if (!tmp_pbody) goto bail; pbody = tmp_pbody; tmp_smime_pbody = tmp_pbody; } if (((WithCrypto & APPLICATION_PGP) != 0) && (msg->security & APPLICATION_PGP) && (!(flags & SEC_ENCRYPT) || C_PgpRetainableSigs)) { tmp_pbody = crypt_pgp_sign_message(msg->content); if (!tmp_pbody) goto bail; flags &= ~SEC_SIGN; pbody = tmp_pbody; tmp_pgp_pbody = tmp_pbody; } if ((WithCrypto != 0) && (msg->security & APPLICATION_SMIME) && (msg->security & APPLICATION_PGP)) { /* here comes the draft ;-) */ } } if (msg->security & SEC_ENCRYPT) { if (((WithCrypto & APPLICATION_SMIME) != 0) && (msg->security & APPLICATION_SMIME)) { tmp_pbody = crypt_smime_build_smime_entity(tmp_smime_pbody, keylist); if (!tmp_pbody) { /* signed ? free it! */ goto bail; } /* free tmp_body if messages was signed AND encrypted ... */ if ((tmp_smime_pbody != msg->content) && (tmp_smime_pbody != tmp_pbody)) { /* detach and don't delete msg->content, * which tmp_smime_pbody->parts after signing. */ tmp_smime_pbody->parts = tmp_smime_pbody->parts->next; msg->content->next = NULL; mutt_body_free(&tmp_smime_pbody); } pbody = tmp_pbody; } if (((WithCrypto & APPLICATION_PGP) != 0) && (msg->security & APPLICATION_PGP)) { pbody = crypt_pgp_encrypt_message(tmp_pgp_pbody, keylist, (flags & SEC_SIGN)); if (!pbody) { /* did we perform a retainable signature? */ if (flags != msg->security) { /* remove the outer multipart layer */ tmp_pgp_pbody = mutt_remove_multipart(tmp_pgp_pbody); /* get rid of the signature */ mutt_body_free(&tmp_pgp_pbody->next); } goto bail; } /* destroy temporary signature envelope when doing retainable * signatures. */ if (flags != msg->security) { tmp_pgp_pbody = mutt_remove_multipart(tmp_pgp_pbody); mutt_body_free(&tmp_pgp_pbody->next); } } } if (pbody) { msg->content = pbody; return 0; } bail: mutt_env_free(&msg->content->mime_headers); return -1; }
/*** Has @{endwin} been called more recently than @{curses.window:refresh}? @function isendwin @treturn bool whether @{endwin} has been called @see isendwin(3x) */ static int Pisendwin(lua_State *L) { return pushboolresult(isendwin()); }
static int remove_packages(void) { char **args; char *env[1]={NULL}; char **p; int i; int delete_count=0; pid_t child; int status; size_t st; args=(char **)malloc((menulen+4) * sizeof(char *)); if(!args) { do_init_dialog(); dialog_msgbox("ERROR", "Can not allocate memory for package list!", 5, 45, TRUE); end_dialog(); return(-1); } p=args; *(p++)="/usr/sbin/pkg"; *(p++)="delete"; *(p++)="-y"; for(i=0;i<menulen;i++) { if(menu[i].ITEM_CHECKED) { *(p++)=menu[i].ITEM_PROMPT; delete_count++; } } *(p)=NULL; if(!delete_count) { do_init_dialog(); dialog_msgbox(NULL, "No packages selected", 5, 24, TRUE); end_dialog(); free(args); return(-1); } /* Ensure stdio is "right" */ if(!isendwin()) endwin(); child=vfork(); if(child==0) { execve(args[0], args, env); fprintf(stderr,"ERROR: %d!\n",errno); _exit(EXIT_FAILURE); } free(args); if(child==-1) { do_init_dialog(); dialog_msgbox(NULL, "Can not fork()", 5, 18, TRUE); end_dialog(); return(-1); } waitpid(child, &status, 0); /* On an error return, pause */ if(WIFSIGNALED(status) || (WIFEXITED(status) && WEXITSTATUS(status))) { fputs("\n\nPress ENTER to continue... ",stderr); fgetln(stdin, &st); } return(0); }
void Game::endCurses( void ) { if (this->_curses_started && !isendwin()) endwin(); }
int imap_fetch_message (CONTEXT *ctx, MESSAGE *msg, int msgno) { IMAP_DATA* idata; HEADER* h; ENVELOPE* newenv; char buf[LONG_STRING]; char path[_POSIX_PATH_MAX]; char *pc; long bytes; progress_t progressbar; int uid; int cacheno; IMAP_CACHE *cache; int read; int rc; /* Sam's weird courier server returns an OK response even when FETCH * fails. Thanks Sam. */ short fetched = 0; idata = (IMAP_DATA*) ctx->data; h = ctx->hdrs[msgno]; if ((msg->fp = msg_cache_get (idata, h))) { if (HEADER_DATA(h)->parsed) return 0; else goto parsemsg; } /* we still do some caching even if imap_cachedir is unset */ /* see if we already have the message in our cache */ cacheno = HEADER_DATA(h)->uid % IMAP_CACHE_LEN; cache = &idata->cache[cacheno]; if (cache->path) { /* don't treat cache errors as fatal, just fall back. */ if (cache->uid == HEADER_DATA(h)->uid && (msg->fp = fopen (cache->path, "r"))) return 0; else { unlink (cache->path); FREE (&cache->path); } } if (!isendwin()) mutt_message _("Fetching message..."); if (!(msg->fp = msg_cache_put (idata, h))) { cache->uid = HEADER_DATA(h)->uid; mutt_mktemp (path, sizeof (path)); cache->path = safe_strdup (path); if (!(msg->fp = safe_fopen (path, "w+"))) { FREE (&cache->path); return -1; } } /* mark this header as currently inactive so the command handler won't * also try to update it. HACK until all this code can be moved into the * command handler */ h->active = 0; snprintf (buf, sizeof (buf), "UID FETCH %u %s", HEADER_DATA(h)->uid, (mutt_bit_isset (idata->capabilities, IMAP4REV1) ? (option (OPTIMAPPEEK) ? "BODY.PEEK[]" : "BODY[]") : "RFC822")); imap_cmd_start (idata, buf); do { if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE) break; pc = idata->buf; pc = imap_next_word (pc); pc = imap_next_word (pc); if (!ascii_strncasecmp ("FETCH", pc, 5)) { while (*pc) { pc = imap_next_word (pc); if (pc[0] == '(') pc++; if (ascii_strncasecmp ("UID", pc, 3) == 0) { pc = imap_next_word (pc); uid = atoi (pc); if (uid != HEADER_DATA(h)->uid) mutt_error (_("The message index is incorrect. Try reopening the mailbox.")); } else if ((ascii_strncasecmp ("RFC822", pc, 6) == 0) || (ascii_strncasecmp ("BODY[]", pc, 6) == 0)) { pc = imap_next_word (pc); if (imap_get_literal_count(pc, &bytes) < 0) { imap_error ("imap_fetch_message()", buf); goto bail; } mutt_progress_init (&progressbar, _("Fetching message..."), MUTT_PROGRESS_SIZE, NetInc, bytes); if (imap_read_literal (msg->fp, idata, bytes, &progressbar) < 0) goto bail; /* pick up trailing line */ if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE) goto bail; pc = idata->buf; fetched = 1; } /* UW-IMAP will provide a FLAGS update here if the FETCH causes a * change (eg from \Unseen to \Seen). * Uncommitted changes in mutt take precedence. If we decide to * incrementally update flags later, this won't stop us syncing */ else if ((ascii_strncasecmp ("FLAGS", pc, 5) == 0) && !h->changed) { if ((pc = imap_set_flags (idata, h, pc)) == NULL) goto bail; } } } } while (rc == IMAP_CMD_CONTINUE); /* see comment before command start. */ h->active = 1; fflush (msg->fp); if (ferror (msg->fp)) { mutt_perror (cache->path); goto bail; } if (rc != IMAP_CMD_OK) goto bail; if (!fetched || !imap_code (idata->buf)) goto bail; msg_cache_commit (idata, h); parsemsg: /* Update the header information. Previously, we only downloaded a * portion of the headers, those required for the main display. */ rewind (msg->fp); /* It may be that the Status header indicates a message is read, but the * IMAP server doesn't know the message has been \Seen. So we capture * the server's notion of 'read' and if it differs from the message info * picked up in mutt_read_rfc822_header, we mark the message (and context * changed). Another possibility: ignore Status on IMAP?*/ read = h->read; newenv = mutt_read_rfc822_header (msg->fp, h, 0, 0); mutt_merge_envelopes(h->env, &newenv); /* see above. We want the new status in h->read, so we unset it manually * and let mutt_set_flag set it correctly, updating context. */ if (read != h->read) { h->read = read; mutt_set_flag (ctx, h, MUTT_NEW, read); } h->lines = 0; fgets (buf, sizeof (buf), msg->fp); while (!feof (msg->fp)) { h->lines++; fgets (buf, sizeof (buf), msg->fp); } h->content->length = ftell (msg->fp) - h->content->offset; /* This needs to be done in case this is a multipart message */ #if defined(HAVE_PGP) || defined(HAVE_SMIME) h->security = crypt_query (h->content); #endif mutt_clear_error(); rewind (msg->fp); HEADER_DATA(h)->parsed = 1; return 0; bail: safe_fclose (&msg->fp); imap_cache_del (idata, h); if (cache->path) { unlink (cache->path); FREE (&cache->path); } return -1; }
int doupdate(void) { int y; bool clearall; PDC_LOG(("doupdate() - called\n")); if (!curscr) return ERR; if (isendwin()) /* coming back after endwin() called */ { reset_prog_mode(); clearall = TRUE; SP->alive = TRUE; /* so isendwin() result is correct */ } else clearall = curscr->_clear; for (y = 0; y < SP->lines; y++) { PDC_LOG(("doupdate() - Transforming line %d of %d: %s\n", y, SP->lines, (curscr->_firstch[y] != _NO_CHANGE) ? "Yes" : "No")); if (clearall || curscr->_firstch[y] != _NO_CHANGE) { int first, last; chtype *src = curscr->_y[y]; chtype *dest = pdc_lastscr->_y[y]; if (clearall) { first = 0; last = COLS - 1; } else { first = curscr->_firstch[y]; last = curscr->_lastch[y]; } while (first <= last) { int len = 0; /* build up a run of changed cells; if two runs are separated by a single unchanged cell, ignore the break */ if (clearall) len = last - first + 1; else while (first + len <= last && (src[first + len] != dest[first + len] || (len && first + len < last && src[first + len + 1] != dest[first + len + 1]) ) ) len++; /* update the screen, and pdc_lastscr */ if (len) { PDC_transform_line(y, first, len, src + first); memcpy(dest + first, src + first, len * sizeof(chtype)); first += len; } /* skip over runs of unchanged cells */ while (first <= last && src[first] == dest[first]) first++; } curscr->_firstch[y] = _NO_CHANGE; curscr->_lastch[y] = _NO_CHANGE; } } curscr->_clear = FALSE; if (SP->visibility) PDC_gotoyx(curscr->_cury, curscr->_curx); SP->cursrow = curscr->_cury; SP->curscol = curscr->_curx; return OK; }
void endCurses() { if (curses_ON && !isendwin()) endwin(); }