home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser-CD 2001 January / LCD_01_2001.iso / develop / dhst / c / dhsttest.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-01  |  1.7 KB  |  75 lines

  1. /* Filename                    : Dhsttest.c - Example for use of dhst.c
  2.  * Number of functions    : 1.1
  3.  * Version                    : ?
  4.  * Author                    : Nicolas Richeton - trashman@netcourrier.com
  5.  * Last update                : 16/02/2000
  6.  * Statut                    : Freeware
  7.  * Downloaded from        : http://www.geocities.com/SiliconValley/Hills/2239/apc
  8.  * Comments                    : Add a document "Test " to document history
  9.  * History                    : 16/02/2000 - First version
  10.  */
  11.  
  12. #include    <mgx_dos.h>
  13. #include <mt_aes.h>
  14. #include <portab.h>
  15. #include    <stdio.h>
  16. #include <string.h>
  17. #include "dhst.h"
  18. #include    <stdlib.h>
  19.  
  20. #ifndef NULL
  21. #define NULL        ((void *)0L)
  22. #endif
  23. char    *File_GetFullName( char *dest, char *src );
  24.  
  25.  
  26. VOID main (WORD argc, const UBYTE *argv[])
  27. {
  28.     WORD ap_id;
  29.     UWORD    msg[8];
  30.     ULONG    count = 0;
  31.     UBYTE    buf[1024];
  32.     UBYTE    path[1024];
  33.     
  34.     ap_id = appl_init();
  35.     path[0] = 'A' + Dgetdrv();
  36.     path[1] = 0;
  37.     Dgetpath( buf, 0 );
  38.     strcat( path, buf );
  39.     strcpy( buf, getenv( "_PNAM" ) );
  40.     strcat( path, "\\" );
  41.     strcat( path, buf );
  42.     printf( "\n%s", path );
  43.     if( ( ( count = DHST_init( ap_id ) ) == 0) && ( argc > 1 ) )
  44.     {
  45.         printf( "\nAdding %s", argv[1] );
  46.         count = DHST_write( ap_id, count, "DHSTTest", path, File_GetFullName( buf, argv[1] ), argv[1] );
  47.         while( count != 0 )
  48.         {
  49.             evnt_mesag( (WORD *)msg );
  50.             count = DHST_evnt_ack( ap_id, count, msg[0], msg[3], msg[4] );    
  51.         } 
  52.         DHST_exit( ap_id, count );
  53.     }
  54.     appl_exit();
  55. }
  56.  
  57. char    *File_GetFullName( char *dest, char *src )
  58. {
  59.     long j = 0; 
  60.     long i = strlen( src ) - 1;
  61.     
  62.     strcpy( dest, "" );
  63.     while( (i >= 0) && (src[i] != '\\') )
  64.         i--;
  65.  
  66.     j = i;
  67.     for( i++; i < strlen( src ); i++ )
  68.     {
  69.         dest[i-j-1] = src[i];
  70.     }
  71.     dest[i-j-1] = 0;
  72.  
  73.     return( dest );    
  74. }
  75.