Compaq AA-RH99A-TE Remote Starter User Manual


 
Example 3–2: Extension That Uses Linked Lists: callout.c (cont.)
#define NUM_PROCESSOR_FIELDS
(sizeof(processor_fields)/sizeof(processor_fields[0]))
#define NUM_CALLOUT_FIELDS (sizeof(callout_fields)/sizeof(callout_fields[0]))
main(int argc, char **argv)
{
DataStruct processor_ptr, processor, callout;
long next, ncpus, ptr_val, i;
char buf[256], *func, *error, arg[13];
int cpuflag = 0, cpuarg = 0;
long headptr;
Status status;
char *resp;
if ( !(argc == 1 || argc == 2) ) {
fprintf(stderr, "Usage: callout [cpu]\n");
quit(1);
}
check_args(argc, argv, help_string);
if (argc == 2) {
cpuflag = 1;
errno = 0;
cpuarg = atoi(argv[1]);
if (errno != 0)
fprintf(stderr, "Invalid argument value for the cpu number.\n");
}
if(!check_fields("struct processor", processor_fields, NUM_PROCESSOR_FIELDS,
NULL)){
field_errors(processor_fields, NUM_PROCESSOR_FIELDS);
quit(1);
}
if(!check_fields("struct callout", callout_fields, NUM_CALLOUT_FIELDS, NULL)){
field_errors(callout_fields, NUM_CALLOUT_FIELDS);
quit(1);
}
/* This gives the same result as "(kdbx) p processor_ptr" */
if(!read_sym_addr("processor_ptr", &headptr, &error)){
fprintf(stderr, "%s\n", error);
quit(1);
}
/* get ncpus */
if(!read_sym_val("ncpus", NUMBER, &ncpus, &error)){
fprintf(stderr, "Couldnt read ncpus:\n");
fprintf(stderr, "%s\n", error);
quit(1);
}
for (i=0; i < ncpus; i++) {
/* if user wants only one cpu and this is not the one, skip */
if (cpuflag)
if (cpuarg != i) continue;
/* get the ith pointer (values) in the array */
Writing Extensions to the kdbx Debugger 3–25