nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

auto-int.c (677B)


      1 #include "substdio.h"
      2 #include "readwrite.h"
      3 #include "exit.h"
      4 #include "scan.h"
      5 #include "fmt.h"
      6 
      7 char buf1[256];
      8 substdio ss1 = SUBSTDIO_FDBUF(write,1,buf1,sizeof(buf1));
      9 
     10 void puts(s)
     11 char *s;
     12 {
     13   if (substdio_puts(&ss1,s) == -1) _exit(111);
     14 }
     15 
     16 int main(int argc, char **argv)
     17 {
     18   char *name;
     19   char *value;
     20   unsigned long num;
     21   char strnum[FMT_ULONG];
     22 
     23   if (argc != 3) return 100;
     24   name = argv[1];
     25   if (!name) return 100;
     26   value = argv[2];
     27   if (!value) return 100;
     28 
     29   scan_ulong(value,&num);
     30   strnum[fmt_ulong(strnum,num)] = 0;
     31 
     32   puts("int ");
     33   puts(name);
     34   puts(" = ");
     35   puts(strnum);
     36   puts(";\n");
     37   if (substdio_flush(&ss1) == -1) return 111;
     38   return 0;
     39 }