The getsubopt(3) Function
Many UNIX platforms support suboptions. Suboptions are useful when your application has many possible parameter values and suboptions, which are best specified by name. SGI's IRIX 6.5 documents an example of suboptions using its mount(1) command:
# mount -o rw,hard,bg,wsize=1024 speed:/usr /usr
In this example, the -o represents the option, which is then followed by an argument consisting of suboptions. The argument rw,hard,bg,wsize=1024 has several suboptions, which are separated by commas. As the example illustrates, some suboptions take arguments and others do not.
To make it easier for the application writer to parse suboptions, the function getsubopt(3) is provided. Its synopsis is as follows:
#include <stdlib.h> ...
Get Advanced UNIX Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.