/[radius]/radius/radiusd/tsh.c
ViewVC logotype

Diff of /radius/radiusd/tsh.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by gray, Sat Sep 27 17:05:55 2003 UTC revision 1.5 by gray, Sun Sep 28 22:18:02 2003 UTC
# Line 50  static RADIUS_REQ test_req; Line 50  static RADIUS_REQ test_req;
50  static char *tsh_ps1 = "(radiusd) ";  static char *tsh_ps1 = "(radiusd) ";
51  static char *tsh_ps2 = "[radiusd] ";  static char *tsh_ps2 = "[radiusd] ";
52    
53    static char *tsh_readline(const char *prompt);
54    
55  static void tsh_help(int argc, char **argv, char *cmd);  static void tsh_help(int argc, char **argv, char *cmd);
56  static void tsh_query_nas(int argc, char **argv, char *cmd);  static void tsh_query_nas(int argc, char **argv, char *cmd);
57  #ifdef USE_SERVER_GUILE  #ifdef USE_SERVER_GUILE
# Line 62  static void tsh_debug(int argc, char **a Line 64  static void tsh_debug(int argc, char **a
64  static void tsh_quit(int argc, char **argv, char *cmd);  static void tsh_quit(int argc, char **argv, char *cmd);
65  static void tsh_req_define(int argc, char **argv, char *cmd);  static void tsh_req_define(int argc, char **argv, char *cmd);
66  static void tsh_req_print(int argc, char **argv, char *cmd);  static void tsh_req_print(int argc, char **argv, char *cmd);
67    static void tsh_rewrite_stack(int argc, char **argv, char *cmd);
68    
69  typedef void (*tsh_command) (int argc, char **argv, char *cmd);  typedef void (*tsh_command) (int argc, char **argv, char *cmd);
70    
# Line 78  struct command_table { Line 81  struct command_table {
81  #ifdef USE_SERVER_GUILE  #ifdef USE_SERVER_GUILE
82          {"g", "guile", NULL, N_("Enter Guile"), tsh_guile},          {"g", "guile", NULL, N_("Enter Guile"), tsh_guile},
83  #endif  #endif
84            {"rs", "rewrite-stack", N_("[NUMBER]"),
85             N_("Print or set the Rewrite stack size"),
86             tsh_rewrite_stack},
87          {"r", "run-rewrite", N_("FUNCTION(args..)"),          {"r", "run-rewrite", N_("FUNCTION(args..)"),
88           N_("Run given Rewrite function"), tsh_run_rewrite},           N_("Run given Rewrite function"), tsh_run_rewrite},
89          {"s", "source", N_("FILE"),          {"s", "source", N_("FILE"),
# Line 85  struct command_table { Line 91  struct command_table {
91          {"t", "timespan", N_("TIMESPAN [DOW [HH [MM]]]"),          {"t", "timespan", N_("TIMESPAN [DOW [HH [MM]]]"),
92           N_("Check the timespan interval"), tsh_timespan},           N_("Check the timespan interval"), tsh_timespan},
93          {"d", "debug", N_("LEVEL"), N_("Set debugging level"), tsh_debug},          {"d", "debug", N_("LEVEL"), N_("Set debugging level"), tsh_debug},
94          {"request-d", "request-define", N_("[PAIR [,PAIR]]"), N_("Define a request"),          {"rd", "request-define", N_("[PAIR [,PAIR]]"), N_("Define a request"),
95           tsh_req_define },           tsh_req_define },
96          {"request-p", "request-print", NULL, N_("Print the request"),          {"rp", "request-print", NULL, N_("Print the request"),
97           tsh_req_print},           tsh_req_print},
98          {"quit", "quit", NULL, N_("Quit the shell"), tsh_quit},          {"quit", "quit", NULL, N_("Quit the shell"), tsh_quit},
99          {NULL}          {NULL}
# Line 140  tsh_help(int argc, char **argv, char *cm Line 146  tsh_help(int argc, char **argv, char *cm
146                    
147          for (cp = command_table; cp->shortname; cp++) {          for (cp = command_table; cp->shortname; cp++) {
148                  int len = strlen(cp->shortname);                  int len = strlen(cp->shortname);
149                  if (len == strlen(cp->longname))  
150                          n = printf("%s", cp->longname);                  n = printf("%-8.8s%s", cp->shortname, cp->longname);
                 else  
                         n = printf("(%*.*s)%s", len, len, cp->longname,  
                                    cp->longname + len);  
151                  if (cp->usage)                  if (cp->usage)
152                          n += printf(" %s", cp->usage);                          n += printf(" %s", cp->usage);
153                  print_doc(n, gettext(cp->doc));                  print_doc(n, gettext(cp->doc));
# Line 188  tsh_guile(int argc ARG_UNUSED, char **ar Line 191  tsh_guile(int argc ARG_UNUSED, char **ar
191  #endif  #endif
192    
193  static void  static void
194    tsh_rewrite_stack(int argc, char **argv, char *cmd)
195    {
196            if (argc > 2) {
197                    fprintf(stderr,
198                            _("%s: wrong number of arguments\n"), argv[0]);
199                    return;
200            }
201            if (argc == 1)
202                    printf("%lu\n", (long unsigned) rewrite_get_stack_size());
203            else {
204                    char *p;
205                    size_t n = strtoul(argv[1], &p, 0);
206                    if (*p)
207                            fprintf(stderr,
208                                    _("%s: argument is not a number\n"), argv[0]);
209                    else
210                            rewrite_set_stack_size(n);
211            }
212    }
213    
214    static void
215  tsh_run_rewrite(int argc, char **argv, char *cmd)  tsh_run_rewrite(int argc, char **argv, char *cmd)
216  {  {
217          Datatype type;          Datatype type;
# Line 204  tsh_run_rewrite(int argc, char **argv, c Line 228  tsh_run_rewrite(int argc, char **argv, c
228          while (*cmd && !isspace(*cmd))          while (*cmd && !isspace(*cmd))
229                  cmd++;                  cmd++;
230    
231          if (interpret(cmd, &test_req, &type, &datum))          if (rewrite_interpret(cmd, &test_req, &type, &datum))
232                  printf("?\n");                  printf("?\n");
233          else {          else {
234                  switch (type) {                  switch (type) {
# Line 458  tsh_readline_internal() Line 482  tsh_readline_internal()
482          }          }
483  }  }
484    
485  char *  static char *
486  tsh_readline(const char *prompt)  tsh_readline(const char *prompt)
487  {  {
488          if (interactive)          if (interactive)
# Line 539  tsh_find_entry(char *cmd) Line 563  tsh_find_entry(char *cmd)
563  static tsh_command  static tsh_command
564  tsh_find_function(char *name)  tsh_find_function(char *name)
565  {  {
566          struct command_table *cp = tsh_find_entry(name);          struct command_table *cp;
567            if (name[0] == '?' && name[1] == 0)
568                    name = "help";
569            cp = tsh_find_entry(name);
570          return cp ? cp->handler : NULL;          return cp ? cp->handler : NULL;
571  }  }
572    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26