Home | History | Annotate | Download | only in 023-many-interfaces
      1 /*
      2  * Copyright 2006 The Android Open Source Project
      3  *
      4  * Generate a big pile of interface classes.
      5  */
      6 #include <stdio.h>
      7 
      8 /*
      9  * Create N interface files.
     10  */
     11 static int createFiles(int count)
     12 {
     13     FILE* fp;
     14     int i;
     15 
     16     for (i = 0; i < count; i++) {
     17         char nameBuf[32];
     18 
     19         snprintf(nameBuf, sizeof(nameBuf), "src/Interface%03d.java", i);
     20         fp = fopen(nameBuf, "w");
     21         if (fp == NULL) {
     22             fprintf(stderr, "ERROR: unable to open %s\n", nameBuf);
     23             return -1;
     24         }
     25 
     26         fprintf(fp, "interface Interface%03d {\n", i);
     27         if ((i & 0x01) != 0)
     28             fprintf(fp, "    int func%03d();\n", i);
     29         fprintf(fp, "}\n");
     30         fclose(fp);
     31     }
     32 
     33     fp = fopen("func-decl", "w");
     34     fprintf(fp, "    implements\n");
     35     for (i = 0; i < count; i++) {
     36         fprintf(fp, "        Interface%03d%s\n", i, (i == count-1) ? "" : ",");
     37     }
     38     fprintf(fp, "\n");
     39     for (i = 1; i < count; i += 2) {
     40         fprintf(fp, "    public int func%03d() { return %d; }\n", i, i);
     41     }
     42     fclose(fp);
     43 
     44     return 0;
     45 }
     46 
     47 int main()
     48 {
     49     int result;
     50 
     51     result = createFiles(100);
     52 
     53     return (result != 0);
     54 }
     55