"Fossies" - the Fresh Open Source Software Archive

Member "postal-0.76/postal-list.cpp" (10 Apr 2008, 590 Bytes) of package /linux/privat/postal-0.76.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "postal-list.cpp" see the Fossies "Dox" file reference documentation.

    1 #include "expand.h"
    2 #include <cstdlib>
    3 #include <cstring>
    4 #include <stdio.h>
    5 
    6 
    7 void usage()
    8 {
    9   printf("Usage: postal-list input-file conversion-file\n");
   10   exit(1);
   11 }
   12 
   13 int main(int argc, char **argv)
   14 {
   15   if(argc != 3)
   16     usage();
   17   NameExpand exp(argv[2]);
   18   FILE *fp = fopen(argv[1], "r");
   19   if(!fp)
   20     usage();
   21   char buf[1024];
   22   while(fgets(buf, sizeof(buf), fp) )
   23   {
   24     if(buf[0] && buf[0] != '\n')
   25     {
   26       strtok(buf, "\n");
   27       string str;
   28       while(!exp.expand(str, buf, true))
   29       {
   30         printf("%s\n", str.c_str());
   31       }
   32     }
   33   }
   34   fclose(fp);
   35   return 0;
   36 }