File indexing completed on 2024-04-21 04:03:14

0001 //testing preprocessor script
0002 //nothing useful, just a toy :)
0003 
0004 #include <stdio.h>
0005 #include <string.h>
0006 #include <kvbox.h>
0007 
0008 int main()
0009 {
0010   char line[1001];
0011   char line2[1004];
0012   int prompt;
0013   while (1) {
0014     fgets (line, 1000, stdin);
0015     int len = strlen(line);
0016     if (line[len-1] != '\n') continue;
0017     line[len-1] = '\0';
0018     prompt = 0;
0019     if (len && (line[len-2] == 1))
0020     {
0021       line[len-2] = '\0';
0022       prompt = 1;
0023     }
0024     len = strlen(line);
0025     line2[0] = prompt ? '2' : '1';
0026     line2[1] = ' ';
0027     //we output all lines in reverse order :)
0028     //not really useful, just a toy :)
0029     //note that this breaks ANSI sequences
0030     for (int i = 0; i < len; i++)
0031       line2[2 + i] = line[len - 1 - i];
0032     line2[len+2] = '\n';
0033     line2[len+3] = '\0';
0034     fputs (line2,stdout);
0035     fflush(stdout);
0036   };
0037   return 0;
0038 }
0039