summaryrefslogtreecommitdiffstats
path: root/test cases/native/5 install script/src/exe.c
blob: 2df3ee885e0e33aba9d638f515f4f669b4e7bd76 (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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char * argv[]) {
    if (argc != 2) {
        fprintf(stderr, "Takes exactly 2 arguments\n");
        return 1;
    }

    char * dirname = getenv("MESON_INSTALL_DESTDIR_PREFIX");
    char * fullname = malloc(strlen(dirname) + 1 + strlen(argv[1]) + 1);
    strcpy(fullname, dirname);
    strcat(fullname, "/");
    strcat(fullname, argv[1]);

    FILE * fp = fopen(fullname, "w");
    if (!fp)
        return 1;

    fputs("Some text\n", fp);
    fclose(fp);

    free(fullname);

    return 0;
}