1 /*
2  * commands.h --
3  *
4  * Yet Another FTP Client
5  * Copyright (C) 1998-2001, Martin Hedenfalk <mhe@stacken.kth.se>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version. See COPYING for more details.
11  */
12 
13 #ifndef _commands_h_included
14 #define _commands_h_included
15 
16 #include <config.h>
17 #include "args.h"
18 
19 #define DEFCMD(CMDNAME)    void cmd_ ## CMDNAME (int argc, char **argv)
20 
21 #define maxargs(n) \
22   if(argc > n+1) { \
23     char *fooargs; \
24     fooargs = args_cat(argc, argv, n+1); \
25     fprintf(stderr, _("unexpected arguments -- '%s', try '%s --help'" \
26 					  " for more information\n"), fooargs, argv[0]); \
27     free(fooargs); \
28     return; \
29   }
30 
31 #define maxargs_nohelp(n) \
32   if(argc > n+1) { \
33     char *fooargs; \
34     fooargs = args_cat(argc, argv, n+1); \
35     fprintf(stderr, _("unexpected arguments -- '%s'\n"), fooargs); \
36     free(fooargs); \
37     return; \
38   }
39 
40 #define minargs(n) \
41   if(argc <= n) { \
42     fprintf(stderr, _("missing argument, try '%s --help'" \
43 					  " for more information\n"), argv[0]); \
44     return; \
45   }
46 
47 #define minargs_nohelp(n) \
48   if(argc <= n) { \
49     fprintf(stderr, _("missing argument\n")); \
50     return; \
51   }
52 
53 #define need_connected() \
54   if(!ftp_connected()) { \
55     fprintf(stderr, _("Not connected. Try 'open --help'" \
56 					  " for more information.\n")); \
57     return; \
58   }
59 
60 #define need_loggedin() \
61   if(!ftp_loggedin()) { \
62     fprintf(stderr, _("Not logged in. Try 'user --help'" \
63 					  " for more information.\n")); \
64     return; \
65   }
66 
67 typedef enum {
68 	cpNone, cpRemoteFile, cpRemoteDir, cpLocalFile,
69 	cpCommand, cpAlias, cpVariable, cpHostname, cpBookmark,
70 	cpFtpList, cpTaglist, cpLocalTaglist, cpUnset
71 } cpl_t;
72 
73 /* in completion.c */
74 extern cpl_t force_completion_type;
75 
76 DEFCMD(cachelist);
77 DEFCMD(status);
78 DEFCMD(quit);
79 DEFCMD(exit);
80 DEFCMD(filetime);
81 DEFCMD(source);
82 DEFCMD(system);
83 DEFCMD(switch);
84 
85 /* in bookmark.c */
86 DEFCMD(bookmark);
87 
88 /* cacheops.c */
89 DEFCMD(cache);
90 
91 /* login.c */
92 DEFCMD(open);
93 DEFCMD(reopen);
94 DEFCMD(close);
95 DEFCMD(user);
96 
97 DEFCMD(cdup);
98 DEFCMD(cd);
99 DEFCMD(pwd);
100 DEFCMD(url);
101 DEFCMD(mkdir);
102 DEFCMD(rmdir);
103 DEFCMD(mv);
104 DEFCMD(chmod);
105 DEFCMD(cat);
106 DEFCMD(page);
107 DEFCMD(zcat);
108 DEFCMD(zpage);
109 
110 DEFCMD(quote);
111 DEFCMD(site);
112 DEFCMD(rhelp);
113 DEFCMD(rstatus);
114 DEFCMD(sstatus);
115 DEFCMD(nop);
116 DEFCMD(idle);
117 
118 /* rm.c */
119 DEFCMD(rm);
120 
121 /* get.c */
122 DEFCMD(get);
123 
124 /* put.c */
125 DEFCMD(put);
126 
127 /* fxp.c */
128 DEFCMD(fxp);
129 
130 /* ls.c */
131 DEFCMD(ls);
132 DEFCMD(nlist);
133 DEFCMD(list);
134 
135 /* help.c */
136 DEFCMD(help);
137 DEFCMD(version);
138 DEFCMD(warranty);
139 DEFCMD(copyright);
140 
141 /* set.c */
142 DEFCMD(set);
143 
144 /* alias.c */
145 DEFCMD(alias);
146 DEFCMD(unalias);
147 
148 /* local.c */
149 DEFCMD(lpwd);
150 DEFCMD(lcd);
151 DEFCMD(shell);
152 
153 #ifdef SECFTP
154 /* in ../lib/security.c */
155 DEFCMD(prot);
156 #endif
157 
158 /* tag.c */
159 DEFCMD(tag);
160 DEFCMD(untag);
161 DEFCMD(taglist);
162 DEFCMD(taginfo);
163 
164 /* ltag.c */
165 DEFCMD(ltag);
166 DEFCMD(luntag);
167 DEFCMD(ltaglist);
168 DEFCMD(ltaginfo);
169 
170 #define OPT_HELP(help) { opt_help(argc, argv, _(help), NULL, NULL); \
171  if(optind == -1) return; }
172 
173 #define OPT_HELP_NEW(descr, usage, help) \
174   { \
175     opt_help(argc, argv, descr, usage, help); \
176     if (optind == -1) return; \
177   }
178 
179 void show_help(const char* descr, const char* usage, const char* help);
180 void opt_help(int argc, char **argv, const char* descr, const char* usage, const char* help);
181 void expand_alias_parameters(args_t **args, args_t *alias_args);
182 
183 #endif
184