File: funsyste.c

package info (click to toggle)
icmake 6.22-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,120 kB
  • ctags: 1,045
  • sloc: ansic: 9,241; makefile: 1,138; asm: 126; sh: 124
file content (44 lines) | stat: -rw-r--r-- 1,049 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
\funcref{fun\_system}{void fun\_system ()}
    {}
    {}
    {}
    {fun\_exec()}
    {funsyste.c}
    {

        This function expects a system string as last pushed {\em e\_str}
        value. The string is executed through a {\em system()} call (if this
        fails, an error is issued).

    }
*/

#include "icm-exec.h"

void fun_system ()
{
    register char
        *sys;					/* cmd string */
    register int
    	ret,					/* system() return */
    	mode;					/* P_CHECK wanted? */

    mode = stack [sp].vu.intval;		/* get mode arg */
    sys = stack [sp - 1].vu.i->ls.str;		/* get cmd string */

    if (echo)					/* re-echo if requested */
        puts (sys);
    fflush (stdout);

#ifdef MSDOS
    _heapmin ();				/* max memory under DOS */
#endif
    
    ret = system (sys);				/* do system call */
    if (ret && P_CHECKMODE (mode))		/* terminate upon failure? */
        error ("system - failure of system call (status %d)", ret);
        
    reg.type = e_int;				/* return result as */
    reg.vu.intval = ret;			/* e_int */
}