Exemplo n.º 1
0
void	main_parser(char *func_name)
{
	int		func_id;

	func_id = atoi(func_name);
	switch (func_id)
	{
		case 0 : ret_error(2); break ;
		default : ret_error(2); break ;
	}
}
Exemplo n.º 2
0
int		main(int argc, char **argv)
{
	int		fd;

	if (argc != 2)
	{
		ret_error(0);
		return (EXIT_FAILURE);
	}
	fd = open(argv[1], O_RDONLY);
	if (fd == -1)
	{
		ret_error(1);
		return (EXIT_FAILURE);
	}
	file_read(fd);
	return (EXIT_SUCCESS);
}
Exemplo n.º 3
0
int main(){

    printf("Now, program will start.......\n");
    null_line();
    ret_pass();
    printf("PASS: Program finished that.......\n");
    null_line();
    ret_fail();
    printf("FAIL: Program failed in.......\n");
    null_line();
    ret_error();
    printf("ERROR: Found error in .......\n");

    return 0;
}
Exemplo n.º 4
0
int setupterm(const char *tname, int Filedes, int *errret)
{
struct term	*term_ptr;
int status;

	T((T_CALLED("setupterm(\"%s\",%d,%p)"), tname, Filedes, errret));

	if (tname == 0) {
		tname = getenv("TERM");
		if (tname == 0 || *tname == '\0') {
			ret_error0(-1, "TERM environment variable not set.\n");
                }
	}
	if (strlen(tname) > MAX_NAME_SIZE) {
		ret_error(-1, "TERM environment must be <= %d characters.\n",
		    MAX_NAME_SIZE);
	}

	T(("your terminal name is %s", tname));

	term_ptr = typeCalloc(TERMINAL, 1);

	if (term_ptr == 0) {
		ret_error0(-1, "Not enough memory to create terminal structure.\n") ;
        }
#if USE_DATABASE
	status = grab_entry(tname, &term_ptr->type);
#else
	status = 0;
#endif

	/* try fallback list if entry on disk */
	if (status != 1)
	{
	    const TERMTYPE	*fallback = _nc_fallback(tname);

	    if (fallback)
	    {
		memcpy(&term_ptr->type, fallback, sizeof(TERMTYPE));
		status = 1;
	    }
	}

	if (status == -1)
	{
		ret_error0(-1, "terminals database is inaccessible\n");
	}
	else if (status == 0)
	{
		ret_error(0, "'%s': unknown terminal type.\n", tname);
	}

	set_curterm(term_ptr);

	if (command_character  &&  getenv("CC"))
		do_prototype();

	strlcpy(ttytype, cur_term->type.term_names, NAMESIZE);

	/*
	 * Allow output redirection.  This is what SVr3 does.
	 * If stdout is directed to a file, screen updates go
	 * to standard error.
	 */
	if (Filedes == STDOUT_FILENO && !isatty(Filedes))
	    Filedes = STDERR_FILENO;
	cur_term->Filedes = Filedes;

	_nc_get_screensize(&LINES, &COLS);

	if (errret)
		*errret = 1;

	T((T_CREATE("screen %s %dx%d"), tname, LINES, COLS));

	if (generic_type) {
		ret_error(0, "'%s': I need something more specific.\n", tname);
	}
	if (hard_copy) {
		ret_error(1, "'%s': I can't handle hardcopy terminals.\n", tname);
	}
	returnCode(OK);
}
Exemplo n.º 5
0
int setupterm(char *termname, int filedes, int *errret)
{
    static int	_been_here = FALSE;
    char		filename1[1024];
    char		filename2[1024];
    char		*directory = SRCDIR;
    char		*terminfo;
    struct term	*term_ptr;
    char 		*rows, *cols;

    if (_been_here == FALSE) {
        _been_here = TRUE;
#ifdef TRACE
        _init_trace();
        if (_tracing)
            _tracef("setupterm(%s,%d,%x) called", termname, filedes, errret);
#endif

        if (termname == NULL)
        {
            termname = getenv("TERM");
            if (termname == NULL)
                ret_error0(-1, "TERM environment variable not set.\n");
        }

        term_ptr = (struct term *) malloc(sizeof(struct term));

        if (term_ptr == NULL)
            ret_error0(-1, "Not enough memory to create terminal structure.\n") ;

        if ((terminfo = getenv("TERMINFO")) != NULL)
            directory = terminfo;

        sprintf(filename1, "%s/%c/%s", directory, termname[0], termname);
        sprintf(filename2, "%s/%c/%s", SRCDIR, termname[0], termname);

        if (read_entry(filename1, term_ptr) < 0 &&  read_entry(filename2, term_ptr) < 0)
            ret_error(0, "'%s': Unknown terminal type.\n", termname);

        if (command_character  &&  getenv("CC"))
            do_prototype();

        cur_term = term_ptr;
        strncpy(ttytype, cur_term->term_names, NAMESIZE - 1);
        ttytype[NAMESIZE - 1] = '\0';
        cur_term->Filedes = filedes;

        /* figure out the size of the screen */

        rows = getenv("LINES");
        if (rows != (char *)NULL)
            LINES = atoi(rows);

        cols = getenv("COLUMNS");
        if (cols != (char *)NULL)
            COLS = atoi(cols);

        if (_use_env == FALSE)
            if (lines > 0 && columns > 0) {
                LINES = lines;
                COLS  = columns;
            }
        /* use envirronment; if not set then use window size */
#ifdef TRACE
        _tracef("using environment to find screen size");
#endif
        if (LINES <= 0 || COLS <= 0) {
            if (resize(filedes) == 1) {
                fprintf(stderr, "can't find the screen size");
                exit(1);
            }
        }
        lines = LINES;
        columns = COLS;

#ifdef TRACE
        _tracef("screen size is %dx%d and %dx%d", COLS, LINES, columns, lines);
#endif

#ifdef TERMIOS
        tcgetattr(filedes, &cur_term->Ottyb);
        if (cur_term->Ottyb.c_oflag & XTABS)
            tab = back_tab = NULL;

        cur_term->Nttyb = cur_term->Ottyb;
        cur_term->Nttyb.c_oflag &= ~XTABS;
#else
        gtty(filedes, &cur_term->Ottyb);
        if (cur_term->Ottyb.sg_flags & XTABS)
            tab = back_tab = NULL;

        cur_term->Nttyb = cur_term->Ottyb;
        cur_term->Nttyb.sg_flags &= ~XTABS;
#endif

        def_prog_mode();

        if (errret)
            *errret = 1;
    }
    return(1);
}