gethopt.h 918 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * gethopt; options processing with both single-character and whole-work
  3. * options both introduced with -
  4. */
  5. #ifndef __GETHOPT_D
  6. #define __GETHOPT_D
  7. #include <stdio.h>
  8. #include <string.h>
  9. struct h_opt {
  10. int option;
  11. char *optword;
  12. char optchar;
  13. char *opthasarg;
  14. char *optdesc;
  15. } ;
  16. #define HOPTERR ((struct h_opt*)-1)
  17. struct h_context {
  18. char **argv;
  19. int argc;
  20. int optchar;
  21. int optind;
  22. char *optarg;
  23. char optopt;
  24. int opterr:1;
  25. int optend:1;
  26. } ;
  27. extern char *hoptarg(struct h_context *);
  28. extern int hoptind(struct h_context *);
  29. extern char hoptopt(struct h_context *);
  30. extern void hoptset(struct h_context *, int, char **);
  31. extern int hopterr(struct h_context *, int);
  32. extern struct h_opt *gethopt(struct h_context *, struct h_opt*, int);
  33. extern void hoptusage(char *, struct h_opt*, int, char *);
  34. #endif/*__GETHOPT_D*/