check transfer  0.1
Check data transfer for SDAccell OpenCL application
Functions
parse_cmd.cpp File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "parse_cmd.h"

Go to the source code of this file.

Functions

int GetFromCommnadLine (int argc, char **argv, const char *name, int defValue)
 Get integer value from command line. More...
 
int GetStrFromCommnadLine (int argc, char **argv, const char *name, char *defValue, char *dst, int dstLen)
 Get string value from command line. More...
 

Function Documentation

◆ GetFromCommnadLine()

int GetFromCommnadLine ( int  argc,
char **  argv,
const char *  name,
int  defValue 
)

Get integer value from command line.

format command line: <name1> <value1> <name2> <value2>

Parameters
argcnumber of argument
argvpointers to arguments
namekey of argument
defValuedefault value for arguments
Returns
value of argument or default value of argument

Definition at line 29 of file parse_cmd.cpp.

Referenced by main(), TF_CheckTransferIn::TF_CheckTransferIn(), and TF_CheckTransferOut::TF_CheckTransferOut().

30 {
31  int ret=defValue;
32  for( int ii=1; ii<argc-1; ii++ )
33  {
34  if( 0==strcmp( argv[ii], name) )
35  {
36  ret=atoi( argv[ii+1] );
37  }
38  }
39  return ret;
40 }

◆ GetStrFromCommnadLine()

int GetStrFromCommnadLine ( int  argc,
char **  argv,
const char *  name,
char *  defValue,
char *  dst,
int  dstLen 
)

Get string value from command line.

format command line: <name1> <text1> <name2> <text2>

Parameters
argcnumber of argument
argvpointers to arguments
namekey of argument
defValuedefault value for arguments
dstpointer to destination string, NULL - do not copy
dstLenmax number of chars in the dst
Returns
0 - name not found, 1 - found only name, 2 - found name and text

Definition at line 58 of file parse_cmd.cpp.

Referenced by TF_Device::TF_Device().

59 {
60  int ret=0;
61  int index=0;
62  for( int ii=1; ii<argc; ii++ )
63  {
64  if( 0==strcmp( argv[ii], name) )
65  {
66  if( ii==(argc-1) )
67  ret=1;
68  else
69  {
70  ret=2; index=ii;
71  }
72 
73  break;
74  }
75  }
76  if( NULL!=dst )
77  {
78  if( 2==ret )
79  strncpy( dst, argv[index+1], dstLen );
80  else
81  strncpy( dst, defValue, dstLen );
82  dst[dstLen-1]=0;
83  }
84  return ret;
85 }