2 wmget - A background download manager as a Window Maker dock app
3 Copyright (c) 2001-2003 Aaron Trickey <aaron@amtrickey.net>
5 Permission is hereby granted, free of charge, to any person
6 obtaining a copy of this software and associated documentation files
7 (the "Software"), to deal in the Software without restriction,
8 including without limitation the rights to use, copy, modify, merge,
9 publish, distribute, sublicense, and/or sell copies of the Software,
10 and to permit persons to whom the Software is furnished to do so,
11 subject to the following conditions:
13 The above copyright notice and this permission notice shall be
14 included in all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 ********************************************************************
25 wmget.c - main() and a few common functions
27 This file contains the main() for wmget; it simply checks for the
28 presence of ``dock'' as the first argument and invokes server(),
29 request(), cancel(), or list() as appropriate. Also found here are
30 a few global utilities.
40 #include <sys/types.h>
45 void debug_dump_job (Job
*job
)
47 if (output_level () < OL_DEBUG
)
57 "continue_from=%d\n\n",
59 job
->status
, job
->progress
, job
->stop_request
,
60 job
->prog_max
, job
->options
.display
, job
->source_url
,
61 job
->options
.save_to
, job
->options
.continue_from
);
65 const char *home_directory (void)
67 static char *home_directory
= 0;
71 return home_directory
;
73 home_directory
= getenv ("HOME");
75 if (!home_directory
) {
76 pwent
= getpwuid (geteuid ());
77 home_directory
= strdup (pwent
->pw_dir
);
80 return home_directory
;
84 int main (int argc
, char **argv
)
87 int (*function
) (int, char **) = &request
;
94 /* Cheat, because we don't invoke getopt until we know what mode
97 for (arg
= argv
; *arg
; ++arg
) {
98 if (strcmp (*arg
, "dock") == 0) {
101 } else if (strcmp (*arg
, "cancel") == 0) {
104 } else if (strcmp (*arg
, "list") == 0) {
107 } else if (strcmp (*arg
, "-v") == 0
108 || strcmp (*arg
, "--version") == 0) {
109 puts (WMGET_VERSION_BANNER
);
110 puts (WMGET_COPYRIGHT
);
113 } else if (strcmp (*arg
, "-h") == 0
114 || strcmp (*arg
, "--help") == 0) {
120 return function (argc
, argv
);