comparison win/dw.c @ 2126:97839ff3c985

Win: Switch to using _snprintf() for compatibility with old versions of Visual C.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 28 Jun 2020 05:39:08 +0000
parents 37758cfed67b
children 663467f6eee4
comparison
equal deleted inserted replaced
2125:37758cfed67b 2126:97839ff3c985
4274 { 4274 {
4275 strncpy(_dw_exec_dir, argv[0], (size_t)(pos - argv[0])); 4275 strncpy(_dw_exec_dir, argv[0], (size_t)(pos - argv[0]));
4276 if((pos++) && !_dw_app_id[0]) 4276 if((pos++) && !_dw_app_id[0])
4277 { 4277 {
4278 /* If we have a binary name, use that for the Application ID instead. */ 4278 /* If we have a binary name, use that for the Application ID instead. */
4279 snprintf(_dw_app_id, 100, "%s.%s", DW_APP_DOMAIN_DEFAULT, pos); 4279 _snprintf(_dw_app_id, 100, "%s.%s", DW_APP_DOMAIN_DEFAULT, pos);
4280 strncpy(_dw_app_name, pos, 100); 4280 strncpy(_dw_app_name, pos, 100);
4281 } 4281 }
4282 } 4282 }
4283 } 4283 }
4284 /* If that failed... just get the current directory */ 4284 /* If that failed... just get the current directory */
4429 { 4429 {
4430 dw_messagebox("Dynamic Windows", DW_MB_OK|DW_MB_ERROR, "Could not initialize the object window. error code %d", GetLastError()); 4430 dw_messagebox("Dynamic Windows", DW_MB_OK|DW_MB_ERROR, "Could not initialize the object window. error code %d", GetLastError());
4431 exit(1); 4431 exit(1);
4432 } 4432 }
4433 4433
4434 if(!_dw_app_id[0]) 4434 if(!_dw_app_id[0])
4435 { 4435 {
4436 /* Generate an Application ID based on the PID if all else fails. */ 4436 /* Generate an Application ID based on the PID if all else fails. */
4437 snprintf(_dw_app_id, 100, "%s.pid.%d", DW_APP_DOMAIN_DEFAULT, getpid()); 4437 _snprintf(_dw_app_id, 100, "%s.pid.%d", DW_APP_DOMAIN_DEFAULT, getpid());
4438 } 4438 }
4439 if(!_dw_app_name[0]) 4439 if(!_dw_app_name[0])
4440 { 4440 {
4441 /* If we still don't have an app name, get the executable name */ 4441 /* If we still don't have an app name, get the executable name */
4442 char fullpath[261] = {0}, *pos; 4442 char fullpath[261] = {0}, *pos;
4443 GetModuleFileNameA(DWInstance, fullpath, 260); 4443 GetModuleFileNameA(DWInstance, fullpath, 260);
4444 pos = strrchr(fullpath, '\\'); 4444 pos = strrchr(fullpath, '\\');
4445 if(pos) 4445 if(pos)
4446 pos++; 4446 pos++;
4447 strncpy(_dw_app_name, pos ? pos : fullpath, 100); 4447 strncpy(_dw_app_name, pos ? pos : fullpath, 100);
4448 } 4448 }
4449 4449
4450 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) 4450 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
4451 /* Register HTML renderer class */ 4451 /* Register HTML renderer class */
4452 memset(&wc, 0, sizeof(WNDCLASS)); 4452 memset(&wc, 0, sizeof(WNDCLASS));
4453 wc.lpszClassName = BrowserClassName; 4453 wc.lpszClassName = BrowserClassName;