static void errmsg(UINT id, DWORD code) { char buffer [512]; char format [128]; LoadStringA(GetModuleHandleA(NULL), id, format, 128); wnsprintfA(buffer, 512, format, code); MessageBoxA(NULL, buffer, "gdi++ ERROR", MB_OK|MB_ICONSTOP); }
int modify_segd_option(char_t const* option, char const* option_value/*, unsigned option_value_size*/) { int i_ret = APP_SUCCESS; int i = 0; size_t size = 0; char tmp_buf[MAX_STRING_SIZE*2] = {0}; errno_t err_code = 0x0; #if defined(UNICODE) || defined(_UNICODE) err_code = wcstombs_s(&size, tmp_buf, sizeof(tmp_buf), option, MAX_STRING_SIZE); if(err_code != 0){ set_last_error(IDS_STRING5010); output_log(IDS_STRING5010, option); return i_ret = APP_FAULT; } #else strcpy(tmp_buf, option); #endif //defined(UNICODE) || defined(_UNICODE) tmp_buf[size] = 0x0; size = sizeof(__segd_option_items)/sizeof(__segd_option_items[0]); for(i = 0; i < size; ++i) if(strcmp(tmp_buf, __segd_option_items[i].key_name_) == 0) break; i_ret = __segd_option_items[i].function_ptr_(__segd_option_items[i].value_ptr_, option_value); if(i_ret != APP_SUCCESS){ set_last_error(IDS_STRING5009); output_log(IDS_STRING5009, option); return i_ret;} for(i = 0; i < __config_file_line_size; ++i) if(strcmp(tmp_buf, __config_file_lines[i].key_name_) == 0) break; StrCpyA(__config_file_lines[i].value_, option_value); wnsprintfA(__config_file_lines[i].line_, sizeof(__config_file_lines[i].line_), "%s %s", tmp_buf, option_value); return i_ret; }
/* * Try to create a single .trashinfo file. Return TRUE if successful, else FALSE */ static BOOL try_create_trashinfo_file(const char *info_dir, const char *file_name, const char *original_file_name) { SYSTEMTIME curr_time; char datebuf[200]; char *path = SHAlloc(strlen(info_dir)+strlen(file_name)+strlen(trashinfo_suffix)+1); int writer = -1; if (path==NULL) return FALSE; wsprintfA(path, "%s%s%s", info_dir, file_name, trashinfo_suffix); TRACE("Trying to create '%s'\n", path); writer = open(path, O_CREAT|O_WRONLY|O_TRUNC|O_EXCL, 0600); if (writer==-1) goto error; write(writer, trashinfo_header, strlen(trashinfo_header)); if (!XDG_WriteDesktopStringEntry(writer, "Path", XDG_URLENCODE, original_file_name)) goto error; GetLocalTime( &curr_time ); wnsprintfA(datebuf, 200, "%04d-%02d-%02dT%02d:%02d:%02d", curr_time.wYear, curr_time.wMonth, curr_time.wDay, curr_time.wHour, curr_time.wMinute, curr_time.wSecond); if (!XDG_WriteDesktopStringEntry(writer, "DeletionDate", 0, datebuf)) goto error; close(writer); SHFree(path); return TRUE; error: if (writer != -1) { close(writer); unlink(path); } SHFree(path); return FALSE; }