home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilsc / computils / !CompUtils / Resources / ExpCode / cc / c / Example
Encoding:
Text File  |  1995-07-31  |  1.6 KB  |  68 lines

  1. /* Note - this is designed for Easy C, so changes changes may be needed */
  2. #include <roslib.h>
  3.  
  4. #include "CompUtils:ExpCode.cc.h.Universal"
  5. #include <stdlib.h>
  6. #include <stdio.h>
  7.  
  8.  
  9. #define INFILE "RAM:$.Infile"
  10. #define OUTFILE "RAM:$.Outfile"
  11.  
  12. #define IBUFF (10*1024)
  13.  
  14. main()
  15. {
  16.     os_error    *errorptr;
  17.     char        filename[] = INFILE;
  18.     os_filestr  fs; /* Easy C only? */
  19.  
  20.     /* Claim the source buffer */
  21.     ExpCode_SrcBufferPtr = malloc(IBUFF);
  22.     ExpCode_SrcLength = IBUFF;
  23.  
  24.     /* Set up filename pointer */
  25.     ExpCode_FilenamePtr = filename;
  26.  
  27.     /* Set up output flags for 8-bit linear, not enhanced */
  28.     ExpCode_OutputFlags = 0x00;
  29.  
  30.     /* Finally, set up offset into file */
  31.     ExpCode_DataOffset = 0;
  32.  
  33.     /* Call initialisation routine and display any errors */
  34.     errorptr = ExpCode_Init();
  35.     if (errorptr)
  36.     {
  37.         printf("Error: %s\n", errorptr->errmess);
  38.         exit(1);
  39.     }
  40.  
  41.     /* Claim destination buffer */
  42.     ExpCode_DestBufferPtr = malloc(ExpCode_SampleLength);
  43.     ExpCode_DestLength = ExpCode_SampleLength;
  44.  
  45.     /* Process the sample */
  46.     errorptr = ExpCode_Process();
  47.     if (errorptr)
  48.     {
  49.         printf("Error: %s\n", errorptr->errmess);
  50.         exit(1);
  51.     }
  52.  
  53.     /* Save output to file - may be Easy C specific */
  54.     fs.action = 10;
  55.     fs.objname = OUTFILE;
  56.     fs.loadaddr = 0xffd; /* filetype = Data */
  57.     fs.startaddr = (int)ExpCode_DestBufferPtr;
  58.     fs.endaddr = fs.startaddr + ExpCode_SampleLength;
  59.     errorptr = os_file(&fs);
  60.     if (errorptr)
  61.     {
  62.         printf("Error: %s\n", errorptr->errmess);
  63.         exit(1);
  64.     }
  65.  
  66.     /* All done - no need to free the buffers in this case */
  67. }
  68.