From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: From: steve.simon@snellwilcox.com To: 9fans@cse.psu.edu MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-tynzcitkqhglhrxkiazbyhtfrn" Subject: [9fans] cookies Date: Fri, 13 Jun 2003 12:17:40 +0100 Topicbox-Message-UUID: cae32346-eacb-11e9-9e20-41e7f4b1d025 This is a multi-part message in MIME format. --upas-tynzcitkqhglhrxkiazbyhtfrn Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit 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 --upas-tynzcitkqhglhrxkiazbyhtfrn Content-Disposition: attachment; filename=cookconv.c Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit /* cookieconv.c - convert Microsoft IE6 cookie files into webcookies(4) format */ #include #include #include 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); } } --upas-tynzcitkqhglhrxkiazbyhtfrn--