All pastes #270553 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-12-07 13:55 UTC
rendered paste body
typedef struct  s_ops
{
  int   a;
  int   A;
  int   m;
  int   z;
  int   t;
}       t_ops;



void    init(t_ops *ops)
{
    ops->a = 0;
    ops->A = 0;
    ops->m = 0;
    ops->z = 0;
    ops->t = 0;
}

int     verifnbr(char *nbr)
{
  char    test[] = "-0123456789";
  int   i;
  int   j;
  int   tem;

  for (i = 0; nbr[i]; i++)
    {
      tem = 0;
      if (nbr[i] == '-' && i != 0)
        return (0);
      for (j = 0; test[j]; j++)
        if (nbr[i] == test[j])
          tem = 1;
      if (tem == 0)
        return (0);
    }
  return (1);
}

void    getop(t_ops *ops, char **argv)
{
  int   i;
  int   j;

  init(ops);
  i = 1;
  while (verifnbr(argv[i]) == 0 && argv[i][0] == '-')
    {
      j = 0;
      while (argv[i][j])
        {
          if (argv[i][j] == 'a')
            ops->a = 1;
          if (argv[i][j] == 'A')
            ops->A = 1;
          if (argv[i][j] == 'm')
            ops->m = 1;
          if (argv[i][j] == 'z')
            ops->z = 1;
          if (argv[i][j] == 't')
            ops->t = 1;
          j++;
        }
      i++;
    }
}