Annotation of q_a/samples/readwrit/readwrit.c, revision 1.1

1.1     ! root        1: #define STRICT
        !             2: #define NOMINMAX
        !             3: #include <windows.h>
        !             4: #include <stdlib.h>
        !             5: #include <stdio.h>
        !             6: #include <string.h>
        !             7: 
        !             8: #include "DataBase.h"
        !             9: 
        !            10: VOID Read ( PSZ psz ) ;
        !            11: VOID Write ( PSZ psz ) ;
        !            12: 
        !            13: #define MAX 100
        !            14: 
        !            15: /*
        !            16:  * This is a simple driver to test my database dll's ability to handle
        !            17:  * multiple read's and writes without corrupting the database.
        !            18:  *
        !            19:  */
        !            20: 
        !            21: 
        !            22: 
        !            23: void main( void )
        !            24: {
        !            25:     char psz[20], psztmp[10] ;
        !            26:     int  i ;
        !            27:     DWORD idThread ;
        !            28: 
        !            29:     printf ( "\nStart of program\n" ) ;
        !            30: 
        !            31: /*
        !            32:  * Create the reader/writers to stress the database
        !            33:  *
        !            34:  */
        !            35: 
        !            36:     for ( i=1; i<=MAX; i++ )
        !            37:     {
        !            38:         strcat (strcpy ( psz,"In Thread #" ),itoa( i,psztmp, 10)) ;
        !            39:         CreateThread ( NULL, 0, (LPTHREAD_START_ROUTINE)Write,psz, 0,
        !            40:                  &idThread ) ;
        !            41: 
        !            42:         CreateThread ( NULL, 0, (LPTHREAD_START_ROUTINE)Read, psz, 0,
        !            43:                  &idThread ) ;
        !            44: 
        !            45:         Sleep( 0 ) ;                        // Relinquish timeslice
        !            46:         printf ( "psz = %s\n", psz ) ;      // Print result of the test
        !            47:     }
        !            48: 
        !            49:     printf ( "\nEnd of program\n" ) ;
        !            50: 
        !            51:     exit ( EXIT_SUCCESS ) ;
        !            52: }
        !            53: 
        !            54: 
        !            55: VOID Read ( PSZ psz )
        !            56: {
        !            57:   ReadDataBase ( psz, NULL ) ;
        !            58: }
        !            59: 
        !            60: VOID Write ( PSZ psz )
        !            61: {
        !            62: 
        !            63:   WriteDataBase ( psz, NULL ) ;
        !            64: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.