summaryrefslogtreecommitdiffstats
path: root/tests/023-many-interfaces/iface-gen.c
blob: 1e3284a9e6fbb205418883287f783c37db3d16f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * Copyright 2006 The Android Open Source Project
 *
 * Generate a big pile of interface classes.
 */
#include <stdio.h>

/*
 * Create N interface files.
 */
static int createFiles(int count)
{
    FILE* fp;
    int i;

    for (i = 0; i < count; i++) {
        char nameBuf[32];

        sprintf(nameBuf, "src/Interface%03d.java", i);
        fp = fopen(nameBuf, "w");
        if (fp == NULL) {
            fprintf(stderr, "ERROR: unable to open %s\n", nameBuf);
            return -1;
        }

        fprintf(fp, "interface Interface%03d {\n", i);
        if ((i & 0x01) != 0)
            fprintf(fp, "    int func%03d();\n", i);
        fprintf(fp, "}\n");
        fclose(fp);
    }

    fp = fopen("func-decl", "w");
    fprintf(fp, "    implements\n");
    for (i = 0; i < count; i++) {
        fprintf(fp, "        Interface%03d%s\n", i, (i == count-1) ? "" : ",");
    }
    fprintf(fp, "\n");
    for (i = 1; i < count; i += 2) {
        fprintf(fp, "    public int func%03d() { return %d; }\n", i, i);
    }
    fclose(fp);

    return 0;
}

int main()
{
    int result;

    result = createFiles(100);

    return (result != 0);
}