Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:ragge:20061007091934

Diff

Diff from 1.48 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/pcc/pcc/cc/cc/cc.c

Annotated File View

ragge
1.48
1 /*      $Id: cc.c,v 1.48 2006/10/07 09:19:34 ragge Exp $        */
ragge
1.3
2 /*
3  * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * Redistributions of source code and documentation must retain the above
10  * copyright notice, this list of conditions and the following disclaimer.
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditionsand the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * All advertising materials mentioning features or use of this software
15  * must display the following acknowledgement:
16  *      This product includes software developed or owned by Caldera
17  *      International, Inc.
18  * Neither the name of Caldera International, Inc. nor the names of other
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
23  * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED.  IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
27  * FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT,
31  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
ragge
1.2
35
ragge
1.1
36 /*
ragge
1.3
37  * Front-end to the C compiler.
ragge
1.18
38  *
39  * Brief description of its syntax:
40  * - Files that end with .c are passed via cpp->ccom->as->ld
41  * - Files that end with .s are passed as->ld
42  * - Files that end with .o are passed directly to ld
43  * - Multiple files may be given on the command line.
44  * - Unrecognized options are all sent directly to ld.
45  * -c or -S cannot be combined with -o if multiple files are given.
46  *
47  * This file should be rewritten readable.
ragge
1.1
48  */
ragge
1.9
49 #include <sys/types.h>
ragge
1.36
50 #include <sys/wait.h>
ragge
1.2
51
ragge
1.1
52 #include <stdio.h>
53 #include <ctype.h>
54 #include <signal.h>
ragge
1.4
55 #include <string.h>
56 #include <fcntl.h>
57 #include <unistd.h>
58 #include <stdlib.h>
ragge
1.36
59 #include <stdarg.h>
60 #include <libgen.h>
pj
1.38
61 #include <errno.h>
ragge
1.24
62
ragge
1.39
63 #include "../../config.h"
64
ragge
1.24
65 #include "ccconfig.h"
ragge
1.3
66 /* C command */
ragge
1.1
67
ragge
1.20
68 #define MKS(x) _MKS(x)
69 #define _MKS(x) #x
70
71 /*
72  * Many specific definitions, should be declared elsewhere.
73  */
74 #define STDINC    "/usr/include"
75
ragge
1.3
76 #define SBSIZE 10000
ragge
1.12
77 #define MAXINC 100
ragge
1.3
78 #define MAXFIL 100
ragge
1.12
79 #define MAXLIB 10000
ragge
1.14
80 #define MAXAV  10000
ragge
1.3
81 #define MAXOPT 100
82 char    *tmp3;
83 char    *tmp4;
ragge
1.1
84 char    *outfile;
pj
1.31
85 char *copy(char *as),*setsuf(char *aschar ch);
ragge
1.4
86 int getsuf(char []);
87 int main(intchar *[]);
ragge
1.36
88 void error(char *, ...);
89 void errorx(int evalchar *, ...);
ragge
1.4
90 int nodup(char **, char *);
91 int callsys(char [], char *[]);
92 int cunlink(char *);
ragge
1.36
93 void dexit(int eval);
ragge
1.4
94 void idexit(int);
pj
1.30
95 char *gettmp();
ragge
1.14
96 char    *av[MAXAV];
ragge
1.3
97 char    *clist[MAXFIL];
98 char    *llist[MAXLIB];
ragge
1.4
99 char    alist[20];
ragge
1.43
100 char    *xlist[100];
101 int     xnum;
102 int     dflag;
ragge
1.3
103 int     pflag;
104 int     sflag;
105 int     cflag;
106 int     eflag;
107 int     gflag;
ragge
1.5
108 int     vflag;
ragge
1.7
109 int     tflag;
ragge
1.8
110 int     Eflag;
ragge
1.4
111 int     Oflag;
ragge
1.3
112 int     proflag;
ragge
1.1
113 int     exfail;
ragge
1.10
114 int     Xflag;
ragge
1.14
115 int     nostartfilesBstatic;
ragge
1.20
116 int     nostdinc;
ragge
1.43
117 int     onlyas;
ragge
1.14
118
ragge
1.23
119 char    *pass0 = LIBEXECDIR "/ccom";
120 char    *passp = LIBEXECDIR "/cpp";
ragge
1.47
121 char    *Bflag;
ragge
1.20
122 char    *sysinc;
ragge
1.25
123 char *cppadd[] = CPPADD;
124 char *dynlinker[] = DYNLINKER;
125 char *crt0file = CRT0FILE;
126 char *startfiles[] = STARTFILES;
127 char *endfiles[] = ENDFILES;
128 char *cppmdadd[] = CPPMDADD;
ragge
1.48
129 #ifndef STARTLABEL
130 #define STARTLABEL "__start"
131 #endif
ragge
1.1
132
ragge
1.4
133 int
pj
1.26
134 main(int argcchar *argv[])
135 {
ragge
1.15
136         char *t, *u;
ragge
1.1
137         char *assource;
ragge
1.3
138         char **pv, *ptemp[MAXOPT], **pvt;
ragge
1.36
139         int ncnlijcnxona;
ragge
1.3
140
ragge
1.36
141         i = nc = nl = nxo = 0;
ragge
1.3
142         pv = ptemp;
143         while(++i < argc) {
ragge
1.18
144                 if (argv[i][0] == '-')
145                 switch (argv[i][1]) {
ragge
1.3
146                 default:
147                         goto passa;
ragge
1.22
148
ragge
1.47
149                 case 'B'/* other search paths for binaries */
150                         Bflag = &argv[i][2];
ragge
1.22
151                         break;
152
ragge
1.10
153                 case 'X':
154                         Xflag++;
155                         break;
ragge
1.15
156                 case 'W'/* Ignore (most of) W-flags */
157                         if (strncmp(argv[i], "-Wl,"4) == 0) {
158                                 /* options to the linker */
159                                 t = &argv[i][4];
160                                 while ((u = strchr(t','))) {
161                                         *u++ = 0;
162                                         llist[nl++] = t;
163                                         t = u;
164                                 }
165                                 llist[nl++] = t;
166                         }
167                         break;
168
ragge
1.6
169                 case 'f'/* Ignore -ffreestanding */
170                         break;
ragge
1.14
171
ragge
1.25
172                 case 'g'/* create debug output */
173                         gflag++;
174                         break;
175
ragge
1.20
176                 case 'i':
177                         if (strcmp(argv[i], "-isystem") == 0) {
178                                 sysinc = argv[++i];
179                         } else
180                                 goto passa;
181                         break;
182
ragge
1.14
183                 case 'n'/* handle -n flags */
184                         if (strcmp(argv[i], "-nostdinc") == 0)
ragge
1.20
185                                 nostdinc++;
ragge
1.14
186                         else if (strcmp(argv[i], "-nostartfiles") == 0)
187                                 nostartfiles = 1;
188                         else
189                                 goto passa;
190                         break;
191
ragge
1.7
192                 case 'x':
ragge
1.43
193                         xlist[xnum++] = argv[i];
ragge
1.7
194                         break;
195                 case 't':
196                         tflag++;
197                         break;
ragge
1.1
198                 case 'S':
199                         sflag++;
200                         cflag++;
ragge
1.3
201                         break;
ragge
1.1
202                 case 'o':
ragge
1.18
203                         if (outfile)
ragge
1.36
204                                 errorx(8"too many -o");
ragge
1.18
205                         outfile = argv[++i];
ragge
1.3
206                         break;
ragge
1.1
207                 case 'O':
ragge
1.4
208                         Oflag++;
ragge
1.3
209                         break;
ragge
1.1
210                 case 'p':
211                         proflag++;
ragge
1.3
212                         break;
ragge
1.1
213                 case 'E':
ragge
1.8
214                         Eflag++;
215                         break;
ragge
1.1
216                 case 'P':
217                         pflag++;
ragge
1.3
218                         *pv++ = argv[i];
ragge
1.1
219                 case 'c':
220                         cflag++;
ragge
1.3
221                         break;
222
ragge
1.24
223 #if 0
ragge
1.3
224                 case '2':
225                         if(argv[i][2] == '\0')
226                                 pref = "/lib/crt2.o";
227                         else {
228                                 pref = "/lib/crt20.o";
229                         }
230                         break;
ragge
1.24
231 #endif
ragge
1.1
232                 case 'D':
233                 case 'I':
234                 case 'U':
235                 case 'C':
ragge
1.20
236                         *pv++ = argv[i];
ragge
1.3
237                         if (pv >= ptemp+MAXOPT)
238                                 {
ragge
1.36
239                                 error("Too many DIUC options");
ragge
1.3
240                                 --pv;
241                                 }
242                         break;
243
ragge
1.1
244                 case 'd':
ragge
1.3
245                         dflag++;
ragge
1.4
246                         strncpy(alistargv[i], 19);
ragge
1.3
247                         break;
ragge
1.5
248                 case 'v':
ragge
1.39
249                         printf("%s\n"VERSSTR);
ragge
1.5
250                         vflag++;
251                         break;
ragge
1.14
252
253                 case 's':
254                         if (strcmp(argv[i], "-static") == 0)
255                                 Bstatic = 1;
256                         else
257                                 goto passa;
258                         break;
ragge
1.3
259                 } else {
260                 passa:
261                         t = argv[i];
ragge
1.11
262                         if (*argv[i] == '-' && argv[i][1] == 'L')
263                                 ;
264                         else if((c=getsuf(t))=='c' || c=='s'|| Eflag) {
ragge
1.3
265                                 clist[nc++] = t;
266                                 if (nc>=MAXFIL)
267                                         {
ragge
1.36
268                                         error("Too many source files");
ragge
1.3
269                                         exit(1);
270                                         }
271                                 t = setsuf(t'o');
272                         }
273                         if (nodup(llistt)) {
274                                 llist[nl++] = t;
275                                 if (nl >= MAXLIB)
276                                         {
ragge
1.36
277                                         error("Too many object/library files");
ragge
1.3
278                                         exit(1);
279                                         }
280                                 if (getsuf(t)=='o')
281                                         nxo++;
ragge
1.1
282                         }
283                 }
284         }
ragge
1.18
285         /* Sanity checking */
286         if (nc == 0 && nl == 0)
ragge
1.36
287                 errorx(8"no input files");
ragge
1.18
288         if (outfile && (cflag || sflag) && nc > 1)
ragge
1.36
289                 errorx(8"-o given with -c || -S and more than one file");
ragge
1.19
290         if (outfile && clist[0] && strcmp(outfileclist[0]) == 0)
ragge
1.36
291                 errorx(8"output file will be clobbered");
ragge
1.18
292
ragge
1.4
293         if (gflagOflag = 0;
ragge
1.24
294 #if 0
295         if (proflag)
ragge
1.3
296                 pref = "/lib/mcrt0.o";
ragge
1.24
297 #endif
ragge
1.3
298         if(nc==0)
299                 goto nocom;
300         if (pflag==0) {
pj
1.30
301                 tmp3 = gettmp();
302                 tmp4 = gettmp();
ragge
1.1
303         }
ragge
1.3
304         if (signal(SIGINTSIG_IGN) != SIG_IGN/* interrupt */
ragge
1.1
305                 signal(SIGINTidexit);
ragge
1.3
306         if (signal(SIGTERMSIG_IGN) != SIG_IGN)        /* terminate */
ragge
1.1
307                 signal(SIGTERMidexit);
ragge
1.3
308         pvt = pv;
ragge
1.1
309         for (i=0i<nci++) {
ragge
1.18
310                 /*
311                  * C preprocessor
312                  */
ragge
1.37
313                 if (nc>1 && !Eflag)
ragge
1.1
314                         printf("%s:\n"clist[i]);
ragge
1.43
315                 onlyas = 0;
pj
1.32
316                 assource = tmp3;
ragge
1.3
317                 if (getsuf(clist[i])=='s') {
ragge
1.1
318                         assource = clist[i];
ragge
1.43
319                         onlyas = 1;
320                         goto assemble;
321                 } else if (getsuf(clist[i])=='S') {
322                         assource = clist[i];
323                         onlyas = 1;
pj
1.32
324                 }
ragge
1.1
325                 if (pflag)
326                         tmp4 = setsuf(clist[i], 'i');
ragge
1.5
327                 na = 0;
328                 av[na++] = "cpp";
ragge
1.20
329                 av[na++] = "-D__PCC__=" MKS(PCC_MAJOR);
ragge
1.40
330                 av[na++] = "-D__PCC_MINOR__=" MKS(PCC_MINOR);
331                 av[na++] = "-D__PCC_MINORMINOR__=" MKS(PCC_MINORMINOR);
ragge
1.20
332                 if (!nostdinc)
ragge
1.21
333                         av[na++] = "-S"av[na++] = STDINC;
ragge
1.20
334                 if (sysinc)
335                         av[na++] = "-S"av[na++] = sysinc;
ragge
1.5
336                 for (j = 0cppadd[j]; j++)
337                         av[na++] = cppadd[j];
ragge
1.24
338                 for (j = 0cppmdadd[j]; j++)
339                         av[na++] = cppmdadd[j];
ragge
1.7
340                 if (tflag)
ragge
1.20
341                         av[na++] = "-t";
ragge
1.7
342                 for(pv=ptemppv <pvtpv++)
343                         av[na++] = *pv;
ragge
1.5
344                 av[na++] = clist[i];
ragge
1.20
345                 if (!Eflag)
346                         av[na++] = tmp4;
ragge
1.3
347                 av[na++]=0;
348                 if (callsys(passpav))
349                         {exfail++; eflag++;}
ragge
1.11
350                 if (Eflag)
ragge
1.37
351                         continue;
ragge
1.43
352                 if (onlyas)
ragge
1.7
353                         goto assemble;
ragge
1.18
354
355                 /*
356                  * C compiler
357                  */
ragge
1.25
358                 na = 0;
359                 av[na++]= "ccom";
360                 if (gflag)
361                         av[na++] = "-g";
ragge
1.44
362                 if (Oflag) {
363                         av[na++] = "-xtemps";
364                 }
ragge
1.45
365                 for (j = 0j < xnumj++)
366                         av[na++] = xlist[j];
ragge
1.25
367                 av[na++] = tmp4;
ragge
1.3
368                 if (pflag || exfail)
369                         {
ragge
1.1
370                         cflag++;
371                         continue;
ragge
1.3
372                         }
ragge
1.16
373                 if(sflag) {
374                         if (outfile)
375                                 assource = tmp3 = outfile;
376                         else
377                                 assource = tmp3 = setsuf(clist[i], 's');
378                 }
ragge
1.25
379                 av[na++] = tmp3;
380 #if 0
ragge
1.3
381                 if (proflag) {
382                         av[3] = "-XP";
383                         av[4] = 0;
384                 } else
385                         av[3] = 0;
ragge
1.25
386 #endif
387                 av[na++] = NULL;
ragge
1.3
388                 if (callsys(pass0av)) {
ragge
1.1
389                         cflag++;
390                         eflag++;
391                         continue;
392                 }
393                 if (sflag)
394                         continue;
ragge
1.18
395
396                 /*
397                  * Assembler
398                  */
ragge
1.1
399         assemble:
ragge
1.3
400                 av[0] = "as";
401                 av[1] = "-o";
ragge
1.18
402                 if (outfile && cflag)
403                         av[2] = outfile;
404                 else
405                         av[2] = setsuf(clist[i], 'o');
ragge
1.43
406                 av[3] = onlyas ? tmp4 : assource;
ragge
1.3
407                 if (dflag) {
408                         av[4] = alist;
409                         av[5] = 0;
410                 } else
411                         av[4] = 0;
ragge
1.21
412                 if (callsys("/bin/as"av)) {
ragge
1.1
413                         cflag++;
414                         eflag++;
ragge
1.7
415                         cunlink(tmp4);
ragge
1.1
416                         continue;
417                 }
ragge
1.7
418                 cunlink(tmp4);
ragge
1.1
419         }
ragge
1.18
420
ragge
1.37
421         if (Eflag)
422                 dexit(eflag);
423
ragge
1.18
424         /*
425          * Linker
426          */
ragge
1.1
427 nocom:
428         if (cflag==0 && nl!=0) {
ragge
1.6
429                 j = 0;
430                 av[j++] = "ld";
431                 av[j++] = "-X";
432                 av[j++] = "-d";
433                 av[j++] = "-e";
ragge
1.48
434                 av[j++] = STARTLABEL;
ragge
1.14
435                 if (Bstatic == 0) { /* Dynamic linkage */
ragge
1.24
436                         for (i = 0dynlinker[i]; i++)
437                                 av[j++] = dynlinker[i];
ragge
1.14
438                 }
ragge
1.1
439                 if (outfile) {
ragge
1.3
440                         av[j++] = "-o";
441                         av[j++] = outfile;
442                 }
ragge
1.14
443                 if (!nostartfiles) {
ragge
1.24
444                         av[j++] = crt0file;
445                         for (i = 0startfiles[i]; i++)
446                                 av[j++] = startfiles[i];
ragge
1.14
447                 }
ragge
1.24
448                 i = 0;
ragge
1.14
449                 while(i<nl) {
ragge
1.3
450                         av[j++] = llist[i++];
ragge
1.14
451                         if (j >= MAXAV)
ragge
1.36
452                                 error("Too many ld options");
ragge
1.14
453                 }
ragge
1.11
454 #if 0
ragge
1.3
455                 if (gflag)
456                         av[j++] = "-lg";
ragge
1.11
457 #endif
ragge
1.6
458                 av[j++] = "-lc";
ragge
1.14
459                 if (!nostartfiles) {
ragge
1.24
460                         for (i = 0endfiles[i]; i++)
461                                 av[j++] = endfiles[i];
ragge
1.14
462                 }
ragge
1.3
463                 av[j++] = 0;
464                 eflag |= callsys("/bin/ld"av);
ragge
1.1
465                 if (nc==1 && nxo==1 && eflag==0)
ragge
1.3
466                         cunlink(setsuf(clist[0], 'o'));
ragge
1.46
467                 else if (nc > 0 && eflag == 0) {
468                         /* remove .o files XXX ugly */
469                         for (i = 0i < nci++)
470                                 cunlink(setsuf(clist[i], 'o'));
471                 }
ragge
1.1
472         }
ragge
1.36
473         dexit(eflag);
ragge
1.4
474         return 0;
ragge
1.1
475 }
476
ragge
1.36
477 /*
478  * exit and cleanup after interrupt.
479  */
ragge
1.4
480 void
481 idexit(int arg)
ragge
1.1
482 {
ragge
1.36
483         dexit(100);
ragge
1.1
484 }
485
ragge
1.36
486 /*
487  * exit and cleanup.
488  */
ragge
1.4
489 void
ragge
1.36
490 dexit(int eval)
ragge
1.1
491 {
ragge
1.10
492         if (!pflag && !Xflag) {
ragge
1.1
493                 if (sflag==0)
494                         cunlink(tmp3);
495                 cunlink(tmp4);
496         }
ragge
1.36
497         exit(eval);
ragge
1.1
498 }
499
ragge
1.36
500 static void
501 ccerror(char *sva_list ap)
ragge
1.1
502 {
ragge
1.36
503         vfprintf(Eflag ? stderr : stdoutsap);
ragge
1.8
504         putc('\n'Eflagstderr : stdout);
ragge
1.1
505         exfail++;
506         cflag++;
507         eflag++;
508 }
509
ragge
1.36
510 /*
511  * complain a bit.
512  */
513 void
514 error(char *s, ...)
515 {
516         va_list ap;
517
518         va_start(aps);
519         ccerror(sap);
520         va_end(ap);
521 }
522
523 /*
524  * complain a bit and then exit.
525  */
ragge
1.18
526 void
ragge
1.36
527 errorx(int evalchar *s, ...)
ragge
1.18
528 {
ragge
1.36
529         va_list ap;
530
531         va_start(aps);
532         ccerror(sap);
533         va_end(ap);
534         dexit(eval);
ragge
1.18
535 }
ragge
1.3
536
ragge
1.4
537 int
ragge
1.3
538 getsuf(as)
539 char as[];
ragge
1.1
540 {
541         register char *s;
542
ragge
1.4
543         if ((s = strrchr(as'.')) && s[1] != '\0' && s[2] == '\0')
544                 return s[1];
ragge
1.3
545         return(0);
ragge
1.1
546 }
547
ragge
1.36
548 /*
549  * Get basename of string s and change its suffix to ch.
550  */
ragge
1.1
551 char *
ragge
1.36
552 setsuf(char *schar ch)
ragge
1.1
553 {
ragge
1.36
554         s = copy(basename(s));
pj
1.31
555         s[strlen(s) - 1] = ch;
ragge
1.36
556         return(s);
ragge
1.1
557 }
558
ragge
1.4
559 int
ragge
1.3
560 callsys(fv)
561 char f[], *v[]; {
ragge
1.1
562         int tstatus;
ragge
1.4
563         char *s;
ragge
1.5
564
565         if (vflag) {
ragge
1.41
566                 fprintf(stderr"%s "f);
567                 for (t = 1v[t]; t++)
ragge
1.6
568                         fprintf(stderr"%s "v[t]);
569                 fprintf(stderr"\n");
ragge
1.5
570         }
ragge
1.1
571
ragge
1.3
572         if ((t=fork())==0) {
ragge
1.47
573                 if (Bflag) {
574                         char *a = malloc(strlen(Bflag) + 8);
575                         if ((s = strrchr(f'/'))) {
576                                 strcpy(aBflag);
577                                 strcat(as);
578                                 execv(av);
579                         }
580                 }
ragge
1.1
581                 execv(fv);
ragge
1.4
582                 if ((s = strrchr(f'/')))
583                         execvp(s+1v);
ragge
1.1
584                 printf("Can't find %s\n"f);
ragge
1.3
585                 exit(100);
586         } else
587                 if (t == -1) {
588                         printf("Try again\n");
589                         return(100);
590                 }
591         while(t!=wait(&status));
ragge
1.1
592         if ((t=(status&0377)) != 0 && t!=14) {
ragge
1.3
593                 if (t!=2)               /* interrupt */
ragge
1.36
594                         errorx(8"Fatal error in %s"f);
595                 dexit(eflag);
ragge
1.1
596         }
ragge
1.3
597         return((status>>8) & 0377);
ragge
1.1
598 }
599
ragge
1.3
600 char *
pj
1.28
601 copy(char *as)
ragge
1.3
602 {
pj
1.28
603         char *p;
604
ragge
1.36
605         if ((p = strdup(as)) == NULL)
606                 errorx(8"no space for file names");
ragge
1.3
607
pj
1.28
608         return p;
ragge
1.3
609 }
610
ragge
1.4
611 int
ragge
1.3
612 nodup(los)
613 char **l, *os;
ragge
1.1
614 {
615         register char *t, *s;
616         register int c;
617
618         s = os;
619         if (getsuf(s) != 'o')
ragge
1.3
620                 return(1);
ragge
1.4
621         while((t = *l++)) {
622                 while((c = *s++))
ragge
1.1
623                         if (c != *t++)
624                                 break;
ragge
1.3
625                 if (*t=='\0' && c=='\0')
626                         return(0);
ragge
1.1
627                 s = os;
628         }
ragge
1.3
629         return(1);
ragge
1.1
630 }
631
ragge
1.4
632 int
ragge
1.3
633 cunlink(f)
634 char *f;
ragge
1.1
635 {
ragge
1.13
636         if (f==0 || Xflag)
ragge
1.3
637                 return(0);
638         return(unlink(f));
ragge
1.1
639 }
pj
1.30
640
641 char *
642 gettmp()
643 {
644         char *sfn = strdup("/tmp/ctm.XXXXXX");
645         int fd = -1;
646
647         if ((fd = mkstemp(sfn)) == -1) {
648                 fprintf(stderr"%s: %s\n"sfnstrerror(errno));
649                 exit(8);
650         }
651         close(fd);
652
653         return sfn;
654 }
FishEye: Open Source License registered to PCC.
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-12-26 12:29 +0100