/* statmbx 0.2 * * Copyright 2007,2010, Jeff Kaufman. Distributed under the GPL. * * Reads mbx files and prints out information about unread messages. * */ #include #include #include #define STATMBX_BUF_SIZE 256 #define STATMBX_CONFIG_FILE_NAME ".statmbx" #define STATMBX_DO_BOLD 1 #define SCREEN_WIDTH 80 /* assume we have 80 columns to work with */ #define FROM_HALF 30 /* how many columns to allow from the from line */ /* If we're supporting bold text, print with escape characters. * Otherwise don't bother*/ void statmbx_printMaybeBold(char* str) { #if STATMBX_DO_BOLD printf("%c%c%c%c%s%c%c%c%c", 033, '[', '1', 'm', str ,033,'[','0','m'); #else printf("%s", str); #endif } void statmbx_getRelativeFname(char* base, char* relative, char* fname) { int i, n; for(n=0;n FROM_HALF-1) { name[FROM_HALF - 6] = '.'; name[FROM_HALF - 5] = '.'; name[FROM_HALF - 4] = '.'; name[FROM_HALF - 3] = ' '; name[FROM_HALF - 2] = ' '; name[FROM_HALF - 1] = '\0'; } else { while (i - offset < FROM_HALF-1) name[(i++) - offset] = ' '; name[i-offset] = '\0'; } /* prepare "subj" */ offset = 9; /* length of "Subject: " */ for (i=offset;i SCREEN_WIDTH - FROM_HALF - 2) { subj[SCREEN_WIDTH - FROM_HALF - 2 + 0] = '.'; subj[SCREEN_WIDTH - FROM_HALF - 2 + 1] = '.'; subj[SCREEN_WIDTH - FROM_HALF - 2 + 2] = '.'; subj[SCREEN_WIDTH - FROM_HALF - 2 + 3] = '\0'; } else { while (i - offset < SCREEN_WIDTH - FROM_HALF - 2 - 1) subj[(i++) - offset] = ' '; subj[i-offset] = '\0'; } if (strlen(name) > 0) printf(" %s%s\n", name,subj); } void statmbx_splitConfigLine(char* line, char** mailbox_title, char** mailbox_fname) { int i; for(i = 0 ; i < STATMBX_BUF_SIZE ; i++) if (line[i] == ' ') { line[i] = '\0'; *mailbox_title = line; *mailbox_fname = line+i+1; for(;i