Compaq AA-RH99A-TE Remote Starter User Manual


 
Example 3–5: Extension That Uses Global Symbols: sum.c (cont.)
* cpup no longer exists, emmulate platform_string(),
* a.k.a. get_system_type_string().
read_var("cpup.system_string", STRING, &resp);
*/
read_var("rpb->rpb_vers", NUMBER, &tmp);
if (tmp < 5)
resp = "Unknown System Type";
else
read_var(
"(char *)rpb + rpb->rpb_dsr_off + "
"((struct rpb_dsr *)"
" ((char *)rpb + rpb->rpb_dsr_off))->rpb_sysname_off + sizeof(long)",
STRING, &resp);
sprintf(buf, "cpu: %s\tavail: %d", resp, avail);
print(buf);
free(resp);
read_var("boottime.tv_sec", NUMBER, &secs);
sprintf(buf, "Boot-time:\t%s", ctime(&secs));
buf[strlen(buf) - 1] = \0;
print(buf);
read_var("time.tv_sec", NUMBER, &secs);
sprintf(buf, "Time:\t%s", ctime(&secs));
buf[strlen(buf) - 1] = \0;
print(buf);
read_var("utsname.sysname", STRING, &sysname);
read_var("utsname.release", STRING, &release);
read_var("utsname.version", STRING, &version);
read_var("utsname.machine", STRING, &machine);
sprintf(buf, "Kernel : %s release %s version %s (%s)", sysname, release,
version, machine);
print(buf);
quit(0);
}
3.4 Compiling Custom Extensions
After you have written the extension, you need to compile it. To compile the
extension, enter the following command:
% cc -o test test.c -lkdbx
This cc command compiles an extension named test.c. The kdbx.a
library is linked with the extensions, as specified by the l flag. The output
from this command is named test, as specified by the o flag.
Once the extension compiles successfully, you should test it and, if necessary,
debug it as described in Section 3.5.
When the extension is ready for use, place it in a directory that is accessible
to other users. Extensions provided with the operating system are located
in the /var/kdbx directory.
Writing Extensions to the kdbx Debugger 3–35