Pristine Ack-5.5
[Ack-5.5.git] / util / LLgen / src / machdep.c
1 /* Copyright (c) 1991 by the Vrije Universiteit, Amsterdam, the Netherlands.
2  * For full copyright and restrictions on use see the file COPYING in the top
3  * level of the LLgen tree.
4  */
5
6 /*
7  *  L L G E N
8  *
9  *  An Extended LL(1) Parser Generator
10  *
11  *  Author : Ceriel J.H. Jacobs
12  */
13
14 /*
15  * machdep.c
16  * Machine dependant things
17  */
18
19 # include "types.h"
20
21 # ifndef NORCSID
22 static string rcsid5 = "$Id: machdep.c,v 2.9 1995/07/31 09:16:50 ceriel Exp $";
23 # endif
24
25 /* In this file the following routines are defined: */
26 extern  UNLINK();
27 extern  RENAME();
28 extern string   libpath();
29
30 UNLINK(x) string x; {
31         /* Must remove the file "x" */
32
33 #ifdef USE_SYS
34         sys_remove(x);  /* systemcall to remove file */
35 #else
36         unlink(x);
37 #endif
38 }
39
40 RENAME(x,y) string x,y; {
41         /* Must move the file "x" to the file "y" */
42
43 #ifdef USE_SYS
44         if(! sys_rename(x,y)) fatal(1,"Cannot rename to %s",y);
45 #else
46         unlink(y);
47         if (link(x,y) != 0) fatal(1,"Cannot rename to %s",y);
48         unlink(x);
49 #endif
50 }
51
52 /* to make it easier to patch ... */
53 char libdir[256] = LIBDIR;
54
55 string
56 libpath(s) string s; {
57         /* Must deliver a full pathname to the library file "s" */
58
59         register string p;
60         register length;
61         p_mem alloc();
62         string strcpy(), strcat();
63
64         length = strlen(libdir) + strlen(s) + 2;
65         p = (string) alloc((unsigned) length);
66         strcpy(p,libdir);
67         strcat(p,"/");
68         strcat(p,s);
69         return p;
70 }