github.com/razvanm/vanadium-go-1.3@v0.0.0-20160721203343-4a65068e5915/src/cmd/dist/main.c (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 #include "a.h" 6 7 int vflag; 8 int sflag; 9 char *argv0; 10 11 // cmdtab records the available commands. 12 static struct { 13 char *name; 14 void (*f)(int, char**); 15 } cmdtab[] = { 16 {"banner", cmdbanner}, 17 {"bootstrap", cmdbootstrap}, 18 {"clean", cmdclean}, 19 {"env", cmdenv}, 20 {"install", cmdinstall}, 21 {"version", cmdversion}, 22 }; 23 24 // The OS-specific main calls into the portable code here. 25 void 26 xmain(int argc, char **argv) 27 { 28 int i; 29 30 if(argc <= 1) 31 usage(); 32 33 for(i=0; i<nelem(cmdtab); i++) { 34 if(streq(cmdtab[i].name, argv[1])) { 35 cmdtab[i].f(argc-1, argv+1); 36 return; 37 } 38 } 39 40 xprintf("unknown command %s\n", argv[1]); 41 usage(); 42 }