summaryrefslogtreecommitdiffstats
path: root/getopt.h
blob: fef745f783461929b1bad56adb17c01917c91c5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef GETOPT_H
#define GETOPT_H

/* None of these constants are referenced in the executable portion of */
/* the code ... their sole purpose is to initialize global variables.  */
/* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
#define BADCH (int)'@'
#define NEEDSEP (int)':'
#define MAYBESEP (int)'%'
#define ERRFD 2
#define EMSG ""
#define START "-"

/* Conditionally print out an error message and return (depends on the */
/* setting of 'opterr' and 'opterrfd').  Note that this version of     */
/* TELL() doesn't require the existence of stdio.h.                    */
/* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
#define TELL(S)                                       \
  {                                                   \
    ssize_t dummy_rc;                                 \
    if (eopterr && eopterrfd >= 0)                    \
    {                                                 \
      char option = (char)eoptopt;                    \
      dummy_rc    = write(eopterrfd, (S), strlen(S)); \
      dummy_rc    = write(eopterrfd, &option, 1);     \
      dummy_rc    = write(eopterrfd, "\n", 1);        \
    }                                                 \
  }

int
egetopt(int nargc, char ** nargv, char * ostr);

#endif