3.2.1 Using xv_init( )
Initialization should be done before the application attempts to parse its own command-line
options. Since many programs tend to have command-line parameters, a program tends to
report unknown parameters as illegal arguments. Because XView parameters can also be
specified on the command line to the application, the program must be able to distinguish
between the application’s parameters and XView’s parameters.
xv_init() accepts the attributes XV_INIT_ARGS and XV_INIT_ARGC_PTR_ARGV for pur-
poses of parsing command-line arguments. These attributes both take two parameters as val-
ues: argc and argv. These are typically the same ones passed into main(). Using the
XV_INIT_ARGC_PTR_ARGV attribute, the xv_init() function can be told to modify argc
and argv by removing parameters that are XView-specific, like so:
xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL);
When xv_init returns, argv contains only those parameters that are not specific to
XView, and the application can now assume that all remaining arguments are specific to the
application. So a hypothetical command line might look like this:
% program –display maui:0
The command line is first parsed by xv_init(), and in this case, all arguments are stripped
from the argv variable, leaving just argv[0], whose value is program. argc is modi-
fied to have the value 1 (it was originally 3). The example command-line parameters change
the default server to be the X server running on the machine named maui.
The macro XV_INIT_ARGS is ...