diff options
Diffstat (limited to 'ndb/src/common/util/getarg.3.ps')
-rw-r--r-- | ndb/src/common/util/getarg.3.ps | 458 |
1 files changed, 0 insertions, 458 deletions
diff --git a/ndb/src/common/util/getarg.3.ps b/ndb/src/common/util/getarg.3.ps deleted file mode 100644 index 146fb8e4961..00000000000 --- a/ndb/src/common/util/getarg.3.ps +++ /dev/null @@ -1,458 +0,0 @@ -%!PS-Adobe-3.0 -%%Creator: groff version 1.15 -%%CreationDate: Thu Nov 7 12:53:13 2002 -%%DocumentNeededResources: font Times-Roman -%%+ font Times-Bold -%%+ font Courier-Bold -%%+ font Courier-Oblique -%%+ font Symbol -%%+ font Courier -%%DocumentSuppliedResources: procset grops 1.15 0 -%%Pages: 4 -%%PageOrder: Ascend -%%Orientation: Portrait -%%EndComments -%%BeginProlog -%%BeginResource: procset grops 1.15 0 -/setpacking where{ -pop -currentpacking -true setpacking -}if -/grops 120 dict dup begin -/SC 32 def -/A/show load def -/B{0 SC 3 -1 roll widthshow}bind def -/C{0 exch ashow}bind def -/D{0 exch 0 SC 5 2 roll awidthshow}bind def -/E{0 rmoveto show}bind def -/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def -/G{0 rmoveto 0 exch ashow}bind def -/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def -/I{0 exch rmoveto show}bind def -/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def -/K{0 exch rmoveto 0 exch ashow}bind def -/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def -/M{rmoveto show}bind def -/N{rmoveto 0 SC 3 -1 roll widthshow}bind def -/O{rmoveto 0 exch ashow}bind def -/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def -/Q{moveto show}bind def -/R{moveto 0 SC 3 -1 roll widthshow}bind def -/S{moveto 0 exch ashow}bind def -/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def -/SF{ -findfont exch -[exch dup 0 exch 0 exch neg 0 0]makefont -dup setfont -[exch/setfont cvx]cvx bind def -}bind def -/MF{ -findfont -[5 2 roll -0 3 1 roll -neg 0 0]makefont -dup setfont -[exch/setfont cvx]cvx bind def -}bind def -/level0 0 def -/RES 0 def -/PL 0 def -/LS 0 def -/MANUAL{ -statusdict begin/manualfeed true store end -}bind def -/PLG{ -gsave newpath clippath pathbbox grestore -exch pop add exch pop -}bind def -/BP{ -/level0 save def -1 setlinecap -1 setlinejoin -72 RES div dup scale -LS{ -90 rotate -}{ -0 PL translate -}ifelse -1 -1 scale -}bind def -/EP{ -level0 restore -showpage -}bind def -/DA{ -newpath arcn stroke -}bind def -/SN{ -transform -.25 sub exch .25 sub exch -round .25 add exch round .25 add exch -itransform -}bind def -/DL{ -SN -moveto -SN -lineto stroke -}bind def -/DC{ -newpath 0 360 arc closepath -}bind def -/TM matrix def -/DE{ -TM currentmatrix pop -translate scale newpath 0 0 .5 0 360 arc closepath -TM setmatrix -}bind def -/RC/rcurveto load def -/RL/rlineto load def -/ST/stroke load def -/MT/moveto load def -/CL/closepath load def -/FL{ -currentgray exch setgray fill setgray -}bind def -/BL/fill load def -/LW/setlinewidth load def -/RE{ -findfont -dup maxlength 1 index/FontName known not{1 add}if dict begin -{ -1 index/FID ne{def}{pop pop}ifelse -}forall -/Encoding exch def -dup/FontName exch def -currentdict end definefont pop -}bind def -/DEFS 0 def -/EBEGIN{ -moveto -DEFS begin -}bind def -/EEND/end load def -/CNT 0 def -/level1 0 def -/PBEGIN{ -/level1 save def -translate -div 3 1 roll div exch scale -neg exch neg exch translate -0 setgray -0 setlinecap -1 setlinewidth -0 setlinejoin -10 setmiterlimit -[]0 setdash -/setstrokeadjust where{ -pop -false setstrokeadjust -}if -/setoverprint where{ -pop -false setoverprint -}if -newpath -/CNT countdictstack def -userdict begin -/showpage{}def -}bind def -/PEND{ -clear -countdictstack CNT sub{end}repeat -level1 restore -}bind def -end def -/setpacking where{ -pop -setpacking -}if -%%EndResource -%%IncludeResource: font Times-Roman -%%IncludeResource: font Times-Bold -%%IncludeResource: font Courier-Bold -%%IncludeResource: font Courier-Oblique -%%IncludeResource: font Symbol -%%IncludeResource: font Courier -grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 -def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron -/scaron/zcaron/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef -/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef -/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef -/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent -/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen -/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon -/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O -/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex -/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y -/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft -/guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl -/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut -/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash -/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen -/brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft -/logicalnot/minus/registered/macron/degree/plusminus/twosuperior -/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior -/ordmasculine/guilsinglright/onequarter/onehalf/threequarters -/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE -/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex -/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis -/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn -/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla -/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis -/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash -/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def -/Courier@0 ENC0/Courier RE/Courier-Oblique@0 ENC0/Courier-Oblique RE -/Courier-Bold@0 ENC0/Courier-Bold RE/Times-Bold@0 ENC0/Times-Bold RE -/Times-Roman@0 ENC0/Times-Roman RE -%%EndProlog -%%Page: 1 1 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(GET)72 48 Q -.834(ARG \( 3 \))-.93 F -(OpenBSD Programmer')111.062 E 2.5(sM)-.55 G 108.562(anual GET)-2.5 F --.834(ARG \( 3 \))-.93 F/F1 10/Times-Bold@0 SF -.2(NA)72 108 S(ME).2 E -/F2 10/Courier-Bold@0 SF(getarg)102 120 Q F0(,)A F2(arg_printusage)2.5 E -F0 2.5<ad63>2.5 G(ollect command line options)-2.5 E F1(SYNOPSIS)72 144 -Q F2(#include <getarg.h>)102 156 Q/F3 10/Courier-Oblique@0 SF(int)102 -186 Q F2(getarg)102 198 Q F0(\()A F3(struct getargs)A/F4 10/Symbol SF(*) -6 E F3(args)A F0(,)1.666 E F3(size_t num_args)4.166 E F0(,)1.666 E F3 -(int argc)4.166 E F0(,)1.666 E F3(char)4.166 E F4(**)6 E F3(argv)A F0(,) -1.666 E F3(int)151.666 210 Q F4(*)6 E F3(optind)A F0(\);)A F3(void)102 -240 Q F2(arg_printusage)102 252 Q F0(\()A F3(struct getargs)A F4(*)6 E -F3(args)A F0(,)1.666 E F3(size_t num_args)4.166 E F0(,)1.666 E F3 -(const char)4.166 E F4(*)6 E F3(progname)A F0(,)1.666 E F3(const char) -151.666 264 Q F4(*)6 E F3(extra_string)A F0(\);)A F1(DESCRIPTION)72 300 -Q F2(getarg)102 312 Q F0 2.721 1.666(\(\) c)D 6.053(ollects an)-1.666 F -8.553(yc)-.15 G 6.053(ommand line options gi)-8.553 F -.15(ve)-.25 G -8.552(nt).15 G 8.552(oap)-8.552 G 6.052(rogram in an easily used w) --8.552 F(ay)-.1 E(.)-.65 E F2(arg_printusage)102 324 Q F0 -3.332 1.666 -(\(\) p)D(retty-prints the a)-1.666 E -.25(va)-.2 G -(ilable options, with a short help te).25 E(xt.)-.15 E F3(args)102 342 Q -F0 .855(is the option speci\214cation to use, and it')3.355 F 3.356(sa) --.55 G 3.356(na)-3.356 G .856(rray of)-3.356 F F3 .856(struct getargs) -3.356 F F0(elements.)3.356 E F3(num_args)5.856 E F0(is)3.356 E .344 -(the size of)102 354 R F3(args)2.844 E F0 .344(\(in elements\).)2.844 F -F3(argc)5.344 E F0(and)2.844 E F3(argv)2.844 E F0 .344(are the ar)2.844 -F .344(gument count and ar)-.18 F .344(gument v)-.18 F .344(ector to e) --.15 F .343(xtract op-)-.15 F 1.127(tion from.)102 366 R F3(optind)6.127 -E F0 1.127(is a pointer to an inte)3.627 F 1.127(ger where the inde)-.15 -F 3.627(xt)-.15 G 3.628(ot)-3.627 G 1.128(he last processed ar)-3.628 F -1.128(gument is stored, it)-.18 F -(must be initialised to the \214rst inde)102 378 Q 2.5(x\()-.15 G -(minus one\) to process \(normally 0\) before the \214rst call.)-2.5 E -F3(arg_printusage)102 396 Q F0(tak)4.178 E 4.178(et)-.1 G 1.678(he same) --4.178 F F3(args)4.178 E F0(and)4.178 E F3(num_args)4.178 E F0 1.678 -(as getar)4.178 F(g;)-.18 E F3 1.677(progname is the name of)4.178 F -6.381(the program \(to be)102 408 R F0(progname0)12.381 E F3(0)12.381 E -F0(progname1)A F3(1)12.381 E F0(progname2)A F3(2)12.382 E F0(progname3)A -F3(3)12.382 E F0(progname4)A F3(4)102 420 Q F0(progname5)A F3 -(extra_string)3.404 E F0 .904 -(is a string to print after the actual options to indicate more ar)3.404 -F .904(guments. The)-.18 F .025(usefulness of this function is realised\ - only be people who has used programs that has help strings that doesn') -102 432 R(t)-.18 E(match what the code does.)102 444 Q(The)102 462 Q F3 -(getargs)2.5 E F0(struct has the follo)2.5 E(wing elements.)-.25 E/F5 10 -/Courier@0 SF(struct getargs{)102 504 Q(const char)126 516 Q F4(*)6 E F5 -(long_name;)A(char short_name;)126 528 Q(enum { arg_integer,)126 540 Q -(arg_string,)165 552 Q(arg_flag,)165 564 Q(arg_negative_flag,)165 576 Q -(arg_strings,)165 588 Q(arg_double,)165 600 Q(arg_collect)168 612 Q 6 -(}t)126 624 S(ype;)-6 E(void)126 636 Q F4(*)6 E F5(value;)A(const char) -126 648 Q F4(*)6 E F5(help;)A(const char)126 660 Q F4(*)6 E F5 -(arg_help;)A(};)102 672 Q F3(long_name)102 690 Q F0 .207 -(is the long name of the option, it can be)2.707 F F5(NULL)2.706 E F0 -2.706(,i)C 2.706(fy)-2.706 G .206(ou don')-2.706 F 2.706(tw)-.18 G .206 -(ant a long name.)-2.806 F F3(short_name)5.206 E F0 .397(is the charact\ -ed to use as short option, it can be zero. If the option has a v)102 702 -R .398(alue the)-.25 F F3(value)2.898 E F0 .398 -(\214eld gets \214lled in)2.898 F -.4(RO)77 750 S 152.325(KEN September) -.4 F(24, 1999)2.5 E(1)188.865 E EP -%%Page: 2 2 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(GET)72 48 Q -.834(ARG \( 3 \))-.93 F -(OpenBSD Programmer')111.062 E 2.5(sM)-.55 G 108.562(anual GET)-2.5 F --.834(ARG \( 3 \))-.93 F .737(with that v)102 96 R .737 -(alue interpreted as speci\214ed by the)-.25 F/F1 10/Courier-Oblique@0 -SF(type)3.237 E F0(\214eld.)3.237 E F1(help)5.737 E F0 .737 -(is a longer help string for the option as a)3.237 F 2.833 -(whole, if it')102 108 R(s)-.55 E/F2 10/Courier@0 SF(NULL)5.333 E F0 -2.833(the help te)5.333 F 2.833(xt for the option is omitted \(b)-.15 F -2.834(ut it')-.2 F 5.334(ss)-.55 G 2.834 -(till displayed in the synopsis\).)-5.334 F F1(arg_help)102 120 Q F0 -.391(is a description of the ar)2.891 F .391(gument, if)-.18 F F2(NULL) -2.891 E F0 2.891(ad)2.891 G(ef)-2.891 E .39(ault v)-.1 F .39 -(alue will be used, depending on the type of)-.25 F(the option:)102 132 -Q(ar)102 150 Q(g_inte)-.18 E 59.29(ger the)-.15 F(ar)2.5 E -(gument is a signed inte)-.18 E(ger)-.15 E 2.5(,a)-.4 G(nd)-2.5 E F1 -(value)2.5 E F0(should point to an)2.5 E F1(int)2.5 E F0(.)A F1 -(arg_string)102 168 Q F0(the ar)47 E(gument is a string, and)-.18 E F1 -(value)2.5 E F0(should point to a)2.5 E F1(char)2.5 E/F3 10/Symbol SF(*) -A F0(.)A F1(arg_flag)102 186 Q F0 .4(the ar)59 F .4 -(gument is a \215ag, and)-.18 F F1(value)2.9 E F0 .4(should point to a) -2.9 F F1(int)2.9 E F0 2.9(.I)C 2.9(tg)-2.9 G .4 -(ets \214lled in with ei-)-2.9 F 1.154 -(ther zero or one, depending on ho)209 198 R 3.654(wt)-.25 G 1.153 -(he option is gi)-3.654 F -.15(ve)-.25 G 1.153 -(n, the normal case beeing).15 F .526(one. Note that if the option isn') -209 210 R 3.026(tg)-.18 G -2.15 -.25(iv e)-3.026 H .526(n, the v).25 F -.526(alue isn')-.25 F 3.026(ta)-.18 G .527(ltered, so it should be ini-) --3.026 F(tialised to some useful def)209 222 Q(ault.)-.1 E F1 -(arg_negative_flag)102 240 Q F0 .058(this is the same as)2.558 F F1 -(arg_flag)2.558 E F0 -.2(bu)2.558 G 2.558(ti).2 G 2.558(tr)-2.558 G --2.15 -.25(ev e)-2.558 H .057(rses the meaning of the \215ag \(a gi).25 -F -.15(ve)-.25 G 2.557(ns).15 G(hort)-2.557 E -(option clears the \215ag\), and the synopsis of a long option is ne)209 -252 Q -.05(ga)-.15 G(ted.).05 E F1(arg_strings)102 270 Q F0 .195(the ar) -41 F .195(gument can be gi)-.18 F -.15(ve)-.25 G 2.695(nm).15 G .195 -(ultiple times, and the v)-2.695 F .195 -(alues are collected in an array;)-.25 F F1(value)209 282 Q F0 .947 -(should be a pointer to a)3.447 F F1 .947(struct getarg_strings)3.447 F -F0 .947(structure, which)3.447 F(holds a length and a string pointer)209 -294 Q(.)-.55 E F1(arg_double)102 312 Q F0(ar)47 E .538 -(gument is a double precision \215oating point v)-.18 F .539(alue, and) --.25 F F1(value)3.039 E F0 .539(should point to a)3.039 F F1(double)209 -324 Q F0(.)A F1(arg_collect)102 342 Q F0(allo)41 E .345 -(ws more \214ne-grained control of the option parsing process.)-.25 F F1 -(value)5.344 E F0 .344(should be)2.844 F 2.5(ap)209 354 S(ointer to a) --2.5 E F1(getarg_collect_info)2.5 E F0(structure:)2.5 E F2 -(typedef int \()209 372 Q F3(*)A F2 -(getarg_collect_func\)\(int short_opt,)A(int argc,)407 384 Q(char)407 -396 Q F3(**)6 E F2(argv,)A(int)407 408 Q F3(*)6 E F2(optind,)A(int)407 -420 Q F3(*)6 E F2(optarg,)A(void)407 432 Q F3(*)6 E F2(data\);)A -(typedef struct getarg_collect_info {)209 456 Q -(getarg_collect_func func;)233 468 Q(void)233 480 Q F3(*)6 E F2(data;)A -6(}g)209 492 S(etarg_collect_info;)-6 E F0 -.4(Wi)209 510 S 1.018 -(th the).4 F F1(func)3.518 E F0 1.019 -(member set to a function to call, and)3.518 F F1(data)3.519 E F0 1.019 -(to some application)3.519 F -(speci\214c data. The parameters to the collect function are:)209 522 Q -F1(short_flag)209 540 Q F0 -(non-zero if this call is via a short option \215ag, zero otherwise)2.5 -E F1(argc)209 558 Q F0(,)A F1(argv)6 E F0(the whole ar)2.5 E -(gument list)-.18 E F1(optind)209 576 Q F0(pointer to the inde)2.5 E 2.5 -(xi)-.15 G 2.5(na)-2.5 G -.18(rg)-2.5 G 2.5(vw).18 G(here the \215ag is) --2.5 E F1(optarg)209 594 Q F0(pointer to the inde)2.5 E 2.5(xi)-.15 G -2.5(na)-2.5 G -.18(rg)-2.5 G(v[).18 E F3(*)A F0 -(optind] where the \215ag name starts)A F1(data)209 612 Q F0 -(application speci\214c data)2.5 E -1.1(Yo)209 630 S 3.915(uc)1.1 G -1.415(an modify)-3.915 F F3(*)3.915 E F1(optind)A F0 3.915(,a)C(nd) --3.915 E F3(*)3.915 E F1(optarg)A F0 3.915(,b)C 1.414 -(ut to do this correct you \(more or)-4.115 F(less\) ha)209 642 Q .3 --.15(ve t)-.2 H 2.5(ok).15 G(no)-2.5 E 2.5(wa)-.25 G(bout the inner w) --2.5 E(orkings of getar)-.1 E(g.)-.18 E -1.1(Yo)209 666 S 3.604(uc)1.1 G -1.104(an skip parts of ar)-3.604 F 1.105(guments by increasing)-.18 F F3 -(*)3.605 E F1(optarg)A F0 1.105(\(you could implement)3.605 F(the)209 -678 Q/F4 10/Courier-Bold@0 SF<ad7a>4.567 E F1(3)A F0 .401 -(set of \215ags from)2.901 F F4(gzip)2.9 E F0 .4 -(with this\), or whole ar)2.9 F .4(gument strings by increas-)-.18 F -(ing)209 690 Q F3(*)3.275 E F1(optind)A F0(\(let')3.275 E 3.276(ss)-.55 -G .776(ay you w)-3.276 F .776(ant a \215ag)-.1 F F4<ad63>4.942 E F1 -6.776(xyz)6.776 G F0 .776(to specify a coordinate\); if)-3.5 F -(you also ha)209 702 Q .3 -.15(ve t)-.2 H 2.5(os).15 G(et)-2.5 E F3(*) -2.5 E F1(optarg)A F0(to a sane v)2.5 E(alue.)-.25 E -.4(RO)77 750 S -152.325(KEN September).4 F(24, 1999)2.5 E(2)188.865 E EP -%%Page: 3 3 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(GET)72 48 Q -.834(ARG \( 3 \))-.93 F -(OpenBSD Programmer')111.062 E 2.5(sM)-.55 G 108.562(anual GET)-2.5 F --.834(ARG \( 3 \))-.93 F 9.449 -(The collect function should return one of)209 96 R/F1 10/Courier@0 SF -(ARG_ERR_NO_MATCH)11.948 E F0(,)A F1(ARG_ERR_BAD_ARG)209 108 Q F0(,)A F1 -(ARG_ERR_NO_ARG)6 E F0(on error)2.5 E 2.5(,z)-.4 G(ero otherwise.)-2.5 E --.15(Fo)209 126 S 4.042(ry).15 G 1.542(our con)-4.042 F -.15(ve)-.4 G -1.542(nience there is a function,).15 F/F2 10/Courier-Bold@0 SF -(getarg_optarg)4.042 E F0 1.542(\(\), that returns the)B 1.251 -(traditional ar)209 138 R 1.251(gument string, and you pass it all ar) --.18 F 1.251(guments, sans data, that where)-.18 F(gi)209 150 Q -.15(ve) --.25 G 2.5(nt).15 G 2.5(ot)-2.5 G(he collection function.)-2.5 E(Don') -209 168 Q 2.5(tu)-.18 G(se this more this unless you absolutely ha)-2.5 -E .3 -.15(ve t)-.2 H(o.).15 E .213(Option parsing is similar to what)102 -186 R F1(getopt)2.713 E F0 .214(uses. Short options without ar)2.714 F -.214(guments can be compressed \()-.18 F F2(\255xyz)1.666 E F0 .207 -(is the same as)102 198 R F2 1.873<ad7820ad7920ad7a>4.373 F F0 .207 -(\), and short options with ar)B .207(guments tak)-.18 F 2.706(et)-.1 G -.206(hese as either the rest of the ar)-2.706 F(gv-string)-.18 E -(or as the ne)102 210 Q(xt option \()-.15 E F2<ad6f>1.666 E/F3 10 -/Courier-Oblique@0 SF(foo)A F0 2.5(,o)C(r)-2.5 E F2<ad6f>4.166 E F3(foo) -6 E F0(\).)A .78(Long option names are pre\214x)102 228 R .781 -(ed with -- \(double dash\), and the v)-.15 F .781 -(alue with a = \(equal\),)-.25 F F2(\255-foo=)4.947 E F3(bar)A F0 3.281 -(.L)C(ong)-3.281 E 3.815 -(option \215ags can either be speci\214ed as the)102 240 R 6.315(ya)-.15 -G 3.815(re \()-6.315 F F2(\255-help)1.666 E F0 3.815 -(\), or with an \(boolean parsable\) option)B(\()102 252 Q F2 -(\255-help=)1.666 E F3(yes)A F0(,)A F2(\255-help=)5.659 E F3(true)A F0 -3.993(,o)C 3.993(rs)-3.993 G 1.493(imilar\), or the)-3.993 F 3.993(yc) --.15 G 1.493(an also be ne)-3.993 F -.05(ga)-.15 G 1.493(ted \().05 F F2 -(\255-no-help)1.666 E F0 1.493(is the same as)3.993 F F2(\255-help=) -103.666 264 Q F0 1.363(no\), and if you')B 1.362 -(re really confused you can do it multiple times \()-.5 F F2 -(\255-no-no-help=)1.666 E F3(false)A F0 3.862(,o)C(r)-3.862 E -2.15 -.25 -(ev e)102 276 T(n).25 E F2(\255-no-no-help=)4.166 E F3(maybe)A F0(\).)A -/F4 10/Times-Bold@0 SF(EXAMPLE)72 300 Q F1(#include <stdio.h>)102 330 Q -(#include <string.h>)102 342 Q(#include <getarg.h>)102 354 Q(char)102 -378 Q/F5 10/Symbol SF(*)6 E F1(source = "Ouagadougou";)A(char)102 390 Q -F5(*)6 E F1(destination;)A(int weight;)102 402 Q -(int include_catalog = 1;)102 414 Q(int help_flag;)102 426 Q -(struct getargs args[] = {)102 450 Q 6({")126 462 S 30(source", 's',)-6 -F 6(arg_string, &source,)6 F("source of shippment", "city" },)138 474 Q -6({")126 486 S(destination", 'd', arg_string,)-6 E(&destination,)12 E -("destination of shippment", "city" },)138 498 Q 6({")126 510 S 30 -(weight", 'w',)-6 F(arg_integer, &weight,)6 E -("weight of shippment", "tons" },)138 522 Q 6({")126 534 S 24 -(catalog", 'c',)-6 F(arg_negative_flag, &include_catalog,)6 E -("include product catalog" },)138 546 Q 6({")126 558 S 42(help", 'h',)-6 -F(arg_flag, &help_flag })6 E(};)102 570 Q -(int num_args = sizeof\(args\) / sizeof\(args[0]\); /)102 594 Q F5(*)A -F1(number of elements in args)6 E F5(*)6 E F1(/)A(const char)102 618 Q -F5(*)6 E F1(progname = "ship++";)A(int)102 642 Q(main\(int argc, char) -102 654 Q F5(**)6 E F1(argv\))A({)102 666 Q(int optind = 0;)126 678 Q -(if \(getarg\(args, num_args, argc, argv, &optind\)\) {)126 690 Q -(arg_printusage\(args, num_args, progname, "stuff..."\);)147 702 Q F0 --.4(RO)77 750 S 152.325(KEN September).4 F(24, 1999)2.5 E(3)188.865 E EP -%%Page: 4 4 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(GET)72 48 Q -.834(ARG \( 3 \))-.93 F -(OpenBSD Programmer')111.062 E 2.5(sM)-.55 G 108.562(anual GET)-2.5 F --.834(ARG \( 3 \))-.93 F/F1 10/Courier@0 SF(exit \(1\);)147 96 Q(})126 -108 Q(if \(help_flag\) {)126 120 Q -(arg_printusage\(args, num_args, progname, "stuff..."\);)147 132 Q -(exit \(0\);)147 144 Q(})126 156 Q(if \(destination == NULL\) {)126 168 -Q(fprintf\(stderr, "%s: must specify destination0, progname\);)147 180 Q -(exit\(1\);)147 192 Q(})126 204 Q -(if \(strcmp\(source, destination\) == 0\) {)126 216 Q -(fprintf\(stderr, "%s: destination must be different from source0\);)147 -228 Q(exit\(1\);)147 240 Q(})126 252 Q(/)126 264 Q/F2 10/Symbol SF(*)A -F1(include more stuff here ...)6 E F2(*)6 E F1(/)A(exit\(2\);)126 276 Q -(})102 288 Q F0(The output help output from this program looks lik)102 -306 Q 2.5(et)-.1 G(his:)-2.5 E F1 6($s)102 324 S(hip++ --help)-6 E -(Usage: ship++ [--source=city] [-s city] [--destination=city] [-d city]) -102 336 Q -([--weight=tons] [-w tons] [--no-catalog] [-c] [--help] [-h] stuff...) -120 348 Q(-s city, --source=city)102 360 Q(source of shippment)36 E -(-d city, --destination=city destination of shippment)102 372 Q -(-w tons, --weight=tons)102 384 Q(weight of shippment)36 E -(-c, --no-catalog)102 396 Q(include product catalog)72 E/F3 10 -/Times-Bold@0 SF -.1(BU)72 432 S(GS).1 E F0 .9(It should be more \215e) -102 444 R .9(xible, so it w)-.15 F .901 -(ould be possible to use other more complicated option syntax)-.1 F .901 -(es, such as)-.15 F(what)102 456 Q F1(ps)3.167 E F0 .667(\(1\), and)B F1 -(tar)3.167 E F0 .666(\(1\), uses, or the AFS model where you can skip t\ -he \215ag names as long as the options)B(come in the correct order)102 -468 Q(.)-.55 E(Options with multiple ar)102 486 Q -(guments should be handled better)-.18 E(.)-.55 E(Should be inte)102 504 -Q(greated with SL.)-.15 E(It')102 522 Q 2.5(sv)-.55 G -(ery confusing that the struct you pass in is called getar)-2.65 E(gS.) --.18 E F3 1.666(SEE ALSO)72 546 R F1(getopt)102 558 Q F0(\(3\))A -.4(RO) -77 750 S 152.325(KEN September).4 F(24, 1999)2.5 E(4)188.865 E EP -%%Trailer -end -%%EOF |