OSDN Git Service

Ruby-2.0.0 is now included in the repository.
[molby/Molby.git] / MolLib / cmdtool_stubs.c
1 /*
2  *  cmdtool_stubs.c
3  *
4  *  Created by Toshi Nagata on Sun Jun 17 2001.
5  
6  Copyright (c) 2010 Toshi Nagata. All rights reserved.
7  
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation version 2 of the License.
11  
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  GNU General Public License for more details.
16  */
17
18 /*  Empty stub functions for command-line tool  */
19
20 #include "MolLib.h"
21 #include "Ruby_bind/Molby_extern.h"
22 #include "Missing.h"
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <stdarg.h>
26 #include <string.h>
27 #include <fcntl.h>
28 #include <unistd.h>
29
30 #include <ruby.h>
31
32 Molecule *
33 MoleculeCallback_moleculeAtOrderedIndex(int idx)
34 {
35         return NULL;
36 }
37
38 void
39 MainViewCallback_setNeedsDisplay(MainView *mview, int flag)
40 {
41 }
42
43 /*
44 void
45 MainViewCallback_moleculeReplaced(MainView *mview, struct Molecule *mol)
46 {
47 }
48 */
49
50 void
51 MyAppCallback_beginUndoGrouping(void)
52 {
53 }
54
55 Molecule *
56 MoleculeCallback_currentMolecule(void)
57 {
58         return NULL;
59 }
60
61 void
62 MoleculeCallback_lockMutex(void *mutex)
63 {
64 }
65
66 void
67 MoleculeCallback_unlockMutex(void *mutex)
68 {
69 }
70
71 int
72 MoleculeCallback_callSubProcessAsync(Molecule *mol, const char *cmd, int (*callback)(Molecule *, int), int (*timerCallback)(Molecule *, int), FILE *output, FILE *errout)
73 {
74         return -1;
75 }
76
77 void
78 MyAppCallback_setGlobalSettings(const char *key, const char *value)
79 {
80 }
81
82 void
83 MyAppCallback_hideProgressPanel(void)
84 {
85 }
86
87 int
88 MyAppCallback_showScriptMessage(const char *fmt, ...)
89 {
90         va_list ap;
91         va_start(ap, fmt);
92         return vprintf(fmt, ap);
93 }
94
95 char *
96 MyAppCallback_getDocumentHomeDir(void)
97 {
98         char *s;
99         s = getenv("HOME");
100         return (s == NULL ? NULL : strdup(s));
101 }
102
103 char *
104 MyAppCallback_getHomeDir(void)
105 {
106         char *s;
107         s = getenv("HOME");
108         return (s == NULL ? NULL : strdup(s));
109 }
110
111 RubyValue
112 MyAppCallback_executeScriptFromFile(const char *path, int *status)
113 {
114         return 0;
115 }
116
117 void
118 MyAppCallback_setProgressMessage(const char *msg)
119 {
120 }
121
122 int
123 MainView_isAtomHidden(MainView *mview, int index)
124 {
125         return 0;
126 }
127
128 int
129 MolActionCallback_isUndoRegistrationEnabled(Molecule *mol)
130 {
131         return 0;
132 }
133
134 int
135 MyAppCallback_messageBox(const char *message, const char *title, int flags, int icon)
136 {
137         return printf("%s\n%s\n", title, message);
138 }
139
140 void
141 MainViewCallback_drawInfoText(MainView *mview, const char *label)
142 {
143 }
144
145 int
146 MyAppCallback_checkInterrupt(void)
147 {
148         return 0;
149 }
150
151 char *
152 MyAppCallback_getGlobalSettings(const char *key)
153 {
154         return NULL;
155 }
156
157 void
158 MyAppCallback_setProgressValue(double dval)
159 {
160 }
161
162 void
163 MyAppCallback_showProgressPanel(const char *msg)
164 {
165 }
166
167 int
168 MyAppCallback_getTextWithPrompt(const char *prompt, char *buf, int bufsize)
169 {
170         buf[0] = 0;
171         return 0;
172 }
173
174 int
175 MyAppCallback_callSubProcess(const char *cmdline, const char *procname, int (*callback)(void *), void *callback_data, FILE *output, FILE *errout)
176 {
177         return system(cmdline);
178 }
179
180 void
181 MainViewCallback_display(MainView *mview)
182 {
183 }
184
185 void
186 MainViewCallback_makeFront(MainView *mview)
187 {
188 }
189
190 int
191 MolActionCallback_setUndoRegistrationEnabled(Molecule *mol, int flag)
192 {
193         return 0;
194 }
195
196 void
197 MoleculeCallback_notifyModification(Molecule *mp, int now_flag)
198 {
199 }
200
201 void
202 MyAppCallback_setConsoleColor(int color)
203 {
204 }
205
206 void
207 MyAppCallback_errorMessageBox(const char *fmt, ...)
208 {
209         va_list ap;
210         va_start(ap, fmt);
211         vfprintf(stderr, fmt, ap);
212 }
213
214 int
215 MyAppCallback_registerScriptMenu(const char *title)
216 {
217         return -1;
218 }
219
220 int
221 MyAppCallback_lookupScriptMenu(const char *title)
222 {
223         return 0;
224 }
225
226 void
227 MyAppCallback_endUndoGrouping(void)
228 {
229 }
230
231 void
232 MyAppCallback_showConsoleWindow(void)
233 {
234 }
235
236 void
237 MyAppCallback_hideConsoleWindow(void)
238 {
239 }
240
241 Molecule *
242 MoleculeCallback_openNewMolecule(const char *fname)
243 {
244         return NULL;
245 }
246
247 void MyAppCallback_bell(void)
248 {
249 }
250
251 int MyAppCallback_playSound(const char *filename, int flag)
252 {
253         return 0;
254 }
255
256 void MyAppCallback_stopSound(void)
257 {
258 }
259
260 void
261 MainView_getCamera(MainView *mview, Vector *outCamera, Vector *outLookAt, Vector *outUp)
262 {
263 }
264
265 void
266 RubyDialogInitClass(void)
267 {
268 }
269
270 Molecule *
271 MoleculeCallback_moleculeAtIndex(int idx)
272 {
273         return NULL;
274 }
275
276 void
277 MoleculeCallback_displayName(Molecule *mol, char *buf, int bufsize)
278 {
279         buf[0] = 0;
280 }
281
282 int
283 MoleculeCallback_setDisplayName(Molecule *mol, const char *name)
284 {
285         return 0;
286 }
287
288 void
289 MoleculeCallback_pathName(Molecule *mol, char *buf, int bufsize)
290 {
291         if (mol != NULL && mol->path != NULL) {
292                 strncpy(buf, mol->path, bufsize - 1);
293                 buf[bufsize - 1] = 0;
294         } else buf[0] = 0;
295 }
296
297 IntGroup *
298 MainView_selectedMO(MainView *mview)
299 {
300         return NULL;
301 }
302
303 void
304 MainView_resizeToFit(MainView *mview)
305 {
306 }
307
308 void
309 MolActionCallback_registerUndo(Molecule *mol, MolAction *action)
310 {
311 }
312
313 int
314 main(int argc, char **argv)
315 {
316         int fd;
317         char *scriptdir;
318         static const char fname[] = "startup.rb";
319         char *molbydir = getenv("MOLBYDIR");
320         if (molbydir == NULL) {
321                 fprintf(stderr, "Please define the environmental variable MOLBYDIR to specify the location in which the 'Scripts' directory is present.\n");
322                 exit(1);
323         }
324         asprintf(&scriptdir, "%s%cScripts", molbydir, PATH_SEPARATOR);
325         fd = open(".", O_RDONLY);
326         chdir(scriptdir);
327         
328         Molby_startup(fname, scriptdir);
329
330         fchdir(fd);
331         close(fd);
332         
333         free(scriptdir);
334         
335         ruby_run_node(ruby_options(argc, argv));
336
337         return 0;
338 }