* [9fans] cookies
@ 2003-06-13 11:17 steve.simon
0 siblings, 0 replies; only message in thread
From: steve.simon @ 2003-06-13 11:17 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 381 bytes --]
Hi,
Answering my question, I wrote the cooke converter code attached.
I am using cookies because is that we have a web based bullitin board here,
behind the firewall, that uses a cookie for authentication, nothing
secret, just to ensure posts have their owners names attached so
I feel cookies are an apropriate level of security - no matter
wat you all say :-)
-Steve
[-- Attachment #2: cookconv.c --]
[-- Type: text/plain, Size: 1306 bytes --]
/* cookieconv.c - convert Microsoft IE6 cookie files into webcookies(4) format */
#include <u.h>
#include <libc.h>
#include <bio.h>
int
parse(char **args, int n)
{
char *name, *value, *path, *domain;
vlong expire;
int secure;
if (strcmp(args[8], "*") != 0)
return -1;
name = args[0];
value = args[1];
if ((path = strchr(args[2], '/')) == nil)
return -1;
*path++ = 0;
domain = args[2];
secure = atoi(args[3]) & 1;
expire = atoll(args[4]) + (atoll(args[5]) << 32);
expire /= 10000000LL; // nanosec to sec
expire -= 11644473600LL; // MS epoch to POSIX epoch
print("name=%s value=%s path=/%s domain=%s secure=%d expire=%ld\n",
name, value, path, domain, secure, expire);
return 0;
}
void
main(int argc, char *argv[])
{
int i, j;
Biobuf *b;
char *args[20]; // the most I have seen is 10
argv0 = argv[0];
while(argv++, --argc){
if ((b = Bopen(*argv, OREAD)) == nil){
fprint(2, "%s: %s cannot open - %r\n", argv0, *argv);
continue;
}
while(1){
for (i = 0; i < nelem(args); i++){
if ((args[i] = Brdstr(b, '\n', 1)) == nil)
goto fin;
if (strcmp(args[i], "*") == 0){
parse(args, i);
for (j = 0; j < i; j++)
free(args[j]);
break;
}
}
}
fin:
Bterm(b);
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-06-13 11:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-13 11:17 [9fans] cookies steve.simon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).