src/lib/cmd_parser.h
bRC parse_cmd(const char *line)
   {
      char *a;
      int nbequal = 0;
      if (!line || *line == '\0') {
         return bRC_Error;
      }

      /* Same command line that before */
      if (!strcmp(line, org)) {
         return bRC_OK;
      }

      /*
       * line = delta:minsize=10002 param1=xxx
       *             |     backup command
       */
      pm_strcpy(org, line);
      pm_strcpy(cmd, line);

      if (handle_plugin_name) {
         if ((a = strchr(cmd, ':')) != NULL) {
            *a = ' ';              /* replace : by ' ' for command line processing */

         } else if (strchr(cmd, ' ') != NULL) { /* We have "word1 word2" where we expect "word1: word2" */
            return bRC_Error;
         }
      }

      for (char *p = cmd; *p ; p++) {
         if (*p == '=') {
            nbequal++;
         }
      }

      if (argk) {
         free(argk);
      }
      if (argv) {
         free(argv);
      }

      max_cmd = MAX(nbequal, MAX_CMD_ARGS) + 1;

      argk = (char **) malloc(sizeof(char **) * max_cmd);
      argv = (char **) malloc(sizeof(char **) * max_cmd);

      parse_args(cmd, &args, &argc, argk, argv, max_cmd);

      return bRC_OK;
   }
/*
    * Build args, argc, argk from Plugin Restore|Backup command
    */
Build args, argc, argk from Plugin Restore|Backup command
Build args argc argk from Plugin Restore|Backup command
bRC parse_cmd(const char *line)
   {
      char *a;
      int nbequal = 0;
      if (!line || *line == '\0') {
         return bRC_Error;
      }
      if (!strcmp(line, org)) {
         return bRC_OK;
      }
      pm_strcpy(org, line);
      pm_strcpy(cmd, line);
      if (handle_plugin_name) {
         if ((a = strchr(cmd, ':')) != NULL) {
            *a = ' ';              
         } else if (strchr(cmd, ' ') != NULL) { 
            return bRC_Error;
         }
      }
      for (char *p = cmd; *p ; p++) {
         if (*p == '=') {
            nbequal++;
         }
      }
      if (argk) {
         free(argk);
      }
      if (argv) {
         free(argv);
      }
      max_cmd = MAX(nbequal, MAX_CMD_ARGS) + 1;
      argk = (char **) malloc(sizeof(char **) * max_cmd);
      argv = (char **) malloc(sizeof(char **) * max_cmd);
      parse_args(cmd, &args, &argc, argk, argv, max_cmd);
      return bRC_OK;
   }
bRC parse_cmd ( const char * line ) { char * a ; int nbequal = 0 ; if ( ! line || * line == ' \0 ' ) { return bRC_Error ; } if ( ! strcmp ( line , org ) ) { return bRC_OK ; } pm_strcpy ( org , line ) ; pm_strcpy ( cmd , line ) ; if ( handle_plugin_name ) { if ( ( a = strchr ( cmd , ' ' ) ) != NULL ) { * a = ' ' ; } else if ( strchr ( cmd , ' ' ) != NULL ) { return bRC_Error ; } } for ( char * p = cmd ; * p ; p ++ ) { if ( * p == ' ' ) { nbequal ++ ; } } if ( argk ) { free ( argk ) ; } if ( argv ) { free ( argv ) ; } max_cmd = MAX ( nbequal , MAX_CMD_ARGS ) + 1 ; argk = ( char * * ) malloc ( sizeof ( char * * ) * max_cmd ) ; argv = ( char * * ) malloc ( sizeof ( char * * ) * max_cmd ) ; parse_args ( cmd , & args , & argc , argk , argv , max_cmd ) ; return bRC_OK ; }
Build args, argc, argk from Plugin Restore|Backup command
Build args argc argk from Plugin Restore|Backup command
/* Same command line that before */ /*
       * line = delta:minsize=10002 param1=xxx
       *             |     backup command
       */ /* replace : by ' ' for command line processing */ /* We have "word1 word2" where we expect "word1: word2" */