Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 6/7/83; site hao.UUCP Path: utzoo!linus!security!genrad!grkermit!masscomp!clyde!akgua!sb1!sb6!bpa!burdvax!presby!seismo!hao!pag From: pag@hao.UUCP Newsgroups: net.mail Subject: Program to make dbm files of mkpath database Message-ID: <745@hao.UUCP> Date: Mon, 28-Nov-83 19:38:05 EST Article-I.D.: hao.745 Posted: Mon Nov 28 19:38:05 1983 Date-Received: Thu, 1-Dec-83 03:31:07 EST Organization: High Altitude Obs./NCAR, Boulder CO Lines: 78 Recently Bill Sebok posted some changes to news to allow the "r" mail reply command use an optimal path database. Users of the "mkpath" program will note that mkpath does not create any dbm files. Here is a program to create dbm files for use by Bill Sebok's changes. It assumes that the mkpath database is in the file "/usr/lib/uucp/alpath". --peter gross hao!pag -------------- /* * Program to convert the mkpath database into dbm files * Compile: cc -O mkdbmpath.c -ldbm -o mkdbmpath */ #include #define NEWSPATH "/usr/lib/uucp/alpath" #define LIBU "/usr/lib/uucp" typedef struct { char *dptr; int dsize; }datum; main() { FILE *np; char templine[256]; register char *lp = templine; register char *p; datum lhs, rhs; char *index(); chdir(LIBU); sprintf(lp,"%s.dir",NEWSPATH); if((np=fopen(lp,"w"))==NULL) { fprintf(stderr,"Cannot create %s\n",lp); exit(1); } fclose(np); sprintf(lp,"%s.pag",NEWSPATH); if((np=fopen(lp,"w"))==NULL) { fprintf(stderr,"Cannot create %s\n",lp); exit(1); } fclose(np); if(dbminit(NEWSPATH)<0) { fprintf(stderr,"dbminit failed\n"); exit(1); } if((np=fopen(NEWSPATH,"r"))==NULL) { fprintf(stderr,"Cannot open %s\n",NEWSPATH); exit(1); } while(fgets(lp,128,np) != NULL) { p = index(lp,'\t'); if(p) *p++ = '\0'; lhs.dptr = lp; lhs.dsize = strlen(lhs.dptr) + 1; rhs.dptr = p; p = index(p,'\n'); if(p) *p = '\0'; rhs.dsize = strlen(rhs.dptr) + 1; if(store(lhs,rhs) < 0) { fprintf(stderr,"dbm store error\n"); exit(1); } } }