utils/hyaku-1.1.0/mkhdr.c

/* [<][>]
[^][v][top][bottom][index][help] */

FUNCTIONS

This source file includes following functions.
  1. main
  2. mk_hdr
  3. get_line
  4. print_poem_i
  5. dumpit

   1 #include <stdio.h>
   2 #include <ctype.h>
   3 #include <string.h>
   4 
   5 
   6 long  txtbuff[7][BUFSIZ];
   7 
   8 void  mk_hdr(void);
   9 int   get_line(void);
  10 void  parseit(unsigned char*);
  11 void  print_poem_i(int n);
  12 void  dumpit(void);
  13 
  14 
  15 int
  16 main(int argc, char **argv)
     /* [<][>][^][v][top][bottom][index][help] */
  17 {
  18   mk_hdr();
  19 
  20   return 0;
  21 }
  22 
  23 void
  24 mk_hdr(void)
     /* [<][>][^][v][top][bottom][index][help] */
  25 {
  26   int  n, i;
  27 
  28   printf("
  29 struct s_poem {
  30   long phase1[8];
  31   long phase2[10];
  32   long phase3[8];
  33   long phase4[10];
  34   long phase5[10];
  35   long auth[32];
  36 };
  37 typedef  struct s_poem  *POEM;\n\n");
  38 
  39   printf("struct s_poem poem_table[] = {\n");
  40 
  41   for (i = 1; i <= 100; i++){
  42     while ((n = get_line()) != 7){
  43       if (n < 0) 
  44         break;
  45     }
  46     printf("  /* %d */\n", i);
  47     printf("  {");
  48     print_poem_i(2);    printf("\n   ");
  49     print_poem_i(3);    printf("\n   ");
  50     print_poem_i(4);    printf("\n   ");
  51     print_poem_i(5);    printf("\n   ");
  52     print_poem_i(6);    printf("\n   ");
  53     print_poem_i(1);
  54     printf("},\n");
  55     while ((n = get_line()) != 7){
  56       if (n < 0) 
  57         break;
  58     }
  59   }
  60 
  61   printf("};\n");
  62 }
  63 
  64 int
  65 get_line(void)
     /* [<][>][^][v][top][bottom][index][help] */
  66 {
  67   int  i, j, x;
  68   int  ch;
  69   long c;
  70 
  71   for (i = 0; i < 7; i++)
  72     txtbuff[i][0] = 0;
  73 
  74   for (i = 0; i < 7; i++){
  75     for (;;){
  76       if ((ch = getc(stdin)) < 0){
  77         txtbuff[i][0] = 0;
  78         return i-1;
  79       }
  80       if (!isspace(ch) || (ch == '\n')){
  81         ungetc(ch, stdin);
  82         break;
  83       }
  84     }
  85     j = 0;
  86     for (;;){
  87       if ((ch = getc(stdin)) < 0)
  88         return i;
  89       if (ch == '\n'){
  90         txtbuff[i][j] = 0;
  91         return i+1;
  92       }
  93       if (isspace(ch)){
  94         txtbuff[i][j] = 0;
  95         break;
  96       }
  97       if ((c = ch) > 0x80){
  98         ch = getc(stdin); 
  99         c = (c & 0x7f) * 256 + (ch & 0x7f);
 100       }
 101       if (c != '#'){
 102         txtbuff[i][j] = c;
 103       } else {
 104         txtbuff[i][j] = 0;
 105         for (;;){
 106           if (((ch = getc(stdin)) < 0) || (ch == '\n'))
 107             return i;
 108         }
 109       }
 110       j++;
 111     }
 112     txtbuff[i][j] = 0;
 113   }
 114   return i;
 115 }
 116 
 117 void
 118 print_poem_i(int n)
     /* [<][>][^][v][top][bottom][index][help] */
 119 {
 120   int  i, j;
 121   
 122   printf("{");
 123   for (j = 0; txtbuff[n][j] != 0; j++){
 124     printf("%d,", txtbuff[n][j]);
 125   }
 126   printf("0},"); 
 127 }
 128 
 129 void 
 130 dumpit(void)
     /* [<][>][^][v][top][bottom][index][help] */
 131 {
 132   int  i, j;
 133   
 134   for (i = 0; i < 7; i++){
 135     for (j = 0; txtbuff[i][j] != 0; j++){
 136       if (txtbuff[i][j] < 0x80){
 137         printf("%c", txtbuff[i][j]);
 138       } else {
 139         printf("%c%c", 0x80 | txtbuff[i][j]/256, 0x80 | txtbuff[i][j]);
 140       }
 141     }
 142     printf(" "); 
 143   }
 144   printf("\n"); 
 145 }
 146 

/* [<][>][^][v][top][bottom][index][help] */