Annotation of capa/capa51/GUITools/manager.c, revision 1.1.1.1
1.1 albertel 1: /*
2: * manager.c
3: * Copyright Guy Albertelli II 1997
4: */
5: #include <stdio.h>
6: #include <tk.h>
7: #include <stdlib.h>
8: #include <Capa/capaCommon.h>
9: #include <unistd.h>
10: #include "manager.h"
11:
12: extern Tcl_Interp *gInterp;
13:
14: int Manager_Init(Tcl_Interp *interp);
15: int main(int argc,char **argv)
16: {
17: char * rDisplay,*q,filename[BUFFER_SIZE],buffer[BUFFER_SIZE];
18: int found=1;
19:
20: gInterp=Tcl_CreateInterp();
21: if (gInterp ==NULL)
22: {
23: fprintf(stderr,"Couldn't get a new Tcl Interp\n");
24: return -1;
25: }
26:
27: rDisplay = getenv("DISPLAY");
28:
29: if (rDisplay==NULL)
30: {
31: fprintf(stderr,"getenv for DISPLAY returned NULL\n");
32: return -2;
33: }
34:
35: if (Tcl_SetVar2 (gInterp, "env", "DISPLAY", rDisplay, TCL_GLOBAL_ONLY) == NULL)
36: {
37: fprintf(stderr,"Couldn't set env(DISPLAY) = %s\n",rDisplay);
38: return -3;
39: }
40:
41: q = Tcl_Merge(argc-1, argv+1);
42: Tcl_SetVar(gInterp, "argv", q, TCL_GLOBAL_ONLY);
43: ckfree(q);
44: sprintf(buffer, "%d", argc-1);
45: Tcl_SetVar(gInterp, "argc", buffer, TCL_GLOBAL_ONLY);
46: Tcl_SetVar(gInterp, "argv0", argv[0],TCL_GLOBAL_ONLY);
47: Tcl_SetVar(gInterp, "tcl_interactive","0", TCL_GLOBAL_ONLY);
48:
49: if (Tcl_Init(gInterp) == TCL_ERROR)
50: {
51: fprintf(stderr,"Tcl_Init error\n");
52: fprintf(stderr,"%d\n",TCL_ERROR);
53: fprintf(stderr,"%s\n",gInterp->result);
54: return -4;
55: }
56:
57: if (Tk_Init(gInterp) == TCL_ERROR)
58: {
59: fprintf(stderr,"Tk_Init error\n");
60: fprintf(stderr,"%d\n",TCL_ERROR);
61: fprintf(stderr,"%s\n",gInterp->result);
62: return -5;
63: }
64:
65: Manager_Init(gInterp);
66: Scorer_Init(gInterp);
67:
68: sprintf(filename,"./utils.tcl");
69: if( capa_access(filename, F_OK) == -1 ) {
70: sprintf(filename,"/usr/local/bin/Manager/utils.tcl");
71: if( capa_access(filename, F_OK) == -1 ) {
72: sprintf(filename,"/usr/local/lib/CAPA45/utils.tcl");
73: if( capa_access(filename, F_OK) == -1 ) {
74: sprintf(filename,"/usr/local/lib/utils.tcl");
75: if( capa_access(filename, F_OK) == -1 ) {
76: sprintf(filename,"/usr/local/lib/utils.tcl");
77: if( capa_access(filename, F_OK) == -1 ) {
78: sprintf(filename,"/usr/local/lib/CAPA45/Manager/utils.tcl");
79: if( capa_access(filename, F_OK) == -1 ) {
80: sprintf(filename,"/usr/lib/utils.tcl");
81: if( capa_access(filename, F_OK) == -1 ) { /* I gave up! */
82: found=0;
83: }
84: }
85: }
86: }
87: }
88: }
89: }
90:
91: if( found ) {
92: if (Tcl_EvalFile(gInterp, filename) != TCL_OK)
93: {
94: fprintf(stderr,"%s\n",gInterp->result);
95: return -6;
96: }
97: } else {
98: fprintf(stderr,"Unable to find utils.tcl\n");
99: exit(-7);
100: }
101:
102: sprintf(filename,"./common.tcl");
103: if( capa_access(filename, F_OK) == -1 ) {
104: sprintf(filename,"/usr/local/bin/Manager/common.tcl");
105: if( capa_access(filename, F_OK) == -1 ) {
106: sprintf(filename,"/usr/local/lib/CAPA45/common.tcl");
107: if( capa_access(filename, F_OK) == -1 ) {
108: sprintf(filename,"/usr/local/lib/common.tcl");
109: if( capa_access(filename, F_OK) == -1 ) {
110: sprintf(filename,"/usr/local/lib/common.tcl");
111: if( capa_access(filename, F_OK) == -1 ) {
112: sprintf(filename,"/usr/local/lib/CAPA45/Manager/common.tcl");
113: if( capa_access(filename, F_OK) == -1 ) {
114: sprintf(filename,"/usr/lib/common.tcl");
115: if( capa_access(filename, F_OK) == -1 ) { /* I gave up! */
116: found=0;
117: }
118: }
119: }
120: }
121: }
122: }
123: }
124: if( found ) {
125: if (Tcl_EvalFile(gInterp, filename) != TCL_OK)
126: {
127: fprintf(stderr,"%s\n",gInterp->result);
128: return -6;
129: }
130: } else {
131: fprintf(stderr,"Unable to find common.tcl\n");
132: exit(-7);
133: }
134: sprintf(filename,"./manager.tcl");
135: if( capa_access(filename, F_OK) == -1 ) {
136: sprintf(filename,"/usr/local/bin/Manager/manager.tcl");
137: if( capa_access(filename, F_OK) == -1 ) {
138: sprintf(filename,"/usr/local/lib/CAPA45/manager.tcl");
139: if( capa_access(filename, F_OK) == -1 ) {
140: sprintf(filename,"/usr/local/lib/manager.tcl");
141: if( capa_access(filename, F_OK) == -1 ) {
142: sprintf(filename,"/usr/local/lib/manager.tcl");
143: if( capa_access(filename, F_OK) == -1 ) {
144: sprintf(filename,"/usr/local/lib/CAPA45/Manager/manager.tcl");
145: if( capa_access(filename, F_OK) == -1 ) {
146: sprintf(filename,"/usr/lib/manager.tcl");
147: if( capa_access(filename, F_OK) == -1 ) { /* I gave up! */
148: found=0;
149: }
150: }
151: }
152: }
153: }
154: }
155: }
156:
157: /*
158: fprintf(stderr,"HEY STILL IN DEVELOPEMENT MODE\n");
159: if (Tcl_EvalFile(gInterp, "manager.tcl")
160: != TCL_OK)
161: {
162: fprintf(stderr,"%s\n",gInterp->result);
163: return -6;
164: }
165: */
166:
167: if( found ) {
168: if (Tcl_EvalFile(gInterp, filename) != TCL_OK)
169: {
170: fprintf(stderr,"%s\n",gInterp->result);
171: return -6;
172: }
173: while(Tcl_DoOneEvent(TCL_ALL_EVENTS));
174: } else {
175: fprintf(stderr,"Unable to find manager.tcl\n");
176: exit(-7);
177: }
178: return 0;
179: }
180:
181:
182:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>