Re: Overview of the wget source code (command line options)

2007-07-24 Thread Micah Cowan
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Tony Lewis wrote:
> In addition to whatever Josh and Micah told you, let me add the
> information that follows. More than once I have had to relearn how wget
> deals with command line options. The last time I did so, I created the
> HOWTO that appears below (comments about this information from those in
> the know on this list are welcome). I’m happy to collect any other
> topics that people want to submit and add them to the file. Perhaps
> Micah will even be willing to add it to the repository. :-)

Not a bad idea, for the short term.

For the long term, of course, I'd rather reorganize the code so that a
HOWTO is unnecessary for understanding it. :)

But. since this isn't likely to happen until at least some time after
1.13, as we have just scads of other things to deal with, putting it in
the repo, and probably the tarball distributions as well, is probably a
good idea.

- --
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGpj0R7M8hyUobTrERCLWhAJ46NtHfMKNjRdJBCfv7Bhfu5MIIiACgi64L
I9z5ZG/TSiI7Aaq5yU1d0Ok=
=uJMM
-END PGP SIGNATURE-


RE: Overview of the wget source code (command line options)

2007-07-24 Thread Tony Lewis
Himanshu Gupta wrote:

 

> Thanks Josh and Micah for your inputs.

 

In addition to whatever Josh and Micah told you, let me add the information
that follows. More than once I have had to relearn how wget deals with
command line options. The last time I did so, I created the HOWTO that
appears below (comments about this information from those in the know on
this list are welcome). I'm happy to collect any other topics that people
want to submit and add them to the file. Perhaps Micah will even be willing
to add it to the repository. :-)

 

By the way, if your mail reader throws away line breaks, you will want to
restore them. --Tony

 

To find out what a command line option does:

  Look in src/main.c in the option_data array for the string to corresponds
to

  the command line option; the entries are of the form:

  { "option", 'O', TYPE, "data", argtype },

 

  where you're searching for "option".

 

  If TYPE is OPT_BOOLEAN or OPT_VALUE:

Note the value of "data". Then look at init.c at the commands array for

an entry that starts with the same data. These lines are of the form:

{ "data", &opt.variable, cmd_TYPE },

 

The corresponding line will tell you what variable gets set when that
option

is selected. Now use grep or some other search tool to find out where
the

variable is referenced.

 

For example, the --accept option sets the value of opt.accepts, which is

referenced in ftp.c and utils.c

 

  If the TYPE is anything else:

Look to see how main.c handles that TYPE.

 

For example, OPT__APPEND_OUTPUT sets the option named "logfile" and then

sets the variable append_to_log to true. Searching for append_to_log

shows that it is only used in main.c. Checking init.c (as described
above)

for the option "logfile" shows that it sets the value of opt.lfilename,

which is referenced in mswindows.c, progress.c, and utils.c.

 




 

To add a new command line option:

  The simplest approach is to find an existing option that is close to what
you

  want to accomplish and mirror it. You will need to edit the following
files

  as described.

 

  src/main.c

Add a line to the option_data array in the following format:

  { "option", 'O', TYPE, "data", argtype },

 

where:

  option   is the long name to be accepted from the command line

  Ois the short name (one character) to be accepted from the

   command or '' if there is no short name; the short name

   must only be assigned to one option. Also, there are very

   few short names available and the maintainers are not

   inclined to give them out unless the option is likely to

   be used frequently.

  TYPE is one of the following standard options:

 OPT_VALUEon the command line, option must be

  followed by a value that will be stored

  ?somewhere?

 OPT_BOOLEAN  option is a boolean value that may appear

  on the command line as --option for true

  or --no-option for false

 OPT_FUNCALL  an internal function will be invoked if the

  option is selected on the command line

   Note: If one of these choices won't work for your option

   you can add a new value of the OPT__XXX to the enum list

   and add special code to handle it in src/main.c.

  data For OPT_VALUE and OPT_BOOLEAN, the "name" assigned to the

   option in the commands array defined in src/init.c (see

   below). For OPT_FUNCALL, a pointer to the function to be

   invoked.

  argtype  For OPT_VALUE and OPT_BOOLEAN, use -1. For OPT_FUNCALL use

   no_argument.

 

NOTE: The options *must* appear in alphabetical order because a Boolean

search is used for the list.

 

  src/main.c

Add the help string to function print_help as follows:

N_("\

  -O,  --optiondoes something nifty.\n"),

 

If the short name is '', put spaces in place of "-O,".

 

Select a reasonable place to add the text into the help output in one

of the existing groups of options: Startup, Logging and input file,

Download, Directories, HTTP options, HTTPS (SSL/TLS) options,

FTP options, Recursive download, or Recursive accept/reject.

 

  src/options.h

Define the variable to receive the value of the option in the options

structure.

 

  src/init.c

Add a line to the commands array in the following format:

  { "data", &opt.variable, cmd_TYPE },

 

where:

  data  matches the "data" string you entered above in the

options_data array in src/main.c

  variable  is the

Re: Overview of the wget source code

2007-07-24 Thread Himanshu Gupta
Thanks Josh and Micah for your inputs.

Btw When I said classes I just meant the C files :). Anyway I understand its 
wrong to call them classes. But being a java programmer I'm more into habit of 
talking about classes.

As you guys pointed out, I've started reading the code itself. I'm starting 
with http.c, Let's see how it goes.

Thanks
Himanshu

   
-
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, 
photos & more. 

Re: Overview of the wget source code

2007-07-23 Thread Micah Cowan
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Himanshu Gupta wrote:
> Hi,

Hi!

> Can somebody please point me to a document, which could provide me an
> overview of the classes in source code. I've downloaded the code and
> have no idea of how to go about reading the code.
> 
> I warmly welcome any suggestions on "how to understand the wget source
> code?" or any document, tutorial.

Unfortunately, there isn't one; and isn't likely to be one in the near
future especially since a lot of the code is likely to be reworked
before too terribly long.

The best thing to do is just to read it, and follow up the parts you
don't understand.

BTW, there aren't any "classes", which may be part of your confusion: C
has no such concept; the closest is C "structs" (which in C++ define
classes). While some of the code is at least vaguely object-oriented in
style, I don't really think you could apply that term to Wget's source
in general.

However, the source files are fairly clearly named, and most (all?)
functions have a brief description associated with them, as do the
source files. For example, http.c contains the HTTP protocol-related
code, recur.c manages recursive fetching, html-parse.c handles HTML
parsing, etc.

- --
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGpNDH7M8hyUobTrERCFMvAJ9tiFY2JUWwyllORzYLtTn3Mja3MgCfb1Xv
doQQczsoQofB6hmYNt1gRCY=
=QMU3
-END PGP SIGNATURE-


Overview of the wget source code

2007-07-23 Thread Himanshu Gupta
Hi,

Can somebody please point me to a document, which could provide me an overview 
of the classes in source code. I've downloaded the code and have no idea of how 
to go about reading the code. 

I warmly welcome any suggestions on "how to understand the wget source code?" 
or any document, tutorial.

Thanks 
Himanshu
 
   
-
Got a little couch potato? 
Check out fun summer activities for kids.