File: help.c

package info (click to toggle)
yafc 1.1.1.dfsg.1-4
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,248 kB
  • ctags: 1,679
  • sloc: ansic: 19,338; sh: 10,365; makefile: 155; perl: 38; ruby: 33
file content (87 lines) | stat: -rw-r--r-- 1,959 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* $Id: help.c,v 1.10 2004/05/20 11:10:52 mhe Exp $
 *
 * help.c -- local help and info
 *
 * Yet Another FTP Client
 * Copyright (C) 1998-2001, Martin Hedenfalk <mhe@stacken.kth.se>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version. See COPYING for more details.
 */

#include "syshdr.h"
#include "alias.h"
#include "cmd.h"
#include "input.h"
#include "help.h"
#include "gvars.h"
#include "commands.h"

void cmd_help(int argc, char **argv)
{
#ifdef HAVE_LIBREADLINE
	Function *func;
#endif
	int i;
	listitem *li;

	maxargs_nohelp(1);

  if(argc==2) {
    if(find_func(argv[1], false)) {
       
     char *tmp = (char *)xmalloc(30);
     sprintf(tmp, "%s --help", argv[1]);
     exe_cmdline(tmp, false);
     return;
    }
    else {
			fprintf(stderr, _("No such command '%s'!\n\n"), argv[1]);
    }
  };

	fprintf(stderr, _("Available commands: (commands may be abbreviated)\n"));
#ifdef HAVE_LIBREADLINE
	/* hack to let readline display all commands */
	rl_point=rl_end=0;
	func = rl_named_function("possible-completions");
	if(func)
		func();
	else {
#endif
		for(i=0; cmds[i].cmd; i++)
			printf("%s\n", cmds[i].cmd);
		for(li = gvAliases->first; li; li = li->next)
			printf("%s\n", ((alias *)li->data)->name);
#ifdef HAVE_LIBREADLINE
	}
#endif
}

void cmd_version(int argc, char **argv)
{
	maxargs_nohelp(0);

	printf(FULLVER "\n");

	printf(_("Compiled " __TIME__ " " __DATE__ " (" HOSTTYPE ")\n"));
#if (HAVE_LIBREADLINE >= 210)
	printf(_("Using Readline version %s\n"), rl_library_version);
#elif defined(HAVE_LIBREADLINE)
	printf(_("Using Readline version 2.0\n"));
#endif
}

void cmd_warranty(int argc, char **argv)
{
	maxargs_nohelp(0);
	puts(WARRANTY);
}

void cmd_copyright(int argc, char **argv)
{
	maxargs_nohelp(0);
	puts(COPYRIGHT);
}