slstatus

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.beauhilton.com/slstatus.git
Log | Files | Refs | README | LICENSE

arg.h (1697B)


      1 /* See LICENSE file for copyright and license details. */
      2 #ifndef ARG_H
      3 #define ARG_H
      4 
      5 extern char *argv0;
      6 
      7 /* int main(int argc, char *argv[]) */
      8 #define ARGBEGIN for (argv0 = *argv, *argv ? (argc--, argv++) : ((void *)0);      \
      9                       *argv && (*argv)[0] == '-' && (*argv)[1]; argc--, argv++) { \
     10                  	int i_, argused_;                                         \
     11                  	if ((*argv)[1] == '-' && !(*argv)[2]) {                   \
     12                  		argc--, argv++;                                   \
     13                  		break;                                            \
     14                  	}                                                         \
     15                  	for (i_ = 1, argused_ = 0; (*argv)[i_]; i_++) {           \
     16                  		switch((*argv)[i_])
     17 #define ARGEND   		if (argused_) {                                   \
     18                  			if ((*argv)[i_ + 1]) {                    \
     19                  				break;                            \
     20                  			} else {                                  \
     21                  				argc--, argv++;                   \
     22                  				break;                            \
     23                  			}                                         \
     24                  		}                                                 \
     25                  	}                                                         \
     26                  }
     27 #define ARGC()   ((*argv)[i_])
     28 #define ARGF_(x) (((*argv)[i_ + 1]) ? (argused_ = 1, &((*argv)[i_ + 1])) :        \
     29                   (*(argv + 1))     ? (argused_ = 1, *(argv + 1))        : (x))
     30 #define EARGF(x) ARGF_(((x), exit(1), (char *)0))
     31 #define ARGF()   ARGF_((char *)0)
     32 
     33 #endif