示例#1
1
/*
 * Program entry point.
 */
void main( int argc, char *argv[] )
/*********************************/
{
    OPT_STORAGE         cmdOpts;
    CmdLine *           cmdLine;


#ifndef __WATCOMC__
    _argc = argc;
    _argv = argv;
#endif
    /*** Initialize ***/
    SetBannerFuncError( BannerMessage );
    cmdLine = InitCmdLine( NMAKE_NUM_SECTIONS );

    /*** Parse the command line and translate to Watcom options ***/
    InitParse( &cmdOpts );
    do_parsing( &cmdOpts );
    OptionsTranslate( &cmdOpts, cmdLine );

    /*** Spawn the librarian ***/
    nmake( &cmdOpts, cmdLine );
    FiniParse( &cmdOpts );
    exit( EXIT_SUCCESS );
}
示例#2
0
/*
 * Program entry point.
 */
void main( int argc, char *argv[] )
/*********************************/
{
    OPT_STORAGE         cmdOpts;
    CmdLine *           cmdLine;
    int                 itemsParsed;

#ifndef __WATCOMC__
    _argc = argc;
    _argv = argv;
#endif
    /*** Initialize ***/
    SetBannerFuncError( BannerMessage );
    cmdLine = InitCmdLine( LINK_NUM_SECTIONS );
    SetDefaultFile( TYPE_OBJ_FILE, "object" );
    AllowTypeFile( TYPE_OBJ_FILE, TYPE_LIB_FILE, TYPE_RES_FILE,
                   TYPE_RBJ_FILE, TYPE_RS_FILE, TYPE_EXP_FILE,
                   TYPE_INVALID_FILE );

    /*** Parse the command line and translate to Watcom options ***/
    InitParse( &cmdOpts );
    itemsParsed = do_parsing( &cmdOpts );
    if( itemsParsed == 0 ) {
        PrintHelpMessage();
        exit( EXIT_SUCCESS );
    }
    OptionsTranslate( &cmdOpts, cmdLine );

    /*** Spawn the linker ***/
    if( link( &cmdOpts, cmdLine )  ==  LINK_NOACTION ) {
        FatalError( "Nothing to do!" );
    }
    FiniParse( &cmdOpts );
    exit( EXIT_SUCCESS );
}
示例#3
0
HRESULT
WINAPI
InitCompression(
VOID
)
{
	auto cmd_line_res = InitCmdLine();
	if (cmd_line_res != S_OK) return cmd_line_res;

	if (gzip == NULL)
	{
		auto gzip_env_path = L"%Windir%\\system32\\inetsrv\\gzip.dll";
		wchar_t gzip_path[256];
		auto path_len = ExpandEnvironmentStrings(gzip_env_path, gzip_path, 255);
		if (path_len == 0 || path_len > 255) return E_INVALIDARG;
		gzip = LoadLibrary(gzip_path);
		if (gzip == NULL) return E_FAIL;
	}

	ProcInitCompression = (IisInitCompression)GetProcAddress(gzip, "InitCompression");
	if (ProcInitCompression == NULL) return E_FAIL;
	ProcCreateCompression = (IisCreateCompression)GetProcAddress(gzip, "CreateCompression");
	if (ProcCreateCompression == NULL) return E_FAIL;
	ProcCompress = (IisCompress)GetProcAddress(gzip, "Compress");
	if (ProcCompress == NULL) return E_FAIL;
	ProcDestroyCompression = (IisDestroyCompression)GetProcAddress(gzip, "DestroyCompression");
	if (ProcDestroyCompression == NULL) return E_FAIL;
	ProcDeInitCompression = (IisDeInitCompression)GetProcAddress(gzip, "DeInitCompression");
	if (ProcDeInitCompression == NULL) return E_FAIL;

	return ProcInitCompression();
}
示例#4
0
// --------------------------------------------------------------------------------//
// MAIN	                                                                           //
// --------------------------------------------------------------------------------//
int main(int argc, char* argv[]) 
{
  // process command-line arguments
  CmdLine *cmdLine = InitCmdLine();
  int next_arg = cmdLine->Read(argv,argc);
  if (HELP) { cmdLine->Usage("key-expand <STDIN>|FILE"); exit(1); }
  MESSAGES(VERBOSE); 
  char *INPUT = next_arg==argc ? NULL : argv[next_arg];

  // process
  FileBufferText buffer(INPUT);
  for (long int r=0; buffer.Next()!=NULL; r++) {
    char *inp = buffer.Get();
    char *key = GetNextToken(&inp," \t");
    while (inp[0]!=0) {
      char *val = GetNextToken(&inp," \t");
      printf("%s\t%s\n", key, val);
    }
  }

  // cleanup
  delete cmdLine;

  return 0;
}
示例#5
0
/*
 * Program entry point.
 */
void main( int argc, char *argv[] )
/*********************************/
{
    OPT_STORAGE         cmdOpts;
    CmdLine *           compCmdLine;
    CmdLine *           linkCmdLine;
    int                 itemsParsed;
    int                 compRc = COMPILE_NOACTION;
    int                 linkRc = LINK_NOACTION;

#ifndef __WATCOMC__
    _argc = argc;
    _argv = argv;
#endif
    /*** Initialize ***/
    SetBannerFuncError( BannerMessage );
    compCmdLine = InitCmdLine( CL_C_NUM_SECTIONS );
    linkCmdLine = InitCmdLine( CL_L_NUM_SECTIONS );
    SetDefaultFile( TYPE_C_FILE, "source" );
    AllowTypeFile( TYPE_C_FILE, TYPE_CPP_FILE, TYPE_DEF_FILE, TYPE_OBJ_FILE,
                   TYPE_LIB_FILE, TYPE_RES_FILE, TYPE_INVALID_FILE );
    InitMacro();

    /*** Parse the command line and translate to Watcom options ***/
    InitParse( &cmdOpts );
    itemsParsed = do_parsing( &cmdOpts );
    if( itemsParsed==0 || cmdOpts.help ) {
        if( !cmdOpts.nologo )
            BannerMessage();
        PrintHelpMessage();
        exit( EXIT_SUCCESS );
    }
    OptionsTranslate( &cmdOpts, compCmdLine, linkCmdLine );

    /*** Spawn the compiler ***/
    compRc = compile( &cmdOpts, compCmdLine );
    if( compRc == COMPILE_ERROR )  exit( EXIT_FAILURE );
    if( !cmdOpts.c ) {
        linkRc = link( &cmdOpts, linkCmdLine );
    }
    if( compRc == COMPILE_NOACTION  &&  linkRc == LINK_NOACTION ) {
        FatalError( "Nothing to do!" );
    }
    FiniParse( &cmdOpts );
    exit( EXIT_SUCCESS );
}
示例#6
0
//-----Usage----------
//
void Usage()
{
  int n_methods = 4;
  char METHODS[][20] = { "-permute", "-resample", "-number", "" };
  for (int i=0; i<n_methods; i++) {
    CmdLine *cmd = InitCmdLine(METHODS[i]);
    char s[1000];
    sprintf(s, "rows %s [OPTIONS] <ROWS>", METHODS[i]);
    cmd->Usage(s);
    delete cmd;
  }
}
示例#7
0
/*
 * Make a completely separate copy of a CmdLine.
 */
CmdLine *CloneCmdLine( const CmdLine *oldCmdLine )
/************************************************/
{
    CmdLine *           newCmdLine;
    int                 countSection;
    int                 countArg;

    newCmdLine = InitCmdLine( oldCmdLine->numSections );
    for( countSection=0; countSection<oldCmdLine->numSections; countSection++ ) {
        for( countArg=0; countArg<oldCmdLine[countSection].curItems; countArg++ ) {
            AppendCmdLine( newCmdLine, countSection, oldCmdLine[countSection].args[countArg] );
        }
    }

    return( newCmdLine );
}
示例#8
0
/*
 * Program entry point.
 */
void main( int argc, char *argv[] )
/*********************************/
{
    OPT_STORAGE         cmdOpts;
    CmdLine *           cmdLine;
    int                 itemsParsed;
    int                 rc = RC_NOACTION;

    /*** Initialize ***/
    SetBannerFuncError( BannerMessage );
    cmdLine = InitCmdLine( RC_NUM_SECTIONS );
    SetDefaultFile( TYPE_RC_FILE, "rc" );
    AllowTypeFile( TYPE_RC_FILE, TYPE_INVALID_FILE );

    /*** Parse the command line and translate to Watcom options ***/
    InitParse( &cmdOpts );
    itemsParsed = do_parsing( &cmdOpts );
    if( itemsParsed==0 || cmdOpts.help ) {
        PrintHelpMessage();
        exit( EXIT_SUCCESS );
    }
    OptionsTranslate( &cmdOpts, cmdLine );

    /*** Spawn the compiler ***/
    rc = res_compile( &cmdOpts, cmdLine );
    switch( rc ) {
      case RC_ERROR:
        exit( EXIT_FAILURE );
        break;
      case RC_NOACTION:
        FatalError( "Nothing to do!" );
        break;
      case RC_SUCCESS:
        FiniParse( &cmdOpts );
        exit( EXIT_SUCCESS );
        break;
      default:
        Zoinks();
    }
}
示例#9
0
int WlibMainLine( char *argv[] )
{
    int     retcode;

    InitCmdLine();          // JBS 99/07/09 reset options for each use
    if( !setjmp( Env ) ) {
        ProcessCmdLine( argv );
        ProcessCommands();
        retcode = EXIT_SUCCESS;
    } else {
        retcode = EXIT_FAILURE;
    }
    if( !setjmp( Env ) ) {
        ResetInputLibs();
        ResetFileTab();
        ResetCmdLine();
        ResetLibIo();
        ResetMem();
    } else {
        retcode = EXIT_FAILURE;
    }
    return( retcode );
}
示例#10
0
文件: main.c 项目: Aliandrana/snesdev
int main (int argc, char* argv [])
/* Assembler main program */
{
    unsigned I;

    /* Initialize the cmdline module */
    InitCmdLine (&argc, &argv, "ar65");

    /* We must have a file name */
    if (ArgCount < 2) {
	Usage ();
    }

    /* Check the parameters */
    I = 1;
    while (I < ArgCount) {

	/* Get the argument */
	const char* Arg = ArgVec [I];

	/* Check for an option */
	if (strlen (Arg) != 1) {
	    Usage ();
	}
	switch (Arg [0]) {

	    case 'a':
		AddObjFiles (ArgCount - I - 1, &ArgVec[I+1]);
		break;

	    case 'd':
		DelObjFiles (ArgCount - I - 1, &ArgVec [I+1]);
		break;

	    case 'l':
		ListObjFiles (ArgCount - I - 1, &ArgVec [I+1]);
		break;

	    case 'v':
		++Verbosity;
		break;

	    case 'x':
		ExtractObjFiles (ArgCount - I - 1, &ArgVec [I+1]);
		break;

	    case 'V':
		fprintf (stderr,
       	       	       	 "ar65 V%s - (C) Copyright 1998-2009 Ullrich von Bassewitz\n",
			 GetVersionAsString ());
		break;

	    default:
		fprintf (stderr, "Unknown option: %s\n", Arg);
		Usage ();

	}

	/* Next argument */
	++I;
    }

    /* Return an apropriate exit code */
    return EXIT_SUCCESS;
}
示例#11
0
/*
 * Spawn the Watcom linker.  Returns LINK_NOACTION if there was no file to
 * link, LINK_ERROR if the linker returned a bad status code or if it could
 * not be spawned, or else LINK_SUCCESS if everything went smoothly.
 */
static int link( const OPT_STORAGE *cmdOpts, CmdLine *cmdLine )
/*************************************************************/
{
    char **             args;
    int                 rc;
    char *              cmdFileName;
    FILE *              fp;
    int                 count;
    CmdLine *           spawnCmdLine;

    /*** Make the command file ***/
    args = MergeCmdLine( cmdLine, INVALID_MERGE_CMDLINE );
    cmdFileName = tmpnam( NULL );
    if( !cmdOpts->noinvoke ) {
        fp = fopen( cmdFileName, "wt" );
        if( fp == NULL ) {
            FatalError( "Cannot open temporary file '%s' -- aborting", cmdFileName );
        }
    }
    for( count=0; args[count]!=NULL; count++ ) {
        if( !cmdOpts->noinvoke ) {
            fprintf( fp, "%s\n", args[count] );
        }
        if( cmdOpts->showwopts ) {
            fprintf( stderr, "echo.%s%s%s\n",
                args[count], (count == 0 ? ">" : ">>"), cmdFileName );
        }
    }
    if( !cmdOpts->noinvoke ) {
        fclose( fp );
    }

    /*** Spawn the linker ***/
    spawnCmdLine = InitCmdLine( LINK_NUM_SECTIONS );
    AppendCmdLine( spawnCmdLine, LINK_PROGNAME_SECTION, LINKER );
    AppendFmtCmdLine( spawnCmdLine, LINK_OPTS_SECTION, "@%s", cmdFileName );
    args = MergeCmdLine( spawnCmdLine, INVALID_MERGE_CMDLINE );
    if( cmdOpts->showwopts ) {
        for( count=0; args[count]!=NULL; count++ ) {
            fprintf( stderr, "%s ", args[count] );
        }
        fprintf( stderr, "\n" );
    }
    if( !cmdOpts->noinvoke ) {
        rc = spawnvp( P_WAIT, LINKER, (const char **)args );
    }
    if( cmdOpts->showwopts ) {
        fprintf( stderr, "del %s\n", cmdFileName );
    }
    if( !cmdOpts->noinvoke ) {
        remove( cmdFileName );
        if( rc != 0 ) {
            if( rc == -1  ||  rc == 255 ) {
                FatalError( "Unable to execute '%s'", LINKER );
            } else {
                return( LINK_ERROR );
            }
        }
    }
    DestroyCmdLine( spawnCmdLine );

    return( LINK_SUCCESS );
}
示例#12
0
文件: main.c 项目: MonteCarlos/cc65
int main (int argc, char* argv [])
/* Assembler main program */
{
    unsigned I;

    /* Initialize the cmdline module */
    InitCmdLine (&argc, &argv, "ar65");

    /* We must have a file name */
    if (ArgCount < 2) {
        Usage ();
    }

    /* Check the parameters */
    I = 1;
    while (I < ArgCount) {

        /* Get the argument */
        const char* Arg = ArgVec [I];

        switch (Arg [0]) {

            case 'r': /* POSIX.2 */
            case 'a': /* staying compatible */
                AddObjFiles (ArgCount - I - 1, &ArgVec[I+1]);
                break;

            case 'd':
                DelObjFiles (ArgCount - I - 1, &ArgVec [I+1]);
                break;

            case 't': /* POSIX.2 */
            case 'l': /* staying compatible */
                if (Arg [1] == 'v') {
                    ++Verbosity;
                }
                ListObjFiles (ArgCount - I - 1, &ArgVec [I+1]);
                break;

            case 'v':
                ++Verbosity;
                break;

            case 'x':
                ExtractObjFiles (ArgCount - I - 1, &ArgVec [I+1]);
                break;

            case 'V':
                fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ());
                break;

            default:
                fprintf (stderr, "Unknown option: %s\n", Arg);
                Usage ();

        }

        /* Next argument */
        ++I;
    }

    /* Return an apropriate exit code */
    return EXIT_SUCCESS;
}
示例#13
0
// --------------------------------------------------------------------------------//
// MAIN	                                                                           //
// --------------------------------------------------------------------------------//
int main(int argc, char* argv[]) 
{
  // process command-line arguments
  if (argc<2) { Usage(); exit(1); }
  char *method = argv[1];
  CmdLine *cmdLine = InitCmdLine(method);



  //--------------------------------------------------------------------------------------//
  // OPTION -permute: permute rows                                                        //
  //--------------------------------------------------------------------------------------//
  if (strcmp(method,"-permute")==0) { 
    // read options
    cmdLine->Read(argv+1,argc-1);
    MESSAGES(VERBOSE);

    // initialize random generator
    unsigned long int seed = RND_SEED+getpid()+time(NULL);
    gsl_rng *RANDOM_GENERATOR = InitRandomGenerator(seed);

    // read input
    long int n_lines;
    char **L;
    FILE *fp = LoadStdIn(&n_lines,BUFFER_SIZE);
    if (n_lines==0) return 0;
    ALLOCATE1D(L,n_lines,char *);
    FileBufferText *buffer = new FileBufferText(fp,BUFFER_SIZE);
    Progress PRG("Reading input rows...",n_lines);
    for (long int n=0; n<n_lines; n++) {
      L[n] = StrCopy(buffer->Next());
      PRG.Check();
    }
    PRG.Done();
    
    // permute
    long int *seq;
    ALLOCATE1D(seq,n_lines,long int);
    for (long int k=0; k<n_lines; k++) seq[k] = k;
    gsl_ran_shuffle(RANDOM_GENERATOR,seq,n_lines,sizeof(long int));

    // print output
    Progress PRG1("Printing output rows...",n_lines);
    for (long int n=0; n<n_lines; n++) {
      printf("%s\n", L[seq[n]]);
      PRG1.Check();
    }
    PRG1.Done();

    // cleanup
    FREE1D(seq);
    delete RANDOM_GENERATOR;
    delete buffer;
  }


  //--------------------------------------------------------------------------------------//
  // OPTION -resample: resample rows                                                      //
  //--------------------------------------------------------------------------------------//
  else if (strcmp(method,"-resample")==0) { 
    // read options
    cmdLine->Read(argv+1,argc-1);
    MESSAGES(VERBOSE);

    // initialize random generator
    unsigned long int seed = (RND_SEED==0)?(getpid()+time(NULL)):RND_SEED;
    gsl_rng *RANDOM_GENERATOR = InitRandomGenerator(seed);

    // read input
    long int n_lines;
    char **L;
    FILE *fp = LoadStdIn(&n_lines,BUFFER_SIZE);
    if (n_lines==0) return 0;
    ALLOCATE1D(L,n_lines,char *);
    FileBufferText *buffer = new FileBufferText(fp,BUFFER_SIZE);
    Progress PRG("Reading input rows...",n_lines);
    for (long int n=0; n<n_lines; n++) {
      L[n] = StrCopy(buffer->Next());
      PRG.Check();
    }
    PRG.Done();
    
    // print output
    if (N_SAMPLES<=0) N_SAMPLES = n_lines;
    Progress PRG1("Printing output rows...",N_SAMPLES);
    for (long int n=0; n<N_SAMPLES; n++) {
      long int k = gsl_rng_uniform_int(RANDOM_GENERATOR,n_lines);
      printf("%s\n", L[k]);
      PRG1.Check();
    }
    PRG1.Done();

    // cleanup
    delete RANDOM_GENERATOR;
    delete buffer;
  }


  //--------------------------------------------------------------------------------------//
  // OPTION -number: do row numbering                                                     //
  //--------------------------------------------------------------------------------------//
  else if (strcmp(method,"-number")==0) { 
    // read options
    cmdLine->Read(argv+1,argc-1);
    MESSAGES(VERBOSE);

    // read input
    FileBufferText buffer((char*)NULL,BUFFER_SIZE);
    Progress PRG("Reading input rows...",1);
    long int id = HEADER?0:1;
    for (char *inp=buffer.Next(); inp!=NULL; inp=buffer.Next()) {
      if (id==0) printf("\t");
      else printf("%s%012ld\t", PREFIX, id);
      printf("%s\n", inp);
      id++;
      PRG.Check();
    }
    PRG.Done();    
  }


  //--------------------------------------------------------------------------------------//
  // OTHER OPTIONS                                                                        //
  //--------------------------------------------------------------------------------------//
  else {
    // read options
    int next_arg = cmdLine->Read(argv,argc);
    MESSAGES(VERBOSE);
  
    // allocate buffer
    char *BUFFER = (char *) malloc(BUFFER_SIZE*sizeof(char));
    if (BUFFER==NULL) { fprintf(stderr, "Out of memory!\n"); exit(1); }

    Sequence rows = strlen(ROW_FILE)==0 ? GetRows(&argv[next_arg],argc-next_arg) : LoadRows(ROW_FILE);

    // option 1: use period
    if (PERIOD>0) {
      int choose = MERGE ? -1 : atoi(argv[next_arg]);
      //printf("(PERIOD,NEXTARG,CHOOSE) = (%i,%i,%i)\n", PERIOD, next_arg, choose);
      for (int n=0; ; n++) {
        if (fgets(BUFFER,BUFFER_SIZE,stdin)==NULL) break;
        if (BUFFER[strlen(BUFFER)-1]!='\n') { 
          fprintf(stderr, "Error: line was only partially read (max chars=%i)!\n", BUFFER_SIZE); exit(1);
        }
        if (BUFFER[strlen(BUFFER)-1]=='\n') BUFFER[strlen(BUFFER)-1] = 0;
        if (MERGE) printf("%s%s", BUFFER, n%PERIOD==PERIOD-1?"\n":SEPARATOR); 
        else if (n%PERIOD==choose) printf("%s\n", BUFFER); 
      }
    }

    // option 2: choose rows
    else {
      if (EXCLUDE==true) {
        for (long int n=0,k=1; k<=rows[0]; n++) {
          fgets(BUFFER,BUFFER_SIZE,stdin);
          if (feof(stdin)) break;
          if (BUFFER[strlen(BUFFER)-1]!='\n') { fprintf(stderr, "Error: line was only partially read (max chars=%i)!\n", BUFFER_SIZE); exit(1); }
          if (n<rows[k]) printf("%s", BUFFER);
	  else { ++k; if (EMPTY) printf("\n"); }
        }
        while (true) {
          fgets(BUFFER,BUFFER_SIZE,stdin);
          if (feof(stdin)) break;
          if (BUFFER[strlen(BUFFER)-1]!='\n') { fprintf(stderr, "Error: line was only partially read (max chars=%i)!\n", BUFFER_SIZE); exit(1); }
          printf("%s", BUFFER);
        }
      }
      else {
        for (long int n=0,k=1; k<=rows[0]; n++) {
          fgets(BUFFER,BUFFER_SIZE,stdin);
          if (feof(stdin)) break;
          if (BUFFER[strlen(BUFFER)-1]!='\n') { fprintf(stderr, "Error: line was only partially read (max chars=%i)!\n", BUFFER_SIZE); exit(1); }
          if (n==rows[k]) { printf("%s", BUFFER); k++; }
	  else if (EMPTY) printf("\n"); 
        }
        if (EMPTY) {
          while (true) {
            fgets(BUFFER,BUFFER_SIZE,stdin);
            if (feof(stdin)) break;
            if (BUFFER[strlen(BUFFER)-1]!='\n') { fprintf(stderr, "Error: line was only partially read (max chars=%i)!\n", BUFFER_SIZE); exit(1); }
            printf("\n");
          }
        }
      }
    }

    // clean up
    FREE1D(rows);
    FREE1D(BUFFER);
  }


  // clean up
  delete cmdLine;

  
  return 0;
}