Base code merged to SPIN 2.4
[platform/upstream/curl.git] / src / tool_parsecfg.c
index ca3a451..c5d390b 100644 (file)
@@ -44,8 +44,7 @@ static const char *unslashquote(const char *line, char *param);
 static char *my_get_line(FILE *fp);
 
 /* return 0 on everything-is-fine, and non-zero otherwise */
-int parseconfig(const char *filename,
-                struct Configurable *config)
+int parseconfig(const char *filename, struct GlobalConfig *global)
 {
   int res;
   FILE *file;
@@ -53,6 +52,7 @@ int parseconfig(const char *filename,
   bool usedarg;
   char *home;
   int rc = 0;
+  struct OperationConfig *operation = global->first;
 
   if(!filename || !*filename) {
     /* NULL or no file name attempts to load .curlrc from the homedir! */
@@ -202,13 +202,13 @@ int parseconfig(const char *filename,
         case '#': /* comment */
           break;
         default:
-          warnf(config, "%s:%d: warning: '%s' uses unquoted white space in the"
-                " line that may cause side-effects!\n",
+          warnf(operation, "%s:%d: warning: '%s' uses unquoted white space in"
+                " the line that may cause side-effects!\n",
                 filename, lineno, option);
         }
       }
 
-      if(param && !*param) {
+      if(!*param) {
         /* do this so getparameter can check for required parameters.
            Otherwise it always thinks there's a parameter. */
         if(alloced_param)
@@ -219,13 +219,39 @@ int parseconfig(const char *filename,
 #ifdef DEBUG_CONFIG
       fprintf(stderr, "PARAM: \"%s\"\n",(param ? param : "(null)"));
 #endif
-      res = getparameter(option, param, &usedarg, config);
+      res = getparameter(option, param, &usedarg, global, operation);
 
       if(param && *param && !usedarg)
         /* we passed in a parameter that wasn't used! */
         res = PARAM_GOT_EXTRA_PARAMETER;
 
-      if(res != PARAM_OK) {
+      if(res == PARAM_NEXT_OPERATION) {
+        if(operation->url_list && operation->url_list->url) {
+          /* Allocate the next config */
+          operation->next = malloc(sizeof(struct OperationConfig));
+          if(operation->next) {
+            /* Initialise the newly created config */
+            config_init(operation->next);
+
+            /* Copy the easy handle */
+            operation->next->easy = global->easy;
+
+            /* Set the global config pointer */
+            operation->next->global = global;
+
+            /* Update the last operation pointer */
+            global->last = operation->next;
+
+            /* Move onto the new config */
+            operation->next->prev = operation;
+            operation = operation->next;
+          }
+          else
+            res = PARAM_NO_MEM;
+        }
+      }
+
+      if(res != PARAM_OK && res != PARAM_NEXT_OPERATION) {
         /* the help request isn't really an error */
         if(!strcmp(filename, "-")) {
           filename = (char *)"<stdin>";
@@ -235,7 +261,7 @@ int parseconfig(const char *filename,
            res != PARAM_VERSION_INFO_REQUESTED &&
            res != PARAM_ENGINES_REQUESTED) {
           const char *reason = param2text(res);
-          warnf(config, "%s:%d: warning: '%s' %s\n",
+          warnf(operation, "%s:%d: warning: '%s' %s\n",
                 filename, lineno, option, reason);
         }
       }