cc.c File Reference

#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>

Include dependency graph for cc.c:

Go to the source code of this file.

Data Structures

struct  passinfo
struct  compile
struct  compile::pass
struct  arglist

Defines

#define SHELL   "/bin/sh"
#define PP   "/usr/lib/ncpp"
#define IRREL   "/usr/lib/irrel"
#define CEM   "/usr/lib/ncem"
#define M2EM   "/usr/lib/nm2em"
#define ENCODE   "/usr/lib/em_encode"
#define OPT   "/usr/lib/nopt"
#define CG   "/usr/lib/ncg"
#define AS   "/usr/lib/as"
#define LD   "/usr/lib/ld"
#define CV   "/usr/lib/cv"
#define LIBDIR   "/usr/lib"
#define CRT   "/usr/lib/ncrtso.o"
#define PEM   "/usr/lib/npem"
#define PRT   "/usr/lib/nprtso.o"
#define M2RT   "/usr/lib/nm2rtso.o"
#define LIBC   "/usr/lib/libd.a", "/usr/lib/libc.a"
#define LIBP   "/usr/lib/libp.a", "/usr/lib/libc.a"
#define LIBM2   "/usr/lib/libm2.a", "/usr/lib/libc.a"
#define END   "/usr/lib/libe.a", "/usr/lib/end.a"
#define M2DEF   "-I/usr/lib/m2"
#define INPUT   01
#define OUTPUT   02
#define LOADER   04
#define STDIN   010
#define STDOUT   020
#define NOCLEAN   040
#define O_OUTPUT   0100
#define PREPALWAYS   0200
#define PREPCOND   0400
#define PREPNOLN   01000
#define MAXHEAD   10
#define MAXTAIL   5
#define MAXPASS   7
#define DEFLANG   010
#define PREP_FLAGS
#define MAXARGC   150
#define USTR_SIZE   64
#define init(a)   ((a)->al_argc = 1)
#define cleanup(str)   (str && remove(str))

Typedefs

typedef char USTRING [USTR_SIZE]

Functions

 _PROTOTYPE (char *library,(char *nm))
 _PROTOTYPE (void trapcc,(int sig))
 _PROTOTYPE (int main,(int argc, char *argv[]))
 _PROTOTYPE (int remove,(char *str))
 _PROTOTYPE (char *alloc,(unsigned u))
 _PROTOTYPE (int append,(struct arglist *al, char *arg))
 _PROTOTYPE (int concat,(struct arglist *al1, struct arglist *al2))
 _PROTOTYPE (char *mkstr,(char *dst, char *arg1, char *arg2, char *arg3))
 _PROTOTYPE (int basename,(char *str, char *dst))
 _PROTOTYPE (char *extension,(char *fln))
 _PROTOTYPE (int runvec,(struct arglist *vec, struct passinfo *pass, char *in, char *out))
 _PROTOTYPE (int prnum,(unsigned x))
 _PROTOTYPE (int pr_vec,(struct arglist *vec))
 _PROTOTYPE (int mktempname,(char *nm))
 _PROTOTYPE (int mkbase,(void))
 _PROTOTYPE (int needsprep,(char *name))
 _PROTOTYPE (char *apply,(struct passinfo *pinf, struct compile *cp, char *name, int passindex, int noremove, int first, char *resultname))
 _PROTOTYPE (int applicable,(struct passinfo *pinf, char *suffix))
 _PROTOTYPE (char *process,(char *name, int noremove))
 _PROTOTYPE (int mkvec,(struct arglist *call, char *in, char *out, struct pass *pass, struct passinfo *pinf))
 _PROTOTYPE (int callld,(struct arglist *in, char *out, struct pass *pass, struct passinfo *pinf))
 _PROTOTYPE (int clean,(struct arglist *c))
 _PROTOTYPE (int scanflags,(struct arglist *call, struct passinfo *pinf))
char * library (char *nm)
void trapcc (int sig)
 main (argc, argv)
 remove (char *str)
char * alloc (unsigned u)
 append (struct arglist *al, char *arg)
 concat (struct arglist *al1, struct arglist *al2)
char * mkstr (char *dst, char *arg1, char *arg2, char *arg3)
 basename (char *str, char *dst)
char * extension (char *fln)
 runvec (struct arglist *vec, struct passinfo *pass, char *in, char *out)
 prnum (unsigned x)
 prs (char *str)
 panic (char *str)
 pr_vec (struct arglist *vec)
 ex_vec (struct arglist *vec)
 mktempname (char *nm)
 mkbase ()
 mkloader ()
 needsprep (char *name)
 cfile (char *name)
char * apply (struct passinfo *pinf, struct compile *cp, char *name, passindex, noremove, first, char *resultname)
int applicable (struct passinfo *pinf, char *suffix)
char * process (char *name, noremove)
 mkvec (struct arglist *call, char *in, char *out, struct pass *pass, struct passinfo *pinf)
 callld (struct arglist *in, char *out, struct pass *pass, struct passinfo *pinf)
 clean (struct arglist *c)
 scanflags (struct arglist *call, struct passinfo *pinf)

Variables

passinfo passinfo []
pass preprocessor
pass prepnoln
pass irrel
compile passes []
arglist CALLVEC
int kids = -1
char * o_FILE = "a.out"
char * ProgCall = 0
int RET_CODE = 0
char * stopsuffix
int v_flag = 0
int t_flag = 0
int noexec = 0
int fp_lib = 1
int E_flag = 0
int i_flag = 1
USTRING curfil
USTRING newfil
arglist SRCFILES
arglist LDIRS
arglist LDFILES
arglist GEN_LDFILES
arglist FLAGS
char * tmpdir = "/tmp"
char tmpname [64]
compilecompbase
pass * loader
passinfoloaderinfo
char * source
int maxLlen


Define Documentation

#define AS   "/usr/lib/as"
 

Definition at line 27 of file cc.c.

Referenced by starttcap().

#define CEM   "/usr/lib/ncem"
 

Definition at line 22 of file cc.c.

#define CG   "/usr/lib/ncg"
 

Definition at line 26 of file cc.c.

#define cleanup str   )     (str && remove(str))
 

Definition at line 212 of file cc.c.

Referenced by apply(), do_waitpid(), dowait(), e(), pm_exit(), quit(), and trapcc().

#define CRT   "/usr/lib/ncrtso.o"
 

Definition at line 31 of file cc.c.

#define CV   "/usr/lib/cv"
 

Definition at line 29 of file cc.c.

Referenced by starttcap().

#define DEFLANG   010
 

Definition at line 97 of file cc.c.

Referenced by process().

#define ENCODE   "/usr/lib/em_encode"
 

Definition at line 24 of file cc.c.

#define END   "/usr/lib/libe.a", "/usr/lib/end.a"
 

Definition at line 38 of file cc.c.

#define init a   )     ((a)->al_argc = 1)
 

Definition at line 211 of file cc.c.

Referenced by callld(), cmd_edit(), gzifstream::gzifstream(), gzofstream::gzofstream(), main(), mkvec(), and TTYinfo().

#define INPUT   01
 

Definition at line 60 of file cc.c.

Referenced by callld(), evaluate(), get_list(), mkvec(), prin1(), and unix_exec().

#define IRREL   "/usr/lib/irrel"
 

Definition at line 21 of file cc.c.

#define LD   "/usr/lib/ld"
 

Definition at line 28 of file cc.c.

#define LIBC   "/usr/lib/libd.a", "/usr/lib/libc.a"
 

Definition at line 35 of file cc.c.

#define LIBDIR   "/usr/lib"
 

Definition at line 30 of file cc.c.

Referenced by main().

#define LIBM2   "/usr/lib/libm2.a", "/usr/lib/libc.a"
 

Definition at line 37 of file cc.c.

#define LIBP   "/usr/lib/libp.a", "/usr/lib/libc.a"
 

Definition at line 36 of file cc.c.

#define LOADER   04
 

Definition at line 62 of file cc.c.

Referenced by main(), mkloader(), and process().

#define M2DEF   "-I/usr/lib/m2"
 

Definition at line 39 of file cc.c.

#define M2EM   "/usr/lib/nm2em"
 

Definition at line 23 of file cc.c.

#define M2RT   "/usr/lib/nm2rtso.o"
 

Definition at line 34 of file cc.c.

#define MAXARGC   150
 

Definition at line 195 of file cc.c.

Referenced by append(), and concat().

#define MAXHEAD   10
 

Definition at line 72 of file cc.c.

Referenced by callld(), and mkvec().

#define MAXPASS   7
 

Definition at line 74 of file cc.c.

#define MAXTAIL   5
 

Definition at line 73 of file cc.c.

#define NOCLEAN   040
 

Definition at line 65 of file cc.c.

Referenced by apply().

#define O_OUTPUT   0100
 

Definition at line 66 of file cc.c.

Referenced by mkvec().

#define OPT   "/usr/lib/nopt"
 

Definition at line 25 of file cc.c.

#define OUTPUT   02
 

Definition at line 61 of file cc.c.

Referenced by callld(), evaluate(), get_list(), mkvec(), prin1(), and unix_exec().

#define PEM   "/usr/lib/npem"
 

Definition at line 32 of file cc.c.

#define PP   "/usr/lib/ncpp"
 

Definition at line 20 of file cc.c.

#define PREP_FLAGS
 

Value:

"-D_EM_WSIZE=2", "-D_EM_PSIZE=2", "-D_EM_SSIZE=2", \
                        "-D_EM_LSIZE=4", "-D_EM_FSIZE=4", "-D_EM_DSIZE=8", \
                        "-D__ACK__", "-D__minix", "-D__i86"

Definition at line 115 of file cc.c.

#define PREPALWAYS   0200
 

Definition at line 67 of file cc.c.

Referenced by apply().

#define PREPCOND   0400
 

Definition at line 68 of file cc.c.

Referenced by apply().

#define PREPNOLN   01000
 

Definition at line 69 of file cc.c.

Referenced by apply().

#define PRT   "/usr/lib/nprtso.o"
 

Definition at line 33 of file cc.c.

#define SHELL   "/bin/sh"
 

Definition at line 19 of file cc.c.

#define STDIN   010
 

Definition at line 63 of file cc.c.

#define STDOUT   020
 

Definition at line 64 of file cc.c.

#define USTR_SIZE   64
 

Definition at line 196 of file cc.c.


Typedef Documentation

typedef char USTRING[USTR_SIZE]
 

Definition at line 198 of file cc.c.


Function Documentation

_PROTOTYPE int  scanflags,
(struct arglist *call, struct passinfo *pinf) 
 

_PROTOTYPE int  clean,
(struct arglist *c
 

_PROTOTYPE int  callld,
(struct arglist *in, char *out, struct pass *pass, struct passinfo *pinf) 
 

_PROTOTYPE int  mkvec,
(struct arglist *call, char *in, char *out, struct pass *pass, struct passinfo *pinf) 
 

_PROTOTYPE char *  process,
(char *name, int noremove) 
 

_PROTOTYPE int  applicable,
(struct passinfo *pinf, char *suffix
 

_PROTOTYPE char *  apply,
(struct passinfo *pinf, struct compile *cp, char *name, int passindex, int noremove, int first, char *resultname) 
 

_PROTOTYPE int  needsprep,
(char *name
 

_PROTOTYPE int  mkbase,
(void) 
 

_PROTOTYPE int  mktempname,
(char *nm) 
 

_PROTOTYPE int  pr_vec,
(struct arglist *vec) 
 

_PROTOTYPE int  prnum,
(unsigned x
 

_PROTOTYPE int  runvec,
(struct arglist *vec, struct passinfo *pass, char *in, char *out) 
 

_PROTOTYPE char *  extension,
(char *fln) 
 

_PROTOTYPE int  basename,
(char *str, char *dst) 
 

_PROTOTYPE char *  mkstr,
(char *dst, char *arg1, char *arg2, char *arg3) 
 

_PROTOTYPE int  concat,
(struct arglist *al1, struct arglist *al2) 
 

_PROTOTYPE int  append,
(struct arglist *al, char *arg
 

_PROTOTYPE char *  alloc,
(unsigned u) 
 

_PROTOTYPE int  remove,
(char *str
 

_PROTOTYPE int  main,
(int argc, char *argv[]) 
 

_PROTOTYPE void  trapcc,
(int sig
 

_PROTOTYPE char *  library,
(char *nm) 
 

char* alloc unsigned  u  ) 
 

Definition at line 467 of file cc.c.

References malloc(), p, and panic.

append struct arglist al,
char *  arg
 

Definition at line 476 of file cc.c.

References a, alloc(), MAXARGC, panic, strcpy(), and strlen().

int applicable struct passinfo pinf,
char *  suffix
 

Definition at line 833 of file cc.c.

References p, strlen(), and strncmp().

char* apply struct passinfo pinf,
struct compile cp,
char *  name,
passindex  ,
noremove  ,
first  ,
char *  resultname
 

Definition at line 769 of file cc.c.

References CALLVEC, cfile, cleanup, curfil, first, irrel, mkstr(), mkvec(), newfil, NOCLEAN, o_FILE, passinfo, PREPALWAYS, PREPCOND, prepnoln, PREPNOLN, preprocessor, runvec(), strcpy(), and tmpname.

Referenced by process().

basename char *  str,
char *  dst
 

Definition at line 520 of file cc.c.

References p1.

callld struct arglist in,
char *  out,
struct pass *  pass,
struct passinfo pinf
 

Definition at line 943 of file cc.c.

References append(), CALLVEC, if(), init, INPUT, library(), MAXHEAD, OUTPUT, and scanflags().

Referenced by main().

cfile char *  name  ) 
 

Definition at line 758 of file cc.c.

clean struct arglist c  ) 
 

Definition at line 983 of file cc.c.

References free.

Referenced by main(), onintr(), rundiff(), and runvec().

concat struct arglist al1,
struct arglist al2
 

Definition at line 488 of file cc.c.

References MAXARGC, p, and panic.

Referenced by evalcmd().

ex_vec struct arglist vec  ) 
 

Definition at line 672 of file cc.c.

References access, ENOEXEC, errno, execv, exit(), prs(), and SHELL.

Referenced by runvec().

char* extension char *  fln  ) 
 

Definition at line 542 of file cc.c.

References fn.

Referenced by process().

char* library char *  nm  ) 
 

Definition at line 276 of file cc.c.

References access, arglist::al_argc, arglist::al_argv, f, LDIRS, mkstr(), strcat(), and strlen().

Referenced by callld(), and main().

main argc  ,
argv 
 

Definition at line 311 of file cc.c.

References arglist::al_argc, arglist::al_argv, append(), argc, callld(), clean(), count, E_flag, exit(), FLAGS, fp_lib, free, GEN_LDFILES, i_flag, LDFILES, LDIRS, LIBDIR, library(), LOADER, loader, maxLlen, mkbase(), mkstr(), mktempname(), newfil, noexec, o_FILE, passinfo::p_flags, passinfo::p_name, passinfo::p_to, passinfo, process(), ProgCall, remove(), RET_CODE, SIG_IGN, SIGHUP, SIGINT, signal(), SIGQUIT, source, SRCFILES, stopsuffix, strcmp, strlen(), t_flag, tmpdir, tmpname, and v_flag.

mkbase  ) 
 

Definition at line 713 of file cc.c.

References basename, compbase, mkloader(), p, panic, passes, ProgCall, strcmp, and strlen().

Referenced by main().

mkloader  ) 
 

Definition at line 733 of file cc.c.

References compile::c_passes, compbase, loader, LOADER, loaderinfo, p, passinfo, and strcmp.

Referenced by mkbase().

char* mkstr char *  dst,
char *  arg1,
char *  arg2,
char *  arg3
 

Definition at line 502 of file cc.c.

References p.

Referenced by apply(), library(), main(), and mktempname().

mktempname char *  nm  ) 
 

Definition at line 696 of file cc.c.

References compile::c_callname, compbase, getpid, mkstr(), pid, and tmpdir.

Referenced by main().

mkvec struct arglist call,
char *  in,
char *  out,
struct pass *  pass,
struct passinfo pinf
 

Definition at line 914 of file cc.c.

References append(), i, if(), init, INPUT, MAXHEAD, O_OUTPUT, OUTPUT, scanflags(), and strcmp.

Referenced by apply().

needsprep char *  name  ) 
 

Definition at line 745 of file cc.c.

References close, open, and read.

panic char *  str  ) 
 

Definition at line 649 of file cc.c.

References prs(), SIGINT, and trapcc().

pr_vec struct arglist vec  ) 
 

Definition at line 656 of file cc.c.

References prs(), and strlen().

Referenced by runvec().

prnum unsigned  x  ) 
 

Definition at line 626 of file cc.c.

References cp, and prs().

Referenced by display(), and runvec().

char* process char *  name,
noremove 
 

Definition at line 859 of file cc.c.

References append(), apply(), base, basename, compbase, cp, DEFLANG, E_flag, extension(), first, GEN_LDFILES, LOADER, loaderinfo, passinfo::p_flags, passinfo::p_name, passinfo::p_to, passes, passinfo, stopsuffix, strcat(), strcmp, suffix, and tmpname.

prs char *  str  ) 
 

Definition at line 642 of file cc.c.

References strlen(), and write.

Referenced by badid(), collect(), dochdir(), dologin(), dotimes(), dotrap(), echo(), ex_vec(), execute(), forkexec(), getn(), iosetup(), newfile(), onintr(), panic(), pr_vec(), prn(), prnum(), readhere(), remove(), runvec(), tree(), waitfor(), warn(), and yylex().

remove char *  str  ) 
 

Definition at line 451 of file cc.c.

References noexec, prs(), t_flag, unlink, and v_flag.

Referenced by cleanUpAndFail(), getdiv(), killdiv(), main(), mpartition(), tar(), tmpfile(), uncompress(), and unzRepair().

runvec struct arglist vec,
struct passinfo pass,
char *  in,
char *  out
 

Definition at line 553 of file cc.c.

References clean(), close, creat, E_flag, ex_vec(), fork, kids, noexec, open, passinfo::p_flags, panic, pid, pr_vec(), prnum(), prs(), RET_CODE, SIGHUP, SIGINT, SIGPIPE, SIGQUIT, SIGTERM, status, STDIN, STDOUT, strcmp, strncmp(), v_flag, and wait.

Referenced by apply().

scanflags struct arglist call,
struct passinfo pinf
 

Definition at line 995 of file cc.c.

References arglist::al_argc, arglist::al_argv, FLAGS, p, and passinfo::p_acceptflags.

Referenced by callld(), and mkvec().

void trapcc int  sig  ) 
 

Definition at line 301 of file cc.c.

References cleanup, curfil, exit(), kids, kill, newfil, SIG_IGN, and signal().

Referenced by panic().


Variable Documentation

struct arglist CALLVEC
 

Definition at line 205 of file cc.c.

Referenced by apply(), and callld().

struct compile* compbase
 

Definition at line 238 of file cc.c.

Referenced by mkbase(), mkloader(), mktempname(), and process().

USTRING curfil
 

Definition at line 227 of file cc.c.

int E_flag = 0
 

Definition at line 223 of file cc.c.

Referenced by main(), process(), and runvec().

struct arglist FLAGS
 

Definition at line 233 of file cc.c.

Referenced by main(), and scanflags().

int fp_lib = 1
 

Definition at line 222 of file cc.c.

Referenced by main().

struct arglist GEN_LDFILES
 

Definition at line 232 of file cc.c.

Referenced by main(), and process().

int i_flag = 1
 

Definition at line 224 of file cc.c.

Referenced by main().

struct pass irrel
 

Initial value:

 { "irrel",
                            {0}
                        }

Definition at line 129 of file cc.c.

Referenced by apply().

int kids = -1
 

Definition at line 207 of file cc.c.

Referenced by runvec(), and trapcc().

struct arglist LDFILES
 

Definition at line 231 of file cc.c.

Referenced by main().

struct arglist LDIRS
 

Definition at line 230 of file cc.c.

Referenced by library(), and main().

struct pass* loader
 

Definition at line 239 of file cc.c.

Referenced by main(), and mkloader().

struct passinfo* loaderinfo
 

Definition at line 240 of file cc.c.

Referenced by mkloader(), and process().

int maxLlen
 

Definition at line 242 of file cc.c.

Referenced by main().

USTRING newfil
 

Definition at line 228 of file cc.c.

Referenced by apply(), main(), and trapcc().

int noexec = 0
 

Definition at line 221 of file cc.c.

Referenced by main(), remove(), and runvec().

char* o_FILE = "a.out"
 

Definition at line 209 of file cc.c.

Referenced by apply(), and main().

struct compile passes[]
 

Definition at line 136 of file cc.c.

Referenced by main(), mkbase(), process(), test16a(), and test19f().

struct passinfo passinfo[]
 

Initial value:

 {
        { "cpp", PP, "CPP", "i", "wo=o,I*,D*,U*,P", INPUT|STDOUT },
        { "irrel", IRREL, "i", "i", "m", INPUT},
        { "cem", CEM, "i,c", "k", "m=o,p,wa=a,wo=o,ws=s,w,T*", INPUT|OUTPUT|PREPALWAYS },
        { "pc", PEM, "i,p", "k", "n=L,w,a,A,R", INPUT|OUTPUT|PREPCOND },
        { "m2", M2EM, "i,mod", "k", "n=L,w*,A,R,W*,3,I*", INPUT|OUTPUT|PREPCOND },
        { "encode", ENCODE, "i,e", "k", "", INPUT|STDOUT|PREPCOND|PREPNOLN },
        { "opt", OPT, "k", "m", "", STDIN|STDOUT },
        { "cg", CG, "m", "s", "O=p4", INPUT|OUTPUT },
        { "as", AS, "i,s", "o", "T*", INPUT|O_OUTPUT|PREPCOND },
        { "ld", LD, "o", "out", "i,s", INPUT|LOADER },  
        { "cv", CV, "out", 0, "", INPUT|OUTPUT|NOCLEAN },       
        { 0}
}

Definition at line 100 of file cc.c.

Referenced by apply(), main(), mkloader(), and process().

struct pass prepnoln
 

Initial value:

 { "cpp",
                            { PREP_FLAGS, "-P" }
                            , {0}
                            }

Definition at line 124 of file cc.c.

Referenced by apply().

struct pass preprocessor
 

Initial value:

 { "cpp",
                            { PREP_FLAGS }
                            , {0}
                            }

Definition at line 119 of file cc.c.

Referenced by apply().

char* ProgCall = 0
 

Definition at line 214 of file cc.c.

Referenced by main(), and mkbase().

int RET_CODE = 0
 

Definition at line 216 of file cc.c.

Referenced by main(), and runvec().

char* source
 

Definition at line 241 of file cc.c.

Referenced by def(), getfile(), inf(), main(), rsource(), and unzOpenCurrentFile3().

struct arglist SRCFILES
 

Definition at line 229 of file cc.c.

Referenced by main().

char* stopsuffix
 

Definition at line 218 of file cc.c.

Referenced by main(), and process().

int t_flag = 0
 

Definition at line 220 of file cc.c.

Referenced by main(), and remove().

char* tmpdir = "/tmp"
 

Definition at line 235 of file cc.c.

Referenced by create_file_names(), main(), and mktempname().

char tmpname[64]
 

Definition at line 236 of file cc.c.

int v_flag = 0
 

Definition at line 219 of file cc.c.

Referenced by main(), remove(), and runvec().


Generated on Fri Apr 14 23:04:51 2006 for minix by  doxygen 1.4.6