/* * pretty_feature_name - return a pleasantly displayable form * of feature name variable */ char * pretty_feature_name(char *feat, int width) { FEATURE_S *f; int i, upper = 1; static char fbuf[100]; f = feature_list(feature_list_index(feature_list_id(feat))); if(f && f->dname && f->dname[0]) return(f->dname); /* default: uppercase first letters, dashes become spaces */ for(i = 0; i < sizeof(fbuf)-1 && feat[i]; i++) if(upper){ fbuf[i] = (islower((unsigned char) feat[i])) ? toupper((unsigned char) feat[i]) : feat[i]; upper = 0; } else if(feat[i] == '-'){ fbuf[i] = SPACE; upper++; } else fbuf[i] = feat[i]; fbuf[i] = '\0'; /* cut off right hand edge if necessary */ if(width > 0){ char *p, gbuf[100]; p = short_str(fbuf, gbuf, sizeof(gbuf), width, EndDots); if(p != fbuf){ strncpy(fbuf, p, sizeof(fbuf)-1); fbuf[sizeof(fbuf)-1] = '\0'; } } return(fbuf); }
/*---------------------------------------------------------------------- handle hang up signal -- SIGUSR2 Not much to do. Rely on periodic mail file check pointing. ----------------------------------------------------------------------*/ static RETSIGTYPE usr2_signal(int sig) { char c, *mbox, mboxbuf[20]; int i; MAILSTREAM *stream; NETMBX mb; for(i = 0; i < ps_global->s_pool.nstream; i++) { stream = ps_global->s_pool.streams[i]; if(stream && sp_flagged(stream, SP_LOCKED) && !sp_dead_stream(stream) && !stream->lock && !stream->rdonly && stream->mailbox && (c = *stream->mailbox) != '{' && c != '*') { pine_mail_check(stream); /* write latest state */ stream->rdonly = 1; /* and become read-only */ (void) pine_mail_ping(stream); mbox = stream->mailbox; if(!strucmp(stream->mailbox, ps_global->inbox_name) || !strcmp(stream->mailbox, ps_global->VAR_INBOX_PATH) || !strucmp(stream->original_mailbox, ps_global->inbox_name) || !strcmp(stream->original_mailbox, ps_global->VAR_INBOX_PATH)) mbox = "INBOX"; else if(mail_valid_net_parse(stream->mailbox, &mb) && mb.mailbox) mbox = mb.mailbox; q_status_message1(SM_ASYNC, 3, 7, _("Another email program is accessing %s. Session now Read-Only."), short_str((mbox && *mbox) ? mbox : "folder", mboxbuf, sizeof(mboxbuf), 19, FrontDots)); dprint((1, "** folder %s went read-only **\n\n", stream->mailbox)); } } }
/*---------------------------------------------------------------------- Ask a yes/no question in the status line Args: question -- string to prompt user with dflt -- The default answer to the question (should probably be y or n) on_ctrl_C -- Answer returned on ^C help -- Two line help text flags -- Flags to modify behavior WT_FLUSH_IN - Discard pending input. WT_SEQ_SENSITIVE - Caller is sensitive to sequence number changes caused by unsolicited expunges while we're viewing a message. Result: Messes up the status line, returns y, n, dflt, on_ctrl_C, or SEQ_EXCEPTION ---*/ int want_to(char *question, int dflt, int on_ctrl_C, HelpType help, int flags) { char *free_this = NULL, *free_this2 = NULL, *prompt; int rv, width; size_t len; if(!ps_global->ttyo) return(pre_screen_config_want_to(question, dflt, on_ctrl_C)); #ifdef _WINDOWS if (mswin_usedialog ()) { mswin_flush (); switch (mswin_yesno_utf8 (question)) { default: case 0: return (on_ctrl_C); case 1: return ('y'); case 2: return ('n'); } } #endif /*---- One problem with adding the (y/n) here is that shrinking the screen while in radio_buttons() will cause it to get chopped off. It would be better to truncate the question passed in here and leave the full "(y/n) [x] : " on. ----*/ len = strlen(question) + 4; free_this = (char *) fs_get(len); width = utf8_width(question); if(width + 2 < ps_global->ttyo->screen_cols){ snprintf(free_this, len, "%s? ", question); free_this[len-1] = '\0'; prompt = free_this; } else if(width + 1 < ps_global->ttyo->screen_cols){ snprintf(free_this, len, "%s?", question); free_this[len-1] = '\0'; prompt = free_this; } else if(width < ps_global->ttyo->screen_cols){ snprintf(free_this, len, "%s", question); free_this[len-1] = '\0'; prompt = free_this; } else{ free_this2 = (char *) fs_get(len); snprintf(free_this2, len, "%s? ", question); prompt = short_str(free_this2, free_this, len, ps_global->ttyo->screen_cols-1, MidDots); } if(on_ctrl_C == 'n') /* don't ever let cancel == 'n' */ on_ctrl_C = 0; rv = radio_buttons(prompt, (ps_global->ttyo->screen_rows > 4) ? - FOOTER_ROWS(ps_global) : -1, yorn, dflt, on_ctrl_C, help, flags); if(free_this) fs_give((void **) &free_this); if(free_this2) fs_give((void **) &free_this2); return(rv); }
std::string comment( const id3v2_frame* frame, const id3v2_header *header, bool utf8 ) { const char* p = frame->value; const char* e = frame->value + frame->vsize(header); if (header->version_major==4) { if (frame->flags&0x100) p+=4; if (frame->flags&0x200) { char *b=(char*)alloca(e-p); unsigned long len=deunsync(p, e-p, b); p=b; e=p+len; } } int enc=*p++; char lang[4] = {0,}; if( p+3>=e ) return ""; // do something with the lang ID? maybe set a locale? not here though. p+=3; std::string short_str, long_str; if( enc == 1 || enc == 2 ) { short_str = get_uncode_string( p, e, utf8, enc == 2 ); while (p<e && *(short*)p) p+=2; p+=2; if( p>=e ) #if TAGS_ID3V2_FACIST == 1 return ""; // bogus #else return short_str; #endif long_str = get_uncode_string( p, e, utf8 ); }else #if TAGS_ID3V2_FACIST == 1 if( enc == 0) // enforce encoding or merely assume otherwise it's iso. #endif { std::string short_str( p ); while (p<e && *p) p++; p++; if( p>=e ) #if TAGS_ID3V2_FACIST == 1 return ""; // bogus #else return short_str; #endif long_str = std::string( p, e ); } #if TAGS_ID3V2_FACIST == 1 else return ""; // unknown encoding - bogus #endif purge_crlf( short_str ); purge_crlf( long_str ); #define S short_str #define L long_str return TAGS_ID3V2_COMMENT_RETURNS; #undef S #undef L }