github.com/rohankumardubey/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/src/cmd/dist/a.h (about) 1 // Copyright 2012 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 typedef int bool; 6 7 // The Time unit is unspecified; we just need to 8 // be able to compare whether t1 is older than t2 with t1 < t2. 9 typedef long long Time; 10 11 #define nil ((void*)0) 12 #define nelem(x) (sizeof(x)/sizeof((x)[0])) 13 #ifndef PLAN9 14 #define USED(x) ((void)(x)) 15 #endif 16 17 // A Buf is a byte buffer, like Go's []byte. 18 typedef struct Buf Buf; 19 struct Buf 20 { 21 char *p; 22 int len; 23 int cap; 24 }; 25 26 // A Vec is a string vector, like Go's []string. 27 typedef struct Vec Vec; 28 struct Vec 29 { 30 char **p; 31 int len; 32 int cap; 33 }; 34 35 // Modes for run. 36 enum { 37 CheckExit = 1, 38 }; 39 40 // buf.c 41 bool bequal(Buf *s, Buf *t); 42 void bsubst(Buf *b, char *x, char *y); 43 void bfree(Buf *b); 44 void bgrow(Buf *b, int n); 45 void binit(Buf *b); 46 char* bpathf(Buf *b, char *fmt, ...); 47 char* bprintf(Buf *b, char *fmt, ...); 48 void bwritef(Buf *b, char *fmt, ...); 49 void breset(Buf *b); 50 char* bstr(Buf *b); 51 char* btake(Buf *b); 52 void bwrite(Buf *b, void *v, int n); 53 void bwriteb(Buf *dst, Buf *src); 54 void bwritestr(Buf *b, char *p); 55 void bswap(Buf *b, Buf *b1); 56 void vadd(Vec *v, char *p); 57 void vcopy(Vec *dst, char **src, int n); 58 void vfree(Vec *v); 59 void vgrow(Vec *v, int n); 60 void vinit(Vec *v); 61 void vreset(Vec *v); 62 void vuniq(Vec *v); 63 void splitlines(Vec*, char*); 64 void splitfields(Vec*, char*); 65 66 // build.c 67 extern char *goarch; 68 extern char *gobin; 69 extern char *gochar; 70 extern char *gohostarch; 71 extern char *gohostos; 72 extern char *goos; 73 extern char *goroot; 74 extern char *goroot_final; 75 extern char *goextlinkenabled; 76 extern char *goversion; 77 extern char *defaultcc; 78 extern char *defaultcxx; 79 extern char *workdir; 80 extern char *tooldir; 81 extern char *slash; 82 extern bool rebuildall; 83 extern bool defaultclang; 84 85 int find(char*, char**, int); 86 void init(void); 87 void cmdbanner(int, char**); 88 void cmdbootstrap(int, char**); 89 void cmdclean(int, char**); 90 void cmdenv(int, char**); 91 void cmdinstall(int, char**); 92 void cmdversion(int, char**); 93 94 // buildgc.c 95 void gcopnames(char*, char*); 96 void mkenam(char*, char*); 97 98 // buildruntime.c 99 void mkzasm(char*, char*); 100 void mkzsys(char*, char*); 101 void mkzgoarch(char*, char*); 102 void mkzgoos(char*, char*); 103 void mkzruntimedefs(char*, char*); 104 void mkzversion(char*, char*); 105 void mkzexperiment(char*, char*); 106 107 // buildgo.c 108 void mkzdefaultcc(char*, char*); 109 110 // goc2c.c 111 void goc2c(char*, char*); 112 113 // main.c 114 extern int vflag; 115 extern int sflag; 116 void usage(void); 117 void xmain(int argc, char **argv); 118 119 // portability layer (plan9.c, unix.c, windows.c) 120 bool contains(char *p, char *sep); 121 void errprintf(char*, ...); 122 void fatal(char *msg, ...); 123 bool hasprefix(char *p, char *prefix); 124 bool hassuffix(char *p, char *suffix); 125 bool isabs(char*); 126 bool isdir(char *p); 127 bool isfile(char *p); 128 char* lastelem(char*); 129 Time mtime(char*); 130 void readfile(Buf*, char*); 131 void run(Buf *b, char *dir, int mode, char *cmd, ...); 132 void runv(Buf *b, char *dir, int mode, Vec *argv); 133 void bgrunv(char *dir, int mode, Vec *argv); 134 void bgwait(void); 135 bool streq(char*, char*); 136 bool cansse2(void); 137 void writefile(Buf*, char*, int); 138 void xatexit(void (*f)(void)); 139 void xexit(int); 140 void xfree(void*); 141 void xgetenv(Buf *b, char *name); 142 void xgetwd(Buf *b); 143 void* xmalloc(int n); 144 void* xmalloc(int); 145 int xmemcmp(void*, void*, int); 146 void xmemmove(void*, void*, int); 147 void xmkdir(char *p); 148 void xmkdirall(char*); 149 Time xmtime(char *p); 150 void xprintf(char*, ...); 151 void xqsort(void*, int, int, int(*)(const void*, const void*)); 152 void xreaddir(Vec *dst, char *dir); 153 void* xrealloc(void*, int); 154 void xrealwd(Buf *b, char *path); 155 void xremove(char *p); 156 void xremoveall(char *p); 157 void xsetenv(char*, char*); 158 int xstrcmp(char*, char*); 159 char* xstrdup(char *p); 160 int xstrlen(char*); 161 char* xstrrchr(char*, int); 162 char* xstrstr(char*, char*); 163 char* xworkdir(void); 164 int xsamefile(char*, char*); 165 char* xgetgoarm(void); 166 int xtryexecfunc(void (*)(void));