CVS: seamlessrdp/ClientDLL clipper.cpp,1.2,1.3 clipper.h,1.2,1.3 hash.cpp,1.2,1.3 hash.h,1.2,1.3 stdstring.h,1.3,1.4 tokenizer.cpp,1.2,1.3 tokenizer.h,1.2,1.3 windowdata.cpp,1.2,1.3 windowdata.h,1.2,1.3
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-serv28857/ClientDLL
Modified Files:
clipper.cpp clipper.h hash.cpp hash.h stdstring.h
tokenizer.cpp tokenizer.h windowdata.cpp windowdata.h
Log Message:
Fixed indentation, by running indent-all.
Index: clipper.cpp
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ClientDLL/clipper.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** clipper.cpp 30 Jun 2005 14:14:55 -0000 1.2
--- clipper.cpp 30 Jun 2005 14:46:14 -0000 1.3
***************
*** 15,280 ****
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
! UNREFERENCED_PARAMETER(lpvReserved);
! UNREFERENCED_PARAMETER(hinstDLL);
! switch(fdwReason)
! {
! case DLL_PROCESS_ATTACH:
! break;
[...1196 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.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** clipper.h 30 Jun 2005 14:14:56 -0000 1.2
--- clipper.h 30 Jun 2005 14:46:14 -0000 1.3
***************
*** 51,56 ****
//
! LPHANDLE gphChannel;
! DWORD gdwOpenChannel;
PCHANNEL_ENTRY_POINTS gpEntryPoints;
--- 51,56 ----
//
! LPHANDLE gphChannel;
! DWORD gdwOpenChannel;
PCHANNEL_ENTRY_POINTS gpEntryPoints;
***************
*** 58,64 ****
HRGN m_regionResult;
HWND m_mainWindowHandle = NULL;
! int classAlreadyRegistered=0;
! int const ALWAYS__CLIP = 0;//set this to 0 to turn off clipping when there are no windows
int const HIDE_TSAC_WINDOW = 1;
int const OUTPUT_DEBUG_INFO = 0;
--- 58,64 ----
HRGN m_regionResult;
HWND m_mainWindowHandle = NULL;
! int classAlreadyRegistered = 0;
! int const ALWAYS__CLIP = 0; //set this to 0 to turn off clipping when there are no windows
int const HIDE_TSAC_WINDOW = 1;
int const OUTPUT_DEBUG_INFO = 0;
***************
*** 68,78 ****
// 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);
\ No newline at end of file
--- 68,81 ----
// 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.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** hash.cpp 30 Jun 2005 14:14:56 -0000 1.2
--- hash.cpp 30 Jun 2005 14:46:14 -0000 1.3
***************
*** 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;
***************
*** 55,78 ****
*/
/*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;
}
--- 55,77 ----
*/
/*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;
}
***************
*** 86,115 ****
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
! ** length is less than an integral multiple of sizeof(int).
! **
! ** Note: This fixes the problem of hasing trailing garbage, but
! ** doesn't fix the problem with some CPU's which can't align on
! ** byte boundries. Any decent C compiler *should* fix this, but
! ** it still might extract a performance hit. Also unaddressed is
! ** what happens when using a CPU which addresses data only on
! ** 4-byte boundries when it tries to work with a pointer to a
! ** 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;
! string ++;
! }
! return ret_val;
}
--- 85,114 ----
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
! ** length is less than an integral multiple of sizeof(int).
! **
! ** Note: This fixes the problem of hasing trailing garbage, but
! ** doesn't fix the problem with some CPU's which can't align on
! ** byte boundries. Any decent C compiler *should* fix this, but
! ** it still might extract a performance hit. Also unaddressed is
! ** what happens when using a CPU which addresses data only on
! ** 4-byte boundries when it tries to work with a pointer to a
! ** 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;
! string++;
! }
! return ret_val;
}
***************
*** 120,196 ****
*/
/* 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
! ** allocate space for our new bucket and put our data there, with
! ** 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
! /*
! ** 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;
! return old_data;
! }
#endif
! /*
! ** This key must not be in the table yet. We'll add it to the head of
! ** the list at this spot in the hash table. Speed would be
! ** slightly improved if the list was kept sorted instead. In this case,
! ** this code would be moved into the loop above, and the insertion would
! ** take place as soon as it was determined that the present key in the
! ** 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;
}
--- 119,192 ----
*/
/* 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
! ** allocate space for our new bucket and put our data there, with
! ** 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
! /*
! ** 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;
! return old_data;
! }
#endif
! /*
! ** This key must not be in the table yet. We'll add it to the head of
! ** the list at this spot in the hash table. Speed would be
! ** slightly improved if the list was kept sorted instead. In this case,
! ** this code would be moved into the loop above, and the insertion would
! ** take place as soon as it was determined that the present key in the
! ** 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;
}
***************
*** 200,220 ****
** 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,215 ----
** 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;
}
***************
*** 224,286 ****
*/
! 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.
! ** When we find the node to delete, we set the previous node's next
! ** pointer to point to the node after ourself instead. We then delete
! ** the key from the present node, and return a pointer to the data it
! ** 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
! ** of putting our own 'next' pointer in the array holding
! ** the head of the list. We then dispose of the current
! ** node as above.
! */
! else
! {
! /* 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;
! }
}
! }
! /*
! ** If we get here, it means we didn't find the item in the table.
! ** Signal this by returning NULL.
! */
! return NULL;
}
--- 219,276 ----
*/
! 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.
! ** When we find the node to delete, we set the previous node's next
! ** pointer to point to the node after ourself instead. We then delete
! ** the key from the present node, and return a pointer to the data it
! ** 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
! ** of putting our own 'next' pointer in the array holding
! ** the head of the list. We then dispose of the current
! ** node as above.
! */
! else {
! /* 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;
}
! }
! }
! /*
! ** If we get here, it means we didn't find the item in the table.
! ** Signal this by returning NULL.
! */
! return NULL;
}
***************
*** 293,308 ****
*/
! 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,297 ----
*/
! 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);
}
***************
*** 315,331 ****
*/
! 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;
}
--- 304,320 ----
*/
! 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;
}
***************
*** 335,359 ****
*/
! 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;
! }
}
! }
}
--- 324,345 ----
*/
! 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;
}
! }
! }
}
***************
*** 366,373 ****
typedef struct sort_struct
! {
! char *key;
! void *data;
! } sort_struct;
static sort_struct *sortmap = NULL;
--- 352,359 ----
typedef struct sort_struct
! {
! char *key;
! void *data;
! } sort_struct;
static sort_struct *sortmap = NULL;
***************
*** 375,389 ****
/* 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);
}
***************
*** 394,427 ****
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,414 ----
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;
}
***************
*** 437,454 ****
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);
}
--- 424,441 ----
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);
}
***************
*** 456,524 ****
int main(void)
{
! hash_table table;
! char *strings[] = {
! "The first string",
! "The second string",
! "The third string",
! "The fourth string",
! "A much longer string than the rest in this example.",
! "The last string",
! NULL
! };
! char *junk[] = {
! "The first data",
! "The second data",
! "The third data",
! "The fourth data",
! "The fifth datum",
! "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;
}
#endif /* TEST */
--- 443,508 ----
int main(void)
{
! hash_table table;
! char *strings[] = {
! "The first string",
! "The second string",
! "The third string",
! "The fourth string",
! "A much longer string than the rest in this example.",
! "The last string",
! NULL
! };
! char *junk[] = {
! "The first data",
! "The second data",
! "The third data",
! "The fourth data",
! "The fifth datum",
! "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;
}
#endif /* TEST */
Index: hash.h
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ClientDLL/hash.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** hash.h 30 Jun 2005 14:14:56 -0000 1.2
--- hash.h 30 Jun 2005 14:46:14 -0000 1.3
***************
*** 11,18 ****
*/
! typedef struct bucket {
! char *key;
! void *data;
! struct bucket *next;
} bucket;
--- 11,19 ----
*/
! typedef struct bucket
! {
! char *key;
! void *data;
! struct bucket *next;
} bucket;
***************
*** 26,33 ****
*/
! typedef struct hash_table {
! size_t size;
! size_t count; /* HW */
! bucket **table;
} hash_table;
--- 27,35 ----
*/
! typedef struct hash_table
! {
! size_t size;
! size_t count; /* HW */
! bucket **table;
} hash_table;
***************
*** 37,41 ****
*/
/* HW: returns NULL if it fails */
! hash_table *hash_construct_table(hash_table *table,size_t size);
/*
--- 39,43 ----
*/
/* HW: returns NULL if it fails */
! hash_table *hash_construct_table(hash_table * table, size_t size);
/*
***************
*** 45,49 ****
*/
! void *hash_insert(char *key,void *data,struct hash_table *table);
/*
--- 47,51 ----
*/
! void *hash_insert(char *key, void *data, struct hash_table *table);
/*
***************
*** 52,56 ****
*/
! void *hash_lookup(char *key,struct hash_table *table);
/*
--- 54,58 ----
*/
! void *hash_lookup(char *key, struct hash_table *table);
/*
***************
*** 60,64 ****
*/
! void *hash_del(char *key,struct hash_table *table);
/*
--- 62,66 ----
*/
! void *hash_del(char *key, struct hash_table *table);
/*
***************
*** 69,76 ****
*/
! 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*));
/*
--- 71,78 ----
*/
! 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 *));
/*
***************
*** 86,90 ****
*/
! void hash_free_table(hash_table *table, void (*func)(void *));
#endif /* HASH__H */
--- 88,92 ----
*/
! 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.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** stdstring.h 30 Jun 2005 14:35:30 -0000 1.3
--- stdstring.h 30 Jun 2005 14:46:14 -0000 1.4
***************
*** 1,10 ****
// =============================================================================
// FILE: StdString.h
! // AUTHOR: Joe O'Leary (with outside help noted in comments)
//
! // If you find any bugs in this code, please let me know:
//
! // [email protected]
! // http://www.joeo.net/stdstring.htm (a bit outdated)
//
// The latest version of this code should always be available at the
[...7993 lines suppressed...]
! // }
//}
***************
*** 4233,4239 ****
#ifdef __BORLANDC__
! #pragma option pop // Turn back on inline function warnings
! // #pragma warn +inl // Turn back on inline function warnings
#endif
! #endif // #ifndef STDSTRING_H
--- 4326,4332 ----
#ifdef __BORLANDC__
! #pragma option pop // Turn back on inline function warnings
! // #pragma warn +inl // Turn back on inline function warnings
#endif
! #endif // #ifndef STDSTRING_H
Index: tokenizer.cpp
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ClientDLL/tokenizer.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** tokenizer.cpp 30 Jun 2005 14:14:56 -0000 1.2
--- tokenizer.cpp 30 Jun 2005 14:46:14 -0000 1.3
***************
*** 19,66 ****
#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;
}
! CStdString CTokenizer::Tail() const
! {
! 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;
! }
--- 19,68 ----
#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;
}
! CStdString CTokenizer::Tail() const const const
! {
! 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.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** tokenizer.h 30 Jun 2005 14:14:56 -0000 1.2
--- tokenizer.h 30 Jun 2005 14:46:14 -0000 1.3
***************
*** 23,38 ****
class CTokenizer
{
! public:
! CTokenizer(const CStdString& cs, const CStdString& csDelim);
! void SetDelimiters(const CStdString& csDelim);
! bool Next(CStdString& cs);
! CStdString Tail() const;
! private:
! CStdString m_cs;
! std::bitset<256> m_delim;
! int m_nCurPos;
};
! #endif // !defined(__TOKENIZER_H__)
--- 23,38 ----
class CTokenizer
{
! public:
! CTokenizer(const CStdString & cs, const CStdString & csDelim);
! void SetDelimiters(const CStdString & csDelim);
! bool Next(CStdString & cs);
! CStdString Tail() const;
! private:
! CStdString m_cs;
! std::bitset < 256 > m_delim;
! int m_nCurPos;
};
! #endif // !defined(__TOKENIZER_H__)
Index: windowdata.cpp
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ClientDLL/windowdata.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** windowdata.cpp 30 Jun 2005 14:14:56 -0000 1.2
--- windowdata.cpp 30 Jun 2005 14:46:14 -0000 1.3
***************
*** 11,76 ****
#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;
}
CStdString CWindowData::GetId()
{
! return this->m_csId;
}
CStdString CWindowData::GetTitle()
{
! return this->m_csTitle;
}
int CWindowData::GetX1()
{
! return this->m_iX1;
}
int CWindowData::GetY1()
{
! return this->m_iY1;
}
int CWindowData::GetX2()
{
! return this->m_iX2;
}
int CWindowData::GetY2()
{
! return this->m_iY2;
! }
\ No newline at end of file
--- 11,77 ----
#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;
}
CStdString CWindowData::GetId()
{
! return this->m_csId;
}
CStdString CWindowData::GetTitle()
{
! return this->m_csTitle;
}
int CWindowData::GetX1()
{
! return this->m_iX1;
}
int CWindowData::GetY1()
{
! return this->m_iY1;
}
int CWindowData::GetX2()
{
! return this->m_iX2;
}
int CWindowData::GetY2()
{
! return this->m_iY2;
! }
Index: windowdata.h
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ClientDLL/windowdata.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** windowdata.h 30 Jun 2005 14:14:56 -0000 1.2
--- windowdata.h 30 Jun 2005 14:46:14 -0000 1.3
***************
*** 16,42 ****
class CWindowData
{
! 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();
! int CWindowData::GetX1();
! int CWindowData::GetY1();
! int CWindowData::GetX2();
! int CWindowData::GetY2();
! private:
! CStdString m_csTitle;
! CStdString m_csId;
! int m_iX1,m_iY1,m_iX2,m_iY2;
};
! #endif // !defined(__WINDOWDATA_H__)
\ No newline at end of file
--- 16,42 ----
class CWindowData
{
! 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();
! int CWindowData::GetX1();
! int CWindowData::GetY1();
! int CWindowData::GetX2();
! int CWindowData::GetY2();
! private:
! CStdString m_csTitle;
! CStdString m_csId;
! int m_iX1, m_iY1, m_iX2, m_iY2;
};
! #endif // !defined(__WINDOWDATA_H__)
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click