示例#1
0
/* this gets called once to get the input stream going.
   It is called after the execution of the BEGIN block
   unless there is a getline inside BEGIN {}
*/
void
open_main(void)
{
    CELL argc;

#if USE_BINMODE
    int k = binmode();

    if (k & 1)
	setmode(0, O_BINARY);
    if (k & 2) {
	setmode(1, O_BINARY);
	setmode(2, O_BINARY);
    }
#endif

    cellcpy(&argc, ARGC);
    if (argc.type != C_DOUBLE)
	cast1_to_d(&argc);

    if (argc.dval == 1.0)
	set_main_to_stdin();
    else
	next_main(1);
}
示例#2
0
FIN *
FINopen(char *filename, int main_flag)
{
    FIN *result = 0;
    int fd;
    int oflag = O_RDONLY;

#if USE_BINMODE
    int bm = binmode() & 1;
    if (bm)
	oflag |= O_BINARY;
#endif

    TRACE(("FINopen(%s)\n", filename));
    if ((filename[0] == '-' && filename[1] == 0) ||
	(filename[0] == '/' && !strcmp(filename, "/dev/stdin"))) {
#if USE_BINMODE
	if (bm)
	    setmode(0, O_BINARY);
#endif
	result = FINdopen(0, main_flag);
    } else if ((fd = open(filename, oflag, 0)) != -1) {
	result = FINdopen(fd, main_flag);
    }
    return result;
}
示例#3
0
FIN *
FINopen(char *filename, int main_flag)
{
    int fd;
    int oflag = O_RDONLY;

#if USE_BINMODE
    int bm = binmode() & 1;
    if (bm)
        oflag |= O_BINARY;
#endif

    if (filename[0] == '-' && filename[1] == 0) {
#if USE_BINMODE
        if (bm)
            setmode(0, O_BINARY);
#endif
        return FINdopen(0, main_flag);
    }

    if ((fd = open(filename, oflag, 0)) == -1)
        return (FIN *) 0;
    else
        return FINdopen(fd, main_flag);
}
示例#4
0
PTR
get_pipe(char *command,
	 int type, int *tmp_idp)
{
    PTR retval;
    char xbuff[256];
    char *tmpname;

    *tmp_idp = next_tmp;
    tmpname = tmp_file_name(next_tmp, xbuff + 163);

    if (type == PIPE_OUT) {
	retval = (PTR) fopen(tmpname, (binmode() & 2) ? "wb" : "w");
    } else {
	sprintf(xbuff, "%s > %s", command, tmpname);
	tmp_idp[1] = DOSexec(xbuff);
	retval = (PTR) FINopen(tmpname, 0);
    }

    next_tmp++;
    return retval;
}
示例#5
0
FIN *
FINopen(char *filename, int main_flag)
{
    FIN *result = 0;
    int fd;
    int oflag = O_RDONLY;

#if USE_BINMODE
    int bm = binmode() & 1;
    if (bm)
	oflag |= O_BINARY;
#endif

    if (filename[0] == '-' && filename[1] == 0) {
#if USE_BINMODE
	if (bm)
	    setmode(0, O_BINARY);
#endif
	result = FINdopen(0, main_flag);
    } else if ((fd = open(filename, oflag, 0)) != -1) {
	result = FINdopen(fd, main_flag);
    }
    return result;
}