pag@hao.UUCP (11/29/83)
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 <stdio.h> #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); } } }