Compaq AA-RH99A-TE Remote Starter User Manual


 
Extensions that use arrays. Example 3–3 provides a C language
template and Example 3–4 is the source code for the /var/kdbx/file
extension, which shows how to develop an extension using arrays.
Extensions that use global symbols. Example 3–5 is the source code
for the /var/kdbx/sum extensions, which shows how to pull global
symbols from the kernel. A template is not provided because the means
for pulling global symbols from a kernel can vary greatly, depending
upon the desired output.
Example 3–1: Template Extension Using Lists
#include <stdio.h>
#include <kdbx.h>
static char *help_string =
"<Usage info goes here> \\\n\
1
";
FieldRec fields[] = {
{".<name of next field>", NUMBER, NULL, NULL },
2
<data fields>
};
#define NUM_FIELDS (sizeof(fields)/sizeof(fields[0]))
main(argc, argv)
int argc;
char **argv;
{
DataStruct head;
unsigned int next;
char buf[256], *func, *error;
check_args(argc, argv, help_string);
if(!check_fields("<name of list structure>", fields, NUM_FIELDS, NULL)){
3
field_errors(fields, NUM_FIELDS);
quit(1);
}
if(!read_sym_val("<name of list head>", NUMBER, (caddr_t *) &next, &error)){
4
fprintf(stderr, "%s\n", error);
quit(1);
}
sprintf(buf, "<table header>");
5
print(buf);
do {
if(!cast(next, "<name of list structure>", &head, &error)){
6
fprintf(stderr, "Couldnt cast to a <struct>:\n"); 7
fprintf(stderr, "%s:\n", error);
}
if(!read_field_vals(head, fields, NUM_FIELDS)){
field_errors(fields, NUM_FIELDS);
break;
}
<print data in this list cell>
8
next = (int) fields[0].data;
} while(next != 0);
Writing Extensions to the kdbx Debugger 3–23