Example #1
0
File: more01.c Project: wyj2046/UUP
int main( int argc, char* argv[  ] )
  {
    FILE* fp;
    if ( argc == 1 )
      {
        do_more( fp );
        
      }
    else
      {
        while ( --argc )
          {
            if ( ( fp = fopen( *++argv, "r" ) ) != NULL )
              {
                do_more( fp );
                fclose( fp );
                
              }
            else
              {
                exit( 1 );
                
              }
          }
      }
    return 0;
    
  }
Example #2
0
int main(int argc, char *argv[])
{
  FILE *fp;
  char *pFileName;

  tty_mode(0);

  set_tty_mode();
  if (argc == 1)
  {
    do_more(stdin);
  }
  else
  {
    while(--argc > 0)
    {
      pFileName = *++argv;
      if ((fp = fopen(pFileName, "r")) > 0)
      {
        do_more(fp);        
      }
      else
      {
        fprintf(stderr, "Open file %s error, errno = %d\n", pFileName, errno);
      }
    }
  }

  tty_mode(1);
  return 0;
}
Example #3
0
int main(int argc, char **argv) {
    FILE *fp;
    if (argc == 1) do_more(stdin);
    else
        while (--argc)
            if ((fp = fopen(*++argv, "r")) != NULL) {
                do_more(fp);
                fclose(fp);
            }
            else exit(1);
    return 0;
}
Example #4
0
int main(int ac,char*av[]){

	FILE *fp;
	if(ac==1)
		do_more(stdin);
	else
		while (--ac)
		if((fp = fopen(*++av,"r"))!=NULL){
			do_more(fp);
			fclose(fp);
		}else
			exit(1);
	return 0;
}
Example #5
0
int main(int argc, char *argv[])
{
	FILE * fp;
	int i;
	if(argc == 1) {
		do_more(stdin);
	} else {
		for(i=1; i<argc; ++i) {
			fp = fopen(argv[i], "r");
			do_more(fp);
			fclose(fp);
		}
	}
}
Example #6
0
int main (int argc, char * argv[])
{
	FILE *fp;
	tty_mode(ZERO);
	no_echo_mode();
	signal(SIGINT, ctrl_c);
	signal(SIGQUIT, SIG_IGN);
	if(argc > 2)
		ctrl_c();
	if(argc == 1)
	{
		printf("Type ^c to quit\n");
		do_more_stdin(stdin);
	}else{
		if((fp = fopen(argv[ONE], "r")) != NULL)
		{
			find_num_of_lines(fp);
			fileName = argv[ONE];
			do_more(fp);
			fclose(fp);
		}
	}
	tty_mode(NORM);
	return SUCCESS;
}
Example #7
0
int main(int ac, char *av[])
{
        FILE *fp;
        if (ac == 1)                    // <--- 如果 ac 等于 1 ,表示需要从标准输入获取数据。
                do_more(stdin);         // <--- 然后在这里调用相应的显示方法。
        else
                while(--ac)             // <--- 这里 --ac 和 ++av 的配合相当华丽! 赞一个!
                if((fp = fopen(*++av, "r")) != NULL)
                {
                        do_more(fp);
                        fclose(fp);
                }
                else
                        exit(1);
        return 0;
}
Example #8
0
void boid(int x) {
    try {
        do {
            switch (x) {
            case 1: case 2: case 3: do_something(&x); break;
            }
        } while (x > 0);
    } catch (Bad& ex) {
    }
    while (x < 0) do_more(&x);
}
Example #9
0
int main(int argc, char *argv[]) {
  FILE *fp;
  FILE *fp_tty = fopen("/dev/tty", "w+");

  if (fp_tty == NULL) {
    printf("Can not open or write /dev/tty!\n");
    exit(EXIT_FAILURE);
  }
  if (argc == 1)
    do_more(stdin, fp_tty);
  else 
    while (--argc) {
      if ((fp = fopen(*++argv, "r")) != NULL) {
        do_more(fp, fp_tty);
        fclose(fp);
      }
      else {
        printf("%s is an invalid file!\n", *argv);
        exit(EXIT_FAILURE);
      }
    }
  return EXIT_SUCCESS;
}
Example #10
0
int
main(int argc, char **argv)
{
    
    FILE *fp;
    tty_mode(0);
    rowCol();
    if (argc == 1){
        do_more(stdin);
    }else{
        set_cr_noecho_mode();
        while(--argc){
	    if ((fp = fopen(*++argv,"r")) != NULL){
	        do_more(fp);
		fclose(fp);
	    }else{
	        exit(1);
	    }//if
	}//while
    }
    tty_mode(1);
    return 0;
}
Example #11
0
/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  main
 *  Description:  
 * =====================================================================================
 */
int main(int argc, char *argv[])
{
	FILE *fp;
	if (argc == 1) {
	/* 	fprintf(stderr, "usage: more [-dflpcsu] [+linenum | +/pattern] name1 name2 ...\n");	*/
		do_more(stdin);
	} else {
		while (argc--)
			if ((fp = fopen(*++argv, "r")) != NULL) {
				do_more(fp);
				fclose(fp);
			} else {
				exit(1);
			}

		if ((fp = fopen(*++argv, "r")) != NULL) {
			do_more(fp);
			fclose(fp);
		} else {
			exit(1);
		}
	}				/* ----------  end of function main  ---------- */
	return EXIT_SUCCESS;
}
Example #12
0
main(int ac, char *av[])
{
	FILE	*fp, *fopen();

	if ( ac != 2 ){
		fprintf(stderr,"usage: mmore1 filename\n" );
		exit(1);
	}
	if ( (fp = fopen( av[1] , "r" )) != NULL ){
		do_more( fp );
		fclose( fp );
	}
	else
		fprintf(stderr, "cannot open %s\n", av[1] );
}