gpio  1.4.2
General Purpose I/O Package
gpiounexport

Macros

#define APP_EC_OK   0
 success exit code
 
#define APP_EC_ARGS   2
 command-line options/arguments error exit code
 
#define APP_EC_EXEC   4
 execution exit code
 

Functions

static int strToInt (const string &str, int &val)
 
static void mainInit (int argc, char *argv[])
 Main initialization. More...
 
int main (int argc, char *argv[])
 Main. More...
 

Variables

static char * Argv0
 the command
 
static int ArgsGpio
 gpio number
 
static OptsPgmInfo_T PgmInfo
 Program information. More...
 
static OptsInfo_T OptsInfo []
 Command line options information. More...
 

Detailed Description

Function Documentation

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

Main.

Parameters
argcCommand-line argument count.
argvCommand-line argument list.
Returns
Returns 0 on succes, non-zero on failure.

Definition at line 143 of file gpiounexport.cxx.

References APP_EC_EXEC, APP_EC_OK, ArgsGpio, gpioUnexport(), and mainInit().

144 {
145  char cmd[MAX_PATH];
146  char dir[MAX_PATH];
147 
148  mainInit(argc, argv);
149 
150  if( gpioUnexport(ArgsGpio) < 0 )
151  {
152  return APP_EC_EXEC;
153  }
154 
155  return APP_EC_OK;
156 }
#define APP_EC_EXEC
execution exit code
static void mainInit(int argc, char *argv[])
Main initialization.
int gpioUnexport(int gpio)
Unexport (delete) a GPIO interface.
Definition: gpio.c:221
#define APP_EC_OK
success exit code
static int ArgsGpio
gpio number
static void mainInit ( int  argc,
char *  argv[] 
)
static

Main initialization.

Parameters
argcCommand-line argument count.
argvCommand-line argument list.
Exits:
Program terminates on conversion error.

Definition at line 112 of file gpiounexport.cxx.

References APP_EC_ARGS, ArgsGpio, Argv0, OptsInfo, PgmInfo, and PkgInfo.

Referenced by main().

113 {
114  // name of this process
115  Argv0 = basename(argv[0]);
116 
117  // parse input options
118  argv = OptsGet(Argv0, &PkgInfo, &PgmInfo, OptsInfo, true, &argc, argv);
119 
120  if( argc == 0 )
121  {
122  fprintf(stderr, "%s: No GPIO pin number <gpio> specified.\n", Argv0);
123  fprintf(stderr, "Try '%s --help' for more information.\n", Argv0);
124  exit(APP_EC_ARGS);
125  }
126 
127  else if( strToInt(argv[0], ArgsGpio) < 0 )
128  {
129  fprintf(stderr, "%s: '%s': Bad GPIO number.\n", Argv0, argv[0]);
130  fprintf(stderr, "Try '%s --help' for more information.\n", Argv0);
131  exit(APP_EC_ARGS);
132  }
133 }
static OptsPgmInfo_T PgmInfo
Program information.
static OptsInfo_T OptsInfo[]
Command line options information.
static const PkgInfo_T PkgInfo
Definition: version.h:45
static char * Argv0
the command
static int ArgsGpio
gpio number
#define APP_EC_ARGS
command-line options/arguments error exit code

Variable Documentation

OptsInfo_T OptsInfo[]
static
Initial value:
=
{
{NULL, }
}

Command line options information.

Definition at line 84 of file gpiounexport.cxx.

Referenced by mainInit().

OptsPgmInfo_T PgmInfo
static
Initial value:
=
{
"<gpio>",
"Destroy GPIO exported interface.",
"The %P command destroys a GPIO exported interface for the specified GPIO "
"number.\n\n"
"NOTE: This command requires root privileges.",
NULL
}

Program information.

Definition at line 64 of file gpiounexport.cxx.

Referenced by mainInit().