# HG changeset patch # User Carl Byington # Date 1512665037 28800 # Node ID ad7b880ad3d12a71fefc0b327e338fe6ab53cdce # Parent 506e266f930d7ed4771a96c363c2d03e362615f5 Alfredo Esteban - add -l and -f options to lspst diff -r 506e266f930d -r ad7b880ad3d1 AUTHORS --- a/AUTHORS Mon Nov 20 08:19:28 2017 -0800 +++ b/AUTHORS Thu Dec 07 08:43:57 2017 -0800 @@ -43,6 +43,7 @@ Igor Stroh Zachary Travis Vitaliy Didik + Alfredo Esteban Testing team: Mac OSX - Michael Watson diff -r 506e266f930d -r ad7b880ad3d1 ChangeLog --- a/ChangeLog Mon Nov 20 08:19:28 2017 -0800 +++ b/ChangeLog Thu Dec 07 08:43:57 2017 -0800 @@ -1,3 +1,7 @@ +LibPST 0.6.72 (2017-12-07) +=============================== + * Alfredo Esteban - add -l and -f options to lspst. + LibPST 0.6.71 (2017-07-21) =============================== * Zachary Travis - Add support for the OST 2013 format, and diff -r 506e266f930d -r ad7b880ad3d1 configure.in --- a/configure.in Mon Nov 20 08:19:28 2017 -0800 +++ b/configure.in Thu Dec 07 08:43:57 2017 -0800 @@ -1,5 +1,5 @@ AC_PREREQ(2.60) -AC_INIT(libpst,0.6.71,carl@five-ten-sg.com) +AC_INIT(libpst,0.6.72,carl@five-ten-sg.com) AC_CONFIG_SRCDIR([src/libpst.c]) AC_CONFIG_HEADER([config.h]) AC_CONFIG_MACRO_DIR([m4]) diff -r 506e266f930d -r ad7b880ad3d1 src/define.h --- a/src/define.h Mon Nov 20 08:19:28 2017 -0800 +++ b/src/define.h Thu Dec 07 08:43:57 2017 -0800 @@ -256,5 +256,6 @@ #define PST_LE_GET_INT8(p) (*(int8_t const *)(p)) +#define MAXDATEFMTLEN 40 #endif //DEFINEH_H diff -r 506e266f930d -r ad7b880ad3d1 src/lspst.c --- a/src/lspst.c Mon Nov 20 08:19:28 2017 -0800 +++ b/src/lspst.c Thu Dec 07 08:43:57 2017 -0800 @@ -16,6 +16,10 @@ int32_t type; }; +struct options { + int long_format; + char *date_format; +}; void canonicalize_filename(char *fname); void debug_print(char *fmt, ...); @@ -42,13 +46,13 @@ free(f->dname); } - -void process(pst_item *outeritem, pst_desc_tree *d_ptr) +void process(pst_item *outeritem, pst_desc_tree *d_ptr, struct options o) { struct file_ll ff; pst_item *item = NULL; char *result = NULL; size_t resultlen = 0; + size_t dateresultlen; DEBUG_ENT("process"); memset(&ff, 0, sizeof(ff)); @@ -74,7 +78,7 @@ // if this is a folder, we want to recurse into it pst_convert_utf8(item, &item->file_as); printf("Folder \"%s\"\n", item->file_as.str); - process(item, d_ptr->child); + process(item, d_ptr->child, o); } else if (item->contact && (item->type == PST_TYPE_CONTACT)) { if (!ff.type) ff.type = item->type; @@ -94,10 +98,39 @@ DEBUG_INFO(("I have an email, but the folder isn't an email folder. Processing anyway\n")); } printf("Email"); + if (o.long_format == 1) { + if (item->email->arrival_date) { + char time_buffer[MAXDATEFMTLEN]; + dateresultlen = pst_fileTimeToString(item->email->arrival_date, o.date_format, time_buffer); + if (dateresultlen < 1) + DIE(("Date format error in -f option.\n")); + printf("\tDate: %s", time_buffer); + } + else + printf("\t"); + } if (item->email->outlook_sender_name.str) printf("\tFrom: %s", item->email->outlook_sender_name.str); + else + printf("\t"); + if (o.long_format == 1) { + if (item->email->outlook_recipient_name.str) + printf("\tTo: %s", item->email->outlook_recipient_name.str); + else + printf("\t"); + if (item->email->cc_address.str) + printf("\tCC: %s", item->email->cc_address.str); + else + printf("\t"); + if (item->email->bcc_address.str) + printf("\tBCC: %s", item->email->bcc_address.str); + else + printf("\t"); + } if (item->subject.str) printf("\tSubject: %s", item->subject.str); + else + printf("\t"); printf("\n"); } else if (item->journal && (item->type == PST_TYPE_JOURNAL)) { @@ -152,6 +185,8 @@ printf("Usage: %s [OPTIONS] {PST FILENAME}\n", prog_name); printf("OPTIONS:\n"); printf("\t-d \t- Debug to file. This is a binary log. Use readlog to print it\n"); + printf("\t-l\t- Print the date, CC and BCC fields of emails too (by default only the From and Subject)\n"); + printf("\t-f \t- Select the date format in ctime format (by default \"%%F %%T\")\n"); printf("\t-h\t- Help. This screen\n"); printf("\t-V\t- Version. Display program version\n"); DEBUG_RET(); @@ -178,12 +213,22 @@ char *temp = NULL; //temporary char pointer int c; char *d_log = NULL; + struct options o; + o.long_format = 0; + char *defaultfmtdate = "%F %T"; + o.date_format = defaultfmtdate; - while ((c = getopt(argc, argv, "d:hV"))!= -1) { + while ((c = getopt(argc, argv, "d:f:lhV"))!= -1) { switch (c) { case 'd': d_log = optarg; break; + case 'f': + o.date_format = optarg; + break; + case 'l': + o.long_format = 1; + break; case 'h': usage(argv[0]); exit(0); @@ -242,7 +287,7 @@ d_ptr = pst_getTopOfFolders(&pstfile, item); if (!d_ptr) DIE(("Top of folders record not found. Cannot continue\n")); - process(item, d_ptr->child); // do the childred of TOPF + process(item, d_ptr->child, o); // do the childred of TOPF pst_freeItem(item); pst_close(&pstfile); diff -r 506e266f930d -r ad7b880ad3d1 src/timeconv.c --- a/src/timeconv.c Mon Nov 20 08:19:28 2017 -0800 +++ b/src/timeconv.c Thu Dec 07 08:43:57 2017 -0800 @@ -8,6 +8,11 @@ return ctime_r(&t, result); } +size_t pst_fileTimeToString(const FILETIME* filetime, const char* date_format, char* result) { + time_t t; + t = pst_fileTimeToUnixTime(filetime); + return strftime(result, MAXDATEFMTLEN-1, date_format, localtime(&t)); +} void pst_fileTimeToStructTM (const FILETIME *filetime, struct tm *result) { time_t t1; diff -r 506e266f930d -r ad7b880ad3d1 src/timeconv.h --- a/src/timeconv.h Mon Nov 20 08:19:28 2017 -0800 +++ b/src/timeconv.h Thu Dec 07 08:43:57 2017 -0800 @@ -24,6 +24,14 @@ @return result time_t value */ time_t pst_fileTimeToUnixTime( const FILETIME* filetime); + + /** Convert a FILETIME to string in date_format format. + @param[in] filetime time structure to be converted + @param[in] string ctime_r format of output date + @param[out] result pointer to output buffer, must be at least 30 bytes. + @return result size_t value returned by strftime + */ + size_t pst_fileTimeToString( const FILETIME* filetime, const char* date_format, char* result); #ifdef __cplusplus } #endif diff -r 506e266f930d -r ad7b880ad3d1 xml/libpst.in --- a/xml/libpst.in Mon Nov 20 08:19:28 2017 -0800 +++ b/xml/libpst.in Thu Dec 07 08:43:57 2017 -0800 @@ -35,7 +35,7 @@ - 2016-08-29 + 2017-12-07 @@ -325,6 +325,8 @@ lspst + + pstfile @@ -347,6 +349,18 @@ + -f date-format + + Select the date format for long format listing. Defaults to "%F %T". + + + + -l + + Use long format listing to show the Date, CC and BCC headers. + + + -h Show summary of options and exit. @@ -400,7 +414,7 @@ - 2016-08-29 + 2017-12-07 @@ -568,7 +582,7 @@ - 2016-08-29 + 2017-12-07 @@ -701,7 +715,7 @@ - 2016-08-29 + 2017-12-07