File: msvchelp.c

package info (click to toggle)
allegro4.2 2:4.2.0-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 24,436 kB
  • ctags: 14,714
  • sloc: ansic: 126,425; asm: 17,011; cpp: 3,846; sh: 2,120; objc: 925; makefile: 715; python: 216; pascal: 179; perl: 73
file content (49 lines) | stat: -rw-r--r-- 1,190 bytes parent folder | download
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
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
    char shortfilename[MAX_PATH];
    char *longfilename;
    int ret;
    FILE *fout;
    
    if (argc != 2) {
        fprintf(stderr, "No argument given!\n");
        return 1;
    }
    
    longfilename = getenv(argv[1]);
    if (longfilename == NULL) {
        fprintf(stderr, "Given argument does not correspond to any enviroment variable name!\n");
        return 2;
    }
    
    ret = GetShortPathName(longfilename, shortfilename, MAX_PATH);
    if (ret == 0 || ret > MAX_PATH) {
        fprintf(stderr, "Cannot convert to short name!\n");
        return 3;
    }
    
    fout = fopen("makefile.helper", "wt");
    if (fout == NULL) {
        fprintf(stderr, "Cannot create output file!\n");
        return 4;
    }
    
    ret = fprintf(fout, "%s = %s\n", argv[1], shortfilename);
    if (ret < 0) {
        fprintf(stderr, "Cannot write to the output file!\n");
        return 5;
    }
    
    ret = fclose(fout);
    if (ret != 0) {
        fprintf(stderr, "Cannot close the output file!\n");
        return 6;
    }
    
    return EXIT_SUCCESS;
}