skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

gol_argv.c (697B)


      1 /* ISC license. */
      2 
      3 #include <string.h>
      4 
      5 #include <skalibs/gol.h>
      6 #include <skalibs/strerr.h>
      7 
      8 unsigned int gol_argv (int argc, char const *const *argv, gol_bool const *b, unsigned int bn, gol_arg const *a, unsigned int an, uint64_t *br, char const **ar)
      9 {
     10   int problem = 0 ;
     11   int r ;
     12   if (!argc) strerr_diefu1x(100, "gol: invalid argv") ;
     13   if (argc == 1) return 1 ;
     14   r = gol(argv + 1, argc - 1, b, bn, a, an, br, ar, &problem) ;
     15 
     16   if (r < 0)
     17   {
     18     if (problem >= 0)
     19     {
     20       char s[2] = { argv[-r][problem], 0 } ;
     21       strerr_dief4x(100, "unrecognized ", "short", "option: ", s) ;
     22     }
     23     else strerr_dief3x(100, "unrecognized ", "option: ", argv[-r]) ;
     24   }
     25   else return r + 1 ;
     26 }