File: user_defaults.c

package info (click to toggle)
staden 2.0.0%2Bb11-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,584 kB
  • sloc: ansic: 240,605; tcl: 65,360; cpp: 12,854; makefile: 11,203; sh: 3,023; fortran: 2,033; perl: 63; awk: 46
file content (37 lines) | stat: -rw-r--r-- 760 bytes parent folder | download | duplicates (5)
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
/* NB: Not used; not finished; needs updated to tclX v8 */

#include <tcl.h>
#include "tclXkeylist.h"

static char *def_list = NULL;

int tcl_set_def(ClientData clientData, Tcl_Interp *interp,
		int argc, char **argv) {
    char *new_list;

    /*
     * proc set_def {a1 a2} {
     *    global defn
     *    global $defn
     *    keylset $defn $a1 $a2
     * }
     */

    if (argc != 3) {
	Tcl_AppendResult(interp, "wrong # args: ", argv[0],
			 " name value", NULL);
	return TCL_ERROR;
    }

    new_list = Tcl_SetKeyedListField(interp, argv[1], argv[2], def_list);
    if (NULL == new_list) {
	Tcl_AppendResult(interp, "out of memory", NULL);
	return TCL_ERROR;
    }

    if (def_list)
	xfree(def_list);
    def_list = new_list;

    return TCL_OK;
}