CVS: seamlessrdp/ClientDLL clipper.cpp,1.5,1.6 clipper.h,1.5,1.6 hash.cpp,1.4,1.5 hash.h,1.4,1.5 stdstring.h,1.5,1.6 tokenizer.cpp,1.4,1.5 tokenizer.h,1.4,1.5 windowdata.cpp,1.5,1.6 windowdata.h,1.5,1.6

Peter Åstrand <[email protected]>
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/seamlessrdp/ClientDLL
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10751/ClientDLL

Modified Files:
	clipper.cpp clipper.h hash.cpp hash.h stdstring.h 
	tokenizer.cpp tokenizer.h windowdata.cpp windowdata.h 
Log Message:
Indenting with the CVS version of astyle

Index: clipper.cpp
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ClientDLL/clipper.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** clipper.cpp	1 Jul 2005 07:00:59 -0000	1.5
--- clipper.cpp	28 Aug 2005 12:56:37 -0000	1.6
***************
*** 7,29 ****
  #include "clipper.h"
  
! BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
  {
!     UNREFERENCED_PARAMETER(lpvReserved);
!     UNREFERENCED_PARAMETER(hinstDLL);
! 
!     switch (fdwReason) {
!     case DLL_PROCESS_ATTACH:
          break;
[...1085 lines suppressed...]
          }
      }
!     
!     if ( classAlreadyRegistered = 1 ) {
          HWND hWnd =
!             CreateWindow( TEXT( "WTSWinClipperDummy" ), wd->GetTitle(), WS_POPUP,
!                           0, 0, 0, 0, 0, 0, 0, 0 );
!         ShowWindow( hWnd, 3 );
!         SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOREDRAW );
          wd->TaskbarWindowHandle = hWnd;
!         SetFocus( m_mainWindowHandle );
      }
  }
  
! void DestroyTaskbarWindow( CWindowData * wd )
  {
!     if ( wd->TaskbarWindowHandle != NULL ) {
!         DestroyWindow( wd->TaskbarWindowHandle );
      }
  }

Index: clipper.h
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ClientDLL/clipper.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** clipper.h	1 Jul 2005 07:00:59 -0000	1.5
--- clipper.h	28 Aug 2005 12:56:37 -0000	1.6
***************
*** 62,75 ****
  // declarations
  //
! void WINAPI VirtualChannelOpenEvent(DWORD openHandle, UINT event,
!                                     LPVOID pdata, UINT32 dataLength,
!                                     UINT32 totalLength, UINT32 dataFlags);
! VOID VCAPITYPE VirtualChannelInitEventProc(LPVOID pInitHandle, UINT event,
!         LPVOID pData, UINT dataLength);
! BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints);
  
! void DoClipping(int forceRedraw);
! void CreateRegionFromWindowData(char *, void *);
  
! void CreateAndShowWindow(CWindowData * wd);
! void DestroyTaskbarWindow(CWindowData * wd);
--- 62,75 ----
  // declarations
  //
! void WINAPI VirtualChannelOpenEvent( DWORD openHandle, UINT event,
!                                      LPVOID pdata, UINT32 dataLength,
!                                      UINT32 totalLength, UINT32 dataFlags );
! VOID VCAPITYPE VirtualChannelInitEventProc( LPVOID pInitHandle, UINT event,
!         LPVOID pData, UINT dataLength );
! BOOL VCAPITYPE VirtualChannelEntry( PCHANNEL_ENTRY_POINTS pEntryPoints );
  
! void DoClipping( int forceRedraw );
! void CreateRegionFromWindowData( char *, void * );
  
! void CreateAndShowWindow( CWindowData * wd );
! void DestroyTaskbarWindow( CWindowData * wd );

Index: hash.cpp
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ClientDLL/hash.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** hash.cpp	1 Jul 2005 06:50:52 -0000	1.4
--- hash.cpp	28 Aug 2005 12:56:37 -0000	1.5
***************
*** 1,4 ****
  #include <string.h>
! #include <stdlib.h>
  /* #define NDEBUG */
  #include <assert.h>
--- 1,4 ----
  #include <string.h>
! #include <stdlib.h> 
  /* #define NDEBUG */
  #include <assert.h>
***************
*** 38,42 ****
        when not defined, hash_insert swaps the datapointers, returning a
        pointer to the old data
! */
  /* #define DUPLICATE_KEYS */
  
--- 38,42 ----
        when not defined, hash_insert swaps the datapointers, returning a
        pointer to the old data
! */ 
  /* #define DUPLICATE_KEYS */
  
***************
*** 45,49 ****
  ** something a little less grungy, but it works, so what the heck.
   */
! static void (*function) (void *) = NULL;
  static hash_table *the_table = NULL;
  
--- 45,49 ----
  ** something a little less grungy, but it works, so what the heck.
   */
! static void ( *function ) ( void * ) = NULL;
  static hash_table *the_table = NULL;
  
***************
*** 53,76 ****
  ** can't allocate sufficient memory, signals error by setting the size
  ** of the table to 0.
! */
  /*HW: changed, now returns NULL on malloc-failure */
! hash_table *hash_construct_table(hash_table * table, size_t size)
  {
      size_t i;
      bucket **temp;
! 
      table->size = size;
      table->count = 0;
!     table->table = (bucket **) malloc(sizeof(bucket *) * size);
      temp = table->table;
! 
!     if (NULL == temp) {
          table->size = 0;
          return NULL;            /*HW: was 'table' */
      }
! 
!     for (i = 0; i < size; i++)
!         temp[i] = NULL;
! 
      return table;
  }
--- 53,76 ----
  ** can't allocate sufficient memory, signals error by setting the size
  ** of the table to 0.
! */ 
  /*HW: changed, now returns NULL on malloc-failure */
! hash_table *hash_construct_table( hash_table * table, size_t size )
  {
      size_t i;
      bucket **temp;
!     
      table->size = size;
      table->count = 0;
!     table->table = ( bucket ** ) malloc( sizeof( bucket * ) * size );
      temp = table->table;
!     
!     if ( NULL == temp ) {
          table->size = 0;
          return NULL;            /*HW: was 'table' */
      }
!     
!     for ( i = 0; i < size; i++ )
!         temp[ i ] = NULL;
!         
      return table;
  }
***************
*** 83,92 ****
  */
  
! static unsigned short hash(char *string)
  {
      unsigned short ret_val = 0;
      int i;
! 
!     while (*string) {
          /*
           ** RBS: Added conditional to account for strings in which the
--- 83,92 ----
  */
  
! static unsigned short hash( char *string )
  {
      unsigned short ret_val = 0;
      int i;
!     
!     while ( *string ) {
          /*
           ** RBS: Added conditional to account for strings in which the
***************
*** 101,109 ****
           ** 2-byte unsigned short.
           */
! 
!         if (strlen(string) >= sizeof(unsigned short))
!             i = *(unsigned short *) string;
          else
!             i = (unsigned short) (*string);
          ret_val ^= i;
          ret_val <<= 1;
--- 101,109 ----
           ** 2-byte unsigned short.
           */
!         
!         if ( strlen( string ) >= sizeof( unsigned short ) )
!             i = *( unsigned short * ) string;
          else
!             i = ( unsigned short ) ( *string );
          ret_val ^= i;
          ret_val <<= 1;
***************
*** 117,129 ****
  ** Returns pointer to old data associated with the key, if any, or
  ** NULL if the key wasn't in the table previously.
! */
  /* HW: returns NULL if malloc failed */
! void *hash_insert(char *key, void *data, hash_table * table)
  {
!     unsigned short val = hash(key) % table->size;
      bucket *ptr;
! 
!     assert(NULL != key);
! 
      /*
       ** NULL means this bucket hasn't been used yet.  We'll simply
--- 117,129 ----
  ** Returns pointer to old data associated with the key, if any, or
  ** NULL if the key wasn't in the table previously.
! */ 
  /* HW: returns NULL if malloc failed */
! void *hash_insert( char *key, void *data, hash_table * table )
  {
!     unsigned short val = hash( key ) % table->size;
      bucket *ptr;
!     
!     assert( NULL != key );
!     
      /*
       ** NULL means this bucket hasn't been used yet.  We'll simply
***************
*** 131,153 ****
       ** the table pointing at it.
       */
! 
!     if (NULL == (table->table)[val]) {
!         (table->table)[val] = (bucket *) malloc(sizeof(bucket));
!         if (NULL == (table->table)[val])
              return NULL;
! 
!         if (NULL ==
!                 ((table->table)[val]->key = (char *) malloc(strlen(key) + 1))) {
!             free((table->table)[val]);
!             (table->table)[val] = NULL;
              return NULL;
          }
!         strcpy((table->table)[val]->key, key);
!         (table->table)[val]->next = NULL;
!         (table->table)[val]->data = data;
          table->count++;         /* HW */
!         return (table->table)[val]->data;
      }
! 
      /* HW: added a #define so the hashtable can accept duplicate keys */
  #ifndef DUPLICATE_KEYS
--- 131,153 ----
       ** the table pointing at it.
       */
!     
!     if ( NULL == ( table->table ) [ val ] ) {
!         ( table->table ) [ val ] = ( bucket * ) malloc( sizeof( bucket ) );
!         if ( NULL == ( table->table ) [ val ] )
              return NULL;
!             
!         if ( NULL ==
!                 ( ( table->table ) [ val ] ->key = ( char * ) malloc( strlen( key ) + 1 ) ) ) {
!             free( ( table->table ) [ val ] );
!             ( table->table ) [ val ] = NULL;
              return NULL;
          }
!         strcpy( ( table->table ) [ val ] ->key, key );
!         ( table->table ) [ val ] ->next = NULL;
!         ( table->table ) [ val ] ->data = data;
          table->count++;         /* HW */
!         return ( table->table ) [ val ] ->data;
      }
!     
      /* HW: added a #define so the hashtable can accept duplicate keys */
  #ifndef DUPLICATE_KEYS
***************
*** 155,163 ****
       ** This spot in the table is already in use.  See if the current string
       ** has already been inserted, and if so, increment its count.
!      *//* HW: ^^^^^^^^ ?? */
!     for (ptr = (table->table)[val]; NULL != ptr; ptr = ptr->next)
!         if (0 == strcmp(key, ptr->key)) {
!             void *old_data;
! 
              old_data = ptr->data;
              ptr->data = data;
--- 155,163 ----
       ** This spot in the table is already in use.  See if the current string
       ** has already been inserted, and if so, increment its count.
!      */ /* HW: ^^^^^^^^ ?? */
!     for ( ptr = ( table->table ) [ val ]; NULL != ptr; ptr = ptr->next )
!         if ( 0 == strcmp( key, ptr->key ) ) {
!             void * old_data;
!             
              old_data = ptr->data;
              ptr->data = data;
***************
*** 173,191 ****
       ** list was larger than this one.
       */
! 
!     ptr = (bucket *) malloc(sizeof(bucket));
!     if (NULL == ptr)
          return NULL;            /*HW: was 0 */
! 
!     if (NULL == (ptr->key = (char *) malloc(strlen(key) + 1))) {
!         free(ptr);
          return NULL;
      }
!     strcpy(ptr->key, key);
      ptr->data = data;
!     ptr->next = (table->table)[val];
!     (table->table)[val] = ptr;
      table->count++;             /* HW */
! 
      return data;
  }
--- 173,191 ----
       ** list was larger than this one.
       */
!     
!     ptr = ( bucket * ) malloc( sizeof( bucket ) );
!     if ( NULL == ptr )
          return NULL;            /*HW: was 0 */
!         
!     if ( NULL == ( ptr->key = ( char * ) malloc( strlen( key ) + 1 ) ) ) {
!         free( ptr );
          return NULL;
      }
!     strcpy( ptr->key, key );
      ptr->data = data;
!     ptr->next = ( table->table ) [ val ];
!     ( table->table ) [ val ] = ptr;
      table->count++;             /* HW */
!     
      return data;
  }
***************
*** 196,214 ****
  ** the key is not in the table.
  */
! void *hash_lookup(char *key, hash_table * table)
  {
!     unsigned short val = hash(key) % table->size;
      bucket *ptr;
! 
!     assert(NULL != key);
! 
!     if (NULL == (table->table)[val])
          return NULL;
! 
!     for (ptr = (table->table)[val]; NULL != ptr; ptr = ptr->next) {
!         if (0 == strcmp(key, ptr->key))
              return ptr->data;
      }
! 
      return NULL;
  }
--- 196,214 ----
  ** the key is not in the table.
  */
! void *hash_lookup( char *key, hash_table * table )
  {
!     unsigned short val = hash( key ) % table->size;
      bucket *ptr;
!     
!     assert( NULL != key );
!     
!     if ( NULL == ( table->table ) [ val ] )
          return NULL;
!         
!     for ( ptr = ( table->table ) [ val ]; NULL != ptr; ptr = ptr->next ) {
!         if ( 0 == strcmp( key, ptr->key ) )
              return ptr->data;
      }
!     
      return NULL;
  }
***************
*** 219,233 ****
  */
  
! void *hash_del(char *key, hash_table * table)
  {
!     unsigned short val = hash(key) % table->size;
      void *data;
      bucket *ptr, *last = NULL;
! 
!     assert(NULL != key);
! 
!     if (NULL == (table->table)[val])
          return NULL;            /* HW: was 'return 0' */
! 
      /*
       ** Traverse the list, keeping track of the previous node in the list.
--- 219,233 ----
  */
  
! void *hash_del( char *key, hash_table * table )
  {
!     unsigned short val = hash( key ) % table->size;
      void *data;
      bucket *ptr, *last = NULL;
!     
!     assert( NULL != key );
!     
!     if ( NULL == ( table->table ) [ val ] )
          return NULL;            /* HW: was 'return 0' */
!         
      /*
       ** Traverse the list, keeping track of the previous node in the list.
***************
*** 237,252 ****
       ** contains.
       */
!     for (last = NULL, ptr = (table->table)[val];
!             NULL != ptr; last = ptr, ptr = ptr->next) {
!         if (0 == strcmp(key, ptr->key)) {
!             if (last != NULL) {
                  data = ptr->data;
                  last->next = ptr->next;
!                 free(ptr->key);
!                 free(ptr);
                  table->count--; /* HW */
                  return data;
              }
! 
              /* If 'last' still equals NULL, it means that we need to
               ** delete the first node in the list. This simply consists
--- 237,252 ----
       ** contains.
       */
!     for ( last = NULL, ptr = ( table->table ) [ val ];
!             NULL != ptr; last = ptr, ptr = ptr->next ) {
!         if ( 0 == strcmp( key, ptr->key ) ) {
!             if ( last != NULL ) {
                  data = ptr->data;
                  last->next = ptr->next;
!                 free( ptr->key );
!                 free( ptr );
                  table->count--; /* HW */
                  return data;
              }
!             
              /* If 'last' still equals NULL, it means that we need to
               ** delete the first node in the list. This simply consists
***************
*** 258,264 ****
                  /* HW: changed this bit to match the comments above */
                  data = ptr->data;
!                 (table->table)[val] = ptr->next;
!                 free(ptr->key);
!                 free(ptr);
                  table->count--; /* HW */
                  return data;
--- 258,264 ----
                  /* HW: changed this bit to match the comments above */
                  data = ptr->data;
!                 ( table->table ) [ val ] = ptr->next;
!                 free( ptr->key );
!                 free( ptr );
                  table->count--; /* HW */
                  return data;
***************
*** 266,275 ****
          }
      }
! 
      /*
       ** If we get here, it means we didn't find the item in the table.
       ** Signal this by returning NULL.
       */
! 
      return NULL;
  }
--- 266,275 ----
          }
      }
!     
      /*
       ** If we get here, it means we didn't find the item in the table.
       ** Signal this by returning NULL.
       */
!     
      return NULL;
  }
***************
*** 283,296 ****
  */
  
! static void free_node(char *key, void *data)
  {
!     (void) data;
! 
!     assert(NULL != key);
! 
!     if (NULL != function) {
!         function(hash_del(key, the_table));
      } else
!         hash_del(key, the_table);
  }
  
--- 283,296 ----
  */
  
! static void free_node( char *key, void *data )
  {
!     ( void ) data;
!     
!     assert( NULL != key );
!     
!     if ( NULL != function ) {
!         function( hash_del( key, the_table ) );
      } else
!         hash_del( key, the_table );
  }
  
***************
*** 303,317 ****
  */
  
! void hash_free_table(hash_table * table, void (*func) (void *))
  {
      function = func;
      the_table = table;
! 
!     hash_enumerate(table, free_node);
!     free(table->table);
      table->table = NULL;
      table->size = 0;
      table->count = 0;           /* HW */
! 
      the_table = NULL;
      function = NULL;
--- 303,317 ----
  */
  
! void hash_free_table( hash_table * table, void ( *func ) ( void * ) )
  {
      function = func;
      the_table = table;
!     
!     hash_enumerate( table, free_node );
!     free( table->table );
      table->table = NULL;
      table->size = 0;
      table->count = 0;           /* HW */
!     
      the_table = NULL;
      function = NULL;
***************
*** 323,340 ****
  */
  
! void hash_enumerate(hash_table * table, void (*func) (char *, void *))
  {
      unsigned i;
      bucket *temp;
      bucket *swap;
! 
!     for (i = 0; i < table->size; i++) {
!         if (NULL != (table->table)[i]) {
              /* HW: changed this loop */
!             temp = (table->table)[i];
!             while (NULL != temp) {
                  /* HW: swap trick, in case temp is freed by 'func' */
                  swap = temp->next;
!                 func(temp->key, temp->data);
                  temp = swap;
              }
--- 323,340 ----
  */
  
! void hash_enumerate( hash_table * table, void ( *func ) ( char *, void * ) )
  {
      unsigned i;
      bucket *temp;
      bucket *swap;
!     
!     for ( i = 0; i < table->size; i++ ) {
!         if ( NULL != ( table->table ) [ i ] ) {
              /* HW: changed this loop */
!             temp = ( table->table ) [ i ];
!             while ( NULL != temp ) {
                  /* HW: swap trick, in case temp is freed by 'func' */
                  swap = temp->next;
!                 func( temp->key, temp->data );
                  temp = swap;
              }
***************
*** 361,375 ****
  
  /* HW: used as 'func' for hash_enumerate */
! static void key_get(char *key, void *data)
  {
!     sortmap[counter].key = key;
!     sortmap[counter].data = data;
      counter++;
  }
  
  /* HW: used for comparing the keys in qsort */
! static int key_comp(const void *a, const void *b)
  {
!     return strcmp((*(sort_struct *) a).key, (*(sort_struct *) b).key);
  }
  
--- 361,375 ----
  
  /* HW: used as 'func' for hash_enumerate */
! static void key_get( char *key, void *data )
  {
!     sortmap[ counter ].key = key;
!     sortmap[ counter ].data = data;
      counter++;
  }
  
  /* HW: used for comparing the keys in qsort */
! static int key_comp( const void *a, const void *b )
  {
!     return strcmp( ( *( sort_struct * ) a ).key, ( *( sort_struct * ) b ).key );
  }
  
***************
*** 380,413 ****
        returns 0 on malloc failure, 1 on success
  */
! int hash_sorted_enum(hash_table * table, void (*func) (char *, void *))
  {
      int i;
! 
      /* nothing to do ! */
!     if (NULL == table || 0 == table->count || NULL == func)
          return 0;
! 
      /* malloc an pointerarray for all hashkey's and datapointers */
!     if (NULL ==
!             (sortmap =
!                  (sort_struct *) malloc(sizeof(sort_struct) * table->count)))
          return 0;
! 
      /* copy the pointers to the hashkey's */
      counter = 0;
!     hash_enumerate(table, key_get);
! 
      /* sort the pointers to the keys */
!     qsort(sortmap, table->count, sizeof(sort_struct), key_comp);
! 
      /* call the function for each node */
!     for (i = 0; i < abs((table->count)); i++) {
!         func(sortmap[i].key, sortmap[i].data);
      }
! 
      /* free the pointerarray */
!     free(sortmap);
      sortmap = NULL;
! 
      return 1;
  }
--- 380,413 ----
        returns 0 on malloc failure, 1 on success
  */
! int hash_sorted_enum( hash_table * table, void ( *func ) ( char *, void * ) )
  {
      int i;
!     
      /* nothing to do ! */
!     if ( NULL == table || 0 == table->count || NULL == func )
          return 0;
!         
      /* malloc an pointerarray for all hashkey's and datapointers */
!     if ( NULL ==
!             ( sortmap =
!                   ( sort_struct * ) malloc( sizeof( sort_struct ) * table->count ) ) )
          return 0;
!         
      /* copy the pointers to the hashkey's */
      counter = 0;
!     hash_enumerate( table, key_get );
!     
      /* sort the pointers to the keys */
!     qsort( sortmap, table->count, sizeof( sort_struct ), key_comp );
!     
      /* call the function for each node */
!     for ( i = 0; i < abs( ( table->count ) ); i++ ) {
!         func( sortmap[ i ].key, sortmap[ i ].data );
      }
!     
      /* free the pointerarray */
!     free( sortmap );
      sortmap = NULL;
!     
      return 1;
  }
***************
*** 417,448 ****
  #ifdef TEST
  
! #include <stdio.h>
  //#include "snip_str.h" /* for strdup() */
  
  FILE *o;
  
! void fprinter(char *string, void *data)
  {
!     fprintf(o, "%s:    %s\n", string, (char *) data);
  }
  
! void printer(char *string, void *data)
  {
!     printf("%s:    %s\n", string, (char *) data);
  }
  
  /* function to pass to hash_free_table */
! void strfree(void *d)
  {
      /* any additional processing goes here (if you use structures as data) */
      /* free the datapointer */
!     free(d);
  }
  
  
! int main(void)
  {
      hash_table table;
! 
      char *strings[] = {
                            "The first string",
--- 417,448 ----
  #ifdef TEST
  
! #include <stdio.h> 
  //#include "snip_str.h" /* for strdup() */
  
  FILE *o;
  
! void fprinter( char *string, void *data )
  {
!     fprintf( o, "%s:    %s\n", string, ( char * ) data );
  }
  
! void printer( char *string, void *data )
  {
!     printf( "%s:    %s\n", string, ( char * ) data );
  }
  
  /* function to pass to hash_free_table */
! void strfree( void *d )
  {
      /* any additional processing goes here (if you use structures as data) */
      /* free the datapointer */
!     free( d );
  }
  
  
! int main( void )
  {
      hash_table table;
!     
      char *strings[] = {
                            "The first string",
***************
*** 454,458 ****
                            NULL
                        };
! 
      char *junk[] = {
                         "The first data",
--- 454,458 ----
                            NULL
                        };
!                       
      char *junk[] = {
                         "The first data",
***************
*** 463,507 ****
                         "The sixth piece of data"
                     };
! 
      int i;
      void *j;
! 
!     hash_construct_table(&table, 211);
! 
      /* I know, no checking on strdup ;-)), but using strdup
         to demonstrate hash_table_free with a functionpointer */
!     for (i = 0; NULL != strings[i]; i++)
!         hash_insert(strings[i], strdup(junk[i]), &table);
! 
      /* enumerating to a file */
!     if (NULL != (o = fopen("HASH.HSH", "wb"))) {
!         fprintf(o, "%d strings in the table:\n\n", table.count);
!         hash_enumerate(&table, fprinter);
!         fprintf(o, "\nsorted by key:\n");
!         hash_sorted_enum(&table, fprinter);
!         fclose(o);
      }
! 
      /* enumerating to screen */
!     hash_sorted_enum(&table, printer);
!     printf("\n");
! 
      /* delete 3 strings, should be 3 left */
!     for (i = 0; i < 3; i++) {
          /* hash_del returns a pointer to the data */
!         strfree(hash_del(strings[i], &table));
      }
!     hash_enumerate(&table, printer);
! 
!     for (i = 0; NULL != strings[i]; i++) {
!         j = hash_lookup(strings[i], &table);
!         if (NULL == j)
!             printf("\n'%s' is not in the table", strings[i]);
          else
!             printf("\n%s is still in the table.", strings[i]);
      }
! 
!     hash_free_table(&table, strfree);
! 
      return 0;
  }
--- 463,507 ----
                         "The sixth piece of data"
                     };
!                    
      int i;
      void *j;
!     
!     hash_construct_table( &table, 211 );
!     
      /* I know, no checking on strdup ;-)), but using strdup
         to demonstrate hash_table_free with a functionpointer */
!     for ( i = 0; NULL != strings[ i ]; i++ )
!         hash_insert( strings[ i ], strdup( junk[ i ] ), &table );
!         
      /* enumerating to a file */
!     if ( NULL != ( o = fopen( "HASH.HSH", "wb" ) ) ) {
!         fprintf( o, "%d strings in the table:\n\n", table.count );
!         hash_enumerate( &table, fprinter );
!         fprintf( o, "\nsorted by key:\n" );
!         hash_sorted_enum( &table, fprinter );
!         fclose( o );
      }
!     
      /* enumerating to screen */
!     hash_sorted_enum( &table, printer );
!     printf( "\n" );
!     
      /* delete 3 strings, should be 3 left */
!     for ( i = 0; i < 3; i++ ) {
          /* hash_del returns a pointer to the data */
!         strfree( hash_del( strings[ i ], &table ) );
      }
!     hash_enumerate( &table, printer );
!     
!     for ( i = 0; NULL != strings[ i ]; i++ ) {
!         j = hash_lookup( strings[ i ], &table );
!         if ( NULL == j )
!             printf( "\n'%s' is not in the table", strings[ i ] );
          else
!             printf( "\n%s is still in the table.", strings[ i ] );
      }
!     
!     hash_free_table( &table, strfree );
!     
      return 0;
  }

Index: hash.h
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ClientDLL/hash.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** hash.h	1 Jul 2005 06:50:52 -0000	1.4
--- hash.h	28 Aug 2005 12:56:37 -0000	1.5
***************
*** 3,7 ****
  #define HASH__H
  
! #include <stddef.h>             /* For size_t   */
  /*
  ** A hash table consists of an array of these buckets.      Each bucket
--- 3,7 ----
  #define HASH__H
  
! #include <stddef.h>             /* For size_t   */ 
  /*
  ** A hash table consists of an array of these buckets.      Each bucket
***************
*** 39,45 ****
  ** This is used to construct the table.  If it doesn't succeed, it sets
  ** the table's size to 0, and the pointer to the table to NULL.
! */
  /* HW: returns NULL if it fails */
! hash_table *hash_construct_table(hash_table * table, size_t size);
  
  /*
--- 39,45 ----
  ** This is used to construct the table.  If it doesn't succeed, it sets
  ** the table's size to 0, and the pointer to the table to NULL.
! */ 
  /* HW: returns NULL if it fails */
! hash_table *hash_construct_table( hash_table * table, size_t size );
  
  /*
***************
*** 49,53 ****
  */
  
! void *hash_insert(char *key, void *data, struct hash_table *table);
  
  /*
--- 49,53 ----
  */
  
! void *hash_insert( char *key, void *data, struct hash_table *table );
  
  /*
***************
*** 56,60 ****
  */
  
! void *hash_lookup(char *key, struct hash_table *table);
  
  /*
--- 56,60 ----
  */
  
! void *hash_lookup( char *key, struct hash_table *table );
  
  /*
***************
*** 64,68 ****
  */
  
! void *hash_del(char *key, struct hash_table *table);
  
  /*
--- 64,68 ----
  */
  
! void *hash_del( char *key, struct hash_table *table );
  
  /*
***************
*** 73,80 ****
  */
  
! void hash_enumerate(hash_table * table, void (*func) (char *, void *));
  
  /* HW: same as above, but sorted output ( sorted on 'key') */
! int hash_sorted_enum(hash_table * table, void (*func) (char *, void *));
  
  /*
--- 73,80 ----
  */
  
! void hash_enumerate( hash_table * table, void ( *func ) ( char *, void * ) );
  
  /* HW: same as above, but sorted output ( sorted on 'key') */
! int hash_sorted_enum( hash_table * table, void ( *func ) ( char *, void * ) );
  
  /*
***************
*** 90,94 ****
  */
  
! void hash_free_table(hash_table * table, void (*func) (void *));
  
  #endif /* HASH__H */
--- 90,94 ----
  */
  
! void hash_free_table( hash_table * table, void ( *func ) ( void * ) );
  
  #endif /* HASH__H */

Index: stdstring.h
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ClientDLL/stdstring.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** stdstring.h	1 Jul 2005 06:50:52 -0000	1.5
--- stdstring.h	28 Aug 2005 12:56:37 -0000	1.6
***************
*** 338,342 ****
  
  #ifdef __BORLANDC__
! #pragma option push -w-inl
  //      #pragma warn -inl   // Turn off inline function warnings
  #endif
--- 338,342 ----
  
  #ifdef __BORLANDC__
! #pragma option push -w-inl 
  //      #pragma warn -inl   // Turn off inline function warnings
[...6362 lines suppressed...]
      inline
!     bool operator() ( const CStdStringA & sLeft,
!                       const CStdStringA & sRight ) const
      {
!         return ssicmp( sLeft.c_str(), sRight.c_str() ) == 0;
      }
  };
***************
*** 4393,4397 ****
  
  #ifdef __BORLANDC__
! #pragma option pop              // Turn back on inline function warnings
  //      #pragma warn +inl   // Turn back on inline function warnings
  #endif
--- 4393,4397 ----
  
  #ifdef __BORLANDC__
! #pragma option pop              // Turn back on inline function warnings 
  //      #pragma warn +inl   // Turn back on inline function warnings
  #endif

Index: tokenizer.cpp
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ClientDLL/tokenizer.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** tokenizer.cpp	1 Jul 2005 06:50:52 -0000	1.4
--- tokenizer.cpp	28 Aug 2005 12:56:38 -0000	1.5
***************
*** 19,52 ****
  #endif
  
! CTokenizer::CTokenizer(const CStdString & cs,
!                        const CStdString & csDelim):m_cs(cs), m_nCurPos(0)
  {
!     SetDelimiters(csDelim);
  }
  
! void CTokenizer::SetDelimiters(const CStdString & csDelim)
  {
!     for (int i = 0; i < csDelim.GetLength(); ++i)
!         m_delim.set(static_cast < BYTE > (csDelim[i]));
  }
  
! bool CTokenizer::Next(CStdString & cs)
  {
      cs.Empty();
! 
!     while (m_nCurPos < m_cs.GetLength()
!             && m_delim[static_cast < BYTE > (m_cs[m_nCurPos])])
          ++m_nCurPos;
! 
!     if (m_nCurPos >= m_cs.GetLength())
          return false;
! 
      int nStartPos = m_nCurPos;
!     while (m_nCurPos < m_cs.GetLength()
!             && !m_delim[static_cast < BYTE > (m_cs[m_nCurPos])])
          ++m_nCurPos;
! 
!     cs = m_cs.Mid(nStartPos, m_nCurPos - nStartPos);
! 
      return true;
  }
--- 19,52 ----
  #endif
  
! CTokenizer::CTokenizer( const CStdString & cs,
!                         const CStdString & csDelim ) : m_cs( cs ), m_nCurPos( 0 )
  {
!     SetDelimiters( csDelim );
  }
  
! void CTokenizer::SetDelimiters( const CStdString & csDelim )
  {
!     for ( int i = 0; i < csDelim.GetLength(); ++i )
!         m_delim.set( static_cast < BYTE > ( csDelim[ i ] ) );
  }
  
! bool CTokenizer::Next( CStdString & cs )
  {
      cs.Empty();
!     
!     while ( m_nCurPos < m_cs.GetLength()
!             && m_delim[ static_cast < BYTE > ( m_cs[ m_nCurPos ] ) ] )
          ++m_nCurPos;
!         
!     if ( m_nCurPos >= m_cs.GetLength() )
          return false;
!         
      int nStartPos = m_nCurPos;
!     while ( m_nCurPos < m_cs.GetLength()
!             && !m_delim[ static_cast < BYTE > ( m_cs[ m_nCurPos ] ) ] )
          ++m_nCurPos;
!         
!     cs = m_cs.Mid( nStartPos, m_nCurPos - nStartPos );
!     
      return true;
  }
***************
*** 55,68 ****
  {
      int nCurPos = m_nCurPos;
! 
!     while (nCurPos < m_cs.GetLength()
!             && m_delim[static_cast < BYTE > (m_cs[nCurPos])])
          ++nCurPos;
! 
      CStdString csResult;
! 
!     if (nCurPos < m_cs.GetLength())
!         csResult = m_cs.Mid(nCurPos);
! 
      return csResult;
  }
--- 55,68 ----
  {
      int nCurPos = m_nCurPos;
!     
!     while ( nCurPos < m_cs.GetLength()
!             && m_delim[ static_cast < BYTE > ( m_cs[ nCurPos ] ) ] )
          ++nCurPos;
!         
      CStdString csResult;
!     
!     if ( nCurPos < m_cs.GetLength() )
!         csResult = m_cs.Mid( nCurPos );
!         
      return csResult;
  }

Index: tokenizer.h
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ClientDLL/tokenizer.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** tokenizer.h	1 Jul 2005 06:50:52 -0000	1.4
--- tokenizer.h	28 Aug 2005 12:56:38 -0000	1.5
***************
*** 18,22 ****
  
  #if !defined(_BITSET_)
! #	include <bitset>
  #endif // !defined(_BITSET_)
  
--- 18,22 ----
  
  #if !defined(_BITSET_)
! # include <bitset>
  #endif // !defined(_BITSET_)
  
***************
*** 24,33 ****
  {
      public:
!         CTokenizer(const CStdString & cs, const CStdString & csDelim);
!         void SetDelimiters(const CStdString & csDelim);
! 
!         bool Next(CStdString & cs);
          CStdString Tail() const;
! 
      private:
          CStdString m_cs;
--- 24,33 ----
  {
      public:
!         CTokenizer( const CStdString & cs, const CStdString & csDelim );
!         void SetDelimiters( const CStdString & csDelim );
!         
!         bool Next( CStdString & cs );
          CStdString Tail() const;
!         
      private:
          CStdString m_cs;

Index: windowdata.cpp
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ClientDLL/windowdata.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** windowdata.cpp	1 Jul 2005 07:00:59 -0000	1.5
--- windowdata.cpp	28 Aug 2005 12:56:38 -0000	1.6
***************
*** 5,38 ****
  #include "WindowData.h"
  
! CWindowData::CWindowData(const CStdString & csId):m_csTitle(""), m_csId(""), m_iX1(0), m_iY1(0), m_iX2(0),
!         m_iY2(0)
  {}
  
! void CWindowData::SetId(const CStdString & csId)
  {
      m_csId = csId;
  }
  
! void CWindowData::SetTitle(const CStdString & csTitle)
  {
      m_csTitle = csTitle;
  }
  
! void CWindowData::SetX1(int iX1)
  {
      m_iX1 = iX1;
  }
  
! void CWindowData::SetY1(int iY1)
  {
      m_iY1 = iY1;
  }
  
! void CWindowData::SetX2(int iX2)
  {
      m_iX2 = iX2;
  }
  
! void CWindowData::SetY2(int iY2)
  {
      m_iY2 = iY2;
--- 5,38 ----
  #include "WindowData.h"
  
! CWindowData::CWindowData( const CStdString & csId ) : m_csTitle( "" ), m_csId( "" ), m_iX1( 0 ), m_iY1( 0 ), m_iX2( 0 ),
!         m_iY2( 0 )
  {}
  
! void CWindowData::SetId( const CStdString & csId )
  {
      m_csId = csId;
  }
  
! void CWindowData::SetTitle( const CStdString & csTitle )
  {
      m_csTitle = csTitle;
  }
  
! void CWindowData::SetX1( int iX1 )
  {
      m_iX1 = iX1;
  }
  
! void CWindowData::SetY1( int iY1 )
  {
      m_iY1 = iY1;
  }
  
! void CWindowData::SetX2( int iX2 )
  {
      m_iX2 = iX2;
  }
  
! void CWindowData::SetY2( int iY2 )
  {
      m_iY2 = iY2;

Index: windowdata.h
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ClientDLL/windowdata.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** windowdata.h	1 Jul 2005 07:00:59 -0000	1.5
--- windowdata.h	28 Aug 2005 12:56:38 -0000	1.6
***************
*** 11,24 ****
  {
      public:
!         CWindowData(const CStdString & csId);
! 
!         void CWindowData::SetId(const CStdString & csId);
!         void CWindowData::SetTitle(const CStdString & csTitle);
!         void CWindowData::SetX1(int iX1);
!         void CWindowData::SetY1(int iY1);
!         void CWindowData::SetX2(int iX2);
!         void CWindowData::SetY2(int iY2);
          HWND CWindowData::TaskbarWindowHandle;
! 
          CStdString CWindowData::GetId();
          CStdString CWindowData::GetTitle();
--- 11,24 ----
  {
      public:
!         CWindowData( const CStdString & csId );
!         
!         void CWindowData::SetId( const CStdString & csId );
!         void CWindowData::SetTitle( const CStdString & csTitle );
!         void CWindowData::SetX1( int iX1 );
!         void CWindowData::SetY1( int iY1 );
!         void CWindowData::SetX2( int iX2 );
!         void CWindowData::SetY2( int iY2 );
          HWND CWindowData::TaskbarWindowHandle;
!         
          CStdString CWindowData::GetId();
          CStdString CWindowData::GetTitle();
***************
*** 27,31 ****
          int CWindowData::GetX2();
          int CWindowData::GetY2();
! 
      private:
          CStdString m_csTitle;
--- 27,31 ----
          int CWindowData::GetX2();
          int CWindowData::GetY2();
!         
      private:
          CStdString m_csTitle;



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.