home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / wvhtm064.zip / notes / convert-to-struct / wv-get-c.awk < prev    next >
Text File  |  2000-09-02  |  2KB  |  65 lines

  1. #!/bin/awk -f
  2. {
  3. if ((dup == $5) && (dup != "Bitfield"))
  4.     printf("/*error, dup offset of above line*/ ");
  5. dup = $5
  6. if (match($2,":"))
  7.     {
  8.     if (bitmode != 1)
  9.         {
  10.         type = $1;
  11.         if ((type == "U16") || (type == "S16"))
  12.             printf("temp16 = dread_16ubit(fd,pointer);\n");
  13.         else if ((type == "U8") || (type == "S8"))
  14.             printf("temp8 = dgetc(fd,pointer);\n");
  15.         else if ((type == "U32") || (type == "S32"))
  16.             printf("temp32 = dread_32ubit(fd,pointer);\n");
  17.         }
  18.     split($2,a,"[:]");
  19.     if (bitmode != 1)
  20.         {
  21.         if ((type == "U16") || (type == "S16"))
  22.             printf("item->"a[1]" = (temp16 & "$6");\n");
  23.         else if ((type == "U8") || (type == "S8"))
  24.             printf("item->"a[1]" = (temp8 & "$6");\n");
  25.         else if ((type == "U32") || (type == "S32"))
  26.             printf("item->"a[1]" = (temp32 & "$6");\n");
  27.         apple = a[2] + 0;
  28.         }
  29.     else
  30.         {
  31.         if ((type == "U16") || (type == "S16"))
  32.             printf("item->"a[1]" = (temp16 & "$6") >> "apple";\n");
  33.         else if ((type == "U8") || (type == "S8"))
  34.             printf("item->"a[1]" = (temp8 & "$6") >> "apple";\n");
  35.         else if ((type == "U32") || (type == "S32"))
  36.             printf("item->"a[1]" = (temp32 & "$6") >> "apple";\n");
  37.         apple = apple + a[2];
  38.         }
  39.     bitmode=1;
  40.     }
  41. else
  42.     {
  43.     bitmode=0;
  44.     if ($1 == "U16")
  45.         printf("item->"$2" = dread_16ubit(fd,pointer);\n")
  46.     else if ($1 == "U32")
  47.         printf("item->"$2" = dread_32ubit(fd,pointer);\n")
  48.     else if ($1 == "U8")
  49.         printf("item->"$2" = dgetc(fd,pointer);\n")
  50.     else if ($1 == "S16")
  51.         printf("item->"$2" = (S16)dread_16ubit(fd,pointer);\n")
  52.     else if ($1 == "S32")
  53.         printf("item->"$2" = (S32)dread_32ubit(fd,pointer);\n")
  54.     else if ($1 == "S8")
  55.         printf("item->"$2" = (S8)dgetc(fd,pointer);\n")
  56.     else
  57.         {
  58.         printf("if (fd != NULL)\n");
  59.         printf("    wvGet"$1"(&item->"$2",fd);\n")
  60.         printf("else\n");
  61.         printf("    wvGet"$1"FromBucket(&item->"$2",pointer);\n")
  62.         }
  63.     }
  64. }
  65.