patched suckless dmenu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

arg.h 1011B

5 months ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copy me if you can.
  3. * by 20h
  4. */
  5. #ifndef ARG_H__
  6. #define ARG_H__
  7. extern char *argv0;
  8. /* use main(int argc, char *argv[]) */
  9. #define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
  10. argv[0] && argv[0][0] == '-'\
  11. && argv[0][1];\
  12. argc--, argv++) {\
  13. char argc_;\
  14. char **argv_;\
  15. int brk_;\
  16. if (argv[0][1] == '-' && argv[0][2] == '\0') {\
  17. argv++;\
  18. argc--;\
  19. break;\
  20. }\
  21. for (brk_ = 0, argv[0]++, argv_ = argv;\
  22. argv[0][0] && !brk_;\
  23. argv[0]++) {\
  24. if (argv_ != argv)\
  25. break;\
  26. argc_ = argv[0][0];\
  27. switch (argc_)
  28. #define ARGEND }\
  29. }
  30. #define ARGC() argc_
  31. #define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\
  32. ((x), abort(), (char *)0) :\
  33. (brk_ = 1, (argv[0][1] != '\0')?\
  34. (&argv[0][1]) :\
  35. (argc--, argv++, argv[0])))
  36. #define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\
  37. (char *)0 :\
  38. (brk_ = 1, (argv[0][1] != '\0')?\
  39. (&argv[0][1]) :\
  40. (argc--, argv++, argv[0])))
  41. #endif