home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_08 / NEO4REL5.LZH / NEO4REL5.MSA / JARXXX / JARTEST.C < prev    next >
C/C++ Source or Header  |  1992-11-17  |  1KB  |  43 lines

  1. #include "tos.h"
  2. #include "stdio.h"
  3.  
  4. /* Test program to show the functions of JARxxx. Much of this can be
  5.    simplified for real applications. */
  6.  
  7. #define CJar_cookie    0x434A6172L    /* "CJar" */
  8. #define CJar_xbios    0x434A        /* "CJ" */
  9. #define    CJar_OK        0x6172        /* "ar" */
  10.  
  11. #define my_cookie    0x74657374    /* "test" */
  12.  
  13. #define CJar( mode, cookie, value )    xbios(CJar_xbios,mode,cookie,value)
  14.  
  15. int main(void)
  16. {
  17.   long CJ_data, my_data=0x12345678;
  18.   int ret;
  19.   
  20.   ret = CJar( 0, CJar_cookie, &CJ_data );    /* is it there? */
  21.   if( ret == CJar_OK )                /* yes, print data */
  22.   {
  23.     printf( "JARxxx Version: %d\n%d entries requested by user\n\
  24. %d allocated, %d in use\n\n", (char)(CJ_data>>24), (char)(CJ_data>>16),
  25. (char)(CJ_data>>8), (char)CJ_data );
  26.     ret = CJar( 1, my_cookie, &my_data );    /* make test cookie */
  27.     if( ret==CJar_OK )                /* successful */
  28.     {
  29.       ret = CJar( 0, my_cookie, &CJ_data );
  30.       if( ret==CJar_OK )
  31.       {
  32.         if( CJ_data==my_data ) printf( "Test OK" );
  33.         else printf( "Test failed" );
  34.       }
  35.       else printf( "Could not find my new cookie!" );
  36.     }
  37.     else if( ret==-1 ) printf( "No room in cookie jar" );
  38.     else printf( "Unknown error" );
  39.   }
  40.   else printf( "JARxxx not installed." );
  41.   return ret;
  42. }
  43.