Guest User

twio.c

a guest
Oct 2nd, 2020
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.80 KB | None | 0 0
  1. //twio.c
  2. #include <ctype.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #define                                               r \
  6.                                                     return
  7. #define                                           err(...)fprintf\
  8.                                        (stderr, __VA_ARGS__) /****/
  9.                               #define dsp(...)  printf(__VA_ARGS__)/**/
  10.   #define ofo(t,e) ((size_t) &(((t *)0)->e))  /*        ****           ***/
  11. typedef        char c;           typedef const          void*            cvp;
  12. typedef          int i;             typedef              char*             cp;
  13. typedef           struct              {c t[64]           ;c                   a
  14. [0x40];              c d               [0x40];           }E;                  E*
  15.  ntrz;                i                 off[3]           ;                    c
  16.   asc                 =                  0; c no=0;i j,k,                     l,
  17.     m;                i                  cmpfunc(cvp a,cvp                     b
  18.       ){             for                  (j =0;j<no;j++)                      {
  19.        cp          t1=(                 (cp)((E*)a)+off[j]); cp t2=((cp)((E*)b)+
  20.       off        [j]);  for(;(*t1)&&(*t1==*t2);      t1++,t2     ++)  ;
  21.       l=*(         cp)t1     /**/-*(cp)            t2;/*####*/      m=(
  22.       asc >>     j)?1:      /*#####*/-1;           if/*#####*/       (l
  23.       !=    0)  r l         /*######*/*m;          }r/*#####*/       0;
  24.      }      i   par         /*#######*/(i          n,/*#####*/       cp
  25.      v     []   ) {          /*#######*/k          =/*######*/       0;
  26.      l     =0    ;m           /*######*/=          0/*#####*/        ;;
  27.     for    (j    =2             /*####*/;          j/*###*/         <n;
  28.     j        ++   ){                    i          e               = 0;
  29.     if        ( v  [j]                 [0           ]           !='-')
  30.     continue      ;    switch ( tolower              ( v [j][1]))   {
  31.     case           't'                    :        k++             ;
  32.     e               =                                            ofo
  33.     (E               ,                 t             )           ;
  34.     break             ;                 case      'a'          :
  35.      l++;               e=                 ofo(E,a)          ;
  36.       break               ;case                           'd'
  37.        :m++;                  e =                     ofo
  38.          (E,d);                   break ; default : err
  39.          ("Unknown classifier '%c'"   ,            v[j]
  40.           [1]);                    r 0;              }
  41.            if (k > 1 || l > 1 || m > 1)             {err
  42.            ("Duplicate categorization");            r 0;
  43.             }i a=(islower(v[j][1]))?1:0;            off
  44. [j-2] = e; asc |= a << (j-2); no++; } r 1; } i main(i n, char* v[]) { if (n<3) {
  45. err("Not enough arguments\n"); r-1; } FILE*f; if((f = fopen(v[1],"r")) == NULL){
  46. err           ("Error opening file\n") ;     r -1; } cp line = NULL ;     size_t
  47. l=0/*  /*S*/   ;i ne=0; for(c C=getc(f);    C !=EOF;C=getc(f) ) if (C    =='\n')  
  48. ne++;  /*P*/   ntrz = malloc(sizeof(E) *    ne) ;fseek(f, 0, SEEK_SET)   ;j = 0;
  49. while  /*I*/   (getline(&line,&l,f)!=-1)    { sscanf(line, "%[^/]/%[^"   "/]/%["
  50. "^/]"          ,ntrz     [j].t,     ntrz    [j]     .a,ntrz    [j].d);   for(l=0
  51. ;ntrz          [j]  /**/   .d  /**/  [l]          !='\0';          l++   ); ntrz
  52. [j].d  /*K*/   [l-  /**/   1]  /**/  =0;        j++ ; } ;    fclose(f)   ; if (!
  53. par(n  /*E*/   ,v)  /**/   )r  /**/  -1;          qsort(ntrz ,      ne   ,sizeof
  54. (E)/*  /*!*/   /*\      .*/,/*.    OWLC$    36*/    cmpfunc);for   ( j=0;j < ne;
  55. j++           ){dsp("%s/%s/%s\n",ntrz[j].t, ntrz[j].a,ntrz       [j].d   );}free
  56. (ntrz);r 0;}/* Library Program; (c) Anonymous. License: http://www.wtfpl.net/ */
  57.  
  58.  
Add Comment
Please, Sign In to add comment