/*
- * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#include <ddb/db_macro.h>
#include <ddb/db_output.h> /* For db_printf() */
-extern db_expr_t db_radix;
extern db_expr_t db_max_width;
extern db_expr_t db_tab_stop_width;
extern db_expr_t db_max_line;
db_expr_t db_work[DB_NWORK]; /* work variable */
struct db_variable db_vars[] = {
- { "maxoff", (db_expr_t*)&db_maxoff, FCN_NULL },
- { "autowrap", &db_auto_wrap, FCN_NULL },
- { "completion", &db_auto_completion, FCN_NULL },
- { "maxwidth", &db_max_width, FCN_NULL },
- { "radix", &db_radix, FCN_NULL },
- { "tabstops", &db_tab_stop_width, FCN_NULL },
- { "lines", &db_max_line, FCN_NULL },
- { "thr_act", 0, db_set_default_act },
- { "task", 0, db_get_task_act,
- 1, 2, -1, -1 },
- { "work", &db_work[0], FCN_NULL,
- 1, 1, 0, DB_NWORK-1 },
- { "arg", 0, db_arg_variable,
- 1, 1, 1, DB_MACRO_NARGS,
- 1, 0, DB_MACRO_LEVEL-1, (int *)&db_macro_level },
+ {
+ .name = "maxoff",
+ .valuep = (db_expr_t*)&db_maxoff,
+ },
+ {
+ .name = "autowrap",
+ .valuep = &db_auto_wrap,
+ },
+ {
+ .name = "completion",
+ .valuep = &db_auto_completion,
+ },
+ {
+ .name = "maxwidth",
+ .valuep = &db_max_width,
+ },
+ {
+ .name = "radix",
+ .valuep = &db_radix,
+ },
+ {
+ .name = "tabstops",
+ .valuep = &db_tab_stop_width,
+ },
+ {
+ .name = "lines",
+ .valuep = &db_max_line,
+ },
+ {
+ .name = "thr_act",
+ .fcn = db_set_default_act,
+ },
+ {
+ .name = "task",
+ .fcn = db_get_task_act,
+ .min_level = 1,
+ .max_level = 2,
+ .low = -1,
+ .high = -1,
+ },
+ {
+ .name = "work",
+ .valuep = &db_work[0],
+ .min_level = 1,
+ .max_level = 1,
+ .high = DB_NWORK - 1,
+ },
+ {
+ .name = "arg",
+ .fcn = db_arg_variable,
+ .min_level = 1,
+ .max_level = 1,
+ .low = 1,
+ .high = DB_MACRO_NARGS,
+ .hidden_level = 1,
+ .hidden_low = 0,
+ .hidden_high = DB_MACRO_LEVEL - 1,
+ .hidden_levelp = (int *)&db_macro_level,
+ },
};
struct db_variable *db_evars = db_vars + sizeof(db_vars)/sizeof(db_vars[0]);
/* Prototypes for functions local to this file.
*/
-static char *db_get_suffix(
- register char *suffix,
- short *suffix_value);
+static const char *db_get_suffix(const char *, short *);
-static boolean_t db_cmp_variable_name(
- struct db_variable *vp,
- char *name,
- register db_var_aux_param_t ap);
+static boolean_t db_cmp_variable_name(struct db_variable *, const char *,
+ db_var_aux_param_t);
static int db_find_variable(
struct db_variable **varp,
db_var_aux_param_t ap);
-static int db_set_variable(db_expr_t value);
-
void db_list_variable(void);
-static char *
-db_get_suffix(
- register char *suffix,
- short *suffix_value)
+static const char *
+db_get_suffix(const char *suffix, short *suffix_value)
{
register int value;
}
static boolean_t
-db_cmp_variable_name(
- struct db_variable *vp,
- char *name,
- register db_var_aux_param_t ap)
+db_cmp_variable_name(struct db_variable *vp, const char *name,
+ db_var_aux_param_t ap)
{
- register char *var_np, *np;
- register int level;
+ const char *var_np, *np;
+ int level;
for (np = name, var_np = vp->name; *var_np; ) {
if (*np++ != *var_np++)
|| (level > 0 && (ap->suffix[0] < vp->low
|| (vp->high >= 0 && ap->suffix[0] > vp->high))))
return(FALSE);
- strcpy(ap->modif, (*np)? np+1: "");
+ strlcpy(ap->modif, (*np)? np+1: "", TOK_STRING_SIZE);
ap->thr_act = (db_option(ap->modif, 't')?db_default_act: THREAD_NULL);
ap->level = level;
ap->hidden_level = -1;
return (1);
}
-static int
-db_set_variable(db_expr_t value)
-{
- struct db_variable *vp;
- struct db_var_aux_param aux_param;
- char modif[TOK_STRING_SIZE];
-
- aux_param.modif = modif;
- if (!db_find_variable(&vp, &aux_param))
- return (0);
-
- db_read_write_variable(vp, &value, DB_VAR_SET, &aux_param);
-
- return (1);
-}
-
void
db_read_write_variable(
struct db_variable *vp,
if (ap == 0) {
ap = &aux_param;
- ap->modif = "";
+ ap->modif = NULL;
ap->level = 0;
ap->thr_act = THREAD_NULL;
}
struct db_variable *cur;
unsigned int len;
unsigned int sl;
- unsigned int slen;
- short h;
+ unsigned int slen = 0;
+ short h = 0;
short i;
- short j;
+ unsigned short j;
short k;
short low;
- int hidden_level;
+ int hidden_level = 0;
struct db_var_aux_param aux_param;
- char *p;
- char *q;
+ const char *p = NULL, *q;
char *name;
- db_addr_t offset;
+ db_addr_t offset = 0;
for (cur = db_vars; cur < db_evars; cur++)
if (db_cmp_variable_name(cur, db_tok_string, &aux_param))
return;
}
- strcpy(aux_param.modif, *p ? p + 1 : "");
+ strlcpy(aux_param.modif, *p ? p + 1 : "", TOK_STRING_SIZE);
aux_param.thr_act = (db_option(aux_param.modif, 't') ?
db_default_act : THREAD_NULL);
}
}
void
-db_show_variable(void)
+db_show_variable(__unused db_expr_t addr, __unused boolean_t have_addr,
+ __unused db_expr_t count, __unused char *modif)
{
struct db_variable *cur;
unsigned int l;
unsigned int len;
unsigned int sl;
unsigned int slen;
- short h;
+ short h = 0;
short i;
- short j;
+ unsigned short j;
short k;
int t;
int t1;
len = l + 1;
}
- aux_param.modif = "";
+ aux_param.modif = NULL;
aux_param.level = 1;
aux_param.thr_act = THREAD_NULL;