comparison src/uicommon/gftpui.c @ 374:d207b8241e96

2003-1-21 Brian Masney <masneyb@gftp.org> * lib/config_file.c lib/gftp.h - set the character string arguments to const for the following functions: gftp_lookup_global_option(), gftp_lookup_request_option(), gftp_lookup_bookmark_option(), gftp_set_global_option(), gftp_set_request_option(), gftp_set_bookmark_option() * lib/misc.c lib/gftp.h - set the character string arguments to const for the function gftp_match_filespec() * src/gtk/gftp-gtk.c src/gtk/menu-items.c src/uicommon/gftpui.c - moved more UI independant parts to the uicommon directory. Moved some GUI specific functionality into gftp-gtk.c * src/text/gftp-text.c src/gtk/gftp-gtk.c src/uicommon/gftpui.c - pass the local/remote uidata/request structures to process_command(). Removed old function gftpui_common_init(). Added new gftpui_common_init() that sets up common functionality for a port. * src/gtk/gtkui.c src/gtk/gtkui_transfer.c - moved gftpui_add_file_to_transfer() to gtkui_transfer.c * src/gtk/gtkui_transfer.c - cleaned up these functions some and made them more modular * src/uicommon/gftpui.c src/uicommon/gftpui.h - for all of the command line functions, make the command argument a constant
author masneyb
date Wed, 21 Jan 2004 23:35:40 +0000
parents af541d789f4c
children 14da115b149b
comparison
equal deleted inserted replaced
373:642bc7a87f05 374:d207b8241e96
21 static const char cvsid[] = "$Id$"; 21 static const char cvsid[] = "$Id$";
22 22
23 sigjmp_buf gftpui_common_jmp_environment; 23 sigjmp_buf gftpui_common_jmp_environment;
24 volatile int gftpui_common_use_jmp_environment = 0; 24 volatile int gftpui_common_use_jmp_environment = 0;
25 25
26 static void *gftpui_common_local_uidata, *gftpui_common_remote_uidata;
27 static gftp_request * gftpui_common_local_request,
28 * gftpui_common_remote_request;
29 GStaticMutex gftpui_common_transfer_mutex = G_STATIC_MUTEX_INIT; 26 GStaticMutex gftpui_common_transfer_mutex = G_STATIC_MUTEX_INIT;
30 27 volatile sig_atomic_t gftpui_common_child_process_done = 0;
31 28 gftp_logging_func gftpui_common_logfunc;
32 static gftp_logging_func
33 _gftpui_common_log (gftp_request * request)
34 {
35 if (request == NULL)
36 return (gftpui_common_local_request->logging_function);
37 else
38 return (request->logging_function);
39 }
40 29
41 30
42 static void * 31 static void *
43 _gftpui_common_thread_callback (void * data) 32 _gftpui_common_thread_callback (void * data)
44 { 33 {
108 97
109 return (ret == 0); 98 return (ret == 0);
110 } 99 }
111 100
112 101
113 RETSIGTYPE 102 static RETSIGTYPE
114 gftpui_common_signal_handler (int signo) 103 gftpui_common_signal_handler (int signo)
115 { 104 {
116 signal (signo, gftpui_common_signal_handler); 105 signal (signo, gftpui_common_signal_handler);
117 106
118 if (gftpui_common_use_jmp_environment) 107 if (gftpui_common_use_jmp_environment)
120 else if (signo == SIGINT) 109 else if (signo == SIGINT)
121 exit (1); 110 exit (1);
122 } 111 }
123 112
124 113
114 static RETSIGTYPE
115 gftpui_common_sig_child (int signo)
116 {
117 gftpui_common_child_process_done = 1;
118 }
119
120
121 void
122 gftpui_common_init (int *argc, char ***argv, gftp_logging_func logfunc)
123 {
124 gftp_locale_init ();
125
126 signal (SIGCHLD, gftpui_common_sig_child);
127 signal (SIGPIPE, SIG_IGN);
128 signal (SIGALRM, gftpui_common_signal_handler);
129 signal (SIGINT, gftpui_common_signal_handler);
130
131 gftp_read_config_file (SHARE_DIR);
132 if (gftp_parse_command_line (argc, argv) != 0)
133 exit (0);
134
135 gftpui_common_logfunc = logfunc;
136 }
137
138
125 void 139 void
126 gftpui_common_about (gftp_logging_func logging_function, gpointer logdata) 140 gftpui_common_about (gftp_logging_func logging_function, gpointer logdata)
127 { 141 {
128 char *str; 142 char *str;
129 143
137 logging_function (gftp_logging_misc, logdata, "%s\n", str); 151 logging_function (gftp_logging_misc, logdata, "%s\n", str);
138 } 152 }
139 153
140 154
141 static int 155 static int
142 gftpui_common_cmd_about (void *uidata, gftp_request * request, char *command) 156 gftpui_common_cmd_about (void *uidata, gftp_request * request,
143 { 157 const char *command)
144 gftpui_common_about (_gftpui_common_log (request), 158 {
145 gftpui_common_local_request); 159 gftpui_common_about (gftpui_common_logfunc, NULL);
146 return (1); 160 return (1);
147 } 161 }
148 162
149 163
150 static int 164 static int
151 gftpui_common_cmd_ascii (void *uidata, gftp_request * request, char *command) 165 gftpui_common_cmd_ascii (void *uidata, gftp_request * request,
166 const char *command)
152 { 167 {
153 gftp_set_global_option ("ascii_transfers", GINT_TO_POINTER(1)); 168 gftp_set_global_option ("ascii_transfers", GINT_TO_POINTER(1));
154 return (1); 169 return (1);
155 } 170 }
156 171
157 172
158 static int 173 static int
159 gftpui_common_cmd_binary (void *uidata, gftp_request * request, char *command) 174 gftpui_common_cmd_binary (void *uidata, gftp_request * request,
175 const char *command)
160 { 176 {
161 gftp_set_global_option ("ascii_transfers", GINT_TO_POINTER(0)); 177 gftp_set_global_option ("ascii_transfers", GINT_TO_POINTER(0));
162 return (1); 178 return (1);
163 } 179 }
164 180
165 181
166 static int 182 static int
167 gftpui_common_cmd_chmod (void *uidata, gftp_request * request, char *command) 183 gftpui_common_cmd_chmod (void *uidata, gftp_request * request,
184 const char *command)
168 { 185 {
169 gftpui_callback_data * cdata; 186 gftpui_callback_data * cdata;
170 char *pos; 187 char *pos;
171 188
172 if (!GFTP_IS_CONNECTED (request)) 189 if (!GFTP_IS_CONNECTED (request))
188 else 205 else
189 { 206 {
190 cdata = g_malloc0 (sizeof (*cdata)); 207 cdata = g_malloc0 (sizeof (*cdata));
191 cdata->request = request; 208 cdata->request = request;
192 cdata->uidata = uidata; 209 cdata->uidata = uidata;
193 cdata->input_string = command; 210 cdata->input_string = (char *) command;
194 cdata->source_string = pos; 211 cdata->source_string = pos;
195 cdata->run_function = gftpui_common_run_chmod; 212 cdata->run_function = gftpui_common_run_chmod;
196 213
197 gftpui_common_run_callback_function (cdata); 214 gftpui_common_run_callback_function (cdata);
198 215
202 return (1); 219 return (1);
203 } 220 }
204 221
205 222
206 static int 223 static int
207 gftpui_common_cmd_rename (void *uidata, gftp_request * request, char *command) 224 gftpui_common_cmd_rename (void *uidata, gftp_request * request,
225 const char *command)
208 { 226 {
209 gftpui_callback_data * cdata; 227 gftpui_callback_data * cdata;
210 char *pos; 228 char *pos;
211 229
212 if (!GFTP_IS_CONNECTED (request)) 230 if (!GFTP_IS_CONNECTED (request))
227 else 245 else
228 { 246 {
229 cdata = g_malloc0 (sizeof (*cdata)); 247 cdata = g_malloc0 (sizeof (*cdata));
230 cdata->request = request; 248 cdata->request = request;
231 cdata->uidata = uidata; 249 cdata->uidata = uidata;
232 cdata->source_string = command; 250 cdata->source_string = (char *) command;
233 cdata->input_string = pos; 251 cdata->input_string = pos;
234 cdata->run_function = gftpui_common_run_rename; 252 cdata->run_function = gftpui_common_run_rename;
235 253
236 gftpui_common_run_callback_function (cdata); 254 gftpui_common_run_callback_function (cdata);
237 255
241 return (1); 259 return (1);
242 } 260 }
243 261
244 262
245 static int 263 static int
246 gftpui_common_cmd_delete (void *uidata, gftp_request * request, char *command) 264 gftpui_common_cmd_delete (void *uidata, gftp_request * request,
265 const char *command)
247 { 266 {
248 gftpui_callback_data * cdata; 267 gftpui_callback_data * cdata;
249 268
250 if (!GFTP_IS_CONNECTED (request)) 269 if (!GFTP_IS_CONNECTED (request))
251 { 270 {
261 else 280 else
262 { 281 {
263 cdata = g_malloc0 (sizeof (*cdata)); 282 cdata = g_malloc0 (sizeof (*cdata));
264 cdata->request = request; 283 cdata->request = request;
265 cdata->uidata = uidata; 284 cdata->uidata = uidata;
266 cdata->input_string = command; 285 cdata->input_string = (char *) command;
267 cdata->run_function = gftpui_common_run_delete; 286 cdata->run_function = gftpui_common_run_delete;
268 287
269 gftpui_common_run_callback_function (cdata); 288 gftpui_common_run_callback_function (cdata);
270 289
271 g_free (cdata); 290 g_free (cdata);
274 return (1); 293 return (1);
275 } 294 }
276 295
277 296
278 static int 297 static int
279 gftpui_common_cmd_rmdir (void *uidata, gftp_request * request, char *command) 298 gftpui_common_cmd_rmdir (void *uidata, gftp_request * request,
299 const char *command)
280 { 300 {
281 gftpui_callback_data * cdata; 301 gftpui_callback_data * cdata;
282 302
283 if (!GFTP_IS_CONNECTED (request)) 303 if (!GFTP_IS_CONNECTED (request))
284 { 304 {
294 else 314 else
295 { 315 {
296 cdata = g_malloc0 (sizeof (*cdata)); 316 cdata = g_malloc0 (sizeof (*cdata));
297 cdata->request = request; 317 cdata->request = request;
298 cdata->uidata = uidata; 318 cdata->uidata = uidata;
299 cdata->input_string = command; 319 cdata->input_string = (char *) command;
300 cdata->run_function = gftpui_common_run_rmdir; 320 cdata->run_function = gftpui_common_run_rmdir;
301 321
302 gftpui_common_run_callback_function (cdata); 322 gftpui_common_run_callback_function (cdata);
303 323
304 g_free (cdata); 324 g_free (cdata);
307 return (1); 327 return (1);
308 } 328 }
309 329
310 330
311 static int 331 static int
312 gftpui_common_cmd_site (void *uidata, gftp_request * request, char *command) 332 gftpui_common_cmd_site (void *uidata, gftp_request * request,
333 const char *command)
313 { 334 {
314 gftpui_callback_data * cdata; 335 gftpui_callback_data * cdata;
315 336
316 if (!GFTP_IS_CONNECTED (request)) 337 if (!GFTP_IS_CONNECTED (request))
317 { 338 {
327 else 348 else
328 { 349 {
329 cdata = g_malloc0 (sizeof (*cdata)); 350 cdata = g_malloc0 (sizeof (*cdata));
330 cdata->request = request; 351 cdata->request = request;
331 cdata->uidata = uidata; 352 cdata->uidata = uidata;
332 cdata->input_string = command; 353 cdata->input_string = (char *) command;
333 cdata->run_function = gftpui_common_run_site; 354 cdata->run_function = gftpui_common_run_site;
334 355
335 gftpui_common_run_callback_function (cdata); 356 gftpui_common_run_callback_function (cdata);
336 357
337 g_free (cdata); 358 g_free (cdata);
340 return (1); 361 return (1);
341 } 362 }
342 363
343 364
344 static int 365 static int
345 gftpui_common_cmd_mkdir (void *uidata, gftp_request * request, char *command) 366 gftpui_common_cmd_mkdir (void *uidata, gftp_request * request,
367 const char *command)
346 { 368 {
347 gftpui_callback_data * cdata; 369 gftpui_callback_data * cdata;
348 370
349 if (!GFTP_IS_CONNECTED (request)) 371 if (!GFTP_IS_CONNECTED (request))
350 { 372 {
360 else 382 else
361 { 383 {
362 cdata = g_malloc0 (sizeof (*cdata)); 384 cdata = g_malloc0 (sizeof (*cdata));
363 cdata->request = request; 385 cdata->request = request;
364 cdata->uidata = uidata; 386 cdata->uidata = uidata;
365 cdata->input_string = command; 387 cdata->input_string = (char *) command;
366 cdata->run_function = gftpui_common_run_mkdir; 388 cdata->run_function = gftpui_common_run_mkdir;
367 389
368 gftpui_common_run_callback_function (cdata); 390 gftpui_common_run_callback_function (cdata);
369 391
370 g_free (cdata); 392 g_free (cdata);
373 return (1); 395 return (1);
374 } 396 }
375 397
376 398
377 static int 399 static int
378 gftpui_common_cmd_chdir (void *uidata, gftp_request * request, char *command) 400 gftpui_common_cmd_chdir (void *uidata, gftp_request * request,
401 const char *command)
379 { 402 {
380 gftpui_callback_data * cdata; 403 gftpui_callback_data * cdata;
381 char *tempstr, *newdir = NULL; 404 char *tempstr, *newdir = NULL;
382 405
383 if (!GFTP_IS_CONNECTED (request)) 406 if (!GFTP_IS_CONNECTED (request))
412 } 435 }
413 436
414 cdata = g_malloc0 (sizeof (*cdata)); 437 cdata = g_malloc0 (sizeof (*cdata));
415 cdata->request = request; 438 cdata->request = request;
416 cdata->uidata = uidata; 439 cdata->uidata = uidata;
417 cdata->input_string = newdir != NULL ? newdir : command; 440 cdata->input_string = newdir != NULL ? newdir : (char *) command;
418 cdata->run_function = gftpui_common_run_chdir; 441 cdata->run_function = gftpui_common_run_chdir;
419 442
420 gftpui_common_run_callback_function (cdata); 443 gftpui_common_run_callback_function (cdata);
421 444
422 g_free (cdata); 445 g_free (cdata);
427 return (1); 450 return (1);
428 } 451 }
429 452
430 453
431 static int 454 static int
432 gftpui_common_cmd_close (void *uidata, gftp_request * request, char *command) 455 gftpui_common_cmd_close (void *uidata, gftp_request * request,
456 const char *command)
433 { 457 {
434 gftp_disconnect (request); 458 gftp_disconnect (request);
435 return (1); 459 return (1);
436 } 460 }
437 461
438 462
439 static int 463 static int
440 gftpui_common_cmd_pwd (void *uidata, gftp_request * request, char *command) 464 gftpui_common_cmd_pwd (void *uidata, gftp_request * request,
465 const char *command)
441 { 466 {
442 if (!GFTP_IS_CONNECTED (request)) 467 if (!GFTP_IS_CONNECTED (request))
443 { 468 {
444 request->logging_function (gftp_logging_error, request, 469 request->logging_function (gftp_logging_error, request,
445 _("Error: Not connected to a remote site\n")); 470 _("Error: Not connected to a remote site\n"));
452 return (1); 477 return (1);
453 } 478 }
454 479
455 480
456 static int 481 static int
457 gftpui_common_cmd_quit (void *uidata, gftp_request * request, char *command) 482 gftpui_common_cmd_quit (void *uidata, gftp_request * request,
483 const char *command)
458 { 484 {
459 gftp_shutdown(); 485 gftp_shutdown();
460 486
461 return (0); 487 return (0);
462 } 488 }
463 489
464 490
465 static int 491 static int
466 gftpui_common_cmd_clear (void *uidata, gftp_request * request, char *command) 492 gftpui_common_cmd_clear (void *uidata, gftp_request * request,
467 { 493 const char *command)
468 gftp_logging_func logfunc; 494 {
469
470 if (strcasecmp (command, "cache") == 0) 495 if (strcasecmp (command, "cache") == 0)
471 gftp_clear_cache_files (); 496 gftp_clear_cache_files ();
472 else 497 else
473 { 498 {
474 logfunc = _gftpui_common_log (request); 499 gftpui_common_logfunc (gftp_logging_error, request,
475 logfunc (gftp_logging_error, request, _("Invalid argument\n")); 500 _("Invalid argument\n"));
476 } 501 }
477 502
478 return (1); 503 return (1);
479 } 504 }
480 505
481 506
482 static int 507 static int
483 gftpui_common_clear_show_subhelp (char *topic) 508 gftpui_common_clear_show_subhelp (const char *topic)
484 { 509 {
485 gftp_logging_func logfunc;
486
487 logfunc = gftpui_common_local_request->logging_function;
488 if (strcmp (topic, "cache") == 0) 510 if (strcmp (topic, "cache") == 0)
489 { 511 {
490 logfunc (gftp_logging_misc, NULL, _("Clear the directory cache\n")); 512 gftpui_common_logfunc (gftp_logging_misc, NULL,
513 _("Clear the directory cache\n"));
491 return (1); 514 return (1);
492 } 515 }
493 516
494 return (0); 517 return (0);
495 } 518 }
496 519
497 520
498 static int 521 static int
499 gftpui_common_set_show_subhelp (char *topic) 522 gftpui_common_set_show_subhelp (const char *topic)
500 { 523 {
501 gftp_logging_func logfunc;
502 gftp_config_vars * cv; 524 gftp_config_vars * cv;
503 525
504 logfunc = gftpui_common_local_request->logging_function;
505 if ((cv = g_hash_table_lookup (gftp_global_options_htable, topic)) != NULL) 526 if ((cv = g_hash_table_lookup (gftp_global_options_htable, topic)) != NULL)
506 { 527 {
507 logfunc (gftp_logging_misc, NULL, "%s\n", cv->comment); 528 gftpui_common_logfunc (gftp_logging_misc, NULL, "%s\n", cv->comment);
508 return (1); 529 return (1);
509 } 530 }
510 531
511 return (0); 532 return (0);
512 } 533 }
513 534
514 535
515 static int 536 static int
516 gftpui_common_cmd_ls (void *uidata, gftp_request * request, char *command) 537 gftpui_common_cmd_ls (void *uidata, gftp_request * request,
538 const char *command)
517 { 539 {
518 char *startcolor, *endcolor, *tempstr; 540 char *startcolor, *endcolor, *tempstr;
519 gftpui_callback_data * cdata; 541 gftpui_callback_data * cdata;
520 GList * templist; 542 GList * templist;
521 gftp_file * fle; 543 gftp_file * fle;
528 } 550 }
529 551
530 cdata = g_malloc0 (sizeof (*cdata)); 552 cdata = g_malloc0 (sizeof (*cdata));
531 cdata->request = request; 553 cdata->request = request;
532 cdata->uidata = uidata; 554 cdata->uidata = uidata;
533 cdata->source_string = *command != '\0' ? command : NULL; 555 cdata->source_string = *command != '\0' ? (char *) command : NULL;
534 cdata->run_function = gftpui_common_run_ls; 556 cdata->run_function = gftpui_common_run_ls;
535 557
536 gftpui_common_run_callback_function (cdata); 558 gftpui_common_run_callback_function (cdata);
537 559
538 templist = cdata->files; 560 templist = cdata->files;
559 return (1); 581 return (1);
560 } 582 }
561 583
562 584
563 int 585 int
564 gftpui_common_cmd_open (void *uidata, gftp_request * request, char *command) 586 gftpui_common_cmd_open (void *uidata, gftp_request * request,
587 const char *command)
565 { 588 {
566 gftpui_callback_data * cdata; 589 gftpui_callback_data * cdata;
567 intptr_t retries; 590 intptr_t retries;
568 char *tempstr; 591 char *tempstr;
569 592
624 return (1); 647 return (1);
625 } 648 }
626 649
627 650
628 static int 651 static int
629 gftpui_common_cmd_set (void *uidata, gftp_request * request, char *command) 652 gftpui_common_cmd_set (void *uidata, gftp_request * request,
653 const char *command)
630 { 654 {
631 gftp_config_vars * cv, newcv; 655 gftp_config_vars * cv, newcv;
632 gftp_logging_func logfunc;
633 char *pos, *backpos; 656 char *pos, *backpos;
634 GList * templist; 657 GList * templist;
635 int i; 658 int i;
636 659
637 logfunc = _gftpui_common_log (request);
638
639 if (command == NULL || *command == '\0') 660 if (command == NULL || *command == '\0')
640 { 661 {
641 for (templist = gftp_options_list; 662 for (templist = gftp_options_list;
642 templist != NULL; 663 templist != NULL;
643 templist = templist->next) 664 templist = templist->next)
661 } 682 }
662 else 683 else
663 { 684 {
664 if ((pos = strchr (command, '=')) == NULL) 685 if ((pos = strchr (command, '=')) == NULL)
665 { 686 {
666 logfunc (gftp_logging_error, request, 687 gftpui_common_logfunc (gftp_logging_error, request,
667 _("usage: set [variable = value]\n")); 688 _("usage: set [variable = value]\n"));
668 return (1); 689 return (1);
669 } 690 }
670 *pos = '\0'; 691 *pos = '\0';
671 692
672 for (backpos = pos - 1; 693 for (backpos = pos - 1;
675 *backpos = '\0'; 696 *backpos = '\0';
676 for (++pos; *pos == ' ' || *pos == '\t'; pos++); 697 for (++pos; *pos == ' ' || *pos == '\t'; pos++);
677 698
678 if ((cv = g_hash_table_lookup (gftp_global_options_htable, command)) == NULL) 699 if ((cv = g_hash_table_lookup (gftp_global_options_htable, command)) == NULL)
679 { 700 {
680 logfunc (gftp_logging_error, request, 701 gftpui_common_logfunc (gftp_logging_error, request,
681 _("Error: Variable %s is not a valid configuration variable.\n"), command); 702 _("Error: Variable %s is not a valid configuration variable.\n"), command);
682 return (1); 703 return (1);
683 } 704 }
684 705
685 if (!(cv->ports_shown & GFTP_PORT_TEXT)) 706 if (!(cv->ports_shown & GFTP_PORT_TEXT))
686 { 707 {
687 logfunc (gftp_logging_error, request, 708 gftpui_common_logfunc (gftp_logging_error, request,
688 _("Error: Variable %s is not available in the text port of gFTP\n"), command); 709 _("Error: Variable %s is not available in the text port of gFTP\n"), command);
689 return (1); 710 return (1);
690 } 711 }
691 712
692 if (gftp_option_types[cv->otype].read_function != NULL) 713 if (gftp_option_types[cv->otype].read_function != NULL)
693 { 714 {
706 return (1); 727 return (1);
707 } 728 }
708 729
709 730
710 static int 731 static int
711 gftpui_common_cmd_help (void *uidata, gftp_request * request, char *command) 732 gftpui_common_cmd_help (void *uidata, gftp_request * request,
712 { 733 const char *command)
713 int i, j, ele, numrows, numcols = 6, handled, number_commands; 734 {
714 char *pos; 735 int i, j, ele, numrows, numcols = 6, handled, number_commands, cmdlen,
736 found;
737 const char *pos;
715 738
716 for (number_commands=0; 739 for (number_commands=0;
717 gftpui_common_commands[number_commands].command != NULL; 740 gftpui_common_commands[number_commands].command != NULL;
718 number_commands++); 741 number_commands++);
719 742
720 if (command != NULL && *command != '\0') 743 if (command != NULL && *command != '\0')
721 { 744 {
722 for (pos = command; *pos != ' ' && *pos != '\0'; pos++); 745 for (pos = command; *pos != ' ' && *pos != '\0'; pos++);
723 if (*pos == ' ') 746 cmdlen = pos - command;
724 {
725 *pos++ = '\0';
726 if (*pos == '\0')
727 pos = NULL;
728 }
729 else
730 pos = NULL;
731 747
732 for (i=0; gftpui_common_commands[i].command != NULL; i++) 748 for (i=0; gftpui_common_commands[i].command != NULL; i++)
733 { 749 {
734 if (strcmp (gftpui_common_commands[i].command, command) == 0) 750 if (strncmp (gftpui_common_commands[i].command, command, cmdlen) == 0)
735 break; 751 break;
736 } 752 }
737 753
738 if (gftpui_common_commands[i].cmd_description != NULL) 754 if (gftpui_common_commands[i].cmd_description != NULL)
739 { 755 {
740 if (pos != NULL && gftpui_common_commands[i].subhelp_func != NULL) 756 found = 1;
741 handled = gftpui_common_commands[i].subhelp_func (pos); 757
758 if (*pos != '\0' && *(pos + 1) != '\0' &&
759 gftpui_common_commands[i].subhelp_func != NULL)
760 handled = gftpui_common_commands[i].subhelp_func (pos + 1);
742 else 761 else
743 handled = 0; 762 handled = 0;
744 763
745 if (!handled) 764 if (!handled)
746 printf ("%s\n", _(gftpui_common_commands[i].cmd_description)); 765 printf ("%s\n", _(gftpui_common_commands[i].cmd_description));
747 } 766 }
748 else 767 else
749 *command = '\0'; 768 found = 0;
750 } 769 }
770 else
771 found = 0;
751 772
752 if (command == NULL || *command == '\0') 773 if (!found)
753 { 774 {
754 numrows = number_commands / numcols; 775 numrows = number_commands / numcols;
755 if (number_commands % numcols != 0) 776 if (number_commands % numcols != 0)
756 numrows++; 777 numrows++;
757 778
851 {NULL, 0, NULL, gftpui_common_request_none, 872 {NULL, 0, NULL, gftpui_common_request_none,
852 NULL, NULL}}; 873 NULL, NULL}};
853 874
854 875
855 int 876 int
856 gftpui_common_init (void *locui, gftp_request * locreq, 877 gftpui_common_process_command (void *locui, gftp_request * locreq,
857 void *remui, gftp_request * remreq) 878 void *remui, gftp_request * remreq,
858 { 879 const char *command)
859 gftpui_common_local_uidata = locui; 880 {
860 gftpui_common_local_request = locreq; 881 gftp_request * request;
861
862 gftpui_common_remote_uidata = remui;
863 gftpui_common_remote_request = remreq;
864
865 return (0);
866 }
867
868
869 int
870 gftpui_common_process_command (const char *command)
871 {
872 const char *stpos; 882 const char *stpos;
873 char *pos, *newstr; 883 char *pos, *newstr;
874 gftp_request * request;
875 size_t cmdlen; 884 size_t cmdlen;
876 void *uidata; 885 void *uidata;
877 int ret, i; 886 int ret, i;
878 size_t len; 887 size_t len;
879 888
914 if (pos != NULL) 923 if (pos != NULL)
915 pos++; 924 pos++;
916 else 925 else
917 pos = ""; 926 pos = "";
918 927
928 if (gftpui_common_commands[i].reqtype == gftpui_common_request_local)
929 {
930 request = locreq;
931 uidata = locui;
932 }
933 else if (gftpui_common_commands[i].reqtype == gftpui_common_request_remote)
934 {
935 request = remreq;
936 uidata = remui;
937 }
938 else
939 {
940 request = NULL;
941 uidata = NULL;
942 }
943
919 if (gftpui_common_commands[i].command != NULL) 944 if (gftpui_common_commands[i].command != NULL)
920 { 945 {
921 if (gftpui_common_commands[i].reqtype == gftpui_common_request_local)
922 {
923 request = gftpui_common_local_request;
924 uidata = gftpui_common_local_uidata;
925 }
926 else if (gftpui_common_commands[i].reqtype == gftpui_common_request_remote)
927 {
928 request = gftpui_common_remote_request;
929 uidata = gftpui_common_remote_uidata;
930 }
931 else
932 {
933 request = NULL;
934 uidata = NULL;
935 }
936
937 ret = gftpui_common_commands[i].func (uidata, request, pos); 946 ret = gftpui_common_commands[i].func (uidata, request, pos);
938 } 947 }
939 else 948 else
940 { 949 {
941 gftpui_common_local_request->logging_function (gftp_logging_error, 950 gftpui_common_logfunc (gftp_logging_error, request,
942 gftpui_common_local_request, 951 _("Error: Command not recognized\n"));
943 _("Error: Command not recognized\n"));
944 ret = 1; 952 ret = 1;
945 } 953 }
946 954
947 g_free (newstr); 955 g_free (newstr);
948 return (ret); 956 return (ret);