Commit 260b0f4d authored by Yang Tse's avatar Yang Tse
Browse files

curl tool: create tool_myfunc.[ch] which later on will hold my_* functions

Additionally function my_useragent() now provides default User-Agent string
parent f50d4647
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ SOURCEPATH ../../../src
SOURCE \
    main.c hugehelp.c urlglob.c writeout.c writeenv.c \
    getpass.c homedir.c curlutil.c os-specific.c xattr.c \
    tool_cfgable.c tool_convert.c tool_mfiles.c
    tool_cfgable.c tool_convert.c tool_mfiles.c tool_myfunc.c

SOURCEPATH  ../../../lib
SOURCE \
+3 −2
Original line number Diff line number Diff line
@@ -16,12 +16,13 @@ CURLX_ONES = $(top_srcdir)/lib/strtoofft.c \

CURL_CFILES = main.c hugehelp.c urlglob.c writeout.c writeenv.c \
	getpass.c homedir.c curlutil.c os-specific.c xattr.c \
	tool_cfgable.c tool_convert.c tool_mfiles.c
	tool_cfgable.c tool_convert.c tool_mfiles.c tool_myfunc.c

CURL_HFILES = hugehelp.h setup.h config-win32.h config-mac.h \
	config-riscos.h urlglob.h version.h os-specific.h \
	writeout.h writeenv.h getpass.h homedir.h curlutil.h \
	xattr.h tool_cfgable.h tool_convert.h tool_mfiles.h
	xattr.h tool_cfgable.h tool_convert.h tool_mfiles.h \
	tool_myfunc.h

curl_SOURCES = $(CURL_CFILES) $(CURLX_ONES) $(CURL_HFILES)
+6 −0
Original line number Diff line number Diff line
@@ -145,6 +145,7 @@ RELEASE_OBJS= \
	tool_cfgabler.obj \
	tool_convertr.obj \
	tool_mfilesr.obj \
	tool_myfuncr.obj \
	urlglobr.obj \
	writeoutr.obj \
	xattrr.obj \
@@ -163,6 +164,7 @@ DEBUG_OBJS= \
	tool_cfgabled.obj \
	tool_convertd.obj \
	tool_mfilesd.obj \
	tool_myfuncd.obj \
	urlglobd.obj \
	writeoutd.obj \
	xattrd.obj \
@@ -314,6 +316,8 @@ tool_convertr.obj: tool_convert.c
	$(CCR) $(CFLAGS) /Fo"$@" tool_convert.c
tool_mfilesr.obj: tool_mfiles.c
	$(CCR) $(CFLAGS) /Fo"$@" tool_mfiles.c
tool_myfuncr.obj: tool_myfunc.c
	$(CCR) $(CFLAGS) /Fo"$@" tool_myfunc.c
xattrr.obj: xattr.c
	$(CCR) $(CFLAGS) /Fo"$@" xattr.c
mainr.obj: main.c
@@ -348,6 +352,8 @@ tool_convertd.obj: tool_convert.c
	$(CCD) $(CFLAGS) /Fo"$@" tool_convert.c
tool_mfilesd.obj: tool_mfiles.c
	$(CCD) $(CFLAGS) /Fo"$@" tool_mfiles.c
tool_myfuncd.obj: tool_myfunc.c
	$(CCD) $(CFLAGS) /Fo"$@" tool_myfunc.c
xattrd.obj: xattr.c
	$(CCD) $(CFLAGS) /Fo"$@" xattr.c
maind.obj: main.c
+8 −13
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@
#include "tool_convert.h"
#include "tool_mfiles.h"
#include "tool_cfgable.h"
#include "tool_myfunc.h"
#ifdef USE_MANUAL
#  include "hugehelp.h"
#endif
@@ -4132,7 +4133,6 @@ static int
operate(struct Configurable *config, int argc, argv_item_t argv[])
{
  char errorbuffer[CURL_ERROR_SIZE];
  char useragent[256]; /* buah, we don't want a larger default user agent */
  struct ProgressData progressbar;
  struct getout *urlnode;
  struct getout *nextnode;
@@ -4150,8 +4150,6 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
  curl_off_t uploadfilesize; /* -1 means unknown */
  bool stillflags=TRUE;

  bool allocuseragent=FALSE;

  char *httpgetfields=NULL;

  CURL *curl;
@@ -4281,14 +4279,14 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
    helpf(config->errors, "no URL specified!\n");
    return CURLE_FAILED_INIT;
  }
  if(NULL == config->useragent) {
    /* set non-zero default values: */
    snprintf(useragent, sizeof(useragent),
             CURL_NAME "/" CURL_VERSION " (" OS ") " "%s", curl_version());
    config->useragent= useragent;

  if(!config->useragent)
    config->useragent = my_useragent();
  if(!config->useragent) {
    clean_getout(config);
    res = CURLE_OUT_OF_MEMORY;
    goto quit_curl;
  }
  else
    allocuseragent = TRUE;

  /* On WIN32 we can't set the path to curl-ca-bundle.crt
   * at compile time. So we look here for the file in two ways:
@@ -5393,9 +5391,6 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
  if(heads.stream && (heads.stream != stdout))
    fclose(heads.stream);

  if(allocuseragent)
    Curl_safefree(config->useragent);

  if(config->trace_fopened && config->trace_stream)
    fclose(config->trace_stream);

+2 −3
Original line number Diff line number Diff line
@@ -38,9 +38,7 @@ void free_config_fields(struct Configurable *config)

  Curl_safefree(config->random_file);
  Curl_safefree(config->egd_file);

  /* config->useragent not handled */

  Curl_safefree(config->useragent);
  Curl_safefree(config->cookie);
  Curl_safefree(config->cookiejar);
  Curl_safefree(config->cookiefile);
@@ -123,3 +121,4 @@ void free_config_fields(struct Configurable *config)
  /* config->outs not handled */

}
Loading