main() { int uid, i; FILE *fd; char *myname, fname[128]; uid = getuid(); myname = (char *) getlogin(); if(myname == NULL) myname = getpwuid(uid)->pw_name; sprintf(fname, "%s/%s.key", maildir, myname); comminit(); setup(getpass("Gimme key: ")); mkb(); mkx(); #ifdef debug omout(b); omout(x); #endif mka(); i = creat(fname, 0644); if(i<0) { perror(fname); exit(1); } close(i); fd = fopen(fname, "w"); for(i=0; i<42; i++) nout(a[i], fd); exit(0); }
main() { int i; char *p; uid = getuid(); myname = getlogin(); if(myname == NULL) myname = getpwuid(uid)->pw_name; comminit(); mbuf = itom(0); files(); setup(getpass("Key: ")); mkb(); mkx(); #ifndef debug invert(x, b, x); #else invert(x, b, z); mult(x, z, z); mdiv(z, b, q, z); omout(z); invert(x, b, x); #endif for(i=0; i<fcnt; i++) { sprintf(line, "%s%s.%d", maildir, myname, fnum[i]); if(stat(line, &stbuf)<0) { perror(line); continue; } if(stbuf.st_size == 0) { printf("zero length mail file\n"); unlink(line); continue; } if((mf = fopen(line, "r"))==NULL) { perror(line); continue; } decipher(mf, stdout); cmnd: printf("? "); fgets(buf, sizeof(buf), stdin); if(feof(stdin)) exit(0); switch(buf[0]) { case 'q': exit(0); case 'n': case 'd': case '\n': unlink(line); fclose(mf); break; case '!': system(buf+1); printf("!\n"); goto cmnd; case 's': case 'w': rewind(mf); if(buf[1] == '\n' || buf[1] == '\0') strcpy(buf, "s mbox\n"); for(p=buf; !isspace(*p); p++); for(; isspace(*p); p++); p[strlen(p)-1] = 0; kf = fopen(p, "a"); if(kf == NULL) { perror(p); break; } decipher(mf, kf); fclose(mf); fclose(kf); unlink(line); break; } } exit(0); }
main() { int i; char *p; uid = getuid(); myname = (char *)getlogin(); if(myname == NULL) myname = getpwuid(uid)->pw_name; comminit(); mbuf = itom(0); files(); setup(getpass("Key: ")); mkb(); mkx(); #ifndef debug invert(x, b, x); #else invert(x, b, z); mult(x, z, z); mdiv(z, b, q, z); omout(z); invert(x, b, x); #endif for(i=0; i<fcnt; i++) { sprintf(line, "%s%s.%d", maildir, myname, fnum[i]); if(stat(line, &stbuf)<0) { perror(line); continue; } if(stbuf.st_size == 0) { printf("zero length mail file\n"); unlink(line); continue; } if((mf = fopen(line, "r"))==NULL) { perror(line); continue; } decipher(mf, stdout); cmnd: printf("? "); fgets(buf, sizeof(buf), stdin); if(feof(stdin)) exit(0); switch(buf[0]) { case 'q': exit(0); case 'n': case 'd': case '\n': fclose(mf); unlink(line); break; case '!': system(buf+1); printf("!\n"); goto cmnd; case 's': case 'w': rewind(mf); if(buf[1] == '\n' || buf[1] == '\0') strcpy(buf, "s mbox\n"); for(p = buf+1; isspace(*p); p++); p[strlen(p)-1] = 0; kf = fopen(p, "a"); if(kf == NULL) { perror(p); goto cmnd; } decipher(mf, kf); fclose(mf); fclose(kf); unlink(line); break; default: printf("Commands are:\n"); printf("q quit, leaving unread messages\n"); printf("n delete current message and goto next\n"); printf("d same as above\n"); printf("\\n same as above\n"); printf("! execute shell command\n"); printf("s save message in the named file or mbox\n"); printf("w same as above\n"); printf("? prints this list\n"); goto cmnd; } } exit(0); }