forked from FDOS/freecom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alias.c
53 lines (45 loc) · 1.05 KB
/
alias.c
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
/* $Id$
* ALIAS.C - alias administration module
*
*/
#include "../config.h"
#include <nls_f.h>
#include "../err_fcts.h"
#include "../include/cmdline.h"
#include "../include/command.h"
#include "../include/context.h"
#include "../include/misc.h"
#include "../strings.h"
int cmd_alias(char *param)
{ char *value;
/* Bail on every option */
if(leadOptions(¶m, 0, 0) != E_None)
return 1;
/* *param != whitespace */
switch(breakVarAssign(ctxtAlias, param, &value)) {
case 1: /* no equal sign */
error_syntax(0);
return 1;
case 0: /* displayed */
return 0;
#ifdef DEBUG
case 2: break;
default:
dprintf(("[ALIAS: Invalid response from breakVarAssign()]\n"));
return 1;
#endif
}
/* param[] == alias name -> check its validity */
rtrimsp(param); /* spaces are ignored at its end */
if(!*param) {
error_syntax(0);
return 1;
}
if(!is_fnstr(param)) {
error_no_alias_name(param);
return 1;
}
StrFUpr(param); /* Aliases are case-insensitive */
value = trimsp(value);
return chgCtxt(CTXT_TAG_ALIAS, param, *value? value: 0);
}