home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / ABERMUD.ZIP / OGEN.C < prev    next >
C/C++ Source or Header  |  1989-07-08  |  1KB  |  73 lines

  1. #include <stdio.h>
  2.  
  3. main()
  4. {
  5. saveout(loadup());
  6. }
  7.  
  8. long blob[10000];
  9.  
  10. saveout(n)
  11. {
  12. FILE *a;
  13. extern long blob[];
  14. a=fopen("ob.out","w");
  15. sec_write(a,blob,0,n);
  16. fclose(a);
  17. }
  18.  
  19. loadup()
  20. {
  21. FILE *a;
  22. auto b;
  23. auto ctt;
  24. extern long blob[];
  25. char c[128];
  26. b=0;
  27. ctt=0;
  28. a=fopen("ob.in","r");
  29. while(fgets(c,127,a))
  30. {
  31. if(ctt%4==2) blob[b++]=flags(c);
  32. else
  33. blob[b++]=numarg(c);
  34. ctt++;
  35. }
  36. fclose(a);
  37. return(b);
  38. }
  39.  
  40. flags(str)
  41. char *str;
  42. {
  43. char s2[16],s3[16],s4[128];
  44. long ps;
  45. long res;
  46. char *i;
  47. i=(char *)&res; /* Arggghh urk throw up barf etc - such is B->C conversion */
  48. ps=scan(s2,str,0,"",":");
  49. ps=scan(s3,str,ps,":",":");
  50. ps=scan(s4,str,ps,":","");
  51. printf("Input line is %d\n",str);
  52. res=binproc(s4)<<16; /* highest bits */
  53. res|=numarg(s2)<<8; /* Chars in lowest 16 bits */
  54. res|=numarg(s3);
  55. printf("Result=%d\n",res);
  56. return(res);
  57. }
  58.  
  59. binproc(str)
  60. char *str;
  61. {
  62. long a,b,c;
  63. a=0;
  64. b=0;
  65. while((str[a])&&(str[a]!='\n'))
  66. {
  67. b=b*2+(str[a]-'0');
  68. a++;
  69. }
  70. printf("Binproc of %s is %d\n",str,b);
  71. return(b);
  72. }
  73.