~ubuntu-branches/ubuntu/intrepid/ecl/intrepid

« back to all changes in this revision

Viewing changes to src/c/unixsys.d

  • Committer: Bazaar Package Importer
  • Author(s): Peter Van Eynde
  • Date: 2006-06-21 09:21:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060621092121-txz1f21lj0wh0f67
Tags: 0.9h-20060617-1
* New upstream version
* Updated standards version without real changes. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#endif
30
30
 
31
31
cl_object
32
 
si_system(cl_object cmd)
 
32
si_system(cl_object cmd_string)
33
33
{
34
 
        volatile int code;
35
 
 
36
 
        assert_type_string(cmd);
37
 
        cmd = copy_simple_string(cmd);
38
 
        code = system((const char *)(cmd->string.self));
 
34
        cl_object cmd = si_copy_to_simple_base_string(cmd_string);
 
35
        int code = system((const char *)(cmd->base_string.self));
39
36
        /* FIXME! Are there any limits for system()? */
40
 
        /* if (cmd->string.fillp >= 1024)
 
37
        /* if (cmd->base_string.fillp >= 1024)
41
38
                FEerror("Too long command line: ~S.", 1, cmd);*/
42
39
        /* FIXME! This is a non portable way of getting the exit code */
43
40
        @(return MAKE_FIXNUM(code >> 8))
50
47
}
51
48
 
52
49
cl_object
53
 
si_open_pipe(cl_object cmd)
 
50
si_open_pipe(cl_object cmd_string)
54
51
{
55
52
#ifdef _MSC_VER
56
53
        FEerror("Pipes are not supported under Win32/MSVC", 0);
57
54
#else
58
55
        FILE *ptr;
59
56
        cl_object stream;
60
 
 
61
 
        assert_type_string(cmd);
62
 
        ptr = popen(cmd->string.self, "r");
 
57
        cl_object cmd = si_copy_to_simple_base_string(cmd);
 
58
        ptr = popen(cmd->base_string.self, "r");
63
59
        if (ptr == NULL)
64
60
                @(return Cnil);
65
61
        stream = cl_alloc_object(t_stream);
129
125
        cl_object stream_write;
130
126
        cl_object stream_read;
131
127
@{
132
 
        command = cl_string(command);
133
 
        argv = cl_mapcar(2, @'string', argv);
 
128
        command = si_copy_to_simple_base_string(command);
 
129
        argv = cl_mapcar(2, @'si::copy-to-simple-base-string', argv);
134
130
#if defined(mingw32) || defined (_MSC_VER)
135
131
{
136
132
        BOOL ok;
146
142
           arguments or file names have spaces */
147
143
        command =
148
144
                cl_format(4, Cnil,
149
 
                          make_simple_string("~S~{ ~S~}"),
 
145
                          make_simple_base_string("~S~{ ~S~}"),
150
146
                          command, argv);
151
147
 
152
148
        attr.nLength = sizeof(SECURITY_ATTRIBUTES);
246
242
        st_info.hStdOutput = child_stdout;
247
243
        st_info.hStdError = child_stderr;
248
244
        ZeroMemory(&pr_info, sizeof(PROCESS_INFORMATION));
249
 
        ok = CreateProcess(NULL, command->string.self,
 
245
        ok = CreateProcess(NULL, command->base_string.self,
250
246
                           NULL, NULL, /* lpProcess/ThreadAttributes */
251
247
                           TRUE, /* Inherit handles (for files) */
252
248
                           /*CREATE_NEW_CONSOLE |*/
255
251
                           NULL, /* Current directory */
256
252
                           &st_info, /* Startup info */
257
253
                           &pr_info); /* Process info */
258
 
#else
 
254
#else /* 1 */
259
255
        saved_stdin = GetStdHandle(STD_INPUT_HANDLE);
260
256
        saved_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
261
257
        saved_stderr = GetStdHandle(STD_ERROR_HANDLE);
265
261
        ZeroMemory(&st_info, sizeof(STARTUPINFO));
266
262
        st_info.cb = sizeof(STARTUPINFO);
267
263
        ZeroMemory(&pr_info, sizeof(PROCESS_INFORMATION));
268
 
        ok = CreateProcess(NULL, command->string.self,
 
264
        ok = CreateProcess(NULL, command->base_string.self,
269
265
                           NULL, NULL, /* lpProcess/ThreadAttributes */
270
266
                           TRUE, /* Inherit handles (for files) */
271
267
                           /*CREATE_NEW_CONSOLE |*/
277
273
        SetStdHandle(STD_INPUT_HANDLE, saved_stdin);
278
274
        SetStdHandle(STD_OUTPUT_HANDLE, saved_stdout);
279
275
        SetStdHandle(STD_ERROR_HANDLE, saved_stderr);
280
 
#endif
 
276
#endif /* 1 */
281
277
        if (ok) {
282
278
                CloseHandle(pr_info.hProcess);
283
279
                CloseHandle(pr_info.hThread);
297
293
                child_pid = -1;
298
294
        }
299
295
}
300
 
#else
 
296
#else /* mingw */
301
297
{
302
298
        int child_stdin, child_stdout, child_stderr;
303
299
        argv = CONS(command, nconc(argv, CONS(Cnil, Cnil)));
360
356
                        if (arg == Cnil) {
361
357
                                argv_ptr[j] = NULL;
362
358
                        } else {
363
 
                                argv_ptr[j] = arg->string.self;
 
359
                                argv_ptr[j] = arg->base_string.self;
364
360
                        }
365
361
                }
366
 
                execvp(command->string.self, argv_ptr);
 
362
                execvp(command->base_string.self, argv_ptr);
367
363
                /* at this point exec has failed */
368
364
                perror("exec");
369
365
                abort();
372
368
        close(child_stdout);
373
369
        close(child_stderr);
374
370
}
375
 
#endif
 
371
#endif /* mingw */
376
372
        if (child_pid < 0) {
377
373
                if (parent_write) close(parent_write);
378
374
                if (parent_read) close(parent_read);