home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / auucp+-1.02 / fuucp_plus_src.lzh / sendmail / uupath.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-28  |  1.2 KB  |  63 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "config.h"
  5. #include "support.h"
  6.  
  7. #define VERDATE " 1.00 (30 Sep 90) "
  8.  
  9. static char *version20 = "$VER: uupath" VERDATE "\n\r";
  10.  
  11. void main(int argc, char **argv)
  12. {
  13.   datum key, path;
  14.   int argcount;
  15.   char *buf;
  16.  
  17.   if(argc == 1)
  18.   {
  19.     fprintf(stdout, "AmigaUUCP Plus: uupath" VERDATE "\n");
  20.     fprintf(stdout, "Usage: uupath system [...]\n");
  21.     exit(0);
  22.   }
  23.  
  24.   if(dbminit(MakeConfigPath(UULIB, "palias")) < 0)
  25.     exit(20);
  26.  
  27.   for(argcount = 1; argcount < argc; argcount++)
  28.   {
  29.     key.dptr  = argv[argcount];
  30.     key.dsize = strlen(argv[argcount]) + 1; /* NULL terminated */
  31.  
  32.     path = fetch(key);
  33.     if(path.dptr != NULL)
  34.     {
  35.       buf = malloc(strlen(path.dptr) + 1);
  36.       if(buf != NULL)
  37.       {
  38.         if(strcmp(path.dptr, "%s") == 0)
  39.         {
  40.         }
  41.         else
  42.         {
  43.           strcpy(buf, path.dptr);
  44.           *(buf + strlen(buf) - 3) = '\0'; /* Cut off '!%s' */
  45.  
  46.           fprintf(stdout, "%s\n", buf);
  47.         }
  48.         free(buf);
  49.       }
  50.       else
  51.       {
  52.         fprintf(stderr, "Insufficient free store.\n");
  53.         exit(20);
  54.       }
  55.     }
  56.     else
  57.     {
  58.       fprintf(stdout, "%s: no path found\n", argv[argcount]);
  59.     }
  60.   }
  61.   exit(0);
  62. }
  63.