Skip to content
Snippets Groups Projects
Commit cfb0619b authored by rswindell's avatar rswindell
Browse files

Added support for referencing a message on the command-line with the

'l' (list messages), 'x' (dump index), 'r' (read msgs), and 'v' (view msgs)
commands by "days old", by specifying a negative number (in days).
(e.g. "smbutil r-30" would read messages posted within the past 30 days).
This was added to test the smb_getmsgidx_by_time() function, but has some
value otherwise I suppose.
parent b0ff6adb
No related branches found
No related tags found
No related merge requests found
...@@ -1512,6 +1512,20 @@ short str2tzone(const char* str) ...@@ -1512,6 +1512,20 @@ short str2tzone(const char* str)
return 0; /* UTC */ return 0; /* UTC */
} }
long getmsgnum(const char* str)
{
if(*str == '-') {
time_t t = time(NULL) - (atol(str+1) * 24 * 60 * 60);
printf("%.24s\n", ctime(&t));
idxrec_t idx;
int result = smb_getmsgidx_by_time(&smb, &idx, t);
printf("match = %d, num %d\n", result, idx.number);
if(result >= 0)
return result + 1; /* 1-based offset */
}
return atol(str);
}
/***************/ /***************/
/* Entry point */ /* Entry point */
/***************/ /***************/
...@@ -1736,11 +1750,11 @@ int main(int argc, char **argv) ...@@ -1736,11 +1750,11 @@ int main(int argc, char **argv)
config(); config();
break; break;
case 'l': case 'l':
listmsgs(atol(cmd+1),count); listmsgs(getmsgnum(cmd+1),count);
y=strlen(cmd)-1; y=strlen(cmd)-1;
break; break;
case 'x': case 'x':
dumpindex(atol(cmd+1),count); dumpindex(getmsgnum(cmd+1),count);
y=strlen(cmd)-1; y=strlen(cmd)-1;
break; break;
case 'p': case 'p':
...@@ -1771,7 +1785,7 @@ int main(int argc, char **argv) ...@@ -1771,7 +1785,7 @@ int main(int argc, char **argv)
fprintf(errfp, "\nError %d (%s) unlocking %s\n", i, smb.last_error, smb.file); fprintf(errfp, "\nError %d (%s) unlocking %s\n", i, smb.last_error, smb.file);
break; break;
case 'r': case 'r':
readmsgs(atol(cmd+1)); readmsgs(getmsgnum(cmd+1));
y=strlen(cmd)-1; y=strlen(cmd)-1;
break; break;
case 'R': case 'R':
...@@ -1804,7 +1818,7 @@ int main(int argc, char **argv) ...@@ -1804,7 +1818,7 @@ int main(int argc, char **argv)
break; break;
case 'v': case 'v':
case 'V': case 'V':
viewmsgs(atol(cmd+1),count,cmd[y]=='V'); viewmsgs(getmsgnum(cmd+1),count,cmd[y]=='V');
y=strlen(cmd)-1; y=strlen(cmd)-1;
break; break;
case 'h': case 'h':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment