sgetopt.c (582B)
1 /* ISC license. */ 2 3 /* MT-unsafe */ 4 5 #undef SUBGETOPT_SHORT 6 7 #include <skalibs/buffer.h> 8 #include <skalibs/sgetopt.h> 9 10 int sgetopt_r (int argc, char const *const *argv, char const *opts, subgetopt *o) 11 { 12 int c = subgetopt_r(argc, argv, opts, o) ; 13 if (o->err && ((c == '?') || (c == ':'))) 14 { 15 buffer_puts(buffer_2, o->prog ? o->prog : argv[0]) ; 16 buffer_put(buffer_2, ": ", 2) ; 17 buffer_puts(buffer_2, ((c == '?') && argv[o->ind] && (o->ind < argc)) ? 18 "illegal option" : "option requires an argument") ; 19 buffer_putflush(buffer_2, "\n", 1) ; 20 } 21 return c ; 22 }