Skip to content
Snippets Groups Projects
main.c 60.7 KiB
Newer Older
  • Learn to ignore specific revisions
  •         curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, myprogress);
            curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &progressbar);
          }
    
          /* new in libcurl 7.6.2: */
          curl_easy_setopt(curl, CURLOPT_TELNETOPTIONS, config->telnet_options);
    
    
          /* new in libcurl 7.7: */
          curl_easy_setopt(curl, CURLOPT_RANDOM_FILE, config->random_file);
          curl_easy_setopt(curl, CURLOPT_EGDSOCKET, config->egd_file);
    
          curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, config->connecttimeout);
    
          
          res = curl_easy_perform(curl);
    
          if(config->writeout) {
            ourWriteOut(curl, config->writeout);
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
    #ifdef	VMS
    	if (!config->showerror)  {
    		vms_show = VMSSTS_HIDE;
    	}
    #else
    
          if((res!=CURLE_OK) && config->showerror)
            fprintf(config->errors, "curl: (%d) %s\n", res, errorbuffer);
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
    #endif
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
    
    
          if(config->headerfile && !headerfilep && heads.stream)
            fclose(heads.stream);
    
          if(urlbuffer)
            free(urlbuffer);
          if (outfile && !strequal(outfile, "-") && outs.stream)
            fclose(outs.stream);
          if (config->infile)
            fclose(infd);
          if(headerfilep)
            fclose(headerfilep);
          
    
          if(url)
            free(url);
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
    
    
          if(outfile)
            free(outfile);
    
        if(outfiles)
          free(outfiles);
    
        if(urls)
          /* cleanup memory used for URL globbing patterns */
          glob_cleanup(urls);
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
    
    
        /* empty this urlnode struct */
        if(urlnode->url)
          free(urlnode->url);
        if(urlnode->outfile)
          free(urlnode->outfile);
    
        /* move on to the next URL */
        nextnode=urlnode->next;
        free(urlnode); /* free the node */
        urlnode = nextnode;
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
    
    
      } /* while-loop through all URLs */
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
    
    
      if(allocuseragent)
    
        free(config->useragent);
    
      /* cleanup the curl handle! */
      curl_easy_cleanup(curl);
    
    
      if((config->errors != stderr) &&
         (config->errors != stdout))
        /* it wasn't directed to stdout or stderr so close the file! */
        fclose(config->errors);
    
    
      struct Configurable config;
    
      memset(&config, 0, sizeof(struct Configurable));
      
    
      res = operate(&config, argc, argv);
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
    
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
    #ifdef	VMS
      return (vms_cond[res]|vms_show);
    #else
    
      return res;
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
    #endif
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
    }
    
    
    static char *my_get_line(FILE *fp)
    {
       char buf[4096];
       char *nl = NULL;
       char *retval = NULL;
    
       do
       {
          if (NULL == fgets(buf, sizeof(buf), fp))
             break;
          if (NULL == retval)
             retval = strdup(buf);
          else
          {
             if (NULL == (retval = realloc(retval,
                                           strlen(retval) + strlen(buf) + 1)))
                break;
             strcat(retval, buf);
          }
       }
       while (NULL == (nl = strchr(retval, '\n')));
    
       if (NULL != nl)
         *nl = '\0';
    
       return retval;
    }