当前位置: 首页>>代码示例>>C++>>正文


C++ Usage函数代码示例

本文整理汇总了C++中Usage函数的典型用法代码示例。如果您正苦于以下问题:C++ Usage函数的具体用法?C++ Usage怎么用?C++ Usage使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Usage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int
main (int argc, char **argv)
{

       int rows, cols;
       struct termios tio;
       char buf[BUFSIZ];
       struct winsize ws;
       char *name_of_tty;

       myname = x_basename(argv[0]);

       if (argc > 1) Usage();

       name_of_tty = "/dev/tty";

       if ((ttyfp = fopen (name_of_tty, "r+")) == NULL) {
           fprintf (stderr, "%s:  can't open terminal %s\n",
                    myname, name_of_tty);
           exit (1);
       }
       tty = fileno(ttyfp);

       tcgetattr(tty, &tioorig);
       tio = tioorig;
       tio.c_iflag &= ~ICRNL;
       tio.c_lflag &= ~(ICANON | ECHO);
       tio.c_cflag |= CS8;
       tio.c_cc[VMIN] = 6;
       tio.c_cc[VTIME] = 1;
       signal(SIGINT, onintr);
       signal(SIGQUIT, onintr);
       signal(SIGTERM, onintr);
       tcsetattr(tty, TCSADRAIN, &tio);

       write(tty, getsize, strlen(getsize));
       readstring(ttyfp, buf, size);
       if(sscanf (buf, size, &rows, &cols) != 2) {
               fprintf(stderr, "%s: Can't get rows and columns\r\n", myname);
               onintr(0);
       }
       write(tty, restore, strlen(restore));

       if (ioctl (tty, TIOCGWINSZ, &ws) != -1) {
           /* we don't have any way of directly finding out
              the current height & width of the window in pixels.  We try
              our best by computing the font height and width from the "old"
              struct winsize values, and multiplying by these ratios...*/
           if (ws.ws_col != 0)
               ws.ws_xpixel = cols * (ws.ws_xpixel / ws.ws_col);
           if (ws.ws_row != 0)
               ws.ws_ypixel = rows * (ws.ws_ypixel / ws.ws_row);
           ws.ws_row = rows;
           ws.ws_col = cols;
           ioctl (tty, TIOCSWINSZ, &ws);
       }

       tcsetattr(tty, TCSADRAIN, &tioorig);
       signal(SIGINT, SIG_DFL);
       signal(SIGQUIT, SIG_DFL);
       signal(SIGTERM, SIG_DFL);

       exit(0);
}
开发者ID:firogh,项目名称:firogh.github.com,代码行数:64,代码来源:resize.c

示例2: main

int main(int argc, char* argv[])
{
    int i;
    int nThreads = CPLGetNumCPUs();
    std::vector<CPLJoinableThread*> apsThreads;
    Strategy eStrategy = STRATEGY_RANDOM;
    int bNewDatasetOption = FALSE;
    int nXSize = 5000;
    int nYSize = 5000;
    int nBands = 4;
    char** papszOptions = NULL;
    int bOnDisk = FALSE;
    std::vector<ThreadDescription> asThreadDescription;
    int bMemDriver = FALSE;
    GDALDataset* poMEMDS = NULL;
    int bMigrate = FALSE;
    int nMaxRequests = -1;

    argc = GDALGeneralCmdLineProcessor( argc, &argv, 0 );

    GDALAllRegister();

    for(i = 1; i < argc; i++)
    {
        if( EQUAL(argv[i], "-threads") && i + 1 < argc)
        {
            i ++;
            nThreads = atoi(argv[i]);
        }
        else if( EQUAL(argv[i], "-loops") && i + 1 < argc)
        {
            i ++;
            nLoops = atoi(argv[i]);
            if( nLoops <= 0 )
                nLoops = INT_MAX;
        }
        else if( EQUAL(argv[i], "-max_requests") && i + 1 < argc)
        {
            i ++;
            nMaxRequests = atoi(argv[i]);
        }
        else if( EQUAL(argv[i], "-strategy") && i + 1 < argc)
        {
            i ++;
            if( EQUAL(argv[i], "random") )
                eStrategy = STRATEGY_RANDOM;
            else if( EQUAL(argv[i], "line") )
                eStrategy = STRATEGY_LINE;
            else if( EQUAL(argv[i], "block") )
                eStrategy = STRATEGY_BLOCK;
            else
                Usage();
        }
        else if( EQUAL(argv[i], "-xsize") && i + 1 < argc)
        {
            i ++;
            nXSize = atoi(argv[i]);
            bNewDatasetOption = TRUE;
        }
        else if( EQUAL(argv[i], "-ysize") && i + 1 < argc)
        {
            i ++;
            nYSize = atoi(argv[i]);
            bNewDatasetOption = TRUE;
        }
        else if( EQUAL(argv[i], "-bands") && i + 1 < argc)
        {
            i ++;
            nBands = atoi(argv[i]);
            bNewDatasetOption = TRUE;
        }
        else if( EQUAL(argv[i], "-co") && i + 1 < argc)
        {
            i ++;
            papszOptions = CSLAddString(papszOptions, argv[i]);
            bNewDatasetOption = TRUE;
        }
        else if( EQUAL(argv[i], "-ondisk"))
        {
            bOnDisk = TRUE;
            bNewDatasetOption = TRUE;
        }
        else if( EQUAL(argv[i], "-check"))
        {
            bCheck = TRUE;
            bNewDatasetOption = TRUE;
        }
        else if( EQUAL(argv[i], "-memdriver"))
        {
            bMemDriver = TRUE;
            bNewDatasetOption = TRUE;
        }
        else if( EQUAL(argv[i], "-migrate"))
            bMigrate = TRUE;
        else if( argv[i][0] == '-' )
            Usage();
        else if( pszDataset == NULL )
            pszDataset = argv[i];
        else
        {
//.........这里部分代码省略.........
开发者ID:garnertb,项目名称:gdal,代码行数:101,代码来源:testblockcache.cpp

示例3: RunCommand

	virtual int RunCommand(CSimpleOptA & opts) override
	{
		try
		{
		opts.Init(opts.FileCount(), opts.Files(), optionList, SO_O_NOERR | SO_O_USEALL | SO_O_ICASE);
		while (opts.Next())
		{
			if (opts.LastError() == SO_SUCCESS)
			{
				if (opts.OptionId() == OPT_HELP)
				{
					Usage();
					return 0;
				}
			}
			else
			{
				Usage();
				return 1;
			}
		}

		size_t count = GetAlgorithmCount();

		for (size_t i = 0; i < count; i++)
		{
			tscrypto::tsCryptoString name = GetAlgorithmNameByIndex(i);
			std::shared_ptr<Selftest> test = std::dynamic_pointer_cast<Selftest>(ConstructAlgorithmByIndex(i));
			std::shared_ptr<AlgorithmInfo> info = std::dynamic_pointer_cast<AlgorithmInfo>(test);


			if (!test)
			{
				printf("%-25s -> No self test published\n", name.c_str());
			}
			else 
			{
				tscrypto::tsCryptoString name(info->AlgorithmName());
				tscrypto::tsCryptoString oid(info->AlgorithmOID());
				tscrypto::tsCryptoString id;
				id << info->AlgorithmID();
				name.resize(35, ' ');
				oid.resize(27, ' ');
				id.resize(4, ' ');

				cout << name << " " << oid << "  " << id;

				if (test->runTests(true))
				{
					printf(" -> success\n");
				}
				else
				{
					printf(" -> FAILED\n");
				}
			}
		}
		}
		catch (...)
		{
			printf(" -> EXCEPTION\n");
		}
		return 0;
	}
开发者ID:TecSec,项目名称:OpenVEIL,代码行数:64,代码来源:selftest.cpp

示例4: Usage

static void Usage(int bShort = TRUE)
{
    Usage(NULL, bShort);
}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:4,代码来源:gnmanalyse.cpp

示例5: main

int main(int argc, char* argv[])
{
	char lpPipeName[50];
	char *lpBuffer = NULL;
	unsigned long ulSize = 0;

	BOOL bResult;
	DWORD dwWritten = 0, dwMode;
	HANDLE hPipe;

	Usage();

	printf("Starting...\n");

	if (argc != 3)
		goto Exit0;
	
	if (strlen(argv[1]) < 20)
	{
		sprintf(lpPipeName, "\\\\%s\\\\.\\pipe\\sql\\query", argv[1]);
	}
	else
	{
		printf("Error!server\n");
		goto Exit0;
	}

	ulSize= atol(argv[2]);

	lpBuffer = (char*)malloc(ulSize + 2);
	if (NULL == lpBuffer)
	{
		printf("malloc error!\n");
		goto Exit0;
	}

	memset(lpBuffer, 0, ulSize + 2);
	memset(lpBuffer, 'A', ulSize);
	*lpBuffer = '\x12';
	*(lpBuffer + 1) = '\x01';
	*(lpBuffer + 2) = '\x00';
	
	printf("Connecting Server...\n");

	hPipe = CreateFile(lpPipeName, 
					GENERIC_READ | GENERIC_WRITE,
					0,
					NULL,
					OPEN_EXISTING,
					0,
					NULL);
	if (INVALID_HANDLE_VALUE == hPipe)
	{
		printf("Error!Connect server!%d\n", GetLastError());
		goto Exit0;
	}

   dwMode = PIPE_READMODE_MESSAGE; 
   bResult = SetNamedPipeHandleState( 
      hPipe,    // pipe handle 
      &dwMode,  // new pipe mode 
      NULL,     // don't set maximum bytes 
      NULL);    // don't set maximum time 
   if (!bResult)
   {
		printf("Error!SetNamedPipeHandleState.%d\n", GetLastError());
		goto Exit0;
   }

	bResult = WriteFile(hPipe, lpBuffer, ulSize + 1, &dwWritten, NULL);

	if (!bResult)
	{
		printf("\n\tError!WriteFile.%d\n\n", GetLastError());
		printf("When see the error message, the target may be crashed!!\n\n");
		goto Exit0;
	}

Exit0:
	
	return 0;
}
开发者ID:atassumer,项目名称:Python-Exploit-Search-Tool,代码行数:82,代码来源:22957.cpp

示例6: TabCopyIn

ObitInfoList* TabCopyIn (int argc, char **argv, ObitErr *err)
/*----------------------------------------------------------------------- */
/*  Parse control info from command line                                  */
/*   Input:                                                               */
/*      argc   Number of arguments from command line                      */
/*      argv   Array of strings from command line                         */
/*   Output:                                                              */
/*      err    Obit Error stack                                           */
/*   return  ObitInfoList with defaults/parsed values                     */
/*----------------------------------------------------------------------- */
{
  olong ax;
  gchar *arg;
  gboolean init=FALSE;
  ObitInfoType type;
  gint32 dim[MAXINFOELEMDIM] = {1,1,1,1,1};
  gchar *strTemp;
  oint    itemp, i, j, k;
  ObitInfoList* list=NULL;
  gchar *routine = "TabCopyIn";

  /* error checks */
  g_assert(ObitErrIsA(err));
  if (err->error) return list;

  /* Make default inputs InfoList */
  list = defaultInputs(err);

  /* command line arguments */
  /* fprintf (stderr,"DEBUG arg %d %s\n",argc,argv[0]); DEBUG */
  if (argc<=1) Usage(); /* must have arguments */
  /* parse command line */
  for (ax=1; ax<argc; ax++) {

     /*fprintf (stderr,"DEBUG next arg %s %s\n",argv[ax],argv[ax+1]); DEBUG */
    arg = argv[ax];
    if (strcmp(arg, "-input") == 0){ /* input parameters */
      infile = argv[++ax];
      /* parse input file */
      ObitParserParse (infile, list, err);
      init = TRUE;

    } else if (strcmp(arg, "-output") == 0){ /* output results */
      outfile = argv[++ax];

    } else if (strcmp(arg, "-pgmNumber") == 0) { /*Program number */
      dim[0] = 1;
      itemp = strtol(argv[++ax], NULL, 0);
      ObitInfoListPut (list, "pgmNumber", OBIT_oint, dim, &itemp, err);
      
    } else if (strcmp(arg, "-AIPSuser") == 0) { /* AIPS user number */
      dim[0] = 1;
      itemp = strtol(argv[++ax], NULL, 0);
      ObitInfoListPut (list, "AIPSuser", OBIT_oint, dim, &itemp, err);
      
    } else if (strcmp(arg, "-inSeq") == 0) { /* AIPS sequence number */
      dim[0] = 1;
      itemp = strtol(argv[++ax], NULL, 0);
      ObitInfoListPut (list, "inSeq", OBIT_oint, dim, &itemp, err);
      
    } else if (strcmp(arg, "-inDisk") == 0) { /* input disk number */
      dim[0] = 1;
      itemp = strtol(argv[++ax], NULL, 0);
      ObitInfoListPut (list, "inDisk", OBIT_oint, dim, &itemp, err);
      
     } else if (strcmp(arg, "-DataType") == 0) { /* File type AIPS or FITS */
      strTemp = argv[++ax];
      dim[0] = strlen (strTemp);
      ObitInfoListAlwaysPut (list, "DataType", OBIT_string, dim, strTemp);
      
     } else if (strcmp(arg, "-inName") == 0) { /* AIPS inName*/
      strTemp = argv[++ax];
      dim[0] = strlen (strTemp);
      ObitInfoListAlwaysPut (list, "inName", OBIT_string, dim, strTemp);
      
     } else if (strcmp(arg, "-inClass") == 0) { /* AIPS inClass*/
      strTemp = argv[++ax];
      dim[0] = strlen (strTemp);
      ObitInfoListAlwaysPut (list, "inClass", OBIT_string, dim, strTemp);
      
     } else if (strcmp(arg, "-inFile") == 0) { /*inFile */
      strTemp = argv[++ax];
      dim[0] = strlen (strTemp);
      ObitInfoListAlwaysPut (list, "inFile", OBIT_string, dim, strTemp);
      
   } else { /* unknown argument */
      Usage();
    }
    if (err->error) Obit_traceback_val (err, routine, "GetInput", list);
  } /* end parsing input arguments */
  
  /* Read defaults if no file specified */
  if (!init) ObitParserParse (infile, list, err);

  /* Extract basic information to program globals */
  ObitInfoListGet(list, "pgmNumber", &type, dim, &pgmNumber, err);
  ObitInfoListGet(list, "AIPSuser",  &type, dim, &AIPSuser,  err);
  ObitInfoListGet(list, "nAIPS",     &type, dim, &nAIPS,     err);
  ObitInfoListGet(list, "nFITS",     &type, dim, &nFITS,     err);
  if (err->error) Obit_traceback_val (err, routine, "GetInput", list);
//.........这里部分代码省略.........
开发者ID:kernsuite-debian,项目名称:obit,代码行数:101,代码来源:TabCopy.c

示例7: doProcessInputArgs


//.........这里部分代码省略.........
        if (arg_counter + 1 == argc)
        {
          break_flag = 1;
          break; 
        }
        config_info->config_file_path = Malloc(strlen(argv[arg_counter+1])+1);
	strcpy(config_info->config_file_path, argv[arg_counter + 1]);
      }
      else if (!strcmp("-verify", argv[arg_counter]))
      {
	  printConfigVerify = TRUE;
      }
      else if (!strcmp("-logfile", argv[arg_counter]))
      {
        if (arg_counter + 1 == argc)
        {
          break_flag = 1;
          break;
        }
        config_info->log_file_path = Malloc(strlen(argv[arg_counter+1])+1);
        strcpy(config_info->log_file_path, argv[arg_counter + 1]);
      }
      else if (!strcmp("-loglevel", argv[arg_counter]))
      {
        if ((arg_counter + 1 == argc) || (atoi(argv[arg_counter + 1]) > 1))
        {
          break_flag = 1;
          break; 
        }
	config_info->log_level = atoi(argv[arg_counter + 1]);
      }
      else
      {
        (void) fprintf(stderr, "Unrecognized command line argument\n");
	Usage();
      }
    }
  } 
  if (break_flag)
      Usage();

  /*
   * Create space for the global connection arrays
   */
#ifdef XNO_SYSCONF      /* should only be on FreeBSD 1.x and NetBSD 0.x */
#undef _SC_OPEN_MAX
#endif
#ifdef _SC_OPEN_MAX
    config_info->num_client_conns = sysconf(_SC_OPEN_MAX) - 1;
#else
#ifdef hpux
    config_info->num_client_conns = _NFILE - 1;
#else
    config_info->num_client_conns = getdtablesize() - 1;
#endif
#endif

  client_conn_array = (struct client_conn_buf **) 
     malloc (config_info->num_client_conns * sizeof (struct client_conn_buf *));
  if (!client_conn_array)
  {
    (void) fprintf (stderr, "malloc - client connection array\n");
    exit (1);
  }

  if (!config_info->num_pm_conns)
    config_info->num_pm_conns = MAX_PM_CONNS;
  pm_conn_array = (struct pm_conn_buf **) 
     malloc (config_info->num_client_conns * sizeof (struct pm_conn_buf *));
  if (!pm_conn_array) 
  {
    (void) fprintf (stderr, "malloc - PM connection array\n");
    exit (1);
  }

  if (!config_info->num_servers)
    config_info->num_servers = MAX_SERVERS;
  server_array = (struct server_list **)
    malloc (config_info->num_servers * sizeof (struct server_list *));
  if (!server_array)
  {
    (void) fprintf (stderr, "malloc - server listen array\n");
    exit (1);
  }

  /*
   * check timeout values; if still zero then apply defaults
   */
  if (config_info->pm_data_timeout <= 0)
    config_info->pm_data_timeout = PM_DATA_TIMEOUT_DEFAULT;
  if (config_info->client_listen_timeout <= 0)
    config_info->client_listen_timeout = CLIENT_LISTEN_TIMEOUT_DEFAULT;
  if (config_info->client_data_timeout <= 0)
    config_info->client_data_timeout = CLIENT_DATA_TIMEOUT_DEFAULT;
  if (config_info->pm_listen_port == NULL)
  {
    config_info->pm_listen_port = Malloc(strlen(PM_LISTEN_PORT) + 1);
    strcpy(config_info->pm_listen_port, PM_LISTEN_PORT);
  }
}
开发者ID:aosm,项目名称:X11,代码行数:101,代码来源:misc.c

示例8: main

int main(int argc, char* argv[])
{
  enum {prNone, prTelnet} protocol = prNone;
  const char *pTermType = NULL;
  const BYTE *pAwakSeq = NULL;
  const char *pIF = NULL;
  char **pArgs = &argv[1];
  ComParams comParams;

  while (argc > 1) {
    if (**pArgs != '-')
      break;

    if (!strcmp(*pArgs, "--help")) {
      Usage(argv[0]);
    } else
    if (!strcmp(*pArgs, "--telnet")) {
      protocol = prTelnet;
      pArgs++;
      argc--;
    } else
    if (!strcmp(*pArgs, "--ignore-dsr")) {
      pArgs++;
      argc--;
      comParams.SetIgnoreDSR(TRUE);
    } else
    if (argc < 3) {
      Usage(argv[0]);
    } else
    if (!strcmp(*pArgs, "--terminal")) {
      pArgs++;
      argc--;
      pTermType = *pArgs;
      pArgs++;
      argc--;
    } else
    if (!strcmp(*pArgs, "--baud")) {
      pArgs++;
      argc--;
      comParams.SetBaudRate(*pArgs);
      pArgs++;
      argc--;
    } else
    if (!strcmp(*pArgs, "--data")) {
      pArgs++;
      argc--;
      comParams.SetByteSize(*pArgs);
      pArgs++;
      argc--;
    } else
    if (!strcmp(*pArgs, "--parity")) {
      pArgs++;
      argc--;
      if (!comParams.SetParity(*pArgs)) {
        fprintf(stderr, "Unknown parity value %s\n", *pArgs);
        exit(1);
      }
      pArgs++;
      argc--;
    } else
    if (!strcmp(*pArgs, "--stop")) {
      pArgs++;
      argc--;
      if (!comParams.SetStopBits(*pArgs)) {
        fprintf(stderr, "Unknown stop bits value %s\n", *pArgs);
        exit(1);
      }
      pArgs++;
      argc--;
    } else
    if (!strcmp(*pArgs, "--awak-seq")) {
      pArgs++;
      argc--;
      pAwakSeq = (const BYTE *)*pArgs;
      pArgs++;
      argc--;
    } else
    if (!strcmp(*pArgs, "--interface")) {
      pArgs++;
      argc--;
      pIF = *pArgs;
      pArgs++;
      argc--;
    } else {
      fprintf(stderr, "Unknown option %s\n", *pArgs);
      exit(1);
    }
  }

  if (argc < 3 || argc > 4)
    Usage(argv[0]);

  WSADATA wsaData;

  WSAStartup(MAKEWORD(1, 1), &wsaData);

  Protocol *pProtocol;

  switch (protocol) {
  case prTelnet:
//.........这里部分代码省略.........
开发者ID:Bobfrat,项目名称:coi-services,代码行数:101,代码来源:com2tcp.cpp

示例9: main

int main( int argc, char ** argv )

{
    SHPHandle	hSHP;
    SHPTree	*psTree;
    int		nExpandShapes = 0;
    int		nMaxDepth = 0;
    int		bDoSearch = 0;
    double	adfSearchMin[4], adfSearchMax[4];
    const char *pszOutputIndexFilename = NULL;
    const char *pszInputIndexFilename = NULL;
    const char *pszTargetFile = NULL;

/* -------------------------------------------------------------------- */
/*	Consume flags.							*/
/* -------------------------------------------------------------------- */
    while( argc > 1 )
    {
        if( strcmp(argv[1],"-v") == 0 )
        {
            nExpandShapes = 1;
            argv++;
            argc--;
        }
        else if( strcmp(argv[1],"-maxdepth") == 0 && argc > 2 )
        {
            nMaxDepth = atoi(argv[2]);
            argv += 2;
            argc -= 2;
        }
        else if( strcmp(argv[1],"-o") == 0 && argc > 2 )
        {
            pszOutputIndexFilename = argv[2];
            argv += 2;
            argc -= 2;
        }
        else if( strcmp(argv[1],"-i") == 0 && argc > 2 )
        {
            pszInputIndexFilename = argv[2];
            argv += 2;
            argc -= 2;
        }
        else if( strcmp(argv[1],"-search") == 0 && argc > 5 )
        {
            bDoSearch = 1;

            adfSearchMin[0] = atof(argv[2]);
            adfSearchMin[1] = atof(argv[3]);
            adfSearchMax[0] = atof(argv[4]);
            adfSearchMax[1] = atof(argv[5]);

            adfSearchMin[2] = adfSearchMax[2] = 0.0;
            adfSearchMin[3] = adfSearchMax[3] = 0.0;

            if( adfSearchMin[0] > adfSearchMax[0]
                || adfSearchMin[1] > adfSearchMax[1] )
            {
                printf( "Min greater than max in search criteria.\n" );
                Usage();
            }
            
            argv += 5;
            argc -= 5;
        }
        else if( pszTargetFile == NULL )				
        {
            pszTargetFile = argv[1];
            argv++;
            argc--;
        }
        else
        {
            printf( "Unrecognised argument: %s\n", argv[1] );
            Usage();
        }
    }

/* -------------------------------------------------------------------- */
/*      Do a search with an existing index file?                        */
/* -------------------------------------------------------------------- */
    if( bDoSearch && pszInputIndexFilename != NULL )
    {
        FILE *fp = fopen( pszInputIndexFilename, "rb" );
        int  *panResult, nResultCount = 0, iResult;

        if( fp == NULL )
        {
            perror( pszInputIndexFilename );
            exit( 1 );
        }

        panResult = SHPSearchDiskTree( fp, adfSearchMin, adfSearchMax, 
                                       &nResultCount );

        printf( "Result: " );
        for( iResult = 0; iResult < nResultCount; iResult++ )
            printf( "%d ", panResult[iResult] );
        printf( "\n" );
        free( panResult );

//.........这里部分代码省略.........
开发者ID:OpendTect,项目名称:shapelib,代码行数:101,代码来源:shptreedump.c

示例10: main

int main(int argc, char *argv[]) {

	
	long i;
	int nextSN = 0;
	int base = 0;
	int F = 2;
	int tempposi=0;
	
	
	//--------------
	char *Server = DEFAULT_SERVER;
	char *Filename = "";
	char *Port = DEFAULT_PORT;
	char *Window_size = DEFAULT_WINDOW;
	//Timerhandling
	struct timeouts *timelist = NULL;
	int intervall = 1000; //1000millisekunden

	struct request req;
	struct answer ans;
	int isDropped = false;


	FILE *fp;

	if (argc > 1) {
		for (i = 1; i < argc; i++) {
			if (((argv[i][0] == '-') || (argv[i][0] == '/')) && (argv[i][1] != 0) && (argv[i][2] == 0)) {
				switch (tolower(argv[i][1]))
				{
				case 'a'://Server address
					if (argv[i + 1]) {
						if (argv[i + 1][0] != '-') {
							Server = argv[++i];
							break;
						}
					}
					Usage(argv[0]);
					break;
				case 'p': //server port
					if (argv[i + 1]) {
						if (argv[i + 1][0] != '-') {
							Port = argv[++i];
							break;
						}
					}
					Usage(argv[0]);
					break;
				case 'f': //file name
					if (argv[i + 1]) {
						if (argv[i + 1][0] != '-') {
							Filename = argv[++i];
							break;
						}
					}
					Usage(argv[0]);
					break;
				case 'w': //window size
					if (argv[i + 1]) {
						if (argv[i + 1][0] != '-') {
							Window_size = argv[++i];
							break;
						}
					}
					Usage(argv[0]);
					break;
				default:
					Usage(argv[0]);
					break;
				}
			}
			else Usage(argv[0]);
		}
	}

	initClient(Server, Port);
	File *f = newFile("test.txt");
	
	while (1) {

		
		fromApp(f, &req, nextSN,&tempposi);
	
		//Fenster 1 ---------------------------------------------
		if (nextSN < base + F) {
			printf("Sending Packet: %d\n", nextSN);
			if (nextSN == 1) {
				isDropped = true;
			}
			else isDropped = false;
			timelist = sendData(&req, timelist, isDropped);
			listenToSock();
			//NACKRECEIVE() + DEL_TIMER
			decrement_timer(timelist);
			nextSN++;
		}//-------------------------------------------------------WAIT for TIMEOUT 3 TIMES

		if (nextSN >= base + F) {
			if (timelist->timer == 0) {
//.........这里部分代码省略.........
开发者ID:s72785,项目名称:RnKs-Wirdschon,代码行数:101,代码来源:Client.c

示例11: main

int main(int argc, char **argv)
{
    int             bits_per_pixel = 8, cmsize, i, j, k,
                    cmap_index, chunk_size = 32, nchunks = 16;
    unsigned char * scan_line;
    uint16          *red, *green, *blue;
    TIFF *          tif;

    programName = argv[0];

    if (argc != 4)
        Usage();

    if (!strcmp(argv[1], "-depth"))
         bits_per_pixel = atoi(argv[2]);
    else
         Usage();

    switch (bits_per_pixel) {
        case 8:
            nchunks = 16;
            chunk_size = 32;
            break;
        case 4:
            nchunks = 4;
            chunk_size = 128;
            break;
        case 2:
            nchunks = 2;
            chunk_size = 256;
            break;
	case 1:
	    nchunks = 2;
	    chunk_size = 256;
	    break;
        default:
            Usage();
    }

    if (bits_per_pixel != 1) {
	cmsize = nchunks * nchunks;
    } else {
	cmsize = 2;
    }
    red = (uint16 *) malloc(cmsize * sizeof(uint16));
    green = (uint16 *) malloc(cmsize * sizeof(uint16));
    blue = (uint16 *) malloc(cmsize * sizeof(uint16));

    switch (bits_per_pixel) {
    case 8:
        for (i = 0; i < cmsize; i++) {
            if (i < 32)
                red[i] = 0;
            else if (i < 64)
                red[i] = SCALE(36);
            else if (i < 96)
                red[i] = SCALE(73);
            else if (i < 128)
                red[i] = SCALE(109);
            else if (i < 160)
                red[i] = SCALE(146);
            else if (i < 192)
                red[i] = SCALE(182);
            else if (i < 224)
                red[i] = SCALE(219);
            else if (i < 256)
                red[i] = SCALE(255);

            if ((i % 32) < 4)
                green[i] = 0;
            else if (i < 8)
                green[i] = SCALE(36);
            else if ((i % 32) < 12)
                green[i] = SCALE(73);
            else if ((i % 32) < 16)
                green[i] = SCALE(109);
            else if ((i % 32) < 20)
                green[i] = SCALE(146);
            else if ((i % 32) < 24)
                green[i] = SCALE(182);
            else if ((i % 32) < 28)
                green[i] = SCALE(219);
            else if ((i % 32) < 32)
                green[i] = SCALE(255);

            if ((i % 4) == 0)
                blue[i] = SCALE(0);
            else if ((i % 4) == 1)
                blue[i] = SCALE(85);
            else if ((i % 4) == 2)
                blue[i] = SCALE(170);
            else if ((i % 4) == 3)
                blue[i] = SCALE(255);
        }
        break;
    case 4:
        red[0] = SCALE(255);
        green[0] = 0;
        blue[0] = 0;

//.........这里部分代码省略.........
开发者ID:aosm,项目名称:tcl,代码行数:101,代码来源:tiff-palette.c

示例12: main

int main(int argc, char** argv) {

  if (argc != 2)
    return Usage(std::string(argv[0]));

  // Initialize logging.
  const bool log_to_file = false;

  if (log_to_file) {

    const int nb_rolling_logfiles = 2;
    const int max_logfile_size = 1000000;
    plog::init(plog::verbose, "wave_propagator.log", max_logfile_size, nb_rolling_logfiles);

  } else {

    static plog::ColorConsoleAppender<plog::TxtFormatter> console_appender;
    plog::init(plog::verbose, &console_appender);

  }

  LOG_INFO << "**** 2D/3D wave propagator in heterogeneous media ****\n";

  char const* const parameter_filename_c = argv[1];
  const std::string parameter_filename = std::string(parameter_filename_c);

  RectilinearGrid3D propagation_grid;
  MultiDimensionalStorage4D variable_storage;
  MathematicalParser math_parser;
  std::vector<OutputEvent> output_events;
  TimeloopManager timeloop_manager;
  WaveSolverOptions wave_solver_options = WaveSolverOptions();;

  LOG_INFO << "Reading parameter file \"" << parameter_filename << "\"...";

  std::ifstream parameter_file(parameter_filename.c_str(), std::ifstream::in);
  const int nx_padding = 10;

  ParseParameterFile(nx_padding, &parameter_file, &propagation_grid, 
                     &variable_storage, &math_parser, &output_events,
                     &timeloop_manager, &wave_solver_options);

  parameter_file.close();

  math_parser.PrintConstants();

  const int nb_iter = timeloop_manager.nb_iter();

  // Variables information (hardcoded for now, in variable_definitions.hpp).
  const int nb_variables = variable::NB_VARIABLES;
  
  std::stringstream var_name_msg;

  var_name_msg << "List of variables: [";
  for (int ivar = 0; ivar < nb_variables; ++ivar)
    var_name_msg << " " << variable::VARIABLE_NAMES[ivar];
  var_name_msg << " ]\n";

  LOG_DEBUG << var_name_msg.str();

  const RealT dx = propagation_grid.dx_fast();
  const RealT dy = propagation_grid.dx_medium();
  const RealT dz = propagation_grid.dx_slow();

  RealT* pressure_0 = variable_storage.RawDataSlowDimension(variable::PRESSURE_0);
  RealT* pressure_1 = variable_storage.RawDataSlowDimension(variable::PRESSURE_1);
  RealT* laplace_p = variable_storage.RawDataSlowDimension(variable::LAPLACE_PRESSURE);
  RealT* velocity = variable_storage.RawDataSlowDimension(variable::VELOCITY);

  // Init output events.
  for (auto it = output_events.begin(); it != output_events.end(); ++it)
    it->Create(nb_iter, variable_storage, propagation_grid);

  RealT* sponge_fast = VectorRawData<RealT>(wave_solver_options.sponge_fast());
  RealT* sponge_medium = VectorRawData<RealT>(wave_solver_options.sponge_medium());
  RealT* sponge_slow = VectorRawData<RealT>(wave_solver_options.sponge_slow());

  std::ofstream sponge_fast_out("sponge_fast.txt", std::ofstream::out);
  std::ofstream sponge_medium_out("sponge_medium.txt", std::ofstream::out);
  std::ofstream sponge_slow_out("sponge_slow.txt", std::ofstream::out);

  wave_solver_options.DumpAllSponges(&sponge_fast_out,
                                     &sponge_medium_out,
                                     &sponge_slow_out);

  sponge_fast_out.close();
  sponge_medium_out.close();
  sponge_slow_out.close();

  const RealT dt = timeloop_manager.dt();
  RealT t = 0.0;

  // Main time loop. All numerics (except time step computation) is in
  // here.
  for (int iter = 0; iter < timeloop_manager.nb_iter(); ++iter) {

    t += dt;
    math_parser.AddConstant("t", t);

    const int stencil_radius = 1;
//.........这里部分代码省略.........
开发者ID:RaphaelPoncet,项目名称:2016-macs2-projet-hpc,代码行数:101,代码来源:main.cpp

示例13: main

/*********************************************
 main():
 *********************************************/
int	main	(int argc, char *argv[])
{
  int c;
  long RecordNum=0;
  long RecordLen=0;
  offset RecordEnd=0;
  time_t Time;
  struct tm *TimeS;
  uint64_t SequenceNum;
  uint64_t Number;
  int First=0;
  int PrintString=0;
  char *Label;
  int z;
  while((c = getopt(argc,argv,"bF:v")) != -1)
    {
    switch(c)
      {
      case 'b':	BlankFlag=1; break;
      case 'F':
	Divider=optarg[0];
	if (!strcmp(optarg,"\\n")) Divider='\n';
	break;
      case 'v':	Verbose++; break;
      default:
	Usage(argv[0]);
	exit(-1);
      }
    }

  /* Process each file */
  for( ; optind < argc; optind++)
    {
    SkypeOpenFile(argv[optind]);
    Index=0;
    while( (Index < MemorySize) && (SkypeFindRecord() != (offset)(-1)) )
      {
      RecordNum++;
      if (Verbose) printf("# Record %ld in %s\n",RecordNum,argv[optind]);
      RecordLen = Bytes2Val(4);
      RecordEnd = Index + RecordLen;
      if (Verbose)
	{
	printf("# Record length: %ld bytes (0x%08lx)\n",
		(long)RecordLen,(long)RecordLen);
	}

      if (Index+RecordLen > MemorySize)
	{
	fprintf(stderr,"WARNING: Fractional record being processed.\n");
	/* Permit it to go on! */
	RecordLen = MemorySize - Index;
	}

      SequenceNum = Bytes2Val(4);
      if (Verbose)
	{
	printf("# Sequence: %08lx\n",(unsigned long)SequenceNum);
	}

      /* Process the record */
      First = 0; /* no output yet (first entry not seen) */
      Time=0;
      while(Index < RecordEnd)
        {
	/* Skip until we hit 0x03 */
	while ((Index < RecordEnd) && (Memory[Index] != 0x03))
	   {
	   if (Verbose > 2) printf(" {%02x}",Memory[Index]);
	   Index++;
	   }

	/* Check if we found the start */
	while ((Index < RecordEnd) && (Memory[Index] == 0x03))
		{
		Number=0;
		/* Skip multiple 0x03 */
		while (Memory[Index] == 0x03) Index++;
		Number = ReadNumber();

		PrintString=1;
		Label=NULL;
		switch(Number)
		  {
		  case 15: Label="VoicemailFile"; break;
		  case 16: Label="Call"; break;
		  case 20: Label="Summary"; break;
		  case 36: Label="Language"; break;
		  case 40: Label="Country"; break;
		  case 48: Label="City"; break;
		  case 51: Label="File"; break;
		  case 55: Label="Peek"; break;
		  case 64: Label="Email"; break;
		  case 68: Label="URL"; break;
		  case 72: Label="Description"; break;
		  case 116: Label="Country"; break;
		  case 184: Label="Phone"; break;
//.........这里部分代码省略.........
开发者ID:mulaz,项目名称:skypelog,代码行数:101,代码来源:skypelog.c

示例14: client_test

THREAD_RETURN CYASSL_THREAD client_test(void* args)
{
    SOCKET_T sockfd = 0;

    CYASSL_METHOD*  method  = 0;
    CYASSL_CTX*     ctx     = 0;
    CYASSL*         ssl     = 0;
    
    CYASSL*         sslResume = 0;
    CYASSL_SESSION* session = 0;
    char         resumeMsg[] = "resuming cyassl!";
    int          resumeSz    = sizeof(resumeMsg);

    char msg[32] = "hello cyassl!";   /* GET may make bigger */
    char reply[80];
    int  input;
    int  msgSz = (int)strlen(msg);

    int   port   = yasslPort;
    char* host   = (char*)yasslIP;
    char* domain = (char*)"www.yassl.com";

    int    ch;
    int    version = CLIENT_INVALID_VERSION;
    int    usePsk   = 0;
    int    sendGET  = 0;
    int    benchmark = 0;
    int    doDTLS    = 0;
    int    matchName = 0;
    int    doPeerCheck = 1;
    int    nonBlocking = 0;
    int    resumeSession = 0;
    int    trackMemory   = 0;
    char*  cipherList = NULL;
    char*  verifyCert = (char*)caCert;
    char*  ourCert    = (char*)cliCert;
    char*  ourKey     = (char*)cliKey;

    int     argc = ((func_args*)args)->argc;
    char**  argv = ((func_args*)args)->argv;

    ((func_args*)args)->return_code = -1; /* error state */

#ifdef NO_RSA
    verifyCert = (char*)eccCert;
    ourCert    = (char*)cliEccCert;
    ourKey     = (char*)cliEccKey;
#endif
    (void)resumeSz;
    (void)session;
    (void)sslResume;
    (void)trackMemory;

    while ((ch = mygetopt(argc, argv, "?gdusmNrth:p:v:l:A:c:k:b:z")) != -1) {
        switch (ch) {
            case '?' :
                Usage();
                exit(EXIT_SUCCESS);

            case 'g' :
                sendGET = 1;
                break;

            case 'd' :
                doPeerCheck = 0;
                break;

            case 'u' :
                doDTLS  = 1;
                break;

            case 's' :
                usePsk = 1;
                break;

            case 't' :
            #ifdef USE_CYASSL_MEMORY
                trackMemory = 1;
            #endif
                break;

            case 'm' :
                matchName = 1;
                break;

            case 'h' :
                host   = myoptarg;
                domain = myoptarg;
                break;

            case 'p' :
                port = atoi(myoptarg);
                #if !defined(NO_MAIN_DRIVER) || defined(USE_WINDOWS_API)
                    if (port == 0)
                        err_sys("port number cannot be 0");
                #endif
                break;

            case 'v' :
                version = atoi(myoptarg);
//.........这里部分代码省略.........
开发者ID:pykoder,项目名称:cyassl,代码行数:101,代码来源:client.c

示例15: main

int main(int argc, char** argv)
{
  GroupBy::Option option;

  while (1) {
    static struct option long_options[] = {
      { "width",            required_argument, 0, 'w' },
      { "fields",           required_argument, 0, 'f' },
      { "skip",             required_argument, 0, 's' },
      { "delimiters",       required_argument, 0, 'd' },
      { "join-delimiter",   required_argument, 0, 'j' },
      { "help",             no_argument,       0, '?' },
      { 0,                 0 ,                 0, 0 },
    };

    int c = getopt_long(argc, argv, "w:d:j:f:s:", long_options, NULL);
    if (c == -1) {
      break;
    }

    switch(c) {
    case 'w':
      option.get_key_mode = GroupBy::Option::GET_KEY_MODE_CHARS;
      option.key_length = std::atoi(optarg);
      break;

    case 'f':
      option.get_key_mode = GroupBy::Option::GET_KEY_MODE_FIELDS;
      option.field_length = std::atoi(optarg);
      break;

    case 's':
      option.n_skip = std::atoi(optarg);
      break;

    case 'd':
      option.get_key_mode = GroupBy::Option::GET_KEY_MODE_FIELDS;
      option.delimiters = optarg;
      break;

    case 'j':
      option.join_delimiter = optarg;
      break;

    case '?':
      Usage(argc, argv, option);
      return 0;
      break;

    default:
      Usage(argc, argv, option);
      return -1;
    }
  }

  if (optind < argc) {
    Usage(argc, argv, option);
    return -1;
  }

  argc -= optind;
  argv += optind;

  GroupBy group_by(option);
  while (std::cin) {
    std::string line;
    if (std::getline(std::cin, line).eof()) {
      break;
    }
    group_by.Append(line);
  }

  const std::vector<std::string>& buffers = group_by.Buffers();
  for (std::vector<std::string>::const_iterator it = buffers.begin(); it != buffers.end(); ++it) {
    std::cout << *it << std::endl;
  }

  return 0;
}
开发者ID:takei-yuya,项目名称:groupby,代码行数:79,代码来源:main.cpp


注:本文中的Usage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。