summaryrefslogtreecommitdiff
path: root/lang/icc11/files/as.c
blob: 8921f04ea6e0ccb092ad717877f10b57a15ef382 (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
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/syslimits.h>
#include <unistd.h>

#include "util.h"

int main(int argc, char* argv[])
{
	int i;
	char *s;
	char emul[PATH_MAX];

	for(i = 1; i < argc; i++) {
		if(strncmp(argv[i], "/tmp/i", 6) == 0) {
			strlcpy(emul, EMULDIR, sizeof(emul));
			strlcpy(emul + EMULDIR_LEN, argv[i], sizeof(emul) - EMULDIR_LEN);
			move_tmpicc(emul);
		}
	}

	if((s = getenv("ICC11_REALAS")) == NULL)
		s = "as";
	argv[0] = s;

	execvp(s, argv);

	s = strerror(errno);
	write(STDERR_FILENO, argv[0], strlen(argv[0]));
	write(STDERR_FILENO, ": ", 3);
	write(STDERR_FILENO, s, strlen(s));
	write(STDERR_FILENO, "\n", 1);
	return EXIT_FAILURE;
}