Pete Wilson : Consultant Software Engineer
Lowell MA 978.454.4547 pete at pwilson dot net April 2009
SummarySample code: please take a look at this code and, if you find it useful, you're very free to download, use, and distribute it. All code on the site is free to use.
|
String-compare function understands wildcards: wc_strncmp()Capable, portable (Unix/Win32/RTOS) C-language strncmp() function that honors and correctly interprets the wildcard characters '*' and '?'. |
||
| wc_strncmp.c | string compare with wildcards | |
| wc_strncmp.h | error-code definitions; included by wc_strncmp.c and its callers | |
| makefile | vanilla Unix makefile | |
Command line options parser for Win32: getopt()Port of GNU getopt() to Win32 for anyone who's tired of dealing with getopt() calls in Unix-to-Windows ports. |
||
| getopt.c | Win32 getopt() | |
| getopt.h | included by getopt.c and its callers | |
| Usage | GNU getopt() man page | |
Safe string functions: st4ncat() and st4ncpy()I've tripped myself up with the length-bounded string cat/cpy functions forever: strncat() and strncpy() can silently write unterminated destination strings. I'm aiming for bulletproof code, so I'm starting to use and to talk up the safer functions st4ncat() and st4ncpy(). |
||
| Discussion | Why strncat() and strncpy() are dangerous | |
| st4ncat.c | Safe string cat | |
| st4ncpy.c | Safe string copy | |
| slprintf.c | Another rascal: snprintf(). Here's a safer version | |
Single-character keyboard input for Linux and UnixSources of the MS-Windows kbhit() function that runs under Linux and most flavors of Unix. |
||
| kbhit.c | Complete C-language source file, including test code in main(). | |
Portable, embeddable CLI packageHighly configurable, extensible, and portable CLI package for embedded systems management. A snap to port and integrates with SNMP- and HTTP-based local/remote management. I developed this C-language package with gcc and with MS Visual Studio 6. |
||
| cli.exe 56kb |
Win32 demo .exe file runs from a console window. It's not ready for prime demo time, and it's documented only in its internal "help" commands: very sorry for that! I'll make this demo more intuitive, self-documenting, and generally spiffier shortly. | |
| cli.zip | The entire MSVC++6.0 CLI project, zipped up, with sources that you can modify and extend so as to include and try out whatever new commands you like. | |
SNMP tools, utilities, and librariesIt's nice to have a library of functions you can call from a manager- or agent-like app to handle authentication, encoding/decoding, OID search, MIB walks, and all the rest of the dreary low-level function that SNMP needs. I've collected all that function into a source library that I'll put up here in the next few weeks. And I find it handy to have a few quick management-side tools and utilities, just to do that one-time test, the one I could really use right now. I've written a few that I think useful and I'll put 'em up here, too, along with their source files. |
||