comparison gtk/dw.c @ 1306:dbd507f42947

Added dw_debug() logging function which will output a message to the debugging console. On Windows this uses OutputDebugMessage(), on Mac it uses NSLog() ... The other platforms currently just dump it to stderr. Maybe more enhancements to come.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 03 Nov 2011 23:34:10 +0000
parents 9c8de9cccc07
children 1c3ff83d0d4b
comparison
equal deleted inserted replaced
1305:18a31ab94e3d 1306:dbd507f42947
1219 1219
1220 static SignalHandler _get_signal_handler(GtkWidget *widget, gpointer data) 1220 static SignalHandler _get_signal_handler(GtkWidget *widget, gpointer data)
1221 { 1221 {
1222 int counter = GPOINTER_TO_INT(data); 1222 int counter = GPOINTER_TO_INT(data);
1223 SignalHandler sh; 1223 SignalHandler sh;
1224 char text[100]; 1224 char text[101] = {0};
1225 1225
1226 sprintf(text, "_dw_sigwindow%d", counter); 1226 snprintf(text, 100, "_dw_sigwindow%d", counter);
1227 sh.window = (HWND)gtk_object_get_data(GTK_OBJECT(widget), text); 1227 sh.window = (HWND)gtk_object_get_data(GTK_OBJECT(widget), text);
1228 sprintf(text, "_dw_sigfunc%d", counter); 1228 snprintf(text, 100, "_dw_sigfunc%d", counter);
1229 sh.func = (void *)gtk_object_get_data(GTK_OBJECT(widget), text); 1229 sh.func = (void *)gtk_object_get_data(GTK_OBJECT(widget), text);
1230 sprintf(text, "_dw_intfunc%d", counter); 1230 snprintf(text, 100, "_dw_intfunc%d", counter);
1231 sh.intfunc = (void *)gtk_object_get_data(GTK_OBJECT(widget), text); 1231 sh.intfunc = (void *)gtk_object_get_data(GTK_OBJECT(widget), text);
1232 sprintf(text, "_dw_sigdata%d", counter); 1232 snprintf(text, 100, "_dw_sigdata%d", counter);
1233 sh.data = gtk_object_get_data(GTK_OBJECT(widget), text); 1233 sh.data = gtk_object_get_data(GTK_OBJECT(widget), text);
1234 sprintf(text, "_dw_sigcid%d", counter); 1234 snprintf(text, 100, "_dw_sigcid%d", counter);
1235 sh.cid = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(widget), text)); 1235 sh.cid = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(widget), text));
1236 1236
1237 return sh; 1237 return sh;
1238 } 1238 }
1239 1239
1240 static void _remove_signal_handler(GtkWidget *widget, int counter) 1240 static void _remove_signal_handler(GtkWidget *widget, int counter)
1241 { 1241 {
1242 char text[100]; 1242 char text[101] = {0};
1243 gint cid; 1243 gint cid;
1244 1244
1245 sprintf(text, "_dw_sigcid%d", counter); 1245 snprintf(text, 100, "_dw_sigcid%d", counter);
1246 cid = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(widget), text)); 1246 cid = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(widget), text));
1247 gtk_signal_disconnect(GTK_OBJECT(widget), cid); 1247 gtk_signal_disconnect(GTK_OBJECT(widget), cid);
1248 gtk_object_set_data(GTK_OBJECT(widget), text, NULL); 1248 gtk_object_set_data(GTK_OBJECT(widget), text, NULL);
1249 sprintf(text, "_dw_sigwindow%d", counter); 1249 sbprintf(text, 100, "_dw_sigwindow%d", counter);
1250 gtk_object_set_data(GTK_OBJECT(widget), text, NULL); 1250 gtk_object_set_data(GTK_OBJECT(widget), text, NULL);
1251 sprintf(text, "_dw_sigfunc%d", counter); 1251 sbprintf(text, 100, "_dw_sigfunc%d", counter);
1252 gtk_object_set_data(GTK_OBJECT(widget), text, NULL); 1252 gtk_object_set_data(GTK_OBJECT(widget), text, NULL);
1253 sprintf(text, "_dw_intfunc%d", counter); 1253 sbprintf(text, 100, "_dw_intfunc%d", counter);
1254 gtk_object_set_data(GTK_OBJECT(widget), text, NULL); 1254 gtk_object_set_data(GTK_OBJECT(widget), text, NULL);
1255 sprintf(text, "_dw_sigdata%d", counter); 1255 sbprintf(text, 100, "_dw_sigdata%d", counter);
1256 gtk_object_set_data(GTK_OBJECT(widget), text, NULL); 1256 gtk_object_set_data(GTK_OBJECT(widget), text, NULL);
1257 } 1257 }
1258 1258
1259 static int _set_signal_handler(GtkWidget *widget, HWND window, void *func, gpointer data, void *intfunc) 1259 static int _set_signal_handler(GtkWidget *widget, HWND window, void *func, gpointer data, void *intfunc)
1260 { 1260 {
1261 int counter = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(widget), "_dw_sigcounter")); 1261 int counter = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(widget), "_dw_sigcounter"));
1262 char text[100]; 1262 char text[101] = {0};
1263 1263
1264 sprintf(text, "_dw_sigwindow%d", counter); 1264 snprintf(text, 100, "_dw_sigwindow%d", counter);
1265 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)window); 1265 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)window);
1266 sprintf(text, "_dw_sigfunc%d", counter); 1266 snprintf(text, 100, "_dw_sigfunc%d", counter);
1267 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)func); 1267 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)func);
1268 sprintf(text, "_dw_intfunc%d", counter); 1268 snprintf(text, 100, "_dw_intfunc%d", counter);
1269 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)intfunc); 1269 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)intfunc);
1270 sprintf(text, "_dw_sigdata%d", counter); 1270 snprintf(text, 100, "_dw_sigdata%d", counter);
1271 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)data); 1271 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)data);
1272 1272
1273 counter++; 1273 counter++;
1274 gtk_object_set_data(GTK_OBJECT(widget), "_dw_sigcounter", GINT_TO_POINTER(counter)); 1274 gtk_object_set_data(GTK_OBJECT(widget), "_dw_sigcounter", GINT_TO_POINTER(counter));
1275 1275
1276 return counter - 1; 1276 return counter - 1;
1277 } 1277 }
1278 1278
1279 static void _set_signal_handler_id(GtkWidget *widget, int counter, gint cid) 1279 static void _set_signal_handler_id(GtkWidget *widget, int counter, gint cid)
1280 { 1280 {
1281 char text[100]; 1281 char text[101] = {0};
1282 1282
1283 sprintf(text, "_dw_sigcid%d", counter); 1283 snprintf(text, 100, "_dw_sigcid%d", counter);
1284 gtk_object_set_data(GTK_OBJECT(widget), text, GINT_TO_POINTER(cid)); 1284 gtk_object_set_data(GTK_OBJECT(widget), text, GINT_TO_POINTER(cid));
1285 } 1285 }
1286 1286
1287 static gint _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data) 1287 static gint _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data)
1288 { 1288 {
2037 2037
2038 /* Try to load the WebKitGtk shared libary */ 2038 /* Try to load the WebKitGtk shared libary */
2039 #ifdef USE_WEBKIT 2039 #ifdef USE_WEBKIT
2040 void init_webkit(void) 2040 void init_webkit(void)
2041 { 2041 {
2042 char libname[100]; 2042 char libname[101] = {0};
2043 void *handle = NULL; 2043 void *handle = NULL;
2044 2044
2045 sprintf( libname, "lib%s.so", WEBKIT_LIB); 2045 snprintf( libname, 100, "lib%s.so", WEBKIT_LIB);
2046 handle = dlopen( libname, RTLD_LAZY ); 2046 handle = dlopen( libname, RTLD_LAZY );
2047 2047
2048 /* If we loaded it, grab the symbols we want */ 2048 /* If we loaded it, grab the symbols we want */
2049 if ( handle ) 2049 if ( handle )
2050 { 2050 {
2366 dw_dialog_dismiss((DWDialog *)data, (void *)DW_MB_RETURN_CANCEL); 2366 dw_dialog_dismiss((DWDialog *)data, (void *)DW_MB_RETURN_CANCEL);
2367 return FALSE; 2367 return FALSE;
2368 } 2368 }
2369 2369
2370 /* 2370 /*
2371 * Displays a debug message on the console...
2372 * Parameters:
2373 * format: printf style format string.
2374 * ...: Additional variables for use in the format.
2375 */
2376 void API dw_debug(char *format, ...)
2377 {
2378 va_list args;
2379 char outbuf[1025] = {0};
2380
2381 va_start(args, format);
2382 vsnprintf(outbuf, 1024, format, args);
2383 va_end(args);
2384
2385 fprintf(stderr, "%s", outbuf);
2386 }
2387
2388 /*
2371 * Displays a Message Box with given text and title.. 2389 * Displays a Message Box with given text and title..
2372 * Parameters: 2390 * Parameters:
2373 * title: The title of the message box. 2391 * title: The title of the message box.
2374 * flags: Defines buttons and icons to display 2392 * flags: Defines buttons and icons to display
2375 * format: printf style format string. 2393 * format: printf style format string.
2379 { 2397 {
2380 HWND entrywindow, texttargetbox, imagetextbox, mainbox, okbutton, nobutton, yesbutton, cancelbutton, buttonbox, stext; 2398 HWND entrywindow, texttargetbox, imagetextbox, mainbox, okbutton, nobutton, yesbutton, cancelbutton, buttonbox, stext;
2381 ULONG flStyle = DW_FCF_TITLEBAR | DW_FCF_SHELLPOSITION | DW_FCF_DLGBORDER; 2399 ULONG flStyle = DW_FCF_TITLEBAR | DW_FCF_SHELLPOSITION | DW_FCF_DLGBORDER;
2382 DWDialog *dwwait; 2400 DWDialog *dwwait;
2383 va_list args; 2401 va_list args;
2384 char outbuf[1000]; 2402 char outbuf[1025] = {0};
2385 char **xpm_data = NULL; 2403 char **xpm_data = NULL;
2386 int x, y, extra_width=0,text_width,text_height; 2404 int x, y, extra_width=0,text_width,text_height;
2387 int width,height; 2405 int width,height;
2388 2406
2389 va_start(args, format); 2407 va_start(args, format);
2390 vsnprintf(outbuf, 999, format, args); 2408 vsnprintf(outbuf, 1024, format, args);
2391 va_end(args); 2409 va_end(args);
2392 2410
2393 entrywindow = dw_window_new(HWND_DESKTOP, title, flStyle); 2411 entrywindow = dw_window_new(HWND_DESKTOP, title, flStyle);
2394 mainbox = dw_box_new(DW_VERT, 10); 2412 mainbox = dw_box_new(DW_VERT, 10);
2395 dw_box_pack_start(entrywindow, mainbox, 0, 0, TRUE, TRUE, 0); 2413 dw_box_pack_start(entrywindow, mainbox, 0, 0, TRUE, TRUE, 0);
3709 3727
3710 if (strlen(tempbuf) == 0) 3728 if (strlen(tempbuf) == 0)
3711 tmphandle=gtk_menu_item_new(); 3729 tmphandle=gtk_menu_item_new();
3712 else 3730 else
3713 { 3731 {
3732 char numbuf[11] = {0};
3733
3714 if (check) 3734 if (check)
3715 { 3735 {
3716 char numbuf[10];
3717 if (accel && accel_group) 3736 if (accel && accel_group)
3718 { 3737 {
3719 tmphandle = gtk_check_menu_item_new_with_label(""); 3738 tmphandle = gtk_check_menu_item_new_with_label("");
3720 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf); 3739 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf);
3721 #if 0 /* This isn't working right */ 3740 #if 0 /* This isn't working right */
3723 #endif 3742 #endif
3724 } 3743 }
3725 else 3744 else
3726 tmphandle = gtk_check_menu_item_new_with_label(tempbuf); 3745 tmphandle = gtk_check_menu_item_new_with_label(tempbuf);
3727 gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE); 3746 gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE);
3728 sprintf(numbuf, "%lu", id); 3747 snprintf(numbuf, 10, "%lu", id);
3729 gtk_object_set_data(GTK_OBJECT(menu), numbuf, (gpointer)tmphandle); 3748 gtk_object_set_data(GTK_OBJECT(menu), numbuf, (gpointer)tmphandle);
3730 } 3749 }
3731 else 3750 else
3732 { 3751 {
3733 char numbuf[10];
3734 if (accel && accel_group) 3752 if (accel && accel_group)
3735 { 3753 {
3736 tmphandle=gtk_menu_item_new_with_label(""); 3754 tmphandle=gtk_menu_item_new_with_label("");
3737 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf); 3755 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf);
3738 #if 0 /* This isn't working right */ 3756 #if 0 /* This isn't working right */
3739 gtk_widget_add_accelerator(tmphandle, "activate", accel_group, tmp_key, GDK_MOD1_MASK, 0); 3757 gtk_widget_add_accelerator(tmphandle, "activate", accel_group, tmp_key, GDK_MOD1_MASK, 0);
3740 #endif 3758 #endif
3741 } 3759 }
3742 else 3760 else
3743 tmphandle=gtk_menu_item_new_with_label(tempbuf); 3761 tmphandle=gtk_menu_item_new_with_label(tempbuf);
3744 sprintf(numbuf, "%lu", id); 3762 snprintf(numbuf, 10, "%lu", id);
3745 gtk_object_set_data(GTK_OBJECT(menu), numbuf, (gpointer)tmphandle); 3763 gtk_object_set_data(GTK_OBJECT(menu), numbuf, (gpointer)tmphandle);
3746 } 3764 }
3747 } 3765 }
3748 3766
3749 gtk_widget_show(tmphandle); 3767 gtk_widget_show(tmphandle);
3750 3768
3751 if (submenu) 3769 if (submenu)
3752 { 3770 {
3753 char tempbuf[100]; 3771 char tempbuf[101] = {0};
3754 3772
3755 sprintf(tempbuf, "_dw_submenu%d", submenucount); 3773 snprintf(tempbuf, 100, "_dw_submenu%d", submenucount);
3756 submenucount++; 3774 submenucount++;
3757 gtk_menu_item_set_submenu(GTK_MENU_ITEM(tmphandle), submenu); 3775 gtk_menu_item_set_submenu(GTK_MENU_ITEM(tmphandle), submenu);
3758 gtk_object_set_data(GTK_OBJECT(menu), tempbuf, (gpointer)submenu); 3776 gtk_object_set_data(GTK_OBJECT(menu), tempbuf, (gpointer)submenu);
3759 gtk_object_set_data(GTK_OBJECT(menu), "_dw_submenucount", GINT_TO_POINTER(submenucount)); 3777 gtk_object_set_data(GTK_OBJECT(menu), "_dw_submenucount", GINT_TO_POINTER(submenucount));
3760 } 3778 }
3791 if((tmp = gtk_object_get_data(GTK_OBJECT(start), name))) 3809 if((tmp = gtk_object_get_data(GTK_OBJECT(start), name)))
3792 return tmp; 3810 return tmp;
3793 3811
3794 for(z=0;z<submenucount;z++) 3812 for(z=0;z<submenucount;z++)
3795 { 3813 {
3796 char tempbuf[100]; 3814 char tempbuf[101] = {0};
3797 GtkWidget *submenu, *menuitem; 3815 GtkWidget *submenu, *menuitem;
3798 3816
3799 sprintf(tempbuf, "_dw_submenu%d", z); 3817 snprintf(tempbuf, 100, "_dw_submenu%d", z);
3800 3818
3801 if((submenu = gtk_object_get_data(GTK_OBJECT(start), tempbuf))) 3819 if((submenu = gtk_object_get_data(GTK_OBJECT(start), tempbuf)))
3802 { 3820 {
3803 if((menuitem = _find_submenu_id(submenu, name))) 3821 if((menuitem = _find_submenu_id(submenu, name)))
3804 return menuitem; 3822 return menuitem;
3815 * check: TRUE for checked FALSE for not checked. 3833 * check: TRUE for checked FALSE for not checked.
3816 * deprecated: use dw_menu_item_set_state() 3834 * deprecated: use dw_menu_item_set_state()
3817 */ 3835 */
3818 void dw_menu_item_set_check(HMENUI menu, unsigned long id, int check) 3836 void dw_menu_item_set_check(HMENUI menu, unsigned long id, int check)
3819 { 3837 {
3820 char numbuf[10]; 3838 char numbuf[11] = {0};
3821 GtkWidget *tmphandle; 3839 GtkWidget *tmphandle;
3822 int _locked_by_me = FALSE; 3840 int _locked_by_me = FALSE;
3823 3841
3824 if(!menu) 3842 if(!menu)
3825 return; 3843 return;
3826 3844
3827 DW_MUTEX_LOCK; 3845 DW_MUTEX_LOCK;
3828 sprintf(numbuf, "%lu", id); 3846 snprintf(numbuf, 10, "%lu", id);
3829 tmphandle = _find_submenu_id(menu, numbuf); 3847 tmphandle = _find_submenu_id(menu, numbuf);
3830 3848
3831 if(tmphandle) 3849 if(tmphandle)
3832 { 3850 {
3833 _dw_ignore_click = 1; 3851 _dw_ignore_click = 1;
3845 * id: Menuitem id. 3863 * id: Menuitem id.
3846 * state: TRUE for checked FALSE for not checked. 3864 * state: TRUE for checked FALSE for not checked.
3847 */ 3865 */
3848 void dw_menu_item_set_state(HMENUI menu, unsigned long id, unsigned long state) 3866 void dw_menu_item_set_state(HMENUI menu, unsigned long id, unsigned long state)
3849 { 3867 {
3850 char numbuf[10]; 3868 char numbuf[11] = {0};
3851 GtkWidget *tmphandle; 3869 GtkWidget *tmphandle;
3852 int check; 3870 int check;
3853 int _locked_by_me = FALSE; 3871 int _locked_by_me = FALSE;
3854 3872
3855 if(!menu) 3873 if(!menu)
3856 return; 3874 return;
3857 3875
3858 DW_MUTEX_LOCK; 3876 DW_MUTEX_LOCK;
3859 sprintf(numbuf, "%lu", id); 3877 snprintf(numbuf, 10, "%lu", id);
3860 tmphandle = _find_submenu_id(menu, numbuf); 3878 tmphandle = _find_submenu_id(menu, numbuf);
3861 3879
3862 if ( (state & DW_MIS_CHECKED) || (state & DW_MIS_UNCHECKED) ) 3880 if ( (state & DW_MIS_CHECKED) || (state & DW_MIS_UNCHECKED) )
3863 { 3881 {
3864 if ( state & DW_MIS_CHECKED ) 3882 if ( state & DW_MIS_CHECKED )
6517 } 6535 }
6518 6536
6519 static int _dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator, int extra) 6537 static int _dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator, int extra)
6520 { 6538 {
6521 GtkWidget *clist; 6539 GtkWidget *clist;
6522 char numbuf[10]; 6540 char numbuf[11] = {0};
6523 int z, multi; 6541 int z, multi;
6524 int _locked_by_me = FALSE; 6542 int _locked_by_me = FALSE;
6525 GtkJustification justification; 6543 GtkJustification justification;
6526 6544
6527 DW_MUTEX_LOCK; 6545 DW_MUTEX_LOCK;
6551 6569
6552 for(z=0;z<count;z++) 6570 for(z=0;z<count;z++)
6553 { 6571 {
6554 if(!extra || z > 1) 6572 if(!extra || z > 1)
6555 gtk_clist_set_column_width(GTK_CLIST(clist), z, 50); 6573 gtk_clist_set_column_width(GTK_CLIST(clist), z, 50);
6556 sprintf(numbuf, "%d", z); 6574 snprintf(numbuf, 10, "%d", z);
6557 gtk_object_set_data(GTK_OBJECT(clist), numbuf, GINT_TO_POINTER(flags[z])); 6575 gtk_object_set_data(GTK_OBJECT(clist), numbuf, GINT_TO_POINTER(flags[z]));
6558 if(flags[z]&DW_CFA_RIGHT) 6576 if(flags[z]&DW_CFA_RIGHT)
6559 justification = GTK_JUSTIFY_RIGHT; 6577 justification = GTK_JUSTIFY_RIGHT;
6560 else if(flags[z]&DW_CFA_CENTER) 6578 else if(flags[z]&DW_CFA_CENTER)
6561 justification = GTK_JUSTIFY_CENTER; 6579 justification = GTK_JUSTIFY_CENTER;
6941 * Internal representation of dw_container_set_item() extracted so we can pass 6959 * Internal representation of dw_container_set_item() extracted so we can pass
6942 * two data pointers; icon and text for dw_filesystem_set_item(). 6960 * two data pointers; icon and text for dw_filesystem_set_item().
6943 */ 6961 */
6944 void _dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data, char *text) 6962 void _dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data, char *text)
6945 { 6963 {
6946 char numbuf[10], textbuffer[100]; 6964 char numbuf[11], textbuffer[101];
6947 int flag = 0; 6965 int flag = 0;
6948 GtkWidget *clist; 6966 GtkWidget *clist;
6949 int _locked_by_me = FALSE; 6967 int _locked_by_me = FALSE;
6950 6968
6951 DW_MUTEX_LOCK; 6969 DW_MUTEX_LOCK;
6954 { 6972 {
6955 DW_MUTEX_UNLOCK; 6973 DW_MUTEX_UNLOCK;
6956 return; 6974 return;
6957 } 6975 }
6958 6976
6959 sprintf(numbuf, "%d", column); 6977 snprintf(numbuf, 10, "%d", column);
6960 flag = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(clist), numbuf)); 6978 flag = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(clist), numbuf));
6961 if(pointer) 6979 if(pointer)
6962 { 6980 {
6963 row += GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(clist), "_dw_insertpos")); 6981 row += GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(clist), "_dw_insertpos"));
6964 } 6982 }
6986 } 7004 }
6987 else if(flag & DW_CFA_ULONG) 7005 else if(flag & DW_CFA_ULONG)
6988 { 7006 {
6989 ULONG tmp = *((ULONG *)data); 7007 ULONG tmp = *((ULONG *)data);
6990 7008
6991 sprintf(textbuffer, "%lu", tmp); 7009 snprintf(textbuffer, 100, "%lu", tmp);
6992 7010
6993 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); 7011 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
6994 } 7012 }
6995 else if(flag & DW_CFA_DATE) 7013 else if(flag & DW_CFA_DATE)
6996 { 7014 {
7113 * handle: Handle to the container window (widget). 7131 * handle: Handle to the container window (widget).
7114 * column: Zero based column. 7132 * column: Zero based column.
7115 */ 7133 */
7116 int dw_container_get_column_type(HWND handle, int column) 7134 int dw_container_get_column_type(HWND handle, int column)
7117 { 7135 {
7118 char numbuf[10]; 7136 char numbuf[11] = {0};
7119 int flag, rc; 7137 int flag, rc;
7120 GtkWidget *clist; 7138 GtkWidget *clist;
7121 int _locked_by_me = FALSE; 7139 int _locked_by_me = FALSE;
7122 7140
7123 DW_MUTEX_LOCK; 7141 DW_MUTEX_LOCK;
7126 { 7144 {
7127 DW_MUTEX_UNLOCK; 7145 DW_MUTEX_UNLOCK;
7128 return 0; 7146 return 0;
7129 } 7147 }
7130 7148
7131 sprintf(numbuf, "%d", column); 7149 snprintf(numbuf, 10, "%d", column);
7132 flag = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(clist), numbuf)); 7150 flag = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(clist), numbuf));
7133 7151
7134 if(flag & DW_CFA_BITMAPORICON) 7152 if(flag & DW_CFA_BITMAPORICON)
7135 rc = DW_CFA_BITMAPORICON; 7153 rc = DW_CFA_BITMAPORICON;
7136 else if(flag & DW_CFA_STRING) 7154 else if(flag & DW_CFA_STRING)
8926 */ 8944 */
8927 int dw_module_load(char *name, HMOD *handle) 8945 int dw_module_load(char *name, HMOD *handle)
8928 { 8946 {
8929 int len; 8947 int len;
8930 char *newname; 8948 char *newname;
8931 char errorbuf[1024]; 8949 char errorbuf[1025] = {0};
8932 8950
8933 8951
8934 if(!handle) 8952 if(!handle)
8935 return -1; 8953 return -1;
8936 8954
9549 * size: Size in bytes of the shared memory region to allocate. 9567 * size: Size in bytes of the shared memory region to allocate.
9550 * name: A string pointer to a unique memory name. 9568 * name: A string pointer to a unique memory name.
9551 */ 9569 */
9552 HSHM dw_named_memory_new(void **dest, int size, char *name) 9570 HSHM dw_named_memory_new(void **dest, int size, char *name)
9553 { 9571 {
9554 char namebuf[1024]; 9572 char namebuf[1025] = {0};
9555 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm)); 9573 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm));
9556 9574
9557 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); 9575 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
9558 sprintf(namebuf, "/tmp/.dw/%s", name); 9576 snprintf(namebuf, 1024, "/tmp/.dw/%s", name);
9559 9577
9560 if((handle->fd = open(namebuf, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0) 9578 if((handle->fd = open(namebuf, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0)
9561 { 9579 {
9562 free(handle); 9580 free(handle);
9563 return NULL; 9581 return NULL;
9595 * size: Size in bytes of the shared memory region to requested. 9613 * size: Size in bytes of the shared memory region to requested.
9596 * name: A string pointer to a unique memory name. 9614 * name: A string pointer to a unique memory name.
9597 */ 9615 */
9598 HSHM dw_named_memory_get(void **dest, int size, char *name) 9616 HSHM dw_named_memory_get(void **dest, int size, char *name)
9599 { 9617 {
9600 char namebuf[1024]; 9618 char namebuf[1025] = {0};
9601 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm)); 9619 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm));
9602 9620
9603 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH); 9621 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
9604 sprintf(namebuf, "/tmp/.dw/%s", name); 9622 snprintf(namebuf, 1024, "/tmp/.dw/%s", name);
9605 9623
9606 if((handle->fd = open(namebuf, O_RDWR)) < 0) 9624 if((handle->fd = open(namebuf, O_RDWR)) < 0)
9607 { 9625 {
9608 free(handle); 9626 free(handle);
9609 return NULL; 9627 return NULL;
10258 { 10276 {
10259 for(z=0;z<256;z++) 10277 for(z=0;z<256;z++)
10260 { 10278 {
10261 if(!pagearray[z]) 10279 if(!pagearray[z])
10262 { 10280 {
10263 char text[100]; 10281 char text[101] = {0};
10264 int num = z; 10282 int num = z;
10265 10283
10266 if(front) 10284 if(front)
10267 num |= 1 << 16; 10285 num |= 1 << 16;
10268 10286
10269 sprintf(text, "_dw_page%d", z); 10287 snprintf(text, 100, "_dw_page%d", z);
10270 /* Save the real id and the creation flags */ 10288 /* Save the real id and the creation flags */
10271 gtk_object_set_data(GTK_OBJECT(handle), text, GINT_TO_POINTER(num)); 10289 gtk_object_set_data(GTK_OBJECT(handle), text, GINT_TO_POINTER(num));
10272 DW_MUTEX_UNLOCK; 10290 DW_MUTEX_UNLOCK;
10273 return z; 10291 return z;
10274 } 10292 }
10371 10389
10372 DW_MUTEX_LOCK; 10390 DW_MUTEX_LOCK;
10373 realpage = _get_physical_page(handle, pageid); 10391 realpage = _get_physical_page(handle, pageid);
10374 if(realpage < 0 || realpage > 255) 10392 if(realpage < 0 || realpage > 255)
10375 { 10393 {
10376 char ptext[100]; 10394 char ptext[101] = {0};
10377 int num; 10395 int num;
10378 10396
10379 sprintf(ptext, "_dw_page%d", (int)pageid); 10397 snprintf(ptext, 100, "_dw_page%d", (int)pageid);
10380 num = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(handle), ptext)); 10398 num = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(handle), ptext));
10381 realpage = 0xFF & num; 10399 realpage = 0xFF & num;
10382 } 10400 }
10383 10401
10384 if(realpage > -1 && realpage < 256) 10402 if(realpage > -1 && realpage < 256)
10412 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page) 10430 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page)
10413 { 10431 {
10414 GtkWidget *label, *child, *oldlabel, **pagearray; 10432 GtkWidget *label, *child, *oldlabel, **pagearray;
10415 gchar *text = NULL; 10433 gchar *text = NULL;
10416 int num, z, realpage = -1, pad, _locked_by_me = FALSE; 10434 int num, z, realpage = -1, pad, _locked_by_me = FALSE;
10417 char ptext[100]; 10435 char ptext[101] = {0};
10418 10436
10419 DW_MUTEX_LOCK; 10437 DW_MUTEX_LOCK;
10420 sprintf(ptext, "_dw_page%d", (int)pageid); 10438 snprintf(ptext, 100, "_dw_page%d", (int)pageid);
10421 num = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(handle), ptext)); 10439 num = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(handle), ptext));
10422 gtk_object_set_data(GTK_OBJECT(handle), ptext, NULL); 10440 gtk_object_set_data(GTK_OBJECT(handle), ptext, NULL);
10423 pagearray = (GtkWidget **)gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray"); 10441 pagearray = (GtkWidget **)gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray");
10424 10442
10425 if(!pagearray) 10443 if(!pagearray)