Menu

Tag: svn

Project: hexed

Well the current project is hexed, a command line HEXadecimal file EDitor. The first update is a simple test for cmdargs, a command line argument parser. Cmdargs is released as public domain software so you can use it in other projects without restrictions. Cmdargs can handle both long and short arguments with options. For long arguments cmdargs can accept either ‘‐’ or ‘‐‐’ as the argument switch. Any short arguments that don’t require an option can be set in the same switch (-a -b -c  or -abc). Options can be set either by ‘:’, ‘=’ or with whitespace as in (-e:10 -b=100 -f filename). The accepted arguments are passed as a single struct array called Arglist with longer args listed before shorter ones in alphabetical order.

Arglist arglist[] = {
{"bar", 0},       // set the bar arg
{"b", 0},         // set the b arg
{"foobar", 0},    // set the foobar arg
{"foo", 0},       // set the foo arg
{"f", 0},         // set the f arg
{NULL, 0}         // must be the last entry
};

This struct and argv from main() are sent to parsecmdargs() in a loop until the end of the arguments are reached.… more...