aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstddjb/gol_argv.c
blob: 9e648e3f0011ed1ed23c4b579dac7232537d237d (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
/* ISC license. */

#include <skalibs/gol.h>
#include <skalibs/strerr.h>

unsigned int gol_argv (char const *const *argv, gol_bool const *b, unsigned int bn, gol_arg const *a, unsigned int an, uint64_t *br, char const **ar)
{
  int problem = 0 ;
  int r = gol(argv, b, bn, a, an, br, ar, &problem) ;

  if (r < 0)
  {
    if (problem > 0)
    {
      char s[2] = { argv[-r-1][problem], 0 } ;
      strerr_dief4x(100, "unrecognized ", "short ", "option: ", s) ;
    }
    else if (!problem)
      strerr_dief3x(100, "invalid ", "option: ", argv[-r-1]) ;
    else if (problem == -1)
      strerr_dief4x(100, "unrecognized ", "boolean ", "option: ", argv[-r-1]) ;
    else
      strerr_dief3x(100, "unrecognized ", "option with argument: ", argv[-r-1]) ;
  }
  else return r ;
}