Пример #1
0
void main (int argc, char** argv)
{
  FILE* pfile = NULL;
  int k;
  int thechar;
  char* defaultDir;

  fnInitGpfGlobals();
  SetCurrentNameSpace(NWOS2_NAME_SPACE);
  defaultDir = (char *)getenv("PERL_ROOT");
  if (!defaultDir || (strlen(defaultDir) == 0))
    defaultDir = "sys:\\perl\\scripts";
  chdir(defaultDir);

  k = 1;
  while (k < argc)
  {
    // open the next file and print it out
    pfile = fopen(argv[k],"r");
    if (pfile)
    {
      while ((thechar = getc(pfile)) != EOF)
      {
        if (thechar != 0x0d)
          printf("%c",thechar);
      }
      fclose (pfile);
    }
    k++;
  }
}
Пример #2
0
void main (int argc, char** argv)
{
  fnInitGpfGlobals();
  if (argc>1 && argv[1]!=NULL && strcmp(argv[1],"-d")==0) {
    int n;
    for (n=0; n < argc; n++) {
      printf("%2d: '%s'\n", n, argv[n]);
    }
  } else {
    while (--argc) {
      printf("%s%c", *++argv, argc==1 ? '\n' : ' ');
    }
  }
}
Пример #3
0
int
main(int argc, const char **argv)
{
    STR *str;
    int i;
    STR *tmpstr;
    /* char *namelist;    */

	#ifdef NETWARE
		fnInitGpfGlobals();	/* For importing the CLIB calls in place of Watcom calls */
	#endif	/* NETWARE */

    myname = argv[0];
    linestr = str_new(80);
    for (argc--,argv++; argc; argc--,argv++) {
	if (argv[0][0] != '-' || !argv[0][1])
	    break;
	switch (argv[0][1]) {
#ifdef DEBUGGING
	case 'D':
	    debug = atoi(argv[0]+2);
#if YYDEBUG
	    yydebug = (debug & 1);
#endif
	    break;
#endif
	case '0': case '1': case '2': case '3': case '4':
	case '5': case '6': case '7': case '8': case '9':
	    maxfld = atoi(argv[0]+1);
	    absmaxfld = TRUE;
	    break;
	case 'F':
	    fswitch = argv[0][2];
	    break;
	case 'n':
	    namelist = savestr(argv[0]+2);
	    break;
	case 'o':
	    old_awk = TRUE;
	    break;
	case '-':
	    argc--,argv++;
	    goto switch_end;
	case 0:
	    break;
	default:
#if defined(OS2) || defined(WIN32) || defined(NETWARE)
	    fprintf(stderr, "Unrecognized switch: %s\n",argv[0]);
            usage();
#else
	    fatal("Unrecognized switch: %s\n",argv[0]);
#endif
	}
    }
  switch_end:

    /* open script */

    if (argv[0] == NULL) {
#if defined(OS2) || defined(WIN32) || defined(NETWARE)
	if ( isatty(fileno(stdin)) )
	    usage();
#endif
        argv[0] = "-";
    }
    filename = savestr(argv[0]);

    if (strEQ(filename,"-"))
	argv[0] = "";
    if (!*argv[0])
	rsfp = stdin;
    else
	rsfp = fopen(argv[0],"r");
    if (rsfp == NULL)
	fatal("Awk script \"%s\" doesn't seem to exist.\n",filename);

    /* init tokener */

    bufptr = str_get(linestr);
    symtab = hnew();
    curarghash = hnew();

    /* now parse the report spec */

    if (yyparse())
	fatal("Translation aborted due to syntax errors.\n");

#ifdef DEBUGGING
    if (debug & 2) {
	int type, len;

	for (i=1; i<mop;) {
	    type = ops[i].ival;
	    len = type >> 8;
	    type &= 255;
	    printf("%d\t%d\t%d\t%-10s",i++,type,len,opname[type]);
	    if (type == OSTRING)
		printf("\t\"%s\"\n",ops[i].cval),i++;
	    else {
		while (len--) {
		    printf("\t%d",ops[i].ival),i++;
		}
		putchar('\n');
	    }
	}
    }