Logo Search packages:      
Sourcecode: fence-agents version File versions  Download package

static int parse_cli ( int  argc,
char *  argv[],
int *  operation,
int *  mode,
char **  hostname,
char **  port 
) [static]

Parse arguments from command line.

Parameters:
argcNumber of arguments in argv
argvArray of arguments
modePointer to int will be filled with OPERATION_DEFAULT or OPERATION_HELP.
modePointer to int will be filled with MODE_DEFAULT, MODE_IP4MODE or MODE_IP4MODE.
Returns:
1 on success, otherwise 0.

Definition at line 230 of file fence_nss_wrapper.c.

References MODE_DEFAULT, MODE_IP4MODE, MODE_IP6MODE, MODE_NO_SSL, MODE_RAW, OPERATION_DEFAULT, and OPERATION_HELP.

Referenced by main().

                                                                                                 {
  int opt;

  *operation=OPERATION_DEFAULT;
  *mode=MODE_DEFAULT;
  *port=NULL;
  *hostname=NULL;

  while ((opt=getopt(argc,argv,"h46rz"))!=-1) {
    switch (opt) {
      case 'h':
        *operation=OPERATION_HELP;

        return 0;
      break;

      case '4':
        (*mode)&=~MODE_IP6MODE;
        (*mode)|=MODE_IP4MODE;
      break;

      case '6':
        (*mode)&=~MODE_IP4MODE;
        (*mode)|=MODE_IP6MODE;
      break;

      case 'r':
        (*mode)|=MODE_RAW;
      break;

      case 'z':
        (*mode)|=MODE_NO_SSL;
      break;

      default:
        return 0;
      break;
    }
  }

  if (argc-optind<2) {
    fprintf(stderr,"Hostname and port is expected!\n");

    return 0;
  }

  *hostname=argv[optind];
  *port=argv[optind+1];

  return 1;
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index