Exemple #1
0
/*
 * Main file of myselect
 * Links everything together, and executes the program
 *
 * Precondition: argc > 1
 * Postcondition: The elements are printed on the screen
 */
int      main(int argc, char** argv)
{
    int  count;
    int  bytes;
    char input[READMIN + 2];

    if(argc < 2 || !my_strpos(argv[1], '*'))
    {
        my_str("No files found!\n");
        exit(1);
    }

    signal(SIGWINCH, show_elems);

    //Get all the termcaps
    init_caps();

    //Prepare the terminal
    init_terminal();

    //Setup the elements
    setup_elems(argc - 1, &argv[1]);

    //Turn off the cursor
    tputs(gl_env.cursoroff, 0, my_termprint);

    //Print the elements for the first time
    show_elems();

    //Main loop
    while(1)
    {
        bytes = read(0, &input, READMIN + 2);
        input[bytes] = '\0';

        if(!gl_env.flag)
        {
            check_char(input);
        }
    }
    
    return 0;
}
Exemple #2
0
int main(int argc, char** argv){

	int  data;
	char input[READMIN + 2];

	if(argc < 2){
		my_str("Usage: ./myselect itemSelector\n");
		exit(1);
	}
	if(my_strpos(argv[1], '*') == 0){
		my_str("No files were found\n");
		exit(1);
	}

	signal(SIGWINCH, show_elems);

	init_caps(); //Get the termcaps

	init_terminal();  //initilize the terminal

	setup_elems(argc - 1, &argv[1]);  //Setup elems

	tputs(gl_env.cursoroff, 0, my_termprint);  //Turn off cursor	

	show_elems();  //actually show the elements

	while(1){
		data = read(0, &input, READMIN + 2);
		input[data] = '\0';

		if(!gl_env.flag){
			check_char(input);
		}
	}
	
	return 0;
}