|
| |||||||||||||
#include "mit-copyright.h"#include "port.h"#include "variables.h"#include "error.h"#include "main.h"Go to the source code of this file.
Data Structures | |
| struct | standard_port_info |
Defines | |
| #define | DEFAULT_OK 0 |
| #define | DEFAULT_NOTOK 1 |
| #define | DISABLED 2 |
| #define | INPUT_DESC 0 |
| #define | OUTPUT_DESC 1 |
| #define | FILTER 2 |
| #define | OUTPUT_PROC 3 |
Functions | |
| string | tty_filter () |
| int | tty_filter_init () |
| void | usage () |
| char * | plain_driver (string input) |
| char * | tty_driver (string input) |
| string | noop_filter (string input) |
| string | plain_filter (string input) |
| string | fancy_filter (string input) |
| void | init_standard_ports (int *pargc, char **argv) |
|
|
Definition at line 109 of file standard_ports.c. |
|
|
Definition at line 108 of file standard_ports.c. |
|
|
Definition at line 110 of file standard_ports.c. |
|
|
Definition at line 116 of file standard_ports.c. Referenced by init_standard_ports(). |
|
|
Definition at line 114 of file standard_ports.c. Referenced by init_standard_ports(). |
|
|
Definition at line 115 of file standard_ports.c. Referenced by init_standard_ports(). |
|
|
Definition at line 117 of file standard_ports.c. Referenced by init_standard_ports(). |
|
|
Definition at line 91 of file standard_ports.c. References tty_filter(). 00093 {
00094 return (tty_filter(input, 1));
00095 }
|
|
||||||||||||
|
Definition at line 184 of file standard_ports.c. References create_port_from_files(), create_port_from_filter(), create_port_from_output_proc(), ERROR2, FILTER, INPUT_DESC, OUTPUT_DESC, OUTPUT_PROC, progname, string, string_Eq, usage(), and var_set_variable(). 00187 {
00188 struct standard_port_info *p;
00189 string first_working_port = "";
00190 string default_port = "";
00191 char **new, **current;
00192 int fallback = 0;
00193
00194 /*
00195 * Process argument list handling "-disable <port>" and
00196 * "-default <output port>" arguments, as well as "-ttymode"
00197 */
00198 for (new = current = argv + 1; *current; current++) {
00199 if (string_Eq((string) * current, "-disable")) {
00200 current++;
00201 *pargc -= 2;
00202 if (!*current)
00203 usage();
00204 if ((p = get_standard_port_info((string) * current)))
00205 p->port_setup_status = DISABLED;
00206 }
00207 else if (string_Eq((string) * current, "-default")) {
00208 current++;
00209 *pargc -= 2;
00210 if (!*current)
00211 usage();
00212 default_port = (string) * current;
00213 if ((p = get_standard_port_info((string) * current)))
00214 p->port_setup_status = DEFAULT_OK;
00215 }
00216 else if (string_Eq((string) * current, "-ttymode")) {
00217 default_port = (string) "tty";
00218 (*pargc)--;
00219 if ((p = get_standard_port_info(default_port))) {
00220 p->port_setup_status = DEFAULT_OK;
00221 if ((p = get_standard_port_info((string) "X")))
00222 p->port_setup_status = DISABLED;
00223 }
00224 }
00225 else
00226 *(new++) = *current;
00227 }
00228 *new = *current;
00229
00230 /*
00231 * Initialize all non-disabled ports. If a port reports an error,
00232 * disable that port. Set default_port if not already set
00233 * by the -default argument to the first non-disabled port.
00234 */
00235 for (p = standard_port_info_table; p->port_name; p++) {
00236 if (p->port_setup_status == DISABLED)
00237 continue;
00238
00239 if (p->port_init && (*(p->port_init)) (p->port_name,
00240 *first_working_port,
00241 pargc, argv)) {
00242 p->port_setup_status = DISABLED;
00243 continue;
00244 }
00245
00246 if (fallback == 1) {
00247 /*
00248 * we are doing fallback, make DEFAULT_NOTOK ports
00249 * OK
00250 */
00251 p->port_setup_status = DEFAULT_OK;
00252 }
00253 if (!*first_working_port)
00254 first_working_port = p->port_name;
00255 switch (p->type) {
00256 case INPUT_DESC:
00257 create_port_from_files(p->port_name, fdopen(p->setup_arg, "r"), 0);
00258 break;
00259
00260 case OUTPUT_DESC:
00261 create_port_from_files(p->port_name, 0, fdopen(p->setup_arg, "w"));
00262 break;
00263
00264 case FILTER:
00265 create_port_from_filter(p->port_name, p->function);
00266 break;
00267
00268 case OUTPUT_PROC:
00269 create_port_from_output_proc(p->port_name, p->function);
00270 break;
00271 }
00272 }
00273
00274 if (!default_port[0]) {
00275 /* no default port has been set */
00276 for (p = get_standard_port_info(first_working_port); p->port_name; p++)
00277 if ((p->port_setup_status == DEFAULT_OK))
00278 break;
00279 if (p->port_name)
00280 var_set_variable("output_driver", p->port_name);
00281 else { /* no suitable default has been found */
00282 if (fallback == -1) /* complain, since
00283 * indeterminate */
00284 ERROR2(
00285 "To receive Jabbergrams, (type `%s -ttymode').\n",
00286 progname);
00287 exit(1);
00288 }
00289 }
00290 else
00291 var_set_variable("output_driver", default_port);
00292
00293 }
|
|
|
Definition at line 69 of file standard_ports.c. 00071 {
00072 return (input);
00073 }
|
|
|
Definition at line 37 of file standard_ports.c. References string, and tty_filter(). 00039 {
00040 string processed_input = tty_filter(input, 0);
00041
00042 fputs(processed_input, stdout);
00043 fflush(stdout);
00044 free(processed_input);
00045 return (NULL);
00046 }
|
|
|
Definition at line 80 of file standard_ports.c. References tty_filter(). 00082 {
00083 return (tty_filter(input, 0));
00084 }
|
|
|
Definition at line 53 of file standard_ports.c. References string, and tty_filter(). 00055 {
00056 string processed_input = tty_filter(input, 1);
00057
00058 fputs(processed_input, stdout);
00059 fflush(stdout);
00060 free(processed_input);
00061 return (NULL);
00062 }
|
|
|
Referenced by fancy_filter(), plain_driver(), plain_filter(), and tty_driver(). |
|
|
|
|
|
Definition at line 28 of file jctl.c. References whoami. 00029 {
00030 fprintf(stderr, "Usage: %s %s[-h] command <args...>\n%s\
00031 -h Display help\n\
00032 \n\
00033 Commands:\n\
00034 help Display help\n\
00035 reread Reread description file (.jwgc.desc)\n\
00036 subscribe <jid> Subscribe to <jid>'s presence\n\
00037 unsubscribe <jid> Unsubscribe from <jid>'s presence\n\
00038 nickname <jid> <nick> Sets a nickname <nick> on <jid>\n\
00039 group <jid> <group> Sets a group <group> on <jid>\n\
00040 set <var> <setting> Set variable <var> to <setting>\n\
00041 show <var> Show variable setting of <var>\n\
00042 shutdown Log off of jabber server and shut down jwgc\n\
00043 join <chatroom jid> Join a jabber groupchat room\n\
00044 leave <chatroom jid> Leave a jabber groupchat room\n\
00045 register <jid> Register with agent <jid>\n\
00046 search <jid> Search with agent <jid>\n%s\
00047 \n\
00048 <nick> in nickname and <group> in group can be left blank to unset a\n\
00049 nickname or group, respectively.\n\
00050 ",
00051 whoami,
00052 #ifdef NODEBUG
00053 "",
00054 "",
00055 ""
00056 #else
00057 "[-d <flags>] ",
00058 " -d Enable/Disable debugging (leave <flags> blank for usage)\n",
00059 " debug <debug flags> Modify current debugging flags\n"
00060 #endif /* NODEBUG */
00061 );
00062
00063 exit(1);
00064 }
|
| Last updated at Tue Dec 18 21:07:42 PST 2007. | This site and project hosted by... |