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
......@@ -1512,6 +1512,20 @@ short str2tzone(const char* str)
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 */
/***************/
......@@ -1736,11 +1750,11 @@ int main(int argc, char **argv)
config();
break;
case 'l':
listmsgs(atol(cmd+1),count);
listmsgs(getmsgnum(cmd+1),count);
y=strlen(cmd)-1;
break;
case 'x':
dumpindex(atol(cmd+1),count);
dumpindex(getmsgnum(cmd+1),count);
y=strlen(cmd)-1;
break;
case 'p':
......@@ -1771,7 +1785,7 @@ int main(int argc, char **argv)
fprintf(errfp, "\nError %d (%s) unlocking %s\n", i, smb.last_error, smb.file);
break;
case 'r':
readmsgs(atol(cmd+1));
readmsgs(getmsgnum(cmd+1));
y=strlen(cmd)-1;
break;
case 'R':
......@@ -1804,7 +1818,7 @@ int main(int argc, char **argv)
break;
case 'v':
case 'V':
viewmsgs(atol(cmd+1),count,cmd[y]=='V');
viewmsgs(getmsgnum(cmd+1),count,cmd[y]=='V');
y=strlen(cmd)-1;
break;
case 'h':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment