From scmnotify @ osdn.net Tue Jan 7 13:22:23 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Tue, 07 Jan 2020 13:22:23 +0900 Subject: [Ttssh2-commit] =?utf-8?q?=5B8454=5D_/manual_=E3=82=92_Version_4_?= =?utf-8?b?55So44GoIDUg55So44Gr5YiG5Ymy44GZ44KL?= Message-ID: <1578370943.344116.76444.nullmailer@users.osdn.me> Revision: 8454 https://osdn.net/projects/ttssh2/scm/svn/commits/8454 Author: doda Date: 2020-01-07 13:22:22 +0900 (Tue, 07 Jan 2020) Log Message: ----------- /manual を Version 4 用と 5 用に分割する ML: [Ttssh2-devel 4270] 旧URLは取り合えず Version 4 へのリダイレクトとする。 Modified Paths: -------------- trunk/doc/web/manual/index.html.en trunk/doc/web/manual/index.html.ja Added Paths: ----------- trunk/doc/web/manual/.htaccess trunk/doc/web/manual/4/ trunk/doc/web/manual/4/index.html.en trunk/doc/web/manual/4/index.html.ja trunk/doc/web/manual/5/ trunk/doc/web/manual/5/index.html.en trunk/doc/web/manual/5/index.html.ja -------------- next part -------------- Added: trunk/doc/web/manual/.htaccess =================================================================== --- trunk/doc/web/manual/.htaccess (rev 0) +++ trunk/doc/web/manual/.htaccess 2020-01-07 04:22:22 UTC (rev 8454) @@ -0,0 +1,2 @@ +Redirect permanent /manual/ja https://ttssh2.osdn.jp/manual/4/ja +Redirect permanent /manual/en https://ttssh2.osdn.jp/manual/4/en Copied: trunk/doc/web/manual/4/index.html.en (from rev 8453, trunk/doc/web/manual/index.html.en) =================================================================== --- trunk/doc/web/manual/4/index.html.en (rev 0) +++ trunk/doc/web/manual/4/index.html.en 2020-01-07 04:22:22 UTC (rev 8454) @@ -0,0 +1,22 @@ + + + + + + Tera Term Manual + + + + + + + + Copied: trunk/doc/web/manual/4/index.html.ja (from rev 8453, trunk/doc/web/manual/index.html.ja) =================================================================== --- trunk/doc/web/manual/4/index.html.ja (rev 0) +++ trunk/doc/web/manual/4/index.html.ja 2020-01-07 04:22:22 UTC (rev 8454) @@ -0,0 +1,22 @@ + + + + + + Tera Term マニュアル + + + + + + + + Copied: trunk/doc/web/manual/5/index.html.en (from rev 8453, trunk/doc/web/manual/index.html.en) =================================================================== --- trunk/doc/web/manual/5/index.html.en (rev 0) +++ trunk/doc/web/manual/5/index.html.en 2020-01-07 04:22:22 UTC (rev 8454) @@ -0,0 +1,22 @@ + + + + + + Tera Term Manual + + + + + + + + Copied: trunk/doc/web/manual/5/index.html.ja (from rev 8453, trunk/doc/web/manual/index.html.ja) =================================================================== --- trunk/doc/web/manual/5/index.html.ja (rev 0) +++ trunk/doc/web/manual/5/index.html.ja 2020-01-07 04:22:22 UTC (rev 8454) @@ -0,0 +1,22 @@ + + + + + + Tera Term マニュアル + + + + + + + + Modified: trunk/doc/web/manual/index.html.en =================================================================== --- trunk/doc/web/manual/index.html.en 2020-01-06 03:09:49 UTC (rev 8453) +++ trunk/doc/web/manual/index.html.en 2020-01-07 04:22:22 UTC (rev 8454) @@ -6,16 +6,16 @@ Tera Term Manual - + Modified: trunk/doc/web/manual/index.html.ja =================================================================== --- trunk/doc/web/manual/index.html.ja 2020-01-06 03:09:49 UTC (rev 8453) +++ trunk/doc/web/manual/index.html.ja 2020-01-07 04:22:22 UTC (rev 8454) @@ -6,16 +6,16 @@ Tera Term マニュアル - + From scmnotify @ osdn.net Tue Jan 7 13:34:11 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Tue, 07 Jan 2020 13:34:11 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NTVdIOODnuODi+ODpeOCouODq+iHqg==?= =?utf-8?b?5L2T44Gu572u44GN5aC044KSIHN2bjppZ25vcmUg44Gr6L+95Yqg44GX44Gf?= Message-ID: <1578371651.148073.104394.nullmailer@users.osdn.me> Revision: 8455 https://osdn.net/projects/ttssh2/scm/svn/commits/8455 Author: doda Date: 2020-01-07 13:34:10 +0900 (Tue, 07 Jan 2020) Log Message: ----------- マニュアル自体の置き場を svn:ignore に追加した マニュアル自体は別ツリーで管理している為。 Property Changed: ---------------- trunk/doc/web/manual/4/ trunk/doc/web/manual/5/ -------------- next part -------------- Index: trunk/doc/web/manual/4 =================================================================== --- trunk/doc/web/manual/4 2020-01-07 04:22:22 UTC (rev 8454) +++ trunk/doc/web/manual/4 2020-01-07 04:34:10 UTC (rev 8455) Property changes on: trunk/doc/web/manual/4 ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,2 ## +en +ja Index: trunk/doc/web/manual/5 =================================================================== --- trunk/doc/web/manual/5 2020-01-07 04:22:22 UTC (rev 8454) +++ trunk/doc/web/manual/5 2020-01-07 04:34:10 UTC (rev 8455) Property changes on: trunk/doc/web/manual/5 ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,2 ## +en +ja From scmnotify @ osdn.net Wed Jan 8 00:44:01 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Wed, 08 Jan 2020 00:44:01 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NTZdIOODleOCoeOCpOODq+mAgeS/oQ==?= =?utf-8?b?44Gn44OQ44Kk44OK44Oq44Kq44OX44K344On44Oz44GM5L2/44GI44KL44KI?= =?utf-8?b?44GG44Gr44GX44Gf?= Message-ID: <1578411841.710784.9226.nullmailer@users.osdn.me> Revision: 8456 https://osdn.net/projects/ttssh2/scm/svn/commits/8456 Author: zmatsuo Date: 2020-01-08 00:44:00 +0900 (Wed, 08 Jan 2020) Log Message: ----------- ファイル送信でバイナリオプションが使えるようにした - [file]/[Send file...] - ファイルドロップ Modified Paths: -------------- trunk/teraterm/teraterm/clipboar.c trunk/teraterm/teraterm/sendmem.cpp trunk/teraterm/teraterm/sendmem.h trunk/teraterm/teraterm/vtwin.cpp trunk/teraterm/ttpmacro/fileread.cpp trunk/teraterm/ttpmacro/fileread.h -------------- next part -------------- Modified: trunk/teraterm/teraterm/clipboar.c =================================================================== --- trunk/teraterm/teraterm/clipboar.c 2020-01-07 04:34:10 UTC (rev 8455) +++ trunk/teraterm/teraterm/clipboar.c 2020-01-07 15:44:00 UTC (rev 8456) @@ -804,7 +804,7 @@ * @param str_w \x95\xB6\x8E\x9A\x97\xF1\x82ւ̃|\x83C\x83\x93\x83^ * malloc()\x82\xB3\x82ꂽ\x83o\x83b\x83t\x83@\x81A\x91\x97\x90M\x8A\xAE\x97\xB9\x8E\x9E\x82Ɏ\xA9\x93\xAE\x82\xC5free()\x82\xB3\x82\xEA\x82\xE9 * @param str_len \x95\xB6\x8E\x9A\x92\xB7(wchar_t\x92P\x88\xCA) - * 0\x82̂Ƃ\xAB\x81Astr_w\x82\xA9\x82當\x8E\x9A\x97񒷂𓾂\xE9 + * 0 \x82̏ꍇ\x82\xCD L'\0' \x82܂\xC5 */ static void CBSendStart(wchar_t *str_w, size_t str_len) { @@ -812,9 +812,7 @@ if (str_len == 0) { str_len = wcslen(str_w); } - sm = SendMemInit(str_w, - str_len * sizeof(wchar_t), - SendMemTypeTextLF); + sm = SendMemTextW(str_w, str_len); if (sm == NULL) return; if (ts.PasteDelayPerLine != 0) { Modified: trunk/teraterm/teraterm/sendmem.cpp =================================================================== --- trunk/teraterm/teraterm/sendmem.cpp 2020-01-07 04:34:10 UTC (rev 8455) +++ trunk/teraterm/teraterm/sendmem.cpp 2020-01-07 15:44:00 UTC (rev 8456) @@ -1,5 +1,5 @@ /* - * (C) 2019 TeraTerm Project + * (C) 2019-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,9 +27,12 @@ */ #include +#include #include #define _CRTDBG_MAP_ALLOC #include +#include +#include #include "tttypes.h" #include "ttcommon.h" @@ -49,6 +52,12 @@ #include "sendmem.h" +typedef enum { + SendMemTypeTextLF, // wchar_t 0x0a + SendMemTypeTextCRLF, // wchar_t 0x0d + 0x0a + SendMemTypeBinary, +} SendMemType; + // \x91\x97\x90M\x92\x86\x82\xC9VTWIN\x82ɔr\x91\xBC\x82\xF0\x82\xA9\x82\xAF\x82\xE9 #define USE_ENABLE_WINDOW 0 // 1=\x94r\x91\xBC\x82\xB7\x82\xE9 @@ -408,16 +417,9 @@ } /** - * \x83\x81\x83\x82\x83\x8A\x82ɂ\xA0\x82\xE9\x83f\x81[\x83^\x82𑗐M\x82\xB7\x82\xE9 - * \x83f\x81[\x83^\x82͑\x97\x90M\x8FI\x97\xB9\x8C\xE3\x82\xC9free()\x82\xB3\x82\xEA\x82\xE9 - * - * @param ptr \x83f\x81[\x83^\x82փ|\x83C\x83\x93\x83^(malloc()\x82\xB3\x82ꂽ\x97̈\xE6) - * \x91\x97\x90M\x8C\xE3(\x92\x86\x92f\x8C\xE3)\x81A\x8E\xA9\x93\xAE\x93I\x82\xC9free()\x82\xB3\x82\xEA\x82\xE9 - * @param len \x83f\x81[\x83^\x92\xB7(byte) - * \x95\xB6\x8E\x9A\x97\xF1(wchar_t)\x82̏ꍇ\x82\xE0byte\x90\x94 - * @param type \x95\xB6\x8E\x9A\x97\xF1(wchar_t,LF or CRLF or \x83o\x83C\x83i\x83\x8A) + * \x8F\x89\x8A\xFA\x89\xBB */ -SendMem *SendMemInit(void *ptr, size_t len, SendMemType type) +static SendMem *SendMemInit_() { if (sendmem_work != NULL) { // \x91\x97\x90M\x92\x86 @@ -427,20 +429,11 @@ if (p == NULL) { return NULL; } - if (type == SendMemTypeTextCRLF || type == SendMemTypeTextLF) { - // \x89\xFC\x8Ds\x83R\x81[\x83h\x82𒲐\xAE\x82\xB5\x82Ă\xA8\x82\xAD - size_t new_len = len / sizeof(wchar_t); - p->send_ptr = (BYTE *)NormalizeLineBreak((wchar_t *)ptr, &new_len); - p->send_len = new_len * sizeof(wchar_t); - free(ptr); - } else { - p->send_ptr = (BYTE *)ptr; - p->send_len = len; - } - if (p->send_ptr == NULL) { - return NULL; - } - p->type = type; + + p->send_ptr = NULL; + p->send_len = 0; + + p->type = SendMemTypeBinary; p->local_echo_enable = FALSE; p->delay_per_char = 0; // (ms) p->delay_per_line = 0; // (ms) @@ -451,6 +444,56 @@ return p; } +/** + * \x83\x81\x83\x82\x83\x8A\x82ɂ\xA0\x82\xE9\x83e\x83L\x83X\x83g\x82𑗐M\x82\xB7\x82\xE9 + * \x83f\x81[\x83^\x82͑\x97\x90M\x8FI\x97\xB9\x8C\xE3\x82\xC9free()\x82\xB3\x82\xEA\x82\xE9 + * + * @param ptr \x83f\x81[\x83^\x82փ|\x83C\x83\x93\x83^(malloc()\x82\xB3\x82ꂽ\x97̈\xE6) + * \x91\x97\x90M\x8C\xE3(\x92\x86\x92f\x8C\xE3)\x81A\x8E\xA9\x93\xAE\x93I\x82\xC9free()\x82\xB3\x82\xEA\x82\xE9 + * @param len \x95\xB6\x8E\x9A\x97\xF1\x92\xB7(wchar_t\x92P\x88\xCA) + * 0 \x82̏ꍇ\x82\xCD L'\0' \x82܂\xC5 + */ +SendMem *SendMemTextW(wchar_t *str, size_t len) +{ + SendMem *p = SendMemInit_(); + if (p == NULL) { + return NULL; + } + + if (len == 0) { + len = wcslen(str); + } + + // \x89\xFC\x8Ds\x83R\x81[\x83h\x82𒲐\xAE\x82\xB5\x82Ă\xA8\x82\xAD + size_t new_len = len; + p->send_ptr = (BYTE *)NormalizeLineBreak((wchar_t *)str, &new_len); + p->send_len = new_len * sizeof(wchar_t); + free(str); + p->type = SendMemTypeTextLF; + return p; +} + +/** + * \x83\x81\x83\x82\x83\x8A\x82ɂ\xA0\x82\xE9\x83f\x81[\x83^\x82𑗐M\x82\xB7\x82\xE9 + * \x83f\x81[\x83^\x82͑\x97\x90M\x8FI\x97\xB9\x8C\xE3\x82\xC9free()\x82\xB3\x82\xEA\x82\xE9 + * + * @param ptr \x83f\x81[\x83^\x82փ|\x83C\x83\x93\x83^(malloc()\x82\xB3\x82ꂽ\x97̈\xE6) + * \x91\x97\x90M\x8C\xE3(\x92\x86\x92f\x8C\xE3)\x81A\x8E\xA9\x93\xAE\x93I\x82\xC9free()\x82\xB3\x82\xEA\x82\xE9 + * @param len \x83f\x81[\x83^\x92\xB7(byte) + */ +SendMem *SendMemBinary(void *ptr, size_t len) +{ + SendMem *p = SendMemInit_(); + if (p == NULL) { + return NULL; + } + + p->send_ptr = (BYTE *)ptr; + p->send_len = len; + p->type = SendMemTypeBinary; + return p; +} + void SendMemInitEcho(SendMem *sm, BOOL echo) { sm->local_echo_enable = echo; @@ -529,18 +572,25 @@ return TRUE; } #else -BOOL SendMemSendFile(const wchar_t *filename, BOOL binary) // binary\x96\xA2\x91Ή\x9E +BOOL SendMemSendFile(const wchar_t *filename, BOOL binary) { - binary = FALSE; - - size_t str_len; - wchar_t *str_ptr = LoadFileWW(filename, &str_len); - if (str_ptr == NULL) { - return FALSE; + SendMem *sm; + if (!binary) { + size_t str_len; + wchar_t *str_ptr = LoadFileWW(filename, &str_len); + if (str_ptr == NULL) { + return FALSE; + } + sm = SendMemTextW(str_ptr, str_len); } - str_len *= sizeof(wchar_t); - - SendMem *sm = SendMemInit(str_ptr, str_len, SendMemTypeTextLF); + else { + size_t data_len; + unsigned char *data_ptr = LoadFileBinary(filename, &data_len); + if (data_ptr == NULL) { + return FALSE; + } + sm = SendMemBinary(data_ptr, data_len); + } SendMemInitDialog(sm, hInst, HVTWin, ts.UILanguageFile); SendMemInitDialogCaption(sm, L"send file"); // title SendMemInitDialogFilename(sm, filename); @@ -559,9 +609,9 @@ BOOL SendMemPasteString(wchar_t *str) { const size_t len = wcslen(str); - CommTextOutW(&cv, str, len); + CommTextOutW(&cv, str, (int)len); if (ts.LocalEcho > 0) { - CommTextEchoW(&cv, str, len); + CommTextEchoW(&cv, str, (int)len); } free(str); Modified: trunk/teraterm/teraterm/sendmem.h =================================================================== --- trunk/teraterm/teraterm/sendmem.h 2020-01-07 04:34:10 UTC (rev 8455) +++ trunk/teraterm/teraterm/sendmem.h 2020-01-07 15:44:00 UTC (rev 8456) @@ -1,5 +1,5 @@ /* - * (C) 2019 TeraTerm Project + * (C) 2019-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,15 +33,10 @@ extern "C" { #endif -typedef enum { - SendMemTypeTextLF, // wchar_t 0x0a - SendMemTypeTextCRLF, // wchar_t 0x0d + 0x0a - SendMemTypeBinary, -} SendMemType; - typedef struct SendMemTag SendMem; -SendMem *SendMemInit(void *ptr, size_t len, SendMemType type); +SendMem *SendMemTextW(wchar_t *ptr, size_t len); +SendMem *SendMemBinary(void *ptr, size_t len); void SendMemInitEcho(SendMem *sm, BOOL echo); void SendMemInitDelay(SendMem *sm, DWORD per_line, DWORD per_char); void SendMemInitDialog(SendMem *sm, HINSTANCE hInstance, HWND hWndParent, const char *UILanguageFile); Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2020-01-07 04:34:10 UTC (rev 8455) +++ trunk/teraterm/teraterm/vtwin.cpp 2020-01-07 15:44:00 UTC (rev 8456) @@ -4359,7 +4359,6 @@ ::DragAcceptFiles(hDlgWnd, TRUE); SetDlgTexts(hDlgWnd, TextInfos, _countof(TextInfos), data->UILanguageFile); CenterWindow(hDlgWnd, GetParent(hDlgWnd)); - EnableWindow(GetDlgItem(hDlgWnd, IDC_SENDFILE_CHECK_BINARY), FALSE); return TRUE; case WM_COMMAND: @@ -4741,12 +4740,10 @@ // (2008.5.12 maya) changed to PropertySheet void CVTWindow::OnExternalSetup() { - DWORD ret; - SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, ts.UILanguageFile, "Tera Term", "DLG_TAHOMA_FONT"); CAddSettingPropSheetDlg CAddSetting(m_hInst, HVTWin); - ret = CAddSetting.DoModal(); + INT_PTR ret = CAddSetting.DoModal(); switch (ret) { case (DWORD)-1: case IDABORT: Modified: trunk/teraterm/ttpmacro/fileread.cpp =================================================================== --- trunk/teraterm/ttpmacro/fileread.cpp 2020-01-07 04:34:10 UTC (rev 8455) +++ trunk/teraterm/ttpmacro/fileread.cpp 2020-01-07 15:44:00 UTC (rev 8456) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 TeraTerm Project + * Copyright (C) 2018-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,11 +45,13 @@ /** * \x83t\x83@\x83C\x83\x8B\x82\xF0\x83\x81\x83\x82\x83\x8A\x82ɓǂݍ\x9E\x82\xDE - * @param[out] *_len \x83T\x83C\x83Y(\x8DŌ\xE3\x82ɕt\x89\xC1\x82\xB3\x82\xEA\x82\xE9"\0\0"\x82\xF0\x8A܂\xDE) + * @param[out] *_len \x83T\x83C\x83Y(terminater\x8A܂\xDE) + * @param[in] terminate TRUE \x8DŌ\xE3\x82\xC9 L'\0' ("\0\0")\x82\xF0\x95t\x89\xC1 + * FALSE \x83t\x83@\x83C\x83\x8B\x82\xF0\x82\xBB\x82̂܂ܓǂݍ\x9E\x82\xDE * @retval \x83t\x83@\x83C\x83\x8B\x82̒\x86\x90g\x82ւ̃|\x83C\x83\x93\x83^(\x8Eg\x97p\x8C\xE3free()\x82\xB7\x82邱\x82\xC6) - * NULL=\x83G\x83\x89\x81[ + * NULL=\x83G\x83\x89\x81[ (fclose()\x82\xB7\x82邱\x82\xC6) */ -static void *LoadRawFile(FILE *fp, size_t *_len) +static void *LoadRawFile(FILE *fp, size_t *_len, BOOL terminate) { fseek(fp, 0L, SEEK_END); fpos_t pos; @@ -56,17 +58,56 @@ fgetpos(fp, &pos); fseek(fp, 0L, SEEK_SET); size_t len = (size_t)pos; - char *buf = (char *)malloc(len + 2); - buf[len] = 0; - buf[len+1] = 0; // UTF-16\x91΍\xF4 - fread(buf, 1, len, fp); - len += 2; - *_len = len; + size_t alloc_len = terminate ? len + 2 : len; + char *buf = (char *)malloc(alloc_len); + if (buf == NULL) { + return NULL; + } + size_t rlen = fread(buf, 1, len, fp); + if (rlen != len) { + free(buf); + return NULL; + } + if (terminate) { + buf[len] = 0; + buf[len+1] = 0; // UTF-16\x91΍\xF4 + } + *_len = alloc_len; return buf; } /** * \x83t\x83@\x83C\x83\x8B\x82\xF0\x83\x81\x83\x82\x83\x8A\x82ɓǂݍ\x9E\x82\xDE + * @param[out] *_len \x83T\x83C\x83Y(\x8DŌ\xE3\x82ɕt\x89\xC1\x82\xB3\x82\xEA\x82\xE9"\0\0"\x82\xF0\x8A܂\xDE) + * @retval \x83t\x83@\x83C\x83\x8B\x82̒\x86\x90g\x82ւ̃|\x83C\x83\x93\x83^(\x8Eg\x97p\x8C\xE3free()\x82\xB7\x82邱\x82\xC6) + * NULL=\x83G\x83\x89\x81[ + */ +static void *LoadRawFile(FILE *fp, size_t *_len) +{ + return LoadRawFile(fp, _len, TRUE); +} + +/** + * \x83t\x83@\x83C\x83\x8B\x82\xF0\x83\x81\x83\x82\x83\x8A\x82ɓǂݍ\x9E\x82\xDE + * \x89\xC1\x8DH\x82͍s\x82\xED\x82Ȃ\xA2 + * @param[out] *_len \x83T\x83C\x83Y + * @retval \x83t\x83@\x83C\x83\x8B\x82̒\x86\x90g\x82ւ̃|\x83C\x83\x93\x83^(\x8Eg\x97p\x8C\xE3free()\x82\xB7\x82邱\x82\xC6) + * NULL=\x83G\x83\x89\x81[ + */ +uint8_t *LoadFileBinary(const wchar_t *FileName, size_t *_len) +{ + FILE *fp; + _wfopen_s(&fp, FileName, L"rb"); + if (fp == NULL) { + return NULL; + } + uint8_t *ptr = (uint8_t *)LoadRawFile(fp, _len, FALSE); + fclose(fp); + return ptr; +} + +/** + * \x83t\x83@\x83C\x83\x8B\x82\xF0\x83\x81\x83\x82\x83\x8A\x82ɓǂݍ\x9E\x82\xDE * \x92\x86\x90g\x82\xCDUTF-8\x82ɕϊ\xB7\x82\xB3\x82\xEA\x82\xE9 * \x83t\x83@\x83C\x83\x8B\x82̍Ō\xE3\x82\xCD '\0'\x82Ń^\x81[\x83~\x83l\x81[\x83g\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9 * Modified: trunk/teraterm/ttpmacro/fileread.h =================================================================== --- trunk/teraterm/ttpmacro/fileread.h 2020-01-07 04:34:10 UTC (rev 8455) +++ trunk/teraterm/ttpmacro/fileread.h 2020-01-07 15:44:00 UTC (rev 8456) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 TeraTerm Project + * Copyright (C) 2018-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,6 +35,7 @@ wchar_t *LoadFileWA(const char *FileName, size_t *_len); char *LoadFileAA(const char *FileName, size_t *_len); wchar_t *LoadFileWW(const wchar_t *FileName, size_t *_len); +unsigned char *LoadFileBinary(const wchar_t *FileName, size_t *_len); #ifdef __cplusplus } From scmnotify @ osdn.net Fri Jan 10 22:12:01 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 10 Jan 2020 22:12:01 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NTddIOOCr+ODquODg+ODl+ODnOODvA==?= =?utf-8?b?44OJ44KS6ZaJ44GY44Gq44GE5aC05ZCI44GM44GC44Gj44Gf44Gu44Gn5L+u?= =?utf-8?b?5q2j?= Message-ID: <1578661921.254285.124972.nullmailer@users.osdn.me> Revision: 8457 https://osdn.net/projects/ttssh2/scm/svn/commits/8457 Author: zmatsuo Date: 2020-01-10 22:12:00 +0900 (Fri, 10 Jan 2020) Log Message: ----------- クリップボードを閉じない場合があったので修正 - r8371 - [Ttssh2-devel 4356] Revision Links: -------------- https://osdn.net/projects/ttssh2/scm/svn/commits/8371 Modified Paths: -------------- trunk/teraterm/teraterm/clipboar.c -------------- next part -------------- Modified: trunk/teraterm/teraterm/clipboar.c =================================================================== --- trunk/teraterm/teraterm/clipboar.c 2020-01-07 15:44:00 UTC (rev 8456) +++ trunk/teraterm/teraterm/clipboar.c 2020-01-10 13:12:00 UTC (rev 8457) @@ -1304,10 +1304,12 @@ const size_t alloc_bytes = (str_len + 1) * sizeof(wchar_t); CBCopyWideHandle = GlobalAlloc(GMEM_MOVEABLE, alloc_bytes); if (CBCopyWideHandle == NULL) { + CloseClipboard(); return FALSE; } CBCopyWidePtr = (wchar_t *)GlobalLock(CBCopyWideHandle); if (CBCopyWidePtr == NULL) { + CloseClipboard(); return FALSE; } memcpy(CBCopyWidePtr, str_w, alloc_bytes - sizeof(wchar_t)); From scmnotify @ osdn.net Fri Jan 10 22:12:13 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 10 Jan 2020 22:12:13 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NThdIGtleWNvZGXorablkYrlr77nrZY=?= Message-ID: <1578661933.764975.126177.nullmailer@users.osdn.me> Revision: 8458 https://osdn.net/projects/ttssh2/scm/svn/commits/8458 Author: zmatsuo Date: 2020-01-10 22:12:13 +0900 (Fri, 10 Jan 2020) Log Message: ----------- keycode警告対策 - GetProcAddress() の戻り値を一旦 FARPROC 変数に入れるようにした - cmakeビルド + VS 時警告レベルを4に上げた Modified Paths: -------------- trunk/teraterm/keycode/CMakeLists.txt trunk/teraterm/keycode/keycode.c -------------- next part -------------- Modified: trunk/teraterm/keycode/CMakeLists.txt =================================================================== --- trunk/teraterm/keycode/CMakeLists.txt 2020-01-10 13:12:00 UTC (rev 8457) +++ trunk/teraterm/keycode/CMakeLists.txt 2020-01-10 13:12:13 UTC (rev 8458) @@ -1,12 +1,9 @@ project(keycode) -if(USE_UNICODE_API) - add_definitions(-DUNICODE -D_UNICODE) -endif() - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") -set(SRC +add_executable( + keycode WIN32 keycode.c keycode.ico keycode-version.rc @@ -14,19 +11,23 @@ kc_res.h ) -include_directories( +target_include_directories( + keycode + PRIVATE ../common - ../ttpfile - . ) -add_executable( - keycode WIN32 - ${SRC} - ) +if(MSVC) + target_compile_options( + keycode + PRIVATE + /W4 + ) +endif() -target_link_libraries( +target_compile_options( keycode + PRIVATE ) install( Modified: trunk/teraterm/keycode/keycode.c =================================================================== --- trunk/teraterm/keycode/keycode.c 2020-01-10 13:12:00 UTC (rev 8457) +++ trunk/teraterm/keycode/keycode.c 2020-01-10 13:12:13 UTC (rev 8458) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2006-2017 TeraTerm Project + * (C) 2006-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,7 +48,7 @@ static BOOL Short; static WORD Scan; -int PASCAL WinMain(HINSTANCE hInstance, +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) @@ -63,17 +63,24 @@ pSetDllDir setDllDir; pSetDefDllDir setDefDllDir; + (void)lpszCmdLine; DoCover_IsDebuggerPresent(); if ((module = GetModuleHandleA("kernel32.dll")) != NULL) { - if ((setDefDllDir = (pSetDefDllDir)GetProcAddress(module, "SetDefaultDllDirectories")) != NULL) { + FARPROC func_ptr = GetProcAddress(module, "SetDefaultDllDirectories"); + setDefDllDir = (pSetDefDllDir)func_ptr; + if (setDefDllDir != NULL) { // SetDefaultDllDirectories() \x82\xAA\x8Eg\x82\xA6\x82\xE9\x8Fꍇ\x82́A\x8C\x9F\x8D\xF5\x83p\x83X\x82\xF0 %WINDOWS%\system32 \x82݂̂ɐݒ肷\x82\xE9 (*setDefDllDir)((DWORD)0x00000800); // LOAD_LIBRARY_SEARCH_SYSTEM32 } - else if ((setDllDir = (pSetDllDir)GetProcAddress(module, "SetDllDirectoryA")) != NULL) { - // SetDefaultDllDirectories() \x82\xAA\x8Eg\x82\xA6\x82Ȃ\xAD\x82Ă\xE0\x81ASetDllDirectory() \x82\xAA\x8Eg\x82\xA6\x82\xE9\x8Fꍇ\x82\xCD - // \x83J\x83\x8C\x83\x93\x83g\x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x82\xBE\x82\xAF\x82ł\xE0\x8C\x9F\x8D\xF5\x83p\x83X\x82\xA9\x82\xE7\x82͂\xB8\x82\xB5\x82Ă\xA8\x82\xAD\x81B - (*setDllDir)(""); + else { + func_ptr = GetProcAddress(module, "SetDllDirectoryA"); + setDllDir = (pSetDllDir)func_ptr; + if (setDllDir != NULL) { + // SetDefaultDllDirectories() \x82\xAA\x8Eg\x82\xA6\x82Ȃ\xAD\x82Ă\xE0\x81ASetDllDirectory() \x82\xAA\x8Eg\x82\xA6\x82\xE9\x8Fꍇ\x82\xCD + // \x83J\x83\x8C\x83\x93\x83g\x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x82\xBE\x82\xAF\x82ł\xE0\x8C\x9F\x8D\xF5\x83p\x83X\x82\xA9\x82\xE7\x82͂\xB8\x82\xB5\x82Ă\xA8\x82\xAD\x81B + (*setDllDir)(""); + } } } @@ -121,7 +128,7 @@ DispatchMessage(&msg); } - return msg.wParam; + return (int)msg.wParam; } void KeyDownProc(HWND hWnd, WPARAM wParam, LPARAM lParam) @@ -153,6 +160,8 @@ void KeyUpProc(HWND hWnd, WPARAM wParam, LPARAM lParam) { + (void)wParam; + (void)lParam; if (! KeyDown) { return; } @@ -175,7 +184,7 @@ if (KeyDown) { _snprintf_s(OutStr,sizeof(OutStr),_TRUNCATE,"Key code is %u.",Scan); - TextOutA(hDC,10,10,OutStr,strlen(OutStr)); + TextOutA(hDC,10,10,OutStr, (int)strlen(OutStr)); } else { TextOutA(hDC,10,10,"Push any key.",13); From scmnotify @ osdn.net Fri Jan 10 22:12:36 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 10 Jan 2020 22:12:36 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NTldIOOCr+ODquODg+ODl+ODnOODvA==?= =?utf-8?b?44OJ44GL44KJ44Gu44Oa44O844K544OI5pmC44CB5pS56KGM44KS5bi444Gr?= =?utf-8?b?5q2j6KaP5YyW44GZ44KL?= Message-ID: <1578661956.059295.126290.nullmailer@users.osdn.me> Revision: 8459 https://osdn.net/projects/ttssh2/scm/svn/commits/8459 Author: zmatsuo Date: 2020-01-10 22:12:35 +0900 (Fri, 10 Jan 2020) Log Message: ----------- クリップボードからのペースト時、改行を常に正規化する - 設定など削除 - lng ファイルの DLG_TAB_COPYPASTE_NORMALIZE_LINEBREAK を削除 - iniファイルのNormalizeLineBreakOnPasteを削除 - CPF_NORMALIZE_LINEBREAK 削除 - リソース IDD_TABSHEET_COPYPASTE - Normalize line break when pasting チェックボックスを削除 - レイアウト調整 Modified Paths: -------------- trunk/doc/en/html/setup/teraterm-ini.html trunk/doc/ja/html/setup/teraterm-ini.html trunk/installer/release/TERATERM.INI trunk/installer/release/lang_utf8/French.lng trunk/installer/release/lang_utf8/German.lng trunk/installer/release/lang_utf8/Japanese.lng trunk/installer/release/lang_utf8/Korean.lng trunk/installer/release/lang_utf8/Russian.lng trunk/installer/release/lang_utf8/Simplified Chinese.lng trunk/installer/release/lang_utf8/Traditional Chinese.lng trunk/installer/release/lang_utf8/english.lng trunk/teraterm/common/tt_res.h trunk/teraterm/common/tttypes.h trunk/teraterm/teraterm/addsetting.cpp trunk/teraterm/teraterm/clipboar.c trunk/teraterm/teraterm/sendmem.cpp trunk/teraterm/teraterm/ttermpro.rc trunk/teraterm/ttpset/ttset.c -------------- next part -------------- Modified: trunk/doc/en/html/setup/teraterm-ini.html =================================================================== --- trunk/doc/en/html/setup/teraterm-ini.html 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/doc/en/html/setup/teraterm-ini.html 2020-01-10 13:12:35 UTC (rev 8459) @@ -944,12 +944,6 @@ - NormalizeLineBreakOnPaste - off - <- - - - NotifyClipboardAccess on <- Modified: trunk/doc/ja/html/setup/teraterm-ini.html =================================================================== --- trunk/doc/ja/html/setup/teraterm-ini.html 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/doc/ja/html/setup/teraterm-ini.html 2020-01-10 13:12:35 UTC (rev 8459) @@ -950,12 +950,6 @@ - NormalizeLineBreakOnPaste - off - <- - - - NotifyClipboardAccess on <- Modified: trunk/installer/release/TERATERM.INI =================================================================== --- trunk/installer/release/TERATERM.INI 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/installer/release/TERATERM.INI 2020-01-10 13:12:35 UTC (rev 8459) @@ -591,9 +591,6 @@ ; Nonblinking cursor NonblinkingCursor=off -; Normalize line break when pasting -NormalizeLineBreakOnPaste=off - ; Notify Clipboard access from remote NotifyClipboardAccess=on Modified: trunk/installer/release/lang_utf8/French.lng =================================================================== --- trunk/installer/release/lang_utf8/French.lng 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/installer/release/lang_utf8/French.lng 2020-01-10 13:12:35 UTC (rev 8459) @@ -1,4 +1,4 @@ -; Updated by TeraTerm Project (2019-11-22) +; Updated by TeraTerm Project (2020-01-09) ; Last translated (French language) by Francois MOCQ (2010-07-21) [Tera Term] @@ -223,7 +223,6 @@ DLG_TAB_COPYPASTE_MOUSEPASTEM=Interdire coller avec molette DLG_TAB_COPYPASTE_SELECTLBUTTON=Selection seulement avec bouton G DLG_TAB_COPYPASTE_TRIM_TRAILING_NL=&Trim trailing new line character when pasting -DLG_TAB_COPYPASTE_NORMALIZE_LINEBREAK=&Normalize line break when pasting DLG_TAB_COPYPASTE_CONFIRM_CHANGE_PASTE=Confirmer changer coller DLG_TAB_COPYPASTE_STRINGFILE=Fichier chaîne DLG_TAB_COPYPASTE_DELIMITER=Caractères délimiteurs Modified: trunk/installer/release/lang_utf8/German.lng =================================================================== --- trunk/installer/release/lang_utf8/German.lng 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/installer/release/lang_utf8/German.lng 2020-01-10 13:12:35 UTC (rev 8459) @@ -1,4 +1,4 @@ -; Updated by TeraTerm Project (2019-11-22) +; Updated by TeraTerm Project (2020-01-09) ; Last translated (German language) by Frederik Schwarzer (2010-05-17) [Tera Term] @@ -223,7 +223,6 @@ DLG_TAB_COPYPASTE_MOUSEPASTEM=Einfügen mit mittlerer Maustaste ein DLG_TAB_COPYPASTE_SELECTLBUTTON=&Auswahl nur über Button DLG_TAB_COPYPASTE_TRIM_TRAILING_NL=&Trim trailing new line character when pasting -DLG_TAB_COPYPASTE_NORMALIZE_LINEBREAK=&Normalize line break when pasting DLG_TAB_COPYPASTE_CONFIRM_CHANGE_PASTE=Confirm change &paste DLG_TAB_COPYPASTE_STRINGFILE=&String file DLG_TAB_COPYPASTE_DELIMITER=&Begrenzungszeichen Modified: trunk/installer/release/lang_utf8/Japanese.lng =================================================================== --- trunk/installer/release/lang_utf8/Japanese.lng 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/installer/release/lang_utf8/Japanese.lng 2020-01-10 13:12:35 UTC (rev 8459) @@ -1,4 +1,4 @@ -; Updated by TeraTerm Project (2019-11-22) +; Updated by TeraTerm Project (2020-01-09) [Tera Term] DLG_SYSTEM_FONT=MS Pゴシック,12,128 @@ -222,7 +222,6 @@ DLG_TAB_COPYPASTE_MOUSEPASTEM=中クリックでの貼り付けを無効にする(&M) DLG_TAB_COPYPASTE_SELECTLBUTTON=左クリックでのみ選択を開始する(&O) DLG_TAB_COPYPASTE_TRIM_TRAILING_NL=貼り付け時に末尾の改行を削除する(&T) -DLG_TAB_COPYPASTE_NORMALIZE_LINEBREAK=貼り付け時に改行を正規化する(&N) DLG_TAB_COPYPASTE_CONFIRM_CHANGE_PASTE=危険なクリップボードの貼り付けを確認する(&P) DLG_TAB_COPYPASTE_STRINGFILE=キーワードファイル(&S) DLG_TAB_COPYPASTE_DELIMITER=区切り文字(&I) Modified: trunk/installer/release/lang_utf8/Korean.lng =================================================================== --- trunk/installer/release/lang_utf8/Korean.lng 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/installer/release/lang_utf8/Korean.lng 2020-01-10 13:12:35 UTC (rev 8459) @@ -1,4 +1,4 @@ -; Updated by TeraTerm Project (2019-11-22) +; Updated by TeraTerm Project (2020-01-09) ; Last translated (Korean language) by Daehong Kim (2013-07-25) [Tera Term] @@ -223,7 +223,6 @@ DLG_TAB_COPYPASTE_MOUSEPASTEM=마우스 가운데 버튼 붙여넣기 비활성화(&M) DLG_TAB_COPYPASTE_SELECTLBUTTON=마우스 왼쪽 버튼에 의해서만 선택(&O) DLG_TAB_COPYPASTE_TRIM_TRAILING_NL=&Trim trailing new line character when pasting -DLG_TAB_COPYPASTE_NORMALIZE_LINEBREAK=&Normalize line break when pasting DLG_TAB_COPYPASTE_CONFIRM_CHANGE_PASTE=변경-붙여넣기 확인(&P) DLG_TAB_COPYPASTE_STRINGFILE=문자열 파일(&S) DLG_TAB_COPYPASTE_DELIMITER=구분자 문자(&I) Modified: trunk/installer/release/lang_utf8/Russian.lng =================================================================== --- trunk/installer/release/lang_utf8/Russian.lng 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/installer/release/lang_utf8/Russian.lng 2020-01-10 13:12:35 UTC (rev 8459) @@ -1,4 +1,4 @@ -; Updated by TeraTerm Project (2019-11-22) +; Updated by TeraTerm Project (2020-01-09) ; Last translated (Russian language) by Ryumik Sergey (2017-07-19) [Tera Term] @@ -223,7 +223,6 @@ DLG_TAB_COPYPASTE_MOUSEPASTEM=&Отключить вставку средней кнопкой мыши DLG_TAB_COPYPASTE_SELECTLBUTTON=&Использовать только левую кнопку мыши DLG_TAB_COPYPASTE_TRIM_TRAILING_NL=&Удалить символ новой строки при вставке -DLG_TAB_COPYPASTE_NORMALIZE_LINEBREAK=&Разрешить возврат строки при вставке DLG_TAB_COPYPASTE_CONFIRM_CHANGE_PASTE=&Разрешить вставку изменения DLG_TAB_COPYPASTE_STRINGFILE=&Текстовый файл DLG_TAB_COPYPASTE_DELIMITER=&Разделитель символов Modified: trunk/installer/release/lang_utf8/Simplified Chinese.lng =================================================================== --- trunk/installer/release/lang_utf8/Simplified Chinese.lng 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/installer/release/lang_utf8/Simplified Chinese.lng 2020-01-10 13:12:35 UTC (rev 8459) @@ -1,4 +1,4 @@ -; Updated by TeraTerm Project (2019-11-22) +; Updated by TeraTerm Project (2020-01-09) ; Last translated (Simplified Chinese language) by LiShaohui (2017-04-11) [Tera Term] @@ -223,7 +223,6 @@ DLG_TAB_COPYPASTE_MOUSEPASTEM=禁用中键单击粘贴(&M) DLG_TAB_COPYPASTE_SELECTLBUTTON=仅用鼠标左键(&O) DLG_TAB_COPYPASTE_TRIM_TRAILING_NL=粘贴时修剪换行符(&T) -DLG_TAB_COPYPASTE_NORMALIZE_LINEBREAK=粘贴时规范化换行符(&N) DLG_TAB_COPYPASTE_CONFIRM_CHANGE_PASTE=“危险粘贴剪贴板”确认(&P) DLG_TAB_COPYPASTE_STRINGFILE=关键字文件(&S) DLG_TAB_COPYPASTE_DELIMITER=分隔符(&I) Modified: trunk/installer/release/lang_utf8/Traditional Chinese.lng =================================================================== --- trunk/installer/release/lang_utf8/Traditional Chinese.lng 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/installer/release/lang_utf8/Traditional Chinese.lng 2020-01-10 13:12:35 UTC (rev 8459) @@ -1,4 +1,4 @@ -; Updated by TeraTerm Project (2019-11-22) +; Updated by TeraTerm Project (2020-01-09) ; Last translated (Traditional Chinese language) by kikiqqp (2014-09-20) [Tera Term] @@ -223,7 +223,6 @@ DLG_TAB_COPYPASTE_MOUSEPASTEM=禁用中鍵單擊貼上(&M) DLG_TAB_COPYPASTE_SELECTLBUTTON=僅用滑鼠左鍵(&O) DLG_TAB_COPYPASTE_TRIM_TRAILING_NL=&Trim trailing new line character when pasting -DLG_TAB_COPYPASTE_NORMALIZE_LINEBREAK=&Normalize line break when pasting DLG_TAB_COPYPASTE_CONFIRM_CHANGE_PASTE=「警告貼上剪貼簿」確認(&P) DLG_TAB_COPYPASTE_STRINGFILE=關鍵字文件(&S) DLG_TAB_COPYPASTE_DELIMITER=分隔符(&I) Modified: trunk/installer/release/lang_utf8/english.lng =================================================================== --- trunk/installer/release/lang_utf8/english.lng 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/installer/release/lang_utf8/english.lng 2020-01-10 13:12:35 UTC (rev 8459) @@ -1,4 +1,4 @@ -; Updated by TeraTerm Project (2019-11-22) +; Updated by TeraTerm Project (2020-01-09) [Tera Term] DLG_SYSTEM_FONT=System,14,0 @@ -222,7 +222,6 @@ DLG_TAB_COPYPASTE_MOUSEPASTEM=Disable mouse &M button paste DLG_TAB_COPYPASTE_SELECTLBUTTON=Select &only by L button DLG_TAB_COPYPASTE_TRIM_TRAILING_NL=&Trim trailing new line character when pasting -DLG_TAB_COPYPASTE_NORMALIZE_LINEBREAK=&Normalize line break when pasting DLG_TAB_COPYPASTE_CONFIRM_CHANGE_PASTE=Confirm change &paste DLG_TAB_COPYPASTE_STRINGFILE=&String file DLG_TAB_COPYPASTE_DELIMITER=Del&imiter characters Modified: trunk/teraterm/common/tt_res.h =================================================================== --- trunk/teraterm/common/tt_res.h 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/teraterm/common/tt_res.h 2020-01-10 13:12:35 UTC (rev 8459) @@ -216,7 +216,6 @@ #define IDC_SSH_SETUPDIR_STATIC_VSTORE 2562 #define IDC_SSH_SETUPDIR_EDIT_VSTORE 2563 #define IDC_TRIMNLCHAR 2564 -#define IDC_NORMALIZE_LINEBREAK 2565 #define IDC_CLIPBOARD_NOTIFY 2566 #define IDC_LIST_HIDDEN_FONTS 2567 #define IDC_TITLEFMT_GROUP 2568 Modified: trunk/teraterm/common/tttypes.h =================================================================== --- trunk/teraterm/common/tttypes.h 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/teraterm/common/tttypes.h 2020-01-10 13:12:35 UTC (rev 8459) @@ -379,7 +379,6 @@ #define CPF_CONFIRM_CHANGEPASTE 0x0010 #define CPF_CONFIRM_CHANGEPASTE_CR 0x0020 #define CPF_TRIM_TRAILING_NL 0x0100 -#define CPF_NORMALIZE_LINEBREAK 0x0200 // Title Reporting Type #define IdTitleReportIgnore 0 Modified: trunk/teraterm/teraterm/addsetting.cpp =================================================================== --- trunk/teraterm/teraterm/addsetting.cpp 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/teraterm/teraterm/addsetting.cpp 2020-01-10 13:12:35 UTC (rev 8459) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2019 TeraTerm Project + * Copyright (C) 2008-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -435,7 +435,6 @@ { IDC_DISABLE_PASTE_MBUTTON, "DLG_TAB_COPYPASTE_MOUSEPASTEM" }, { IDC_SELECT_LBUTTON, "DLG_TAB_COPYPASTE_SELECTLBUTTON" }, { IDC_TRIMNLCHAR, "DLG_TAB_COPYPASTE_TRIM_TRAILING_NL" }, - { IDC_NORMALIZE_LINEBREAK, "DLG_TAB_COPYPASTE_NORMALIZE_LINEBREAK" }, { IDC_CONFIRM_CHANGE_PASTE, "DLG_TAB_COPYPASTE_CONFIRM_CHANGE_PASTE" }, { IDC_CONFIRM_STRING_FILE_LABEL, "DLG_TAB_COPYPASTE_STRINGFILE" }, { IDC_DELIMITER, "DLG_TAB_COPYPASTE_DELIMITER" }, @@ -469,10 +468,7 @@ // (6)TrimTrailingNLonPaste SetCheck(IDC_TRIMNLCHAR, (ts.PasteFlag & CPF_TRIM_TRAILING_NL)?BST_CHECKED:BST_UNCHECKED); - // (7)NormalizeLineBreak - SetCheck(IDC_NORMALIZE_LINEBREAK, (ts.PasteFlag & CPF_NORMALIZE_LINEBREAK)?BST_CHECKED:BST_UNCHECKED); - - // (8)ConfirmChangePaste + // (7)ConfirmChangePaste SetCheck(IDC_CONFIRM_CHANGE_PASTE, (ts.PasteFlag & CPF_CONFIRM_CHANGEPASTE)?BST_CHECKED:BST_UNCHECKED); // \x83t\x83@\x83C\x83\x8B\x83p\x83X @@ -485,15 +481,15 @@ EnableDlgItem(IDC_CONFIRM_STRING_FILE_PATH, FALSE); } - // (9)delimiter characters + // (8)delimiter characters SetDlgItemTextA(IDC_DELIM_LIST, ts.DelimList); - // (10)PasteDelayPerLine + // (9)PasteDelayPerLine char buf[64]; _snprintf_s(buf, sizeof(buf), "%d", ts.PasteDelayPerLine); SetDlgItemNum(IDC_PASTEDELAY_EDIT, ts.PasteDelayPerLine); - // (11) SelectOnActivate + // (10) SelectOnActivate SetCheck(IDC_SELECT_ON_ACTIVATE, ts.SelOnActive ? BST_CHECKED : BST_UNCHECKED); // \x83_\x83C\x83A\x83\x8D\x83O\x82Ƀt\x83H\x81[\x83J\x83X\x82𓖂Ă\xE9 @@ -589,15 +585,7 @@ ts.PasteFlag &= ~CPF_TRIM_TRAILING_NL; } - // (7) - if (GetCheck(IDC_NORMALIZE_LINEBREAK)) { - ts.PasteFlag |= CPF_NORMALIZE_LINEBREAK; - } - else { - ts.PasteFlag &= ~CPF_NORMALIZE_LINEBREAK; - } - - // (8)IDC_CONFIRM_CHANGE_PASTE + // (7)IDC_CONFIRM_CHANGE_PASTE if (GetCheck(IDC_CONFIRM_CHANGE_PASTE)) { ts.PasteFlag |= CPF_CONFIRM_CHANGEPASTE; } @@ -606,10 +594,10 @@ } GetDlgItemTextA(IDC_CONFIRM_STRING_FILE, ts.ConfirmChangePasteStringFile, sizeof(ts.ConfirmChangePasteStringFile)); - // (9) + // (8) GetDlgItemTextA(IDC_DELIM_LIST, ts.DelimList, sizeof(ts.DelimList)); - // (10) + // (9) GetDlgItemTextA(IDC_PASTEDELAY_EDIT, buf, sizeof(buf)); val = atoi(buf); ts.PasteDelayPerLine = @@ -616,7 +604,7 @@ (val < 0) ? 0 : (val > 5000) ? 5000 : val; - // (11) SelectOnActivate + // (10) SelectOnActivate ts.SelOnActive = (GetCheck(IDC_SELECT_ON_ACTIVATE) == BST_CHECKED); } Modified: trunk/teraterm/teraterm/clipboar.c =================================================================== --- trunk/teraterm/teraterm/clipboar.c 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/teraterm/teraterm/clipboar.c 2020-01-10 13:12:35 UTC (rev 8459) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2006-2019 TeraTerm Project + * (C) 2006-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -225,10 +225,6 @@ unsigned int len, need_len, alloc_len; HGLOBAL TmpHandle; - if (!(ts.PasteFlag & CPF_NORMALIZE_LINEBREAK)) { - return TRUE; - } - p = CBMemPtr; // \x93\\x82\xE8\x95t\x82\xAF\x83f\x81[\x83^\x82̒\xB7\x82\xB3(len)\x81A\x82\xA8\x82\xE6\x82ѐ\xB3\x8BK\x89\xBB\x8C\xE3\x82̃f\x81[\x83^\x82̒\xB7\x82\xB3(need_len)\x82̃J\x83E\x83\x93\x83g @@ -855,7 +851,7 @@ TrimTrailingNLW(str_w); } - if (!(ts.PasteFlag & CPF_NORMALIZE_LINEBREAK)) { + { // \x89\xFC\x8Ds\x82𐳋K\x89\xBB wchar_t *dest = NormalizeLineBreakW(str_w); free(str_w); Modified: trunk/teraterm/teraterm/sendmem.cpp =================================================================== --- trunk/teraterm/teraterm/sendmem.cpp 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/teraterm/teraterm/sendmem.cpp 2020-01-10 13:12:35 UTC (rev 8459) @@ -381,7 +381,7 @@ { size_t src_len = *len; if (src_len == 0) { - return NULL; + src_len = wcslen(src) + 1; } wchar_t *dest_top = (wchar_t *)malloc(sizeof(wchar_t) * src_len); if (dest_top == NULL) { Modified: trunk/teraterm/teraterm/ttermpro.rc =================================================================== --- trunk/teraterm/teraterm/ttermpro.rc 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/teraterm/teraterm/ttermpro.rc 2020-01-10 13:12:35 UTC (rev 8459) @@ -117,7 +117,7 @@ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,145,220,10 END -IDD_TABSHEET_COPYPASTE DIALOGEX 0, 0, 258, 194 +IDD_TABSHEET_COPYPASTE DIALOGEX 0, 0, 258, 177 STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_SYSMENU FONT 8, "Tahoma", 0, 0, 0x0 BEGIN @@ -131,19 +131,17 @@ CONTROL "Select &only by L button",IDC_SELECT_LBUTTON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,70,200,10 CONTROL "&Trim trailing new line character when pasting",IDC_TRIMNLCHAR, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,85,200,10 - CONTROL "&Normalize line break when pasting",IDC_NORMALIZE_LINEBREAK, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,100,200,10 - CONTROL "Confirm change &paste",IDC_CONFIRM_CHANGE_PASTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,115,200,10 - LTEXT "&String file",IDC_CONFIRM_STRING_FILE_LABEL,22,130,68,8 - EDITTEXT IDC_CONFIRM_STRING_FILE,95,128,106,12,ES_AUTOHSCROLL - PUSHBUTTON "...",IDC_CONFIRM_STRING_FILE_PATH,206,128,13,12 - LTEXT "Del&imiter characters",IDC_DELIMITER,11,145,65,10 - EDITTEXT IDC_DELIM_LIST,95,143,130,12,ES_AUTOHSCROLL - LTEXT "P&aste delay per line",IDC_PASTEDELAY_LABEL,11,160,70,10 - EDITTEXT IDC_PASTEDELAY_EDIT,95,158,24,12,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "ms",IDC_PASTEDELAY_LABEL2,123,160,23,10 + CONTROL "Confirm change &paste",IDC_CONFIRM_CHANGE_PASTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,100,200,10 + LTEXT "&String file",IDC_CONFIRM_STRING_FILE_LABEL,22,115,68,8 + EDITTEXT IDC_CONFIRM_STRING_FILE,95,113,106,12,ES_AUTOHSCROLL + PUSHBUTTON "...",IDC_CONFIRM_STRING_FILE_PATH,206,113,13,12 + LTEXT "Del&imiter characters",IDC_DELIMITER,11,128,65,10 + EDITTEXT IDC_DELIM_LIST,95,126,130,12,ES_AUTOHSCROLL + LTEXT "P&aste delay per line",IDC_PASTEDELAY_LABEL,11,143,70,10 + EDITTEXT IDC_PASTEDELAY_EDIT,95,141,24,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "ms",IDC_PASTEDELAY_LABEL2,123,143,23,10 CONTROL "Ena&bling text selection when the window is activated by mouse",IDC_SELECT_ON_ACTIVATE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,173,229,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,160,229,10 END IDD_TABSHEET_VISUAL DIALOGEX 0, 0, 258, 188 @@ -414,7 +412,7 @@ LEFTMARGIN, 5 RIGHTMARGIN, 252 TOPMARGIN, 5 - BOTTOMMARGIN, 191 + BOTTOMMARGIN, 172 END IDD_TABSHEET_VISUAL, DIALOG Modified: trunk/teraterm/ttpset/ttset.c =================================================================== --- trunk/teraterm/ttpset/ttset.c 2020-01-10 13:12:13 UTC (rev 8458) +++ trunk/teraterm/ttpset/ttset.c 2020-01-10 13:12:35 UTC (rev 8459) @@ -2146,10 +2146,6 @@ if (GetOnOff(Section, "TrimTrailingNLonPaste", FName, FALSE)) ts->PasteFlag |= CPF_TRIM_TRAILING_NL; - // Normalize line break when pasting - if (GetOnOff(Section, "NormalizeLineBreakOnPaste", FName, FALSE)) - ts->PasteFlag |= CPF_NORMALIZE_LINEBREAK; - // List Inactive Font ts->ListHiddenFonts = GetOnOff(Section, "ListHiddenFonts", FName, FALSE); @@ -3495,10 +3491,6 @@ WriteOnOff(Section, "TrimTrailingNLonPaste", FName, (WORD) (ts->PasteFlag & CPF_TRIM_TRAILING_NL)); - // Normalize line break when pasting - WriteOnOff(Section, "NormalizeLineBreakOnPaste", FName, - (WORD) (ts->PasteFlag & CPF_NORMALIZE_LINEBREAK)); - // List Inactive Font WriteOnOff(Section, "ListHiddenFonts", FName, ts->ListHiddenFonts); From scmnotify @ osdn.net Fri Jan 10 22:12:51 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 10 Jan 2020 22:12:51 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NjBdIOS4jemAj+aYjuW6puODhOODvA==?= =?utf-8?b?44Or44OB44OD44OX44KS5aSa6KiA6Kqe5YyW5a++5b+c?= Message-ID: <1578661971.535644.126562.nullmailer@users.osdn.me> Revision: 8460 https://osdn.net/projects/ttssh2/scm/svn/commits/8460 Author: zmatsuo Date: 2020-01-10 22:12:51 +0900 (Fri, 10 Jan 2020) Log Message: ----------- 不透明度ツールチップを多言語化対応 Modified Paths: -------------- trunk/teraterm/teraterm/addsetting.cpp -------------- next part -------------- Modified: trunk/teraterm/teraterm/addsetting.cpp =================================================================== --- trunk/teraterm/teraterm/addsetting.cpp 2020-01-10 13:12:35 UTC (rev 8459) +++ trunk/teraterm/teraterm/addsetting.cpp 2020-01-10 13:12:51 UTC (rev 8460) @@ -849,6 +849,22 @@ } } +static void OpacityTooltip(CTipWin* tip, HWND hDlg, int trackbar, int pos, const char *UILanguageFile) +{ + wchar_t uimsg[MAX_UIMSG]; + get_lang_msgW("TOOLTIP_TITLEBAR_OPACITY", uimsg, sizeof(uimsg), L"Opacity %.1f %%", ts.UILanguageFile); + wchar_t tipbuf[MAX_UIMSG]; + swprintf_s(tipbuf, _countof(tipbuf), uimsg, (pos / 255.0) * 100); + RECT rc; + ::GetWindowRect(::GetDlgItem(hDlg, trackbar), &rc); + tip->SetText(tipbuf); + tip->SetPos(rc.right, rc.bottom); + tip->SetHideTimer(1000); + if (! tip->IsVisible()) { + tip->SetVisible(TRUE); + } +} + BOOL CVisualPropPageDlg::OnCommand(WPARAM wParam, LPARAM lParam) { int sel; @@ -1028,20 +1044,7 @@ SetDlgItemNum(IDC_ALPHA_BLEND_ACTIVE, pos); } SendDlgItemMessage(IDC_ALPHA_BLEND_ACTIVE_TRACKBAR, TBM_SETPOS, TRUE, pos); - - TCHAR tipbuf[32]; - TCHAR uimsg[MAX_UIMSG]; - RECT rc; - get_lang_msg("TOOLTIP_TITLEBAR_OPACITY", uimsg, sizeof(uimsg), "Opacity %.1f %%", ts.UILanguageFile); - _stprintf_s(tipbuf, _countof(tipbuf), uimsg, (pos / 255.0) * 100); - - ::GetWindowRect(GetDlgItem(IDC_ALPHA_BLEND_ACTIVE), &rc); - TipWin->SetText(tipbuf); - TipWin->SetPos(rc.right, rc.bottom); - TipWin->SetHideTimer(1000); - if (! TipWin->IsVisible()) { - TipWin->SetVisible(TRUE); - } + OpacityTooltip(TipWin, m_hWnd, IDC_ALPHA_BLEND_ACTIVE, pos, ts.UILanguageFile); return TRUE; } case IDC_ALPHA_BLEND_INACTIVE | (EN_CHANGE << 16): @@ -1057,19 +1060,7 @@ SetDlgItemNum(IDC_ALPHA_BLEND_INACTIVE, pos); } SendDlgItemMessage(IDC_ALPHA_BLEND_INACTIVE_TRACKBAR, TBM_SETPOS, TRUE, pos); - - TCHAR tipbuf[32], uimsg[MAX_UIMSG]; - RECT rc; - get_lang_msg("TOOLTIP_TITLEBAR_OPACITY", uimsg, sizeof(uimsg), "Opacity %.1f %%", ts.UILanguageFile); - _stprintf_s(tipbuf, _countof(tipbuf), uimsg, (pos / 255.0) * 100); - - ::GetWindowRect(GetDlgItem(IDC_ALPHA_BLEND_INACTIVE), &rc); - TipWin->SetText(tipbuf); - TipWin->SetPos(rc.right, rc.bottom); - TipWin->SetHideTimer(1000); - if (! TipWin->IsVisible()) { - TipWin->SetVisible(TRUE); - } + OpacityTooltip(TipWin, m_hWnd, IDC_ALPHA_BLEND_INACTIVE, pos, ts.UILanguageFile); return TRUE; } } From scmnotify @ osdn.net Fri Jan 10 22:13:05 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 10 Jan 2020 22:13:05 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NjFdIOODhOODvOODq+ODgeODg+ODlw==?= =?utf-8?b?5YaF44Gu44Oh44Oi44Oq44Oq44O844Kv44KS5L+u5q2j?= Message-ID: <1578661985.191307.126792.nullmailer@users.osdn.me> Revision: 8461 https://osdn.net/projects/ttssh2/scm/svn/commits/8461 Author: zmatsuo Date: 2020-01-10 22:13:04 +0900 (Fri, 10 Jan 2020) Log Message: ----------- ツールチップ内のメモリリークを修正 - 表示文字を変更するとメモリリークしていた Modified Paths: -------------- trunk/teraterm/common/tipwin.cpp -------------- next part -------------- Modified: trunk/teraterm/common/tipwin.cpp =================================================================== --- trunk/teraterm/common/tipwin.cpp 2020-01-10 13:12:51 UTC (rev 8460) +++ trunk/teraterm/common/tipwin.cpp 2020-01-10 13:13:04 UTC (rev 8461) @@ -27,7 +27,7 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* - * Copyright (C) 2008-2019 TeraTerm Project + * Copyright (C) 2008-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -304,6 +304,9 @@ TipWin* self = tWin; self->str_len = wcslen(str); + if (self->str != NULL) { + free((void *)self->str); + } self->str = _wcsdup(str); CalcStrRect(); From scmnotify @ osdn.net Fri Jan 10 22:13:16 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 10 Jan 2020 22:13:16 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NjJdIF9EcmF3VGV4dFcoKSDjgpIgdGlw?= =?utf-8?b?d2luLmNwcCDjgYvjgokgbGF5ZXJfZm9yX3VuaWNvZGUuY3BwIOOBuOenuw==?= =?utf-8?b?5YuV?= Message-ID: <1578661996.046859.126958.nullmailer@users.osdn.me> Revision: 8462 https://osdn.net/projects/ttssh2/scm/svn/commits/8462 Author: zmatsuo Date: 2020-01-10 22:13:15 +0900 (Fri, 10 Jan 2020) Log Message: ----------- _DrawTextW() を tipwin.cpp から layer_for_unicode.cpp へ移動 Modified Paths: -------------- trunk/teraterm/common/layer_for_unicode.cpp trunk/teraterm/common/layer_for_unicode.h trunk/teraterm/common/tipwin.cpp -------------- next part -------------- Modified: trunk/teraterm/common/layer_for_unicode.cpp =================================================================== --- trunk/teraterm/common/layer_for_unicode.cpp 2020-01-10 13:13:04 UTC (rev 8461) +++ trunk/teraterm/common/layer_for_unicode.cpp 2020-01-10 13:13:15 UTC (rev 8462) @@ -36,6 +36,7 @@ #include "codeconv.h" #include "compat_win.h" +#include "ttlib.h" // for IsWindowsNTKernel() #include "layer_for_unicode.h" @@ -285,3 +286,19 @@ lpString[0] = 0; return 0; } + +/** + * TODO:9x\x8Cn\x82\xC5DrawTextW\x82\xAA\x8Eg\x82\xA6\x82\xE9? + */ +int _DrawTextW(HDC hdc, LPCWSTR lpchText, int cchText, LPRECT lprc, UINT format) +{ + if (IsWindowsNTKernel()) { + return DrawTextW(hdc, lpchText, cchText, lprc, format); + } + + char *strA = ToCharW(lpchText); + int strA_len = (int)strlen(strA); + int result = DrawTextA(hdc, strA, strA_len, lprc, format); + free(strA); + return result; +} Modified: trunk/teraterm/common/layer_for_unicode.h =================================================================== --- trunk/teraterm/common/layer_for_unicode.h 2020-01-10 13:13:04 UTC (rev 8461) +++ trunk/teraterm/common/layer_for_unicode.h 2020-01-10 13:13:15 UTC (rev 8462) @@ -53,6 +53,7 @@ int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam); ATOM _RegisterClassW(const WNDCLASSW *lpWndClass); +int _DrawTextW(HDC hdc, LPCWSTR lpchText, int cchText, LPRECT lprc, UINT format); #ifdef __cplusplus } Modified: trunk/teraterm/common/tipwin.cpp =================================================================== --- trunk/teraterm/common/tipwin.cpp 2020-01-10 13:13:04 UTC (rev 8461) +++ trunk/teraterm/common/tipwin.cpp 2020-01-10 13:13:15 UTC (rev 8462) @@ -64,7 +64,7 @@ #endif #include -#include "ttlib.h" // for GetMessageboxFont(), IsWindowsNTKernel() +#include "ttlib.h" // for GetMessageboxFont() #include "codeconv.h" #include "layer_for_unicode.h" @@ -85,24 +85,6 @@ int py; } TipWin; -/** - * 9x\x8Cn\x82\xC5DrawTextW\x82\xAA\x8Eg\x82\xA6\x82邩\x82悭\x82킩\x82\xE7\x82Ȃ\xA2 - * \x82Ƃ肠\x82\xA6\x82\xB8\x82\xB1\x82̃t\x83@\x83C\x83\x8B\x82ł̂ݎg\x97p - * \x82\xBB\x82̂\xA4\x82\xBF layer_for_unicode.cpp \x82Ɉړ\xAE\x82\xB7\x82\xE9 - */ -static int _DrawTextW(HDC hdc, LPCWSTR lpchText, int cchText, LPRECT lprc, UINT format) -{ - if (IsWindowsNTKernel()) { - return DrawTextW(hdc, lpchText, cchText, lprc, format); - } - - char *strA = ToCharW(lpchText); - size_t strA_len = strlen(strA); - int result = DrawTextA(hdc, strA, strA_len, lprc, format); - free(strA); - return result; -} - VOID CTipWin::CalcStrRect(VOID) { HDC hdc = CreateCompatibleDC(NULL); From scmnotify @ osdn.net Fri Jan 10 22:13:26 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 10 Jan 2020 22:13:26 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NjNdIOacquS9v+eUqOWkieaVsOOAgQ==?= =?utf-8?b?5pyq5L2/55SoZGVmaW5l44KS5YmK6Zmk?= Message-ID: <1578662006.535004.127275.nullmailer@users.osdn.me> Revision: 8463 https://osdn.net/projects/ttssh2/scm/svn/commits/8463 Author: zmatsuo Date: 2020-01-10 22:13:26 +0900 (Fri, 10 Jan 2020) Log Message: ----------- 未使用変数、未使用defineを削除 Modified Paths: -------------- trunk/teraterm/teraterm/ftdlg_lite.cpp trunk/teraterm/teraterm/protodlg.cpp trunk/teraterm/teraterm/sendmem.cpp trunk/teraterm/teraterm/vtwin.cpp -------------- next part -------------- Modified: trunk/teraterm/teraterm/ftdlg_lite.cpp =================================================================== --- trunk/teraterm/teraterm/ftdlg_lite.cpp 2020-01-10 13:13:15 UTC (rev 8462) +++ trunk/teraterm/teraterm/ftdlg_lite.cpp 2020-01-10 13:13:26 UTC (rev 8463) @@ -1,5 +1,5 @@ /* - * (C) 2019 TeraTerm Project + * (C) 2019-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -183,8 +183,6 @@ HANDLE SmallIcon; HANDLE BigIcon; const char *UILanguageFile_; - wchar_t *Cation; - wchar_t *Filename; public: BOOL Pause; Modified: trunk/teraterm/teraterm/protodlg.cpp =================================================================== --- trunk/teraterm/teraterm/protodlg.cpp 2020-01-10 13:13:15 UTC (rev 8462) +++ trunk/teraterm/teraterm/protodlg.cpp 2020-01-10 13:13:26 UTC (rev 8463) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2007-2019 TeraTerm Project + * (C) 2007-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,12 +36,6 @@ #include "dlglib.h" #include "protodlg.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - ///////////////////////////////////////////////////////////////////////////// // CProtoDlg dialog Modified: trunk/teraterm/teraterm/sendmem.cpp =================================================================== --- trunk/teraterm/teraterm/sendmem.cpp 2020-01-10 13:13:15 UTC (rev 8462) +++ trunk/teraterm/teraterm/sendmem.cpp 2020-01-10 13:13:26 UTC (rev 8463) @@ -391,8 +391,6 @@ // CR+LF -> LF // CR -> LF // LF -> LF (\x95ϊ\xB7\x95s\x97v) - int cr_count = 0; - int lf_count = 0; const wchar_t *p = src; const wchar_t *p_end = src + src_len; wchar_t *dest = dest_top; Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2020-01-10 13:13:15 UTC (rev 8462) +++ trunk/teraterm/teraterm/vtwin.cpp 2020-01-10 13:13:26 UTC (rev 8463) @@ -60,7 +60,9 @@ #include "teraterml.h" #include +#define _CRTDBG_MAP_ALLOC #include +#include #include #include #include @@ -69,7 +71,6 @@ #include #include #include -#include #include #include @@ -101,35 +102,6 @@ #define VTClassName _T("VTWin32") -#undef SetDlgItemText -#define SetDlgItemText SetDlgItemTextA -#undef CreateProcess -#define CreateProcess CreateProcessA -#undef STARTUPINFO -#define STARTUPINFO STARTUPINFOA -#undef GetStartupInfo -#define GetStartupInfo GetStartupInfoA - -#if defined(UNICODE) -#define CreateProcessT CreateProcessW -#define GetStartupInfoT GetStartupInfoW -#define STARTUPINFOT STARTUPINFOW -#define SetDlgItemTextT SetDlgItemTextW -#else -#define CreateProcessT CreateProcessA -#define GetStartupInfoT GetStartupInfoA -#define STARTUPINFOT STARTUPINFOA -#define SetDlgItemTextT SetDlgItemTextA -#endif - -#ifdef _DEBUG -#define malloc(l) _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__) -#define free(p) _free_dbg((p), _NORMAL_BLOCK) -#if defined(_MSC_VER) -#define new ::new(_NORMAL_BLOCK, __FILE__, __LINE__) -#endif -#endif - // \x83E\x83B\x83\x93\x83h\x83E\x8Dő剻\x83{\x83^\x83\x93\x82\xF0\x97L\x8C\xF8\x82ɂ\xB7\x82\xE9 (2005.1.15 yutaka) #define WINDOW_MAXMIMUM_ENABLED 1 @@ -1695,7 +1667,7 @@ } /* copy from ttset.c*/ -static void WriteInt2(PCHAR Sect, PCHAR Key, PCHAR FName, int i1, int i2) +static void WriteInt2(const char *Sect, const char *Key, const char *FName, int i1, int i2) { char Temp[32]; _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d", i1, i2); @@ -4850,10 +4822,10 @@ static BOOL CALLBACK TFontHook(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam) { if (Message == WM_INITDIALOG) { - TCHAR uimsg[MAX_UIMSG]; - get_lang_msgT("DLG_CHOOSEFONT_STC6", uimsg, _countof(uimsg), - _T("\"Font style\" selection here won't affect actual font appearance."), ts.UILanguageFile); - SetDlgItemTextT(Dialog, stc6, uimsg); + wchar_t uimsg[MAX_UIMSG]; + get_lang_msgW("DLG_CHOOSEFONT_STC6", uimsg, _countof(uimsg), + L"\"Font style\" selection here won't affect actual font appearance.", ts.UILanguageFile); + _SetDlgItemTextW(Dialog, stc6, uimsg); SetFocus(GetDlgItem(Dialog,cmb1)); From scmnotify @ osdn.net Fri Jan 10 22:13:35 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 10 Jan 2020 22:13:35 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NjRdIGNtYWtlIOODk+ODq+ODieaZgiBD?= =?utf-8?b?TUFLRV9CVUlMRF9UWVBFPURlYnVnIOOBp+OCqOODqeODvOOBjOWHuuOBpg==?= =?utf-8?b?44GE44Gf44Gu44Gn5L+u5q2j?= Message-ID: <1578662015.043397.127384.nullmailer@users.osdn.me> Revision: 8464 https://osdn.net/projects/ttssh2/scm/svn/commits/8464 Author: zmatsuo Date: 2020-01-10 22:13:34 +0900 (Fri, 10 Jan 2020) Log Message: ----------- cmake ビルド時 CMAKE_BUILD_TYPE=Debug でエラーが出ていたので修正 - 変数を使わない書き方に変更 Modified Paths: -------------- trunk/teraterm/ttpmacro/CMakeLists.txt -------------- next part -------------- Modified: trunk/teraterm/ttpmacro/CMakeLists.txt =================================================================== --- trunk/teraterm/ttpmacro/CMakeLists.txt 2020-01-10 13:13:26 UTC (rev 8463) +++ trunk/teraterm/ttpmacro/CMakeLists.txt 2020-01-10 13:13:34 UTC (rev 8464) @@ -9,42 +9,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") -set(COMMON_SRC - ../common/teraterm.h - ../common/ttcommon.h - ../common/ttddecmnd.h - ../common/tttypes.h - ../common/tt-version.h - ../common/i18n.h - ../common/ttlib.c - ../common/ttlib.h - ../common/tmfc.cpp - ../common/tmfc.h - ../common/tmfc_frame.cpp - ../common/dlglib.h - ../common/dlglib.c - ../common/dlglib_tmpl.cpp - ../common/dlglib_cpp.cpp - ../common/compat_w95.h - ../common/compat_win.h - ../common/compat_win.cpp - ../common/win16api.h - ../common/win16api.c - ../common/codeconv.h - ../common/codeconv.cpp - ../common/dllutil.h - ../common/dllutil.cpp - ../common/layer_for_unicode.h - ../common/layer_for_unicode.cpp - ) - -source_group( - "common" - FILES - ${COMMON_SRC} - ) - -set(SRC +add_executable( + ttpmacro WIN32 ttm_res.h errdlg.cpp errdlg.h @@ -87,38 +53,62 @@ ttmacro_manifest.rc fileread.h fileread.cpp - ${COMMON_SRC} ) -include_directories( +target_sources( + ttpmacro + PRIVATE + ../common/teraterm.h + ../common/ttcommon.h + ../common/ttddecmnd.h + ../common/tttypes.h + ../common/tt-version.h + ../common/i18n.h + ../common/ttlib.c + ../common/ttlib.h + ../common/tmfc.cpp + ../common/tmfc.h + ../common/tmfc_frame.cpp + ../common/dlglib.h + ../common/dlglib.c + ../common/dlglib_tmpl.cpp + ../common/dlglib_cpp.cpp + ../common/compat_w95.h + ../common/compat_win.h + ../common/compat_win.cpp + ../common/win16api.h + ../common/win16api.c + ../common/codeconv.h + ../common/codeconv.cpp + ../common/dllutil.h + ../common/dllutil.cpp + ../common/layer_for_unicode.h + ../common/layer_for_unicode.cpp + ) + +source_group( + "common" + REGULAR_EXPRESSION + "..\/common\/" + ) + +target_include_directories( + ttpmacro + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/../common ${ONIGURUMA_INCLUDE_DIRS} ${SFMT_INCLUDE_DIRS} - ${CMAKE_CURRENT_SOURCE_DIR}/../common ) -link_directories( - ${ONIGURUMA_LIBRARY_DIRS} - ${SFMT_LIBRARY_DIRS} - ) - if (MSVC) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:iphlpapi.dll /DELAYLOAD:user32.dll /MANIFEST:NO") endif() -add_executable( - ttpmacro WIN32 - ${SRC} - ) - target_link_libraries( ttpmacro ttpcmn -# optimized LIBCMT.lib -# debug LIBCMTD.lib - optimized onig - debug onigd - optimized sfmt - debug sfmtd + ${ONIGURUMA_LIB} + ${SFMT_LIB} # iphlpapi delayimp @@ -128,11 +118,6 @@ comdlg32 ) -add_dependencies( - ttpmacro - ttpcmn - ) - install( TARGETS ttpmacro DESTINATION . From scmnotify @ osdn.net Fri Jan 10 22:13:45 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 10 Jan 2020 22:13:45 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NjVdIGNtYWtlIOOBriBVU0VfVU5JQ09E?= =?utf-8?b?RV9BUEkg44KS5YmK6Zmk?= Message-ID: <1578662025.936661.127583.nullmailer@users.osdn.me> Revision: 8465 https://osdn.net/projects/ttssh2/scm/svn/commits/8465 Author: zmatsuo Date: 2020-01-10 22:13:45 +0900 (Fri, 10 Jan 2020) Log Message: ----------- cmake の USE_UNICODE_API を削除 - Unicode版,ANSI版の作り分けを考慮していたが今のところ不要 Modified Paths: -------------- trunk/TTProxy/CMakeLists.txt trunk/TTXKanjiMenu/CMakeLists.txt trunk/TTXSamples/TTXAlwaysOnTop/CMakeLists.txt trunk/TTXSamples/TTXRecurringCommand/CMakeLists.txt trunk/teraterm/teraterm/CMakeLists.txt trunk/teraterm/ttpcmn/CMakeLists.txt trunk/teraterm/ttpmacro/CMakeLists.txt trunk/ttssh2/ttxssh/CMakeLists.txt trunk/version_info.h.in -------------- next part -------------- Modified: trunk/TTProxy/CMakeLists.txt =================================================================== --- trunk/TTProxy/CMakeLists.txt 2020-01-10 13:13:34 UTC (rev 8464) +++ trunk/TTProxy/CMakeLists.txt 2020-01-10 13:13:45 UTC (rev 8465) @@ -1,9 +1,5 @@ project(ttproxy) -if(USE_UNICODE_API) - add_definitions(-DUNICODE -D_UNICODE) -endif() - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") include(${CMAKE_CURRENT_SOURCE_DIR}/../libs/lib_openssl.cmake) Modified: trunk/TTXKanjiMenu/CMakeLists.txt =================================================================== --- trunk/TTXKanjiMenu/CMakeLists.txt 2020-01-10 13:13:34 UTC (rev 8464) +++ trunk/TTXKanjiMenu/CMakeLists.txt 2020-01-10 13:13:45 UTC (rev 8465) @@ -2,10 +2,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") -if(USE_UNICODE_API) - add_definitions(-DUNICODE -D_UNICODE) -endif() - set(SRC resource.h ttxkanjimenu.c Modified: trunk/TTXSamples/TTXAlwaysOnTop/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXAlwaysOnTop/CMakeLists.txt 2020-01-10 13:13:34 UTC (rev 8464) +++ trunk/TTXSamples/TTXAlwaysOnTop/CMakeLists.txt 2020-01-10 13:13:45 UTC (rev 8465) @@ -2,10 +2,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") -if(USE_UNICODE_API) - add_definitions(-DUNICODE -D_UNICODE) -endif() - set(SRC TTXAlwaysOnTop.c ReadMe.txt Modified: trunk/TTXSamples/TTXRecurringCommand/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXRecurringCommand/CMakeLists.txt 2020-01-10 13:13:34 UTC (rev 8464) +++ trunk/TTXSamples/TTXRecurringCommand/CMakeLists.txt 2020-01-10 13:13:45 UTC (rev 8465) @@ -2,10 +2,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") -if(USE_UNICODE_API) - add_definitions(-DUNICODE -D_UNICODE) -endif() - set(COMMON_SRC ../../teraterm/common/dlglib.h ../../teraterm/common/dlglib.c Modified: trunk/teraterm/teraterm/CMakeLists.txt =================================================================== --- trunk/teraterm/teraterm/CMakeLists.txt 2020-01-10 13:13:34 UTC (rev 8464) +++ trunk/teraterm/teraterm/CMakeLists.txt 2020-01-10 13:13:45 UTC (rev 8465) @@ -4,9 +4,6 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_oniguruma.cmake) set(ENABLE_DEBUG_INFO 1) -if(USE_UNICODE_API) - add_definitions(-DUNICODE -D_UNICODE) -endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") Modified: trunk/teraterm/ttpcmn/CMakeLists.txt =================================================================== --- trunk/teraterm/ttpcmn/CMakeLists.txt 2020-01-10 13:13:34 UTC (rev 8464) +++ trunk/teraterm/ttpcmn/CMakeLists.txt 2020-01-10 13:13:45 UTC (rev 8465) @@ -1,9 +1,5 @@ project(ttpcmn) -if(USE_UNICODE_API) - add_definitions(-DUNICODE -D_UNICODE) -endif() - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") set(COMMON_SRC Modified: trunk/teraterm/ttpmacro/CMakeLists.txt =================================================================== --- trunk/teraterm/ttpmacro/CMakeLists.txt 2020-01-10 13:13:34 UTC (rev 8464) +++ trunk/teraterm/ttpmacro/CMakeLists.txt 2020-01-10 13:13:45 UTC (rev 8465) @@ -3,10 +3,6 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_oniguruma.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_SFMT.cmake) -if(USE_UNICODE_API) - add_definitions(-DUNICODE -D_UNICODE) -endif() - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") add_executable( Modified: trunk/ttssh2/ttxssh/CMakeLists.txt =================================================================== --- trunk/ttssh2/ttxssh/CMakeLists.txt 2020-01-10 13:13:34 UTC (rev 8464) +++ trunk/ttssh2/ttxssh/CMakeLists.txt 2020-01-10 13:13:45 UTC (rev 8465) @@ -133,16 +133,7 @@ PRIVATE $<$:_CRTDBG_MAP_ALLOC> ) -if(USE_UNICODE_API) - target_compile_definitions( - ttxssh - PRIVATE - UNICODE - _UNICODE - ) -endif() - target_link_libraries( ttxssh libputty Modified: trunk/version_info.h.in =================================================================== --- trunk/version_info.h.in 2020-01-10 13:13:34 UTC (rev 8464) +++ trunk/version_info.h.in 2020-01-10 13:13:45 UTC (rev 8465) @@ -1,5 +1,4 @@ -#cmakedefine USE_UNICODE_API #cmakedefine SVNVERSION @SVNVERSION@ // infos when generated From scmnotify @ osdn.net Fri Jan 10 22:13:57 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 10 Jan 2020 22:13:57 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NjZdIHRtZmMuY3BwLGgg44GnIHRjaGFy?= =?utf-8?b?IOOCkuS9v+eUqOOBmeOCi+mWouaVsOOCkuWJiumZpA==?= Message-ID: <1578662037.132978.127695.nullmailer@users.osdn.me> Revision: 8466 https://osdn.net/projects/ttssh2/scm/svn/commits/8466 Author: zmatsuo Date: 2020-01-10 22:13:56 +0900 (Fri, 10 Jan 2020) Log Message: ----------- tmfc.cpp,h で tchar を使用する関数を削除 Modified Paths: -------------- trunk/teraterm/common/tmfc.cpp trunk/teraterm/common/tmfc.h trunk/teraterm/teraterm/addsetting.cpp -------------- next part -------------- Modified: trunk/teraterm/common/tmfc.cpp =================================================================== --- trunk/teraterm/common/tmfc.cpp 2020-01-10 13:13:45 UTC (rev 8465) +++ trunk/teraterm/common/tmfc.cpp 2020-01-10 13:13:56 UTC (rev 8466) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 TeraTerm Project + * Copyright (C) 2018-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,7 +33,6 @@ #include #include -#include #include "dlglib.h" #include "ttlib.h" #include "layer_for_unicode.h" @@ -64,11 +63,6 @@ return ::GetDlgItem(m_hWnd, id); } -LRESULT TTCWnd::SendDlgItemMessageT(int id, UINT msg, WPARAM wp, LPARAM lp) -{ - return ::SendDlgItemMessage(m_hWnd, id, msg, wp, lp); -} - LRESULT TTCWnd::SendDlgItemMessageW(int id, UINT msg, WPARAM wp, LPARAM lp) { return ::_SendDlgItemMessageW(m_hWnd, id, msg, wp, lp); @@ -79,11 +73,6 @@ return ::SendDlgItemMessageA(m_hWnd, id, msg, wp, lp); } -void TTCWnd::GetDlgItemTextT(int id, TCHAR *buf, size_t size) -{ - ::GetDlgItemText(m_hWnd, id, buf, (int)size); -} - void TTCWnd::GetDlgItemTextW(int id, wchar_t *buf, size_t size) { _GetDlgItemTextW(m_hWnd, id, buf, (int)size); @@ -94,11 +83,6 @@ ::GetDlgItemTextA(m_hWnd, id, buf, (int)size); } -void TTCWnd::SetDlgItemTextT(int id, const TCHAR *str) -{ - ::SetDlgItemText(m_hWnd, id, str); -} - void TTCWnd::SetDlgItemTextW(int id, const wchar_t *str) { _SetDlgItemTextW(m_hWnd, id, str); @@ -129,12 +113,12 @@ { HWND hWnd = GetDlgItem(id); assert(hWnd != 0); - TCHAR ClassName[32]; - int r = GetClassName(hWnd, ClassName, _countof(ClassName)); + char ClassName[32]; + int r = GetClassNameA(hWnd, ClassName, _countof(ClassName)); assert(r != 0); (void)r; UINT msg = - (_tcscmp(ClassName, _T("ListBox")) == 0) ? LB_SETCURSEL : - (_tcscmp(ClassName, _T("ComboBox")) == 0) ? CB_SETCURSEL : 0; + (strcmp(ClassName, "ListBox") == 0) ? LB_SETCURSEL : + (strcmp(ClassName, "ComboBox") == 0) ? CB_SETCURSEL : 0; assert(msg != 0); ::SendMessage(hWnd, msg, no, 0); } @@ -143,12 +127,12 @@ { HWND hWnd = GetDlgItem(id); assert(hWnd != 0); - TCHAR ClassName[32]; - int r = GetClassName(hWnd, ClassName, _countof(ClassName)); + char ClassName[32]; + int r = GetClassNameA(hWnd, ClassName, _countof(ClassName)); assert(r != 0); (void)r; UINT msg = - (_tcscmp(ClassName, _T("ListBox")) == 0) ? LB_GETCURSEL : - (_tcscmp(ClassName, _T("ComboBox")) == 0) ? CB_GETCURSEL : 0; + (strcmp(ClassName, "ListBox") == 0) ? LB_GETCURSEL : + (strcmp(ClassName, "ComboBox") == 0) ? CB_GETCURSEL : 0; assert(msg != 0); LRESULT lResult = ::SendMessage(hWnd, msg, 0, 0); return (int)lResult; @@ -174,11 +158,6 @@ ::ShowWindow(m_hWnd, nCmdShow); } -void TTCWnd::SetWindowTextT(const TCHAR *str) -{ - ::SetWindowText(m_hWnd, str); -} - void TTCWnd::SetWindowTextW(const wchar_t *str) { _SetWindowTextW(m_hWnd, str); @@ -226,11 +205,6 @@ ModifyStyleCom(GWL_EXSTYLE, dwRemove, dwAdd, nFlags); } -int TTCWnd::MessageBoxT(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType) -{ - return ::MessageBox(m_hWnd, lpText, lpCaption, uType); -} - int TTCWnd::MessageBoxA(const char *lpText, const char *lpCaption, UINT uType) { return ::MessageBoxA(m_hWnd, lpText, lpCaption, uType); Modified: trunk/teraterm/common/tmfc.h =================================================================== --- trunk/teraterm/common/tmfc.h 2020-01-10 13:13:45 UTC (rev 8465) +++ trunk/teraterm/common/tmfc.h 2020-01-10 13:13:56 UTC (rev 8466) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 TeraTerm Project + * Copyright (C) 2018-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,7 +48,6 @@ BOOL EndPaint(LPPAINTSTRUCT lpPaint); LRESULT SendMessage(UINT msg, WPARAM wp, LPARAM lp); void ShowWindow(int nCmdShow); - void SetWindowTextT(const TCHAR *str); void SetWindowTextW(const wchar_t *str); void SetWindowTextA(const char *str); LONG_PTR SetWindowLongPtr(int nIndex, LONG_PTR dwNewLong); @@ -55,11 +54,8 @@ LONG_PTR GetWindowLongPtr(int nIndex); void ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0); void ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0); - int MessageBoxT(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType); int MessageBoxA(const char * lpText, const char *lpCaption, UINT uType); -#if defined(UNICODE) int MessageBoxW(const wchar_t * lpText, const wchar_t *lpCaption, UINT uType); -#endif //virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam); LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam); BOOL GetWindowRect(RECT *R); @@ -69,13 +65,10 @@ BOOL EndDialog(int nResult); // for controls HWND GetDlgItem(int id); - LRESULT SendDlgItemMessageT(int id, UINT msg, WPARAM wp, LPARAM lp); LRESULT SendDlgItemMessageW(int id, UINT msg, WPARAM wp, LPARAM lp); LRESULT SendDlgItemMessageA(int id, UINT msg, WPARAM wp, LPARAM lp); - void GetDlgItemTextT(int id, TCHAR *buf, size_t size); void GetDlgItemTextW(int id, wchar_t *buf, size_t size); void GetDlgItemTextA(int id, char *buf, size_t size); - void SetDlgItemTextT(int id, const TCHAR *str); void SetDlgItemTextW(int id, const wchar_t *str); void SetDlgItemTextA(int id, const char *str); void SetDlgItemNum(int id, LONG Num); Modified: trunk/teraterm/teraterm/addsetting.cpp =================================================================== --- trunk/teraterm/teraterm/addsetting.cpp 2020-01-10 13:13:45 UTC (rev 8465) +++ trunk/teraterm/teraterm/addsetting.cpp 2020-01-10 13:13:56 UTC (rev 8466) @@ -158,7 +158,7 @@ void CGeneralPropPageDlg::OnOK() { - TCHAR buf[64]; + char buf[64]; int val; // (1) @@ -171,8 +171,8 @@ ts.AcceptBroadcast = GetCheck(IDC_ACCEPT_BROADCAST); // (4)IDC_MOUSEWHEEL_SCROLL_LINE - GetDlgItemTextT(IDC_SCROLL_LINE, buf, _countof(buf)); - val = _tstoi(buf); + GetDlgItemText(IDC_SCROLL_LINE, buf, _countof(buf)); + val = atoi(buf); if (val > 0) ts.MouseWheelScrollLine = val; @@ -899,7 +899,7 @@ // \x96\xB3\x8C\x{27B0B3}\x82ꂽ\x82\xE7\x81ABGThemeFile \x82\xF0\x8C\xB3\x82ɖ߂\xB7\x81B strncpy_s(ts.EtermLookfeel.BGThemeFile, BG_THEME_IMAGEFILE_DEFAULT, sizeof(ts.EtermLookfeel.BGThemeFile)); // \x94w\x8Ci\x89摜\x82\xE0\x96\xB3\x8C\x{27B0B7}\x82\xE9\x81B - SetDlgItemTextT(IDC_BGIMG_EDIT, _T("")); + SetDlgItemText(IDC_BGIMG_EDIT, ""); SetDlgItemInt(IDC_EDIT_BGIMG_BRIGHTNESS, BG_THEME_IMAGE_BRIGHTNESS_DEFAULT); EnableDlgItem(IDC_MIXED_THEME_FILE, FALSE); @@ -934,7 +934,7 @@ // \x96\xB3\x8C\x{27B0B3}\x82ꂽ\x82\xE7\x81ABGThemeFile \x82\xF0\x8C\xB3\x82ɖ߂\xB7\x81B strncpy_s(ts.EtermLookfeel.BGThemeFile, BG_THEME_IMAGEFILE_DEFAULT, sizeof(ts.EtermLookfeel.BGThemeFile)); // \x94w\x8Ci\x89摜\x82\xE0\x96\xB3\x8C\x{27B0B7}\x82\xE9\x81B - SetDlgItemTextT(IDC_BGIMG_EDIT, _T("")); + SetDlgItemText(IDC_BGIMG_EDIT, ""); SetDlgItemInt(IDC_EDIT_BGIMG_BRIGHTNESS, BG_THEME_IMAGE_BRIGHTNESS_DEFAULT); } return TRUE; From scmnotify @ osdn.net Fri Jan 10 22:14:06 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 10 Jan 2020 22:14:06 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NjddIGRlYnVnX3Bw6K2m5ZGK5a++562W?= Message-ID: <1578662046.868102.128919.nullmailer@users.osdn.me> Revision: 8467 https://osdn.net/projects/ttssh2/scm/svn/commits/8467 Author: zmatsuo Date: 2020-01-10 22:14:06 +0900 (Fri, 10 Jan 2020) Log Message: ----------- debug_pp警告対策 Modified Paths: -------------- trunk/teraterm/teraterm/debug_pp.cpp -------------- next part -------------- Modified: trunk/teraterm/teraterm/debug_pp.cpp =================================================================== --- trunk/teraterm/teraterm/debug_pp.cpp 2020-01-10 13:13:56 UTC (rev 8466) +++ trunk/teraterm/teraterm/debug_pp.cpp 2020-01-10 13:14:06 UTC (rev 8467) @@ -59,7 +59,7 @@ { // popup SetCheck(IDC_DEBUG_POPUP_ENABLE, UnicodeDebugParam.CodePopupEnable); - for (int i = 0; i < _countof(key_list); i++) { + for (int i = 0; i < (int)_countof(key_list); i++) { SendDlgItemMessage(IDC_DEBUG_POPUP_KEY1, CB_ADDSTRING, 0, (LPARAM)key_list[i].key_str); SendDlgItemMessage(IDC_DEBUG_POPUP_KEY2, CB_ADDSTRING, 0, (LPARAM)key_list[i].key_str); if (UnicodeDebugParam.CodePopupKey1 == key_list[i].key_code) { From scmnotify @ osdn.net Fri Jan 10 22:14:19 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 10 Jan 2020 22:14:19 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NjhdIFRUWENoZWNrVXBkYXRl6K2m5ZGK?= =?utf-8?b?5a++562W?= Message-ID: <1578662059.111529.129134.nullmailer@users.osdn.me> Revision: 8468 https://osdn.net/projects/ttssh2/scm/svn/commits/8468 Author: zmatsuo Date: 2020-01-10 22:14:18 +0900 (Fri, 10 Jan 2020) Log Message: ----------- TTXCheckUpdate警告対策 Modified Paths: -------------- trunk/TTXSamples/TTXCheckUpdate/getcontent.cpp trunk/TTXSamples/TTXCheckUpdate/getcontent.h trunk/TTXSamples/TTXCheckUpdate/parse.cpp trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c -------------- next part -------------- Modified: trunk/TTXSamples/TTXCheckUpdate/getcontent.cpp =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/getcontent.cpp 2020-01-10 13:14:06 UTC (rev 8467) +++ trunk/TTXSamples/TTXCheckUpdate/getcontent.cpp 2020-01-10 13:14:18 UTC (rev 8468) @@ -1,12 +1,8 @@ #include #include -#include -#include -#include -#include -#include #define _CRTDBG_MAP_ALLOC +#include #include #if (defined(_MSC_VER) && (_MSC_VER >= 1600)) || !defined(_MSC_VER) Modified: trunk/TTXSamples/TTXCheckUpdate/getcontent.h =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/getcontent.h 2020-01-10 13:14:06 UTC (rev 8467) +++ trunk/TTXSamples/TTXCheckUpdate/getcontent.h 2020-01-10 13:14:18 UTC (rev 8468) @@ -1,7 +1,5 @@ #include -#include -//#include #include #ifdef __cplusplus Modified: trunk/TTXSamples/TTXCheckUpdate/parse.cpp =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/parse.cpp 2020-01-10 13:14:06 UTC (rev 8467) +++ trunk/TTXSamples/TTXCheckUpdate/parse.cpp 2020-01-10 13:14:18 UTC (rev 8468) @@ -1,7 +1,6 @@ -#include -#include -#include + #define _CRTDBG_MAP_ALLOC +#include #include #include "cJSON/cJSON.h" Modified: trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c 2020-01-10 13:14:06 UTC (rev 8467) +++ trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c 2020-01-10 13:14:18 UTC (rev 8468) @@ -141,7 +141,7 @@ } swprintf(agent, _countof(agent), L"%s_%d", agent_base, pvar->ts->RunningVersion); - result_bool = GetContent(update_info_url, agent, &json_raw_ptr, &json_raw_size); + result_bool = GetContent(update_info_url, agent, (void**)&json_raw_ptr, &json_raw_size); if (!result_bool) { MessageBoxW(hWnd, L"access error?", L"Tera Term", MB_OK | MB_ICONEXCLAMATION); return; From scmnotify @ osdn.net Fri Jan 10 22:14:28 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 10 Jan 2020 22:14:28 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NjldIOODoeODi+ODpeODvOOCkuWkmg==?= =?utf-8?b?6KiA6Kqe5YyW?= Message-ID: <1578662068.287695.129255.nullmailer@users.osdn.me> Revision: 8469 https://osdn.net/projects/ttssh2/scm/svn/commits/8469 Author: zmatsuo Date: 2020-01-10 22:14:28 +0900 (Fri, 10 Jan 2020) Log Message: ----------- メニューを多言語化 Modified Paths: -------------- trunk/ttssh2/ttxssh/ttxssh.c -------------- next part -------------- Modified: trunk/ttssh2/ttxssh/ttxssh.c =================================================================== --- trunk/ttssh2/ttxssh/ttxssh.c 2020-01-10 13:14:18 UTC (rev 8468) +++ trunk/ttssh2/ttxssh/ttxssh.c 2020-01-10 13:14:28 UTC (rev 8469) @@ -1,6 +1,6 @@ /* * Copyright (c) 1998-2001, Robert O'Callahan - * (C) 2004-2019 TeraTerm Project + * (C) 2004-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -2148,13 +2148,8 @@ } } -#define GetFileMenu(menu) GetSubMenuByChildID(menu, 50110) // ID_FILE_NEWCONNECTION -#define GetEditMenu(menu) GetSubMenuByChildID(menu, 50210) // ID_EDIT_COPY2 -#define GetSetupMenu(menu) GetSubMenuByChildID(menu, 50310) // ID_SETUP_TERMINAL -#define GetControlMenu(menu) GetSubMenuByChildID(menu, 50410) // ID_CONTROL_RESETTERMINAL -#define GetHelpMenu(menu) GetSubMenuByChildID(menu, 50990) // ID_HELP_ABOUT - -HMENU GetSubMenuByChildID(HMENU menu, UINT id) { +static HMENU GetSubMenuByChildID(HMENU menu, UINT id) +{ int i, j, items, subitems, cur_id; HMENU m; @@ -2176,27 +2171,35 @@ static void PASCAL TTXModifyMenu(HMENU menu) { - pvar->FileMenu = GetFileMenu(menu); + static const DlgTextInfo MenuTextInfo[] = { + { ID_ABOUTMENU, "MENU_ABOUT" }, + { ID_SSHSETUPMENU, "MENU_SSH" }, + { ID_SSHAUTHSETUPMENU, "MENU_SSH_AUTH" }, + { ID_SSHFWDSETUPMENU, "MENU_SSH_FORWARD" }, + { ID_SSHKEYGENMENU, "MENU_SSH_KEYGEN" }, + { ID_SSHSCPMENU, "MENU_SSH_SCP" }, + }; + // teraterm\x82̃\x81\x83j\x83\x85\x81[ID(tt_res.h) + const UINT ID_FILE_NEWCONNECTION = 50110; + const UINT ID_HELP_ABOUT = 50990; + const UINT ID_SETUP_TCPIP = 50360; + const UINT ID_FILE_CHANGEDIR = 50170; + pvar->FileMenu = GetSubMenuByChildID(menu, ID_FILE_NEWCONNECTION); + /* inserts before ID_HELP_ABOUT */ - UTIL_get_lang_msg("MENU_ABOUT", pvar, "About &TTSSH..."); - insertMenuBeforeItem(menu, 50990, MF_ENABLED, ID_ABOUTMENU, pvar->ts->UIMsg); + insertMenuBeforeItem(menu, ID_HELP_ABOUT, MF_ENABLED, ID_ABOUTMENU, "About &TTSSH..."); /* inserts before ID_SETUP_TCPIP */ - UTIL_get_lang_msg("MENU_SSH", pvar, "SS&H..."); - insertMenuBeforeItem(menu, 50360, MF_ENABLED, ID_SSHSETUPMENU, pvar->ts->UIMsg); - /* inserts before ID_SETUP_TCPIP */ - UTIL_get_lang_msg("MENU_SSH_AUTH", pvar, "SSH &Authentication..."); - insertMenuBeforeItem(menu, 50360, MF_ENABLED, ID_SSHAUTHSETUPMENU, pvar->ts->UIMsg); - /* inserts before ID_SETUP_TCPIP */ - UTIL_get_lang_msg("MENU_SSH_FORWARD", pvar, "SSH F&orwarding..."); - insertMenuBeforeItem(menu, 50360, MF_ENABLED, ID_SSHFWDSETUPMENU, pvar->ts->UIMsg); - UTIL_get_lang_msg("MENU_SSH_KEYGEN", pvar, "SSH KeyGe&nerator..."); - insertMenuBeforeItem(menu, 50360, MF_ENABLED, ID_SSHKEYGENMENU, pvar->ts->UIMsg); + insertMenuBeforeItem(menu, ID_SETUP_TCPIP, MF_ENABLED, ID_SSHSETUPMENU, "SS&H..."); + insertMenuBeforeItem(menu, ID_SETUP_TCPIP, MF_ENABLED, ID_SSHAUTHSETUPMENU, "SSH &Authentication..."); + insertMenuBeforeItem(menu, ID_SETUP_TCPIP, MF_ENABLED, ID_SSHFWDSETUPMENU, "SSH F&orwarding..."); + insertMenuBeforeItem(menu, ID_SETUP_TCPIP, MF_ENABLED, ID_SSHKEYGENMENU, "SSH KeyGe&nerator..."); /* inserts before ID_FILE_CHANGEDIR */ - UTIL_get_lang_msg("MENU_SSH_SCP", pvar, "SS&H SCP..."); - insertMenuBeforeItem(menu, 50170, MF_GRAYED, ID_SSHSCPMENU, pvar->ts->UIMsg); + insertMenuBeforeItem(menu, ID_FILE_CHANGEDIR, MF_GRAYED, ID_SSHSCPMENU, "SS&H SCP..."); + + SetI18MenuStrs("TTSSH", menu, MenuTextInfo, _countof(MenuTextInfo), pvar->ts->UILanguageFile); } static void PASCAL TTXModifyPopupMenu(HMENU menu) { From scmnotify @ osdn.net Sat Jan 11 00:50:04 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Sat, 11 Jan 2020 00:50:04 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NzBdIENoZWNrVXBkYXRl44OX44Op44Kw?= =?utf-8?b?44Kk44Oz44KS5L+u5q2j?= Message-ID: <1578671404.393400.107734.nullmailer@users.osdn.me> Revision: 8470 https://osdn.net/projects/ttssh2/scm/svn/commits/8470 Author: zmatsuo Date: 2020-01-11 00:50:02 +0900 (Sat, 11 Jan 2020) Log Message: ----------- CheckUpdateプラグインを修正 - check updateメニューをhelpに移動 - メニューIDを変更 - m18n, (日本語のみ)追加 Modified Paths: -------------- trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c trunk/installer/release/lang_utf8/Japanese.lng trunk/teraterm/common/i18n.c -------------- next part -------------- Modified: trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt 2020-01-10 13:14:28 UTC (rev 8469) +++ trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt 2020-01-10 15:50:02 UTC (rev 8470) @@ -49,3 +49,9 @@ ttpcmn Wininet.lib ) + +install( + TARGETS TTXCheckUpdate + RUNTIME + DESTINATION . + ) Modified: trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c 2020-01-10 13:14:28 UTC (rev 8469) +++ trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c 2020-01-10 15:50:02 UTC (rev 8470) @@ -1,4 +1,3 @@ -/* -*- coding: utf-8-with-signature-dos -*- */ #include #include @@ -13,6 +12,7 @@ #include "codeconv.h" #include "compat_w95.h" #include "dlglib.h" +#include "i18n.h" #include "resource.h" #include "parse.h" @@ -19,7 +19,7 @@ #include "getcontent.h" #define ORDER 4000 -#define ID_MENUITEM 6000 +#define ID_MENUITEM 55900 // see reference/develop.txt typedef struct { HANDLE hInst; @@ -129,17 +129,21 @@ BOOL result_bool; size_t json_size; char *json_ptr; + const char *UILanguageFile = pvar->ts->UILanguageFile; + wchar_t UIMsg[MAX_UIMSG]; - swprintf(buf, _countof(buf), - L"ネットワークにアクセスします\n" - L" %s\n" - L"よろしいですか?", - update_info_url); + /* \x83t\x83@\x83C\x83\x8B\x82\xF0\x8E擾\x82\xB5\x82Ă\xE0ok? */ + GetI18nStrW("TTXCheckUpdate", "MSG_CHECKUPDATE", UIMsg, _countof(UIMsg), + L"Do you want to check update?\n" + L" %s\n", + UILanguageFile); + swprintf(buf, _countof(buf), UIMsg, update_info_url); result_mb = MessageBoxW(hWnd, buf, L"Tera Term", MB_YESNO | MB_ICONEXCLAMATION); if (result_mb == IDNO) { return; } + /* \x83t\x83@\x83C\x83\x8B\x8E擾\x81A'\0'\x82\xF0\x92lj\xC1\x82\xB7\x82遨 json\x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x8D쐬 */ swprintf(agent, _countof(agent), L"%s_%d", agent_base, pvar->ts->RunningVersion); result_bool = GetContent(update_info_url, agent, (void**)&json_raw_ptr, &json_raw_size); if (!result_bool) { @@ -155,6 +159,7 @@ json_raw_ptr = NULL; json_ptr[json_size - 1] = '\0'; + /* json\x82\xF0\x83p\x81[\x83X\x82\xB7\x82\xE9 */ pvar->versions = ParseJson(json_ptr, &pvar->versions_count); if (pvar->versions == NULL) { MessageBoxW(hWnd, L"parse error?", L"Tera Term", MB_OK | MB_ICONEXCLAMATION); @@ -161,10 +166,12 @@ return; } + /* \x83_\x83C\x83A\x83\x8D\x83O\x82\xF0\x8Fo\x82\xB7 */ SetDialogFont(pvar->ts->DialogFontName, pvar->ts->DialogFontPoint, pvar->ts->DialogFontCharSet, pvar->ts->UILanguageFile, "Tera Term", "DLG_TAHOMA_FONT"); TTDialogBoxParam(pvar->hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, DlgProc, (LPARAM)pvar); + /* \x8FI\x97\xB9 */ free(json_ptr); ParseFree(pvar->versions, pvar->versions_count); pvar->versions = NULL; @@ -176,10 +183,45 @@ pvar->cv = cv; } +/** + * \x83\x81\x83j\x83\x85\x81[\x82\xF0\x92lj\xC1\x82\xB7\x82\xE9 + * + * @param[in] menu \x83\x81\x83j\x83\x85\x81[\x83n\x83\x93\x83h\x83\x8B + * @param[in] beforeItemID \x82\xB1\x82\xCCID\x82̃\x81\x83j\x83\x85\x81[\x82̑O\x82Ƀ\x81\x83j\x83\x85\x81[\x82\xF0\x92lj\xC1 + * @param[in] flags \x83\x81\x83j\x83\x85\x81[flag (InsertMenu\x82̑\xE63\x88\xF8\x90\x94) + * @param[in] newItemID \x83\x81\x83j\x83\x85\x81[ID (InsertMenu\x82̑\xE64\x88\xF8\x90\x94) + * @param[in] text \x83\x81\x83j\x83\x85\x81[\x95\xB6\x8E\x9A\x97\xF1 (InsertMenu\x82̑\xE65\x88\xF8\x90\x94) + * + * TODO: ttlib\x82Ɉړ\xAE + */ +static void insertMenuBeforeItem(HMENU menu, WORD beforeItemID, WORD flags, + WORD newItemID, char *text) +{ + int i, j; + + for (i = GetMenuItemCount(menu) - 1; i >= 0; i--) { + HMENU submenu = GetSubMenu(menu, i); + + for (j = GetMenuItemCount(submenu) - 1; j >= 0; j--) { + if (GetMenuItemID(submenu, j) == beforeItemID) { + InsertMenu(submenu, j, MF_BYPOSITION | flags, newItemID, text); + return; + } + } + } +} + static void WINAPI TTXModifyMenu(HMENU menu) { - HMENU SetupMenu = GetSubMenu(menu, 0); - AppendMenu(SetupMenu, MF_ENABLED, ID_MENUITEM, "Check Update"); + static const DlgTextInfo MenuTextInfo[] = { + { ID_MENUITEM, "MENU_CHECKUPDATE" }, + }; + const UINT ID_HELP_ABOUT = 50990; + const char *UILanguageFile = pvar->ts->UILanguageFile; + + insertMenuBeforeItem(menu, ID_HELP_ABOUT, MF_ENABLED, ID_MENUITEM, "Check &Update..."); + + SetI18MenuStrs("TTXCheckUpdate", menu, MenuTextInfo, _countof(MenuTextInfo), UILanguageFile); } static int WINAPI TTXProcessCommand(HWND hWin, WORD cmd) @@ -219,7 +261,7 @@ } if (!IsWindowsNTKernel()) { - // TODO Windows10以外、未検証 + // TODO Windows10\x88ȊO\x81A\x96\xA2\x8C\x9F\x8F\xD8 return FALSE; } Modified: trunk/installer/release/lang_utf8/Japanese.lng =================================================================== --- trunk/installer/release/lang_utf8/Japanese.lng 2020-01-10 13:14:28 UTC (rev 8469) +++ trunk/installer/release/lang_utf8/Japanese.lng 2020-01-10 15:50:02 UTC (rev 8470) @@ -1,4 +1,4 @@ -; Updated by TeraTerm Project (2020-01-09) +; Updated by TeraTerm Project (2020-01-11) [Tera Term] DLG_SYSTEM_FONT=MS Pゴシック,12,128 @@ -1151,3 +1151,7 @@ DLG_INTERVAL=間隔(秒)(&I) DLG_COMMAND=コマンド(&C) DLG_ADD_NEWLINE=改行を追加(&A) + +[TTXCheckUpdate] +MSG_CHECKUPDATE=アップデートの確認を行いますか?\n %s +MENU_CHECKUPDATE=更新の確認(&U)... Modified: trunk/teraterm/common/i18n.c =================================================================== --- trunk/teraterm/common/i18n.c 2020-01-10 13:14:28 UTC (rev 8469) +++ trunk/teraterm/common/i18n.c 2020-01-10 15:50:02 UTC (rev 8470) @@ -211,12 +211,8 @@ char uimsg[MAX_UIMSG]; GetI18nStr(section, key, uimsg, sizeof(uimsg), NULL, UILanguageFile); if (uimsg[0] != '\0') { - if (nIDDlgItem < id_position_threshold) { - ModifyMenuA(hMenu, nIDDlgItem, MF_BYPOSITION, nIDDlgItem, uimsg); - } - else { - ModifyMenuA(hMenu, nIDDlgItem, MF_BYCOMMAND, nIDDlgItem, uimsg); - } + UINT uFlags = (nIDDlgItem < id_position_threshold) ? MF_BYPOSITION : MF_BYCOMMAND; + ModifyMenuA(hMenu, nIDDlgItem, uFlags, nIDDlgItem, uimsg); } else { if (nIDDlgItem < id_position_threshold) { @@ -231,12 +227,8 @@ wchar_t uimsg[MAX_UIMSG]; GetI18nStrW(section, key, uimsg, _countof(uimsg), NULL, UILanguageFile); if (uimsg[0] != '\0') { - if (nIDDlgItem < id_position_threshold) { - pModifyMenuW(hMenu, nIDDlgItem, MF_BYPOSITION, nIDDlgItem, uimsg); - } - else { - pModifyMenuW(hMenu, nIDDlgItem, MF_BYCOMMAND, nIDDlgItem, uimsg); - } + UINT uFlags = (nIDDlgItem < id_position_threshold) ? MF_BYPOSITION : MF_BYCOMMAND; + pModifyMenuW(hMenu, nIDDlgItem, uFlags, nIDDlgItem, uimsg); } else { if (nIDDlgItem < id_position_threshold) { From scmnotify @ osdn.net Tue Jan 14 01:26:07 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Tue, 14 Jan 2020 01:26:07 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NzFdIEdVSeOCkuWkmuiogOiqnuWMlg==?= Message-ID: <1578932767.156235.146374.nullmailer@users.osdn.me> Revision: 8471 https://osdn.net/projects/ttssh2/scm/svn/commits/8471 Author: zmatsuo Date: 2020-01-14 01:26:06 +0900 (Tue, 14 Jan 2020) Log Message: ----------- GUIを多言語化 Modified Paths: -------------- trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c -------------- next part -------------- Modified: trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c =================================================================== --- trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c 2020-01-10 15:50:02 UTC (rev 8470) +++ trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c 2020-01-13 16:26:06 UTC (rev 8471) @@ -430,24 +430,25 @@ // \x83R\x83\x93\x83g\x83\x8D\x81[\x83\x8B\x83\x81\x83j\x83\x85\x81[\x82\xC9RecurringCommand\x82\xF0\x92lj\xC1\x81B // static void PASCAL TTXModifyMenu(HMENU menu) { + static const DlgTextInfo MenuTextInfo[] = { + { ID_MENU_SETUP, "MENU_SETUP_RECURRING" }, + { ID_MENU_CONTROL, "MENU_CONTROL_RECURRING" }, + }; UINT flag = MF_BYCOMMAND | MF_STRING | MF_ENABLED; pvar->SetupMenu = GetSetupMenu(menu); pvar->ControlMenu = GetControlMenu(menu); - GetI18nStr(SECTION, "MENU_SETUP_RECURRING", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Rec&urring command", pvar->ts->UILanguageFile); - InsertMenu(pvar->SetupMenu, ID_SETUP_ADDITIONALSETTINGS, flag, ID_MENU_SETUP, pvar->ts->UIMsg); + InsertMenu(pvar->SetupMenu, ID_SETUP_ADDITIONALSETTINGS, flag, ID_MENU_SETUP, "Rec&urring command"); if (pvar->enable) { flag |= MF_CHECKED; } + InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, flag, ID_MENU_CONTROL, "Rec&urring command"); + InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, MF_BYCOMMAND | MF_SEPARATOR, 0, NULL); - GetI18nStr(SECTION, "MENU_CONTROL_RECURRING", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Rec&urring command", pvar->ts->UILanguageFile); - InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, flag, ID_MENU_CONTROL, pvar->ts->UIMsg); - InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, MF_BYCOMMAND | MF_SEPARATOR, 0, NULL); + SetI18MenuStrs(SECTION, menu, MenuTextInfo, _countof(MenuTextInfo), pvar->ts->UILanguageFile); } static void PASCAL TTXModifyPopupMenu(HMENU menu) { @@ -465,54 +466,18 @@ // RecurringCommand\x90ݒ\xE8\x83_\x83C\x83A\x83\x8D\x83O\x82̃R\x81[\x83\x8B\x83o\x83b\x83N\x8A֐\x94\x81B // static LRESULT CALLBACK RecurringCommandSetting(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) { - char uimsg[MAX_UIMSG]; -#if 0 - static HFONT DlgFont; - LOGFONT logfont; - HFONT font; -#endif + const static DlgTextInfo text_info[] = { + { 0, "DLG_TITLE" }, + { IDC_ENABLE, "DLG_ENABLE" }, + { IDC_INTERVAL_LABEL, "DLG_INTERVAL" }, + { IDC_COMMAND_LABEL, "DLG_COMMAND" }, + { IDC_ADD_NL, "DLG_ADD_NEWLINE" }, + }; switch (msg) { case WM_INITDIALOG: -#if 0 - font = (HFONT)SendMessage(dlg, WM_GETFONT, 0, 0); - GetObject(font, sizeof(LOGFONT), &logfont); + SetI18DlgStrs(SECTION, dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); - if ((GetI18nLogfont(SECTION, "DLG_TAHOMA_FONT", &logfont, GetDeviceCaps(GetDC(dlg), LOGPIXELSY), - pvar->ts->UILanguageFile) != FALSE) && - ((DlgFont = CreateFontIndirect(&logfont)) != NULL)) { - SendDlgItemMessage(dlg, IDC_ENABLE, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0)); - SendDlgItemMessage(dlg, IDC_INTERVAL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0)); - SendDlgItemMessage(dlg, IDC_INTERVAL_LABEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0)); - SendDlgItemMessage(dlg, IDC_COMMAND, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0)); - SendDlgItemMessage(dlg, IDC_COMMAND_LABEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0)); - SendDlgItemMessage(dlg, IDC_ADD_NL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0)); - } - else { - DlgFont = NULL; - } -#endif - - GetWindowText(dlg, uimsg, sizeof(uimsg)); - GetI18nStr(SECTION, "DLG_TITLE", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), uimsg, pvar->ts->UILanguageFile); - SetWindowText(dlg, pvar->ts->UIMsg); - - GetDlgItemText(dlg, IDC_ENABLE, uimsg, sizeof(uimsg)); - GetI18nStr(SECTION, "DLG_ENABLE", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), uimsg, pvar->ts->UILanguageFile); - SetDlgItemText(dlg, IDC_ENABLE, pvar->ts->UIMsg); - - GetDlgItemText(dlg, IDC_INTERVAL_LABEL, uimsg, sizeof(uimsg)); - GetI18nStr(SECTION, "DLG_INTERVAL", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), uimsg, pvar->ts->UILanguageFile); - SetDlgItemText(dlg, IDC_INTERVAL_LABEL, pvar->ts->UIMsg); - - GetDlgItemText(dlg, IDC_COMMAND_LABEL, uimsg, sizeof(uimsg)); - GetI18nStr(SECTION, "DLG_COMMAND", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), uimsg, pvar->ts->UILanguageFile); - SetDlgItemText(dlg, IDC_COMMAND_LABEL, pvar->ts->UIMsg); - - GetDlgItemText(dlg, IDC_ADD_NL, uimsg, sizeof(uimsg)); - GetI18nStr(SECTION, "DLG_ADD_NEWLINE", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), uimsg, pvar->ts->UILanguageFile); - SetDlgItemText(dlg, IDC_ADD_NL, pvar->ts->UIMsg); - SendMessage(GetDlgItem(dlg, IDC_ENABLE), BM_SETCHECK, pvar->enable?BST_CHECKED:BST_UNCHECKED, 0); SetDlgItemInt(dlg, IDC_INTERVAL, pvar->interval, FALSE); @@ -555,20 +520,10 @@ } EndDialog(dlg, IDOK); -#if 0 - if (DlgFont != NULL) { - DeleteObject(DlgFont); - } -#endif return TRUE; case IDCANCEL: EndDialog(dlg, IDCANCEL); -#if 0 - if (DlgFont != NULL) { - DeleteObject(DlgFont); - } -#endif return TRUE; } break; From scmnotify @ osdn.net Tue Jan 14 01:26:17 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Tue, 14 Jan 2020 01:26:17 +0900 Subject: [Ttssh2-commit] =?utf-8?q?=5B8472=5D_DialogBoxIndirectParamW=28?= =?utf-8?b?KSDjgpLkvb/nlKg=?= Message-ID: <1578932777.106190.146559.nullmailer@users.osdn.me> Revision: 8472 https://osdn.net/projects/ttssh2/scm/svn/commits/8472 Author: zmatsuo Date: 2020-01-14 01:26:16 +0900 (Tue, 14 Jan 2020) Log Message: ----------- DialogBoxIndirectParamW() を使用 - ダイアログのタイトルバーが文字化けする場合があった - 可能なら DialogBoxIndirectParamW() を使用する - 使用できなければ従来どおり DialogBoxIndirectParamA() を使用する Modified Paths: -------------- trunk/teraterm/common/dlglib_cpp.cpp -------------- next part -------------- Modified: trunk/teraterm/common/dlglib_cpp.cpp =================================================================== --- trunk/teraterm/common/dlglib_cpp.cpp 2020-01-13 16:26:06 UTC (rev 8471) +++ trunk/teraterm/common/dlglib_cpp.cpp 2020-01-13 16:26:16 UTC (rev 8472) @@ -1,5 +1,5 @@ /* - * (C) 2005-2019 TeraTerm Project + * (C) 2005-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -225,9 +225,25 @@ return DlgResult; #else DLGTEMPLATE *lpTemplate = TTGetDlgTemplate(hInstance, lpTemplateName); - INT_PTR DlgResult = DialogBoxIndirectParam( - hInstance, lpTemplate, hWndParent, - lpDialogFunc, lParamInit); + INT_PTR DlgResult; + static INT_PTR (WINAPI *pDialogBoxIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam); + + if (pDialogBoxIndirectParamW == NULL) { + HMODULE hDll = LoadLibrary("user32.dll"); + FARPROC *proc = (FARPROC *)&pDialogBoxIndirectParamW; + *proc = GetProcAddress(hDll, "DialogBoxIndirectParamW"); + } + + if (pDialogBoxIndirectParamW == NULL) { + DlgResult = DialogBoxIndirectParamA( + hInstance, lpTemplate, hWndParent, + lpDialogFunc, lParamInit); + } + else { + DlgResult = pDialogBoxIndirectParamW( + hInstance, lpTemplate, hWndParent, + lpDialogFunc, lParamInit); + } free(lpTemplate); return DlgResult; #endif From scmnotify @ osdn.net Tue Jan 14 01:26:25 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Tue, 14 Jan 2020 01:26:25 +0900 Subject: [Ttssh2-commit] [8473] WIP Message-ID: <1578932785.768916.146638.nullmailer@users.osdn.me> Revision: 8473 https://osdn.net/projects/ttssh2/scm/svn/commits/8473 Author: zmatsuo Date: 2020-01-14 01:26:25 +0900 (Tue, 14 Jan 2020) Log Message: ----------- WIP Modified Paths: -------------- trunk/teraterm/ttpfile/CMakeLists.txt -------------- next part -------------- Modified: trunk/teraterm/ttpfile/CMakeLists.txt =================================================================== --- trunk/teraterm/ttpfile/CMakeLists.txt 2020-01-13 16:26:16 UTC (rev 8472) +++ trunk/teraterm/ttpfile/CMakeLists.txt 2020-01-13 16:26:25 UTC (rev 8473) @@ -59,6 +59,11 @@ ) endif() +if (MSVC) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:user32.dll") + # target_link_options ... +endif() + target_link_libraries( ttpfile ttpcmn From scmnotify @ osdn.net Tue Jan 14 01:29:11 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Tue, 14 Jan 2020 01:29:11 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NzRdIOiqpOOBo+OBpuS9nOalreS4rQ==?= =?utf-8?b?44Gu5L+u5q2j44KS44Kz44Of44OD44OI44GX44Gf44Gf44KB44Oq44OQ44O8?= =?utf-8?b?44OI?= Message-ID: <1578932951.814902.7137.nullmailer@users.osdn.me> Revision: 8474 https://osdn.net/projects/ttssh2/scm/svn/commits/8474 Author: zmatsuo Date: 2020-01-14 01:29:11 +0900 (Tue, 14 Jan 2020) Log Message: ----------- 誤って作業中の修正をコミットしたためリバート Modified Paths: -------------- trunk/teraterm/ttpfile/CMakeLists.txt -------------- next part -------------- Modified: trunk/teraterm/ttpfile/CMakeLists.txt =================================================================== --- trunk/teraterm/ttpfile/CMakeLists.txt 2020-01-13 16:26:25 UTC (rev 8473) +++ trunk/teraterm/ttpfile/CMakeLists.txt 2020-01-13 16:29:11 UTC (rev 8474) @@ -59,11 +59,6 @@ ) endif() -if (MSVC) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:user32.dll") - # target_link_options ... -endif() - target_link_libraries( ttpfile ttpcmn From scmnotify @ osdn.net Thu Jan 16 23:20:22 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Thu, 16 Jan 2020 23:20:22 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NzVdIFdpbmRvd3MgOXjjga7jgajjgY0g?= =?utf-8?b?RGlhbG9nQm94SW5kaXJlY3RQYXJhbVcoKSDjgpLkvb/nlKjjgZfjgarjgYQ=?= Message-ID: <1579184422.449308.94020.nullmailer@users.osdn.me> Revision: 8475 https://osdn.net/projects/ttssh2/scm/svn/commits/8475 Author: zmatsuo Date: 2020-01-16 23:20:21 +0900 (Thu, 16 Jan 2020) Log Message: ----------- Windows 9xのとき DialogBoxIndirectParamW() を使用しない - APIは存在するが常に失敗するため - r8472 Revision Links: -------------- https://osdn.net/projects/ttssh2/scm/svn/commits/8472 Modified Paths: -------------- trunk/teraterm/common/dlglib_cpp.cpp -------------- next part -------------- Modified: trunk/teraterm/common/dlglib_cpp.cpp =================================================================== --- trunk/teraterm/common/dlglib_cpp.cpp 2020-01-13 16:29:11 UTC (rev 8474) +++ trunk/teraterm/common/dlglib_cpp.cpp 2020-01-16 14:20:21 UTC (rev 8475) @@ -228,7 +228,9 @@ INT_PTR DlgResult; static INT_PTR (WINAPI *pDialogBoxIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam); - if (pDialogBoxIndirectParamW == NULL) { + // \x92\x8D 9x\x82ł\xCD DialogBoxIndirectParamW \x82\xF0\x8Eg\x97p\x82\xB5\x82Ȃ\xA2 + // DialogBoxIndirectParamW \x82͑\xB6\x8D݂\xB5\x82Ă\xE0\x8F\xED\x82Ɏ\xB8\x94s\x82\xB7\x82\xE9 + if (IsWindowsNTKernel() && pDialogBoxIndirectParamW == NULL) { HMODULE hDll = LoadLibrary("user32.dll"); FARPROC *proc = (FARPROC *)&pDialogBoxIndirectParamW; *proc = GetProcAddress(hDll, "DialogBoxIndirectParamW"); From scmnotify @ osdn.net Thu Jan 16 23:20:32 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Thu, 16 Jan 2020 23:20:32 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NzZdIGNtYWtl44OT44Or44OJaW5zdGFs?= =?utf-8?b?bOaZguOAgWNtYWtl44GMMy4xM+acqua6gOOBruOBqOOBjeODh+ODkOOCsA==?= =?utf-8?b?55So44OV44Kh44Kk44Or44KS44Kk44Oz44K544OI44O844Or44GX44Gq44GE?= Message-ID: <1579184432.853388.94397.nullmailer@users.osdn.me> Revision: 8476 https://osdn.net/projects/ttssh2/scm/svn/commits/8476 Author: zmatsuo Date: 2020-01-16 23:20:32 +0900 (Thu, 16 Jan 2020) Log Message: ----------- cmakeビルドinstall時、cmakeが3.13未満のときデバグ用ファイルをインストールしない - ENABLE_DEBUG_INFO=1 のとき - cmakeが3.13未満のデバグ情報を出力するオプションを指定していない - target_link_options() が使用できないため - Visual Studio 2005 をサポートしているcmakeは3.11.4まで Modified Paths: -------------- trunk/teraterm/teraterm/CMakeLists.txt -------------- next part -------------- Modified: trunk/teraterm/teraterm/CMakeLists.txt =================================================================== --- trunk/teraterm/teraterm/CMakeLists.txt 2020-01-16 14:20:21 UTC (rev 8475) +++ trunk/teraterm/teraterm/CMakeLists.txt 2020-01-16 14:20:32 UTC (rev 8476) @@ -250,7 +250,7 @@ TARGETS teraterm DESTINATION . ) -if(MSVC AND ENABLE_DEBUG_INFO) +if(MSVC AND ENABLE_DEBUG_INFO AND (${CMAKE_VERSION} VERSION_GREATER "3.13")) install( FILES $ From scmnotify @ osdn.net Thu Jan 16 23:20:42 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Thu, 16 Jan 2020 23:20:42 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NzddIFZTMjAwOOeUqOODl+ODreOCuA==?= =?utf-8?b?44Kn44Kv44OI44OV44Kh44Kk44Or6L+95Yqg?= Message-ID: <1579184442.432646.97058.nullmailer@users.osdn.me> Revision: 8477 https://osdn.net/projects/ttssh2/scm/svn/commits/8477 Author: zmatsuo Date: 2020-01-16 23:20:42 +0900 (Thu, 16 Jan 2020) Log Message: ----------- VS2008用プロジェクトファイル追加 Modified Paths: -------------- trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj.filters trunk/TTXSamples/TTXSamples.sln Added Paths: ----------- trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj -------------- next part -------------- Modified: trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj.filters =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj.filters 2020-01-16 14:20:32 UTC (rev 8476) +++ trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj.filters 2020-01-16 14:20:42 UTC (rev 8477) @@ -13,6 +13,12 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + {7f6c33d3-32cc-4cec-be30-1f30eefcde37} + + + {eba3832e-0743-46e0-bc55-5de2f37143ae} + @@ -24,29 +30,26 @@ Source Files - + Source Files - Source Files + common - Source Files + common - Source Files + common - Source Files + common - - Source Files + + cJSON - - Header Files - Header Files @@ -53,15 +56,18 @@ Header Files - - Header Files - - Header Files + common - Header Files + common + + common + + + cJSON + Added: trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj (rev 0) +++ trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj 2020-01-16 14:20:42 UTC (rev 8477) @@ -0,0 +1,255 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: trunk/TTXSamples/TTXSamples.sln =================================================================== --- trunk/TTXSamples/TTXSamples.sln 2020-01-16 14:20:32 UTC (rev 8476) +++ trunk/TTXSamples/TTXSamples.sln 2020-01-16 14:20:42 UTC (rev 8477) @@ -32,6 +32,8 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTXOutputBuffering", "TTXOutputBuffering\TTXOutputBuffering.vcproj", "{80BE71D1-BEA3-4A5D-8F13-362D6364892D}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTXCheckUpdate", "TTXCheckUpdate\TTXCheckUpdate.v8.vcproj", "{937DFA65-5709-4643-B778-482C15DEC581}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -102,6 +104,10 @@ {80BE71D1-BEA3-4A5D-8F13-362D6364892D}.Debug|Win32.Build.0 = Debug|Win32 {80BE71D1-BEA3-4A5D-8F13-362D6364892D}.Release|Win32.ActiveCfg = Release|Win32 {80BE71D1-BEA3-4A5D-8F13-362D6364892D}.Release|Win32.Build.0 = Release|Win32 + {937DFA65-5709-4643-B778-482C15DEC581}.Debug|Win32.ActiveCfg = Debug|Win32 + {937DFA65-5709-4643-B778-482C15DEC581}.Debug|Win32.Build.0 = Debug|Win32 + {937DFA65-5709-4643-B778-482C15DEC581}.Release|Win32.ActiveCfg = Release|Win32 + {937DFA65-5709-4643-B778-482C15DEC581}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From scmnotify @ osdn.net Thu Jan 16 23:20:53 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Thu, 16 Jan 2020 23:20:53 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NzhdIGxvY2FsdGltZV9zKCksIHNzY2Fu?= =?utf-8?b?Zl9zKCksIHN0cmNweV9zKCksIGN0aW1lX3MoKSDjgpLkvb/nlKg=?= Message-ID: <1579184453.689320.97311.nullmailer@users.osdn.me> Revision: 8478 https://osdn.net/projects/ttssh2/scm/svn/commits/8478 Author: zmatsuo Date: 2020-01-16 23:20:53 +0900 (Thu, 16 Jan 2020) Log Message: ----------- localtime_s(), sscanf_s(), strcpy_s(), ctime_s() を使用 Modified Paths: -------------- trunk/teraterm/common/ttlib.c trunk/teraterm/teraterm/vtwin.cpp trunk/teraterm/ttpdlg/ttdlg.c trunk/teraterm/ttpfile/kermit.c trunk/teraterm/ttpfile/quickvan.c trunk/teraterm/ttpfile/ymodem.c trunk/teraterm/ttpfile/zmodem.c -------------- next part -------------- Modified: trunk/teraterm/common/ttlib.c =================================================================== --- trunk/teraterm/common/ttlib.c 2020-01-16 14:20:42 UTC (rev 8477) +++ trunk/teraterm/common/ttlib.c 2020-01-16 14:20:53 UTC (rev 8478) @@ -717,7 +717,7 @@ char buf[MAX_PATH]; char *c; time_t time_local; - struct tm *tm_local; + struct tm tm_local; // \x83t\x83@\x83C\x83\x8B\x96\xBC\x95\x94\x95\xAA\x82݂̂\xF0 flename \x82Ɋi\x94[ ExtractFileName(FName, filename ,sizeof(filename)); @@ -727,10 +727,10 @@ // \x8C\xBB\x8Dݎ\x9E\x8D\x8F\x82\xF0\x8E擾 time(&time_local); - tm_local = localtime(&time_local); + localtime_s(&tm_local, &time_local); // \x8E\x9E\x8D\x8F\x95\xB6\x8E\x9A\x97\xF1\x82ɕϊ\xB7 - if (strftime(buf, sizeof(buf), filename, tm_local) == 0) { + if (strftime(buf, sizeof(buf), filename, &tm_local) == 0) { strncpy_s(buf, sizeof(buf), filename, _TRUNCATE); } @@ -876,7 +876,7 @@ char T[15]; GetNthString(Source,Nth,sizeof(T),T); - if (sscanf(T, "%d", Num) != 1) { + if (sscanf_s(T, "%d", Num) != 1) { *Num = 0; } } @@ -887,7 +887,7 @@ int v; GetNthString(Source, Nth, sizeof(T), T); - if (sscanf(T, "%d", &v) != 1) { + if (sscanf_s(T, "%d", &v) != 1) { v = defval; } Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2020-01-16 14:20:42 UTC (rev 8477) +++ trunk/teraterm/teraterm/vtwin.cpp 2020-01-16 14:20:53 UTC (rev 8478) @@ -3920,7 +3920,7 @@ for (c = 'C' ; c <= 'Z' ; c++) { char tmp[MAX_PATH]; - sprintf(tmp, "%c:\\cygwin\\bin;%c:\\cygwin64\\bin", c, c); + sprintf_s(tmp, "%c:\\cygwin\\bin;%c:\\cygwin64\\bin", c, c); if (SearchPath(tmp, "cygwin1", ".dll", sizeof(file), file, &filename) > 0) { goto found_dll; } @@ -4389,7 +4389,7 @@ char uimsg[MAX_UIMSG]; get_lang_msg("FILEDLG_TRANS_TITLE_SENDFILE", uimsg, sizeof(uimsg), TitSendFile, data->UILanguageFile); - strcpy(title, "Tera Term: "); + strcpy_s(title, "Tera Term: "); strncat_s(title, _countof(title), uimsg, _TRUNCATE); size_t filter_len; Modified: trunk/teraterm/ttpdlg/ttdlg.c =================================================================== --- trunk/teraterm/ttpdlg/ttdlg.c 2020-01-16 14:20:42 UTC (rev 8477) +++ trunk/teraterm/ttpdlg/ttdlg.c 2020-01-16 14:20:53 UTC (rev 8478) @@ -2412,7 +2412,7 @@ char tmpbuf[128]; int msc_ver, vs_ver, msc_low_ver; - strcpy(buf, "Microsoft Visual C++"); + strcpy_s(buf, buf_size, "Microsoft Visual C++"); #ifdef _MSC_FULL_VER // _MSC_VER VS Ver. VS internal Ver. MSVC++ Ver. // 1400 2005 8.0 8.0 Modified: trunk/teraterm/ttpfile/kermit.c =================================================================== --- trunk/teraterm/ttpfile/kermit.c 2020-01-16 14:20:42 UTC (rev 8477) +++ trunk/teraterm/ttpfile/kermit.c 2020-01-16 14:20:53 UTC (rev 8478) @@ -210,7 +210,7 @@ if (fv->LogFlag) { va_start(arg, fmt); - len = _vsnprintf(tmp, sizeof(tmp), fmt, arg); + len = _vsnprintf_s(tmp, sizeof(tmp), _TRUNCATE, fmt, arg); va_end(arg); _lwrite(fv->LogFile, tmp, len); _lwrite(fv->LogFile,"\015\012",2); @@ -716,9 +716,9 @@ memset(&tm, 0, sizeof(tm)); switch (strlen(str)) { case 17: - if ( sscanf(str, "%04d%02d%02d %02d:%02d:%02d", - &tm.tm_year, &tm.tm_mon, &tm.tm_mday, - &tm.tm_hour, &tm.tm_min, &tm.tm_sec) < 6 ) { + if ( sscanf_s(str, "%04d%02d%02d %02d:%02d:%02d", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday, + &tm.tm_hour, &tm.tm_min, &tm.tm_sec) < 6 ) { kv->FileTime = time(NULL); } else { tm.tm_year -= 1900; // 1900- @@ -727,9 +727,9 @@ } break; case 14: - if ( sscanf(str, "%04d%02d%02d %02d:%02d", - &tm.tm_year, &tm.tm_mon, &tm.tm_mday, - &tm.tm_hour, &tm.tm_min) < 5 ) { + if ( sscanf_s(str, "%04d%02d%02d %02d:%02d", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday, + &tm.tm_hour, &tm.tm_min) < 5 ) { kv->FileTime = time(NULL); } else { tm.tm_year -= 1900; // 1900- @@ -739,8 +739,8 @@ } break; case 8: - if ( sscanf(str, "%04d%02d%02d", - &tm.tm_year, &tm.tm_mon, &tm.tm_mday) < 3 ) { + if ( sscanf_s(str, "%04d%02d%02d", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday) < 3 ) { kv->FileTime = time(NULL); } else { tm.tm_year -= 1900; // 1900- @@ -752,9 +752,9 @@ } break; case 15: - if ( sscanf(str, "%02d%02d%02d %02d:%02d:%02d", - &tm.tm_year, &tm.tm_mon, &tm.tm_mday, - &tm.tm_hour, &tm.tm_min, &tm.tm_sec) < 6 ) { + if ( sscanf_s(str, "%02d%02d%02d %02d:%02d:%02d", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday, + &tm.tm_hour, &tm.tm_min, &tm.tm_sec) < 6 ) { kv->FileTime = time(NULL); } else { if (tm.tm_year <= 49) { @@ -765,9 +765,9 @@ } break; case 12: - if ( sscanf(str, "%02d%02d%02d %02d:%02d", - &tm.tm_year, &tm.tm_mon, &tm.tm_mday, - &tm.tm_hour, &tm.tm_min) < 5 ) { + if ( sscanf_s(str, "%02d%02d%02d %02d:%02d", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday, + &tm.tm_hour, &tm.tm_min) < 5 ) { kv->FileTime = time(NULL); } else { if (tm.tm_year <= 49) { @@ -779,8 +779,8 @@ } break; case 6: - if ( sscanf(str, "%02d%02d%02d", - &tm.tm_year, &tm.tm_mon, &tm.tm_mday) < 3 ) { + if ( sscanf_s(str, "%02d%02d%02d", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday) < 3 ) { kv->FileTime = time(NULL); } else { if (tm.tm_year <= 49) { @@ -799,7 +799,7 @@ break; case ',': // File attribute "664" kv->FileAttrFlag |= KMT_ATTR_MODE; - sscanf(str, "%03o", &kv->FileMode); + sscanf_s(str, "%03o", &kv->FileMode); break; case '1': // File length in bytes kv->FileAttrFlag |= KMT_ATTR_SIZE; @@ -1053,9 +1053,10 @@ strncat_s(buf, sizeof(buf), s, _TRUNCATE); } if ( (kv->FileAttrFlag & KMT_ATTR_TIME) != 0 ) { - struct tm *date = localtime(&kv->FileTime); + struct tm date; int len; - len = strftime(t, sizeof(t), "%Y%m%d %H:%M:%S", date); + localtime_s(&date, &kv->FileTime); + len = strftime(t, sizeof(t), "%Y%m%d %H:%M:%S", &date); _snprintf_s(s, sizeof(s), _TRUNCATE, "#%c%s", KmtChar(len), t); strncat_s(buf, sizeof(buf), s, _TRUNCATE); } @@ -1190,7 +1191,9 @@ fv->LogFlag = ((ts->LogFlag & LOG_KMT)!=0); if (fv->LogFlag) { char buf[128]; + char ctime_str[128]; time_t tm = time(NULL); + ctime_s(ctime_str, sizeof(ctime_str), &tm); fv->LogFile = _lcreat("KERMIT.LOG",0); fv->LogCount = 0; @@ -1200,7 +1203,7 @@ kv->KmtMode == IdKmtSend ? "Send" : kv->KmtMode == IdKmtReceive ? "Receive" : kv->KmtMode == IdKmtGet ? "Get" : "Finish", - ctime(&tm) + ctime_str ); _lwrite(fv->LogFile, buf, strlen(buf)); } Modified: trunk/teraterm/ttpfile/quickvan.c =================================================================== --- trunk/teraterm/ttpfile/quickvan.c 2020-01-16 14:20:42 UTC (rev 8477) +++ trunk/teraterm/ttpfile/quickvan.c 2020-01-16 14:20:53 UTC (rev 8478) @@ -783,7 +783,8 @@ { int i, j; struct stat stbuf; - struct tm * tmbuf; + struct tm tmbuf; + char fullname_upper[MAX_PATH]; if (! GetNextFname(fv)) { @@ -820,7 +821,9 @@ QVPutNum2(qv,qv->FileNum,&i); /* file name */ SetDlgItemText(fv->HWin, IDC_PROTOFNAME, &(fv->FullName[fv->DirLen])); - strncpy_s(&(qv->PktOut[i]),sizeof(qv->PktOut)-i,_strupr(&(fv->FullName[fv->DirLen])),_TRUNCATE); + strncpy_s(fullname_upper, sizeof(fullname_upper), &(fv->FullName[fv->DirLen]), _TRUNCATE); + _strupr_s(fullname_upper, sizeof(fullname_upper)); + strncpy_s(&(qv->PktOut[i]),sizeof(qv->PktOut)-i,fullname_upper,_TRUNCATE); FTConvFName(&(qv->PktOut[i])); // replace ' ' by '_' in FName i = strlen(&(qv->PktOut[i])) + i; qv->PktOut[i] = 0; @@ -832,16 +835,16 @@ i++; /* date */ stat(fv->FullName,&stbuf); - tmbuf = localtime(&stbuf.st_mtime); + localtime_s(&tmbuf, &stbuf.st_mtime); - QVPutNum2(qv,(WORD)((tmbuf->tm_year+1900) / 100),&i); - QVPutNum2(qv,(WORD)((tmbuf->tm_year+1900) % 100),&i); - QVPutNum2(qv,(WORD)(tmbuf->tm_mon+1),&i); - QVPutNum2(qv,(WORD)tmbuf->tm_mday,&i); + QVPutNum2(qv,(WORD)((tmbuf.tm_year+1900) / 100),&i); + QVPutNum2(qv,(WORD)((tmbuf.tm_year+1900) % 100),&i); + QVPutNum2(qv,(WORD)(tmbuf.tm_mon+1),&i); + QVPutNum2(qv,(WORD)tmbuf.tm_mday,&i); /* time */ - QVPutNum2(qv,(WORD)tmbuf->tm_hour,&i); - QVPutNum2(qv,(WORD)tmbuf->tm_min,&i); - QVPutNum2(qv,(WORD)tmbuf->tm_sec,&i); + QVPutNum2(qv,(WORD)tmbuf.tm_hour,&i); + QVPutNum2(qv,(WORD)tmbuf.tm_min,&i); + QVPutNum2(qv,(WORD)tmbuf.tm_sec,&i); for (j = i ; j <= 130 ; j++) qv->PktOut[j] = 0; Modified: trunk/teraterm/ttpfile/ymodem.c =================================================================== --- trunk/teraterm/ttpfile/ymodem.c 2020-01-16 14:20:42 UTC (rev 8477) +++ trunk/teraterm/ttpfile/ymodem.c 2020-01-16 14:20:53 UTC (rev 8478) @@ -336,11 +336,13 @@ if (fv->LogFlag) { char buf[128]; + char ctime_str[128]; time_t tm = time(NULL); + ctime_s(ctime_str, sizeof(ctime_str), &tm); _snprintf_s(buf, sizeof(buf), _TRUNCATE, "YMODEM %s start: %s\n", yv->YMode == IdYSend ? "Send" : "Recv", - ctime(&tm)); + ctime_str); _lwrite(fv->LogFile, buf, strlen(buf)); } @@ -583,7 +585,7 @@ } nameend = name + 1 + strlen(name); if (*nameend) { - ret = sscanf(nameend, "%ld%lo%o", &bytes_total, &modtime, &mode); + ret = sscanf_s(nameend, "%ld%lo%o", &bytes_total, &modtime, &mode); if (ret >= 1) { fv->FileSize = bytes_total; yv->RecvFilesize = TRUE; Modified: trunk/teraterm/ttpfile/zmodem.c =================================================================== --- trunk/teraterm/ttpfile/zmodem.c 2020-01-16 14:20:42 UTC (rev 8477) +++ trunk/teraterm/ttpfile/zmodem.c 2020-01-16 14:20:53 UTC (rev 8478) @@ -1040,7 +1040,7 @@ /* file mtime */ p = zv->PktIn + i; if (*p) { - ret = sscanf(p, "%lo%o", &modtime, &mode); + ret = sscanf_s(p, "%lo%o", &modtime, &mode); if (ret >= 1) { fv->FileMtime = modtime; } From scmnotify @ osdn.net Thu Jan 16 23:21:06 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Thu, 16 Jan 2020 23:21:06 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0NzldIOe1guS6huaZguOBruODgOOCpA==?= =?utf-8?b?44Ki44Ot44Kw44KS5aSa6KiA6Kqe5YyW?= Message-ID: <1579184466.336974.97550.nullmailer@users.osdn.me> Revision: 8479 https://osdn.net/projects/ttssh2/scm/svn/commits/8479 Author: zmatsuo Date: 2020-01-16 23:21:06 +0900 (Thu, 16 Jan 2020) Log Message: ----------- 終了時のダイアログを多言語化 - _MessageBoxW() 追加 - pDialogBoxIndirectParamW() 追加 - pHtmlHelpA(), pHtmlHelpW() 追加 Modified Paths: -------------- trunk/teraterm/common/compat_win.cpp trunk/teraterm/common/compat_win.h trunk/teraterm/common/layer_for_unicode.cpp trunk/teraterm/common/layer_for_unicode.h trunk/teraterm/teraterm/vtwin.cpp trunk/teraterm/teraterm/vtwin.h -------------- next part -------------- Modified: trunk/teraterm/common/compat_win.cpp =================================================================== --- trunk/teraterm/common/compat_win.cpp 2020-01-16 14:20:53 UTC (rev 8478) +++ trunk/teraterm/common/compat_win.cpp 2020-01-16 14:21:06 UTC (rev 8479) @@ -1,5 +1,5 @@ /* - * (C) 20018-2019 TeraTerm Project + * (C) 2018-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -65,7 +65,12 @@ BOOL (WINAPI *pAdjustWindowRectEx)(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle); BOOL (WINAPI *pAdjustWindowRectExForDpi)(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi); HWND (WINAPI *pGetConsoleWindow)(void); +int (WINAPI *pMessageBoxW)(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType); +INT_PTR (WINAPI *pDialogBoxIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam); +HWND (WINAPI *pHtmlHelpW)(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData); +HWND (WINAPI *pHtmlHelpA)(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData); + /** * GetConsoleWindow() \x82Ɠ\xAF\x82\xB6\x93\xAE\x8D\xEC\x82\xF0\x82\xB7\x82\xE9 * https://support.microsoft.com/ja-jp/help/124103/how-to-obtain-a-console-window-handle-hwnd @@ -119,6 +124,8 @@ { "ModifyMenuW", (void **)&pModifyMenuW }, { "GetMenuStringW", (void **)&pGetMenuStringW }, { "SendDlgItemMessageW", (void **)&pSendDlgItemMessageW }, + { "MessageBoxW", (void **)&pMessageBoxW }, + { "DialogBoxIndirectParamW", (void **)&pDialogBoxIndirectParamW }, {}, }; @@ -158,6 +165,12 @@ {}, }; +static const APIInfo Lists_hhctrl[] = { + { "HtmlHelpW", (void **)&pHtmlHelpW }, + { "HtmlHelpA", (void **)&pHtmlHelpA }, + {}, +}; + static const DllInfo DllInfos[] = { { _T("user32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_user32 }, { _T("msimg32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_msimg32 }, @@ -166,6 +179,7 @@ { _T("kernel32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_kernel32 }, { _T("shell32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_shell32 }, { _T("Comctl32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_comctl32 }, + { _T("hhctrl.ocx"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_hhctrl }, {}, }; Modified: trunk/teraterm/common/compat_win.h =================================================================== --- trunk/teraterm/common/compat_win.h 2020-01-16 14:20:53 UTC (rev 8478) +++ trunk/teraterm/common/compat_win.h 2020-01-16 14:21:06 UTC (rev 8479) @@ -1,5 +1,5 @@ /* - * (C) 2018-2019 TeraTerm Project + * (C) 2018-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -98,6 +98,10 @@ extern BOOL (WINAPI *pRemoveFontResourceExA)(LPCSTR name, DWORD fl, PVOID pdv); extern BOOL (WINAPI *pRemoveFontResourceExW)(LPCWSTR name, DWORD fl, PVOID pdv); extern HWND (WINAPI *pGetConsoleWindow)(void); +extern int (WINAPI *pMessageBoxW)(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType); +extern INT_PTR (WINAPI *pDialogBoxIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam); +extern HWND (WINAPI *pHtmlHelpW)(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData); +extern HWND (WINAPI *pHtmlHelpA)(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData); #ifdef UNICODE #define pAddFontResourceEx pAddFontResourceExW Modified: trunk/teraterm/common/layer_for_unicode.cpp =================================================================== --- trunk/teraterm/common/layer_for_unicode.cpp 2020-01-16 14:20:53 UTC (rev 8478) +++ trunk/teraterm/common/layer_for_unicode.cpp 2020-01-16 14:21:06 UTC (rev 8479) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 TeraTerm Project + * Copyright (C) 2019-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -302,3 +302,17 @@ free(strA); return result; } + +int _MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType) +{ + if (pMessageBoxW != NULL) { + return pMessageBoxW(hWnd, lpText, lpCaption, uType); + } + + char *textA = ToCharW(lpText); + char *captionA = ToCharW(lpCaption); + int result = MessageBoxA(hWnd, textA, captionA, uType); + free(textA); + free(captionA); + return result; +} Modified: trunk/teraterm/common/layer_for_unicode.h =================================================================== --- trunk/teraterm/common/layer_for_unicode.h 2020-01-16 14:20:53 UTC (rev 8478) +++ trunk/teraterm/common/layer_for_unicode.h 2020-01-16 14:21:06 UTC (rev 8479) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 TeraTerm Project + * Copyright (C) 2019-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,6 +54,7 @@ LPVOID lpParam); ATOM _RegisterClassW(const WNDCLASSW *lpWndClass); int _DrawTextW(HDC hdc, LPCWSTR lpchText, int cchText, LPRECT lprc, UINT format); +int _MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType); #ifdef __cplusplus } Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2020-01-16 14:20:53 UTC (rev 8478) +++ trunk/teraterm/teraterm/vtwin.cpp 2020-01-16 14:21:06 UTC (rev 8479) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2004-2019 TeraTerm Project + * (C) 2004-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1693,14 +1693,18 @@ MessageBeep(0); return; } - get_lang_msg("MSG_DISCONNECT_CONF", ts.UIMsg, sizeof(ts.UIMsg), - "Disconnect?", ts.UILanguageFile); + if (cv.Ready && (cv.PortType==IdTCPIP) && ((ts.PortFlag & PF_CONFIRMDISCONN) != 0) && - ! CloseTT && - (::MessageBox(HVTWin, ts.UIMsg, "Tera Term", - MB_OKCANCEL | MB_ICONEXCLAMATION | MB_DEFBUTTON2)==IDCANCEL)) { - return; + ! CloseTT) { + wchar_t uimsg[MAX_UIMSG]; + get_lang_msgW("MSG_DISCONNECT_CONF", uimsg, _countof(uimsg), + L"Disconnect?", ts.UILanguageFile); + int result = _MessageBoxW(HVTWin, uimsg, L"Tera Term", + MB_OKCANCEL | MB_ICONEXCLAMATION | MB_DEFBUTTON2); + if (result == IDCANCEL) { + return; + } } FileTransEnd(0); Modified: trunk/teraterm/teraterm/vtwin.h =================================================================== --- trunk/teraterm/teraterm/vtwin.h 2020-01-16 14:20:53 UTC (rev 8478) +++ trunk/teraterm/teraterm/vtwin.h 2020-01-16 14:21:06 UTC (rev 8479) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2004-2019 TeraTerm Project + * (C) 2004-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without From scmnotify @ osdn.net Fri Jan 17 00:18:55 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 17 Jan 2020 00:18:55 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0ODBdIOerr+acq+OCteOCpOOCuuOBrg==?= =?utf-8?b?5qiq5bmF44KSNTAw44Gr44GZ44KL44Go6JC944Gh44KL44Gu44KS5L+u5q2j?= Message-ID: <1579187935.031599.107008.nullmailer@users.osdn.me> Revision: 8480 https://osdn.net/projects/ttssh2/scm/svn/commits/8480 Author: doda Date: 2020-01-17 00:18:54 +0900 (Fri, 17 Jan 2020) Log Message: ----------- 端末サイズの横幅を500にすると落ちるのを修正 Modified Paths: -------------- trunk/teraterm/teraterm/buffer.c -------------- next part -------------- Modified: trunk/teraterm/teraterm/buffer.c =================================================================== --- trunk/teraterm/teraterm/buffer.c 2020-01-16 14:21:06 UTC (rev 8479) +++ trunk/teraterm/teraterm/buffer.c 2020-01-16 15:18:54 UTC (rev 8480) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2004-2019 TeraTerm Project + * (C) 2004-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -3662,9 +3662,9 @@ int Y = DrawY; const LONG TmpPtr = GetLinePtr(SY); int istart = IStart; - char bufA[TermWidthMax]; - wchar_t bufW[TermWidthMax]; - char bufWW[TermWidthMax]; + char bufA[TermWidthMax+1]; + wchar_t bufW[TermWidthMax+1]; + char bufWW[TermWidthMax+1]; int lenW = 0; int lenA = 0; TCharAttr CurAttr; From scmnotify @ osdn.net Fri Jan 17 16:02:51 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 17 Jan 2020 16:02:51 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0ODFdICQoU29sdXRpb25EaXIpIOOBqw==?= =?utf-8?b?56m655m944GM5ZCr44G+44KM44Gm44GE44KL44Go44OT44Or44OJ5Ye65p2l?= =?utf-8?b?44Gq44GE44Gu44KS5L+u5q2j?= Message-ID: <1579244571.687365.1569.nullmailer@users.osdn.me> Revision: 8481 https://osdn.net/projects/ttssh2/scm/svn/commits/8481 Author: doda Date: 2020-01-17 16:02:51 +0900 (Fri, 17 Jan 2020) Log Message: ----------- $(SolutionDir) に空白が含まれているとビルド出来ないのを修正 Modified Paths: -------------- trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj -------------- next part -------------- Modified: trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj 2020-01-16 15:18:54 UTC (rev 8480) +++ trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj 2020-01-17 07:02:51 UTC (rev 8481) @@ -61,7 +61,7 @@ /> Revision: 8482 https://osdn.net/projects/ttssh2/scm/svn/commits/8482 Author: doda Date: 2020-01-18 03:15:05 +0900 (Sat, 18 Jan 2020) Log Message: ----------- コードの細かい修正。外から見える動作の変更等は無し。 ・インデントを調整 ・行末の空白を削除 ・コメントの追加&整理 ・不要な PASCAL 呼出規約指定を削除 ・内部状態リセットの為の端末設定ダイアログ呼び出しを関数にまとめた Modified Paths: -------------- trunk/TTXKanjiMenu/ttxkanjimenu.c -------------- next part -------------- Modified: trunk/TTXKanjiMenu/ttxkanjimenu.c =================================================================== --- trunk/TTXKanjiMenu/ttxkanjimenu.c 2020-01-17 07:02:51 UTC (rev 8481) +++ trunk/TTXKanjiMenu/ttxkanjimenu.c 2020-01-17 18:15:05 UTC (rev 8482) @@ -1,7 +1,7 @@ /* * TTX KanjiMenu Plugin * Copyright (C) 2007 Sunao HARA (naoh @ nagoya-u.jp) - * (C) 2007-2009 TeraTerm Project + * (C) 2007-2020 TeraTerm Project */ //// ORIGINAL SOURCE CODE: ttxtest.c @@ -8,7 +8,7 @@ /* Tera Term extension mechanism Robert O'Callahan (roc+tt @ cs.cmu.edu) - + Tera Term by Takashi Teranishi (teranishi @ rikaxp.riken.go.jp) */ @@ -70,6 +70,11 @@ pvar->NeedResetCharSet = FALSE; } +/* + * \x92[\x96\x96\x90ݒ\xE8\x83_\x83C\x83A\x83\x8D\x83O\x82̃t\x83b\x83N\x8A֐\x941: UseOneSetting \x97p + * + * \x91\x97\x90M\x82Ǝ\xF3\x90M\x82̊\xBF\x8E\x9A\x83R\x81[\x83h\x90ݒ肪\x93\xAF\x82\xB6\x82ɂȂ\xE9\x82悤\x82ɒ\xB2\x90\xAE\x82\xB7\x82\xE9\x81B + */ static BOOL PASCAL TTXKanjiMenuSetupTerminal(HWND parent, PTTSet ts) { WORD orgRecvCode, orgSendCode; BOOL ret; @@ -101,6 +106,12 @@ return ret; } +/* + * \x92[\x96\x96\x90ݒ\xE8\x83_\x83C\x83A\x83\x8D\x83O\x82̃t\x83b\x83N\x8A֐\x942: \x93\xE0\x95\x94\x8F\xF3\x91ԃ\x8A\x83Z\x83b\x83g\x97p + * + * \x92[\x96\x96\x90ݒ\xE8\x83_\x83C\x83A\x83\x8D\x83O\x82\xF0\x83t\x83b\x83N\x82\xB5\x81A\x90ݒ\xE8\x83_\x83C\x83A\x83\x8D\x83O\x82\xF0\x8AJ\x82\xA9\x82\xB8\x82\xC9 TRUE \x82\xF0\x95Ԃ\xB7\x8E\x96\x82ɂ\xE6\x82\xC1\x82\xC4 + * \x90ݒ\xE8\x83_\x83C\x83A\x83\x8D\x83O\x8Cďo\x82̌㏈\x97\x9D\x82݂̂𗘗p\x82\xB7\x82\xE9\x81B + */ static BOOL PASCAL ResetCharSet(HWND parent, PTTSet ts) { pvar->NeedResetCharSet = FALSE; return TRUE; @@ -108,14 +119,25 @@ static void PASCAL TTXGetUIHooks(TTXUIHooks *hooks) { if (pvar->NeedResetCharSet) { + // \x93\xE0\x95\x94\x8F\xF3\x91ԃ\x8A\x83Z\x83b\x83g\x82ׂ̈ɌĂяo\x82\xB3\x82ꂽ\x8Fꍇ *hooks->SetupTerminal = ResetCharSet; } else if (pvar->UseOneSetting && (pvar->ts->Language == IdJapanese || pvar->ts->Language == IdKorean)) { + // UseOneSetting \x82\xAA TRUE \x82̎\x9E\x82͒[\x96\x96\x90ݒ\xE8\x83_\x83C\x83A\x83\x8D\x83O\x82̌㏈\x97\x9D\x82ׂ̈Ƀt\x83b\x83N\x82\xB7\x82\xE9 pvar->origSetupTermDlg = *hooks->SetupTerminal; *hooks->SetupTerminal = TTXKanjiMenuSetupTerminal; } } +/* + * \x8A\xBF\x8E\x9A\x83R\x81[\x83h\x8A֘A\x82̓\xE0\x95\x94\x8F\xF3\x91Ԃ̃\x8A\x83Z\x83b\x83g + * TTX\x82\xA9\x82\xE7\x82\xCDTera Term\x82̓\xE0\x95\x94\x8F\xF3\x91Ԃ𒼐ڂ\xA2\x82\xB6\x82\xEA\x82Ȃ\xA2\x88ׁA\x92[\x96\x96\x90ݒ\xE8\x83_\x83C\x83A\x83\x8D\x83O\x82̌㏈\x97\x9D\x82𗘗p\x82\xB7\x82\xE9\x81B + */ +static void CallResetCharSet(HWND hWin){ + pvar->NeedResetCharSet = TRUE; + SendMessage(hWin, WM_COMMAND, MAKELONG(ID_SETUP_TERMINAL, 0), 0); +} + static void PASCAL TTXKanjiMenuReadIniFile(PCHAR fn, PTTSet ts) { char buff[20]; @@ -159,12 +181,11 @@ *hooks->WriteIniFile = TTXKanjiMenuWriteIniFile; } -// #define ID_MI_KANJIMASK 0xFF00 #define ID_MI_KANJIRECV 54009 #define ID_MI_KANJISEND 54109 #define ID_MI_USEONESETTING 54200 -static void PASCAL InsertSendKcodeMenu(HMENU menu) { +static void InsertSendKcodeMenu(HMENU menu) { UINT flag = MF_BYPOSITION | MF_STRING | MF_CHECKED; if (pvar->ts->Language == IdJapanese) { @@ -171,16 +192,16 @@ InsertMenu(menu, 5, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); GetI18nStr(IniSection, "MENU_SEND_SJIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: S&hift_JIS", pvar->ts->UILanguageFile); + "Send: S&hift_JIS", pvar->ts->UILanguageFile); InsertMenu(menu, 6, flag, ID_MI_KANJISEND+IdSJIS, pvar->ts->UIMsg); GetI18nStr(IniSection, "MENU_SEND_EUCJP", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: EU&C-JP", pvar->ts->UILanguageFile); + "Send: EU&C-JP", pvar->ts->UILanguageFile); InsertMenu(menu, 7, flag, ID_MI_KANJISEND+IdEUC, pvar->ts->UIMsg); GetI18nStr(IniSection, "MENU_SEND_JIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: J&IS", pvar->ts->UILanguageFile); + "Send: J&IS", pvar->ts->UILanguageFile); InsertMenu(menu, 8, flag, ID_MI_KANJISEND+IdJIS, pvar->ts->UIMsg); GetI18nStr(IniSection, "MENU_SEND_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: U&TF-8", pvar->ts->UILanguageFile); + "Send: U&TF-8", pvar->ts->UILanguageFile); InsertMenu(menu, 9, flag, ID_MI_KANJISEND+IdUTF8, pvar->ts->UIMsg); } else { // IdKorean @@ -187,16 +208,16 @@ InsertMenu(menu, 2, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); GetI18nStr(IniSection, "MENU_SEND_KS5601", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: K&S5601", pvar->ts->UILanguageFile); + "Send: K&S5601", pvar->ts->UILanguageFile); InsertMenu(menu, 3, flag, ID_MI_KANJISEND+IdSJIS, pvar->ts->UIMsg); GetI18nStr(IniSection, "MENU_SEND_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: U&TF-8", pvar->ts->UILanguageFile); + "Send: U&TF-8", pvar->ts->UILanguageFile); InsertMenu(menu, 4, flag, ID_MI_KANJISEND+IdUTF8, pvar->ts->UIMsg); } } -static void PASCAL DeleteSendKcodeMenu(HMENU menu) { +static void DeleteSendKcodeMenu(HMENU menu) { if (pvar->ts->Language == IdJapanese) { DeleteMenu(menu, 5, MF_BYPOSITION); DeleteMenu(menu, 5, MF_BYPOSITION); @@ -211,7 +232,7 @@ } } -static void PASCAL UpdateRecvMenuCaption(HMENU menu, BOOL UseOneSetting) { +static void UpdateRecvMenuCaption(HMENU menu, BOOL UseOneSetting) { if (UseOneSetting) { if (pvar->ts->Language == IdJapanese) { GetI18nStr(IniSection, "MENU_SJIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), @@ -288,7 +309,7 @@ static void PASCAL TTXModifyMenu(HMENU menu) { UINT flag = MF_ENABLED; - // \x8C\xBE\x8Cꂪ\x93\xFA\x96{\x8C\xEA\x82̂Ƃ\xAB\x82̂݃\x81\x83j\x83\x85\x81[\x82ɒlj\xC1\x82\xB3\x82\xEA\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B (2007.7.14 maya) + // \x8C\xBE\x8Cꂪ\x93\xFA\x96{\x8C\xEA\x82܂\xBD\x82͊؍\x91\x8C\xEA\x82̎\x9E\x82̂݃\x81\x83j\x83\x85\x81[\x82ɒlj\xC1\x82\xB7\x82\xE9 if (pvar->ts->Language != IdJapanese && pvar->ts->Language != IdKorean) { return; } @@ -324,27 +345,27 @@ flag = MF_STRING|MF_CHECKED; if (pvar->ts->Language == IdJapanese) { GetI18nStr(IniSection, "MENU_RECV_SJIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &Shift_JIS", pvar->ts->UILanguageFile); + "Recv: &Shift_JIS", pvar->ts->UILanguageFile); AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdSJIS, pvar->ts->UIMsg); GetI18nStr(IniSection, "MENU_RECV_EUCJP", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &EUC-JP", pvar->ts->UILanguageFile); + "Recv: &EUC-JP", pvar->ts->UILanguageFile); AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdEUC, pvar->ts->UIMsg); GetI18nStr(IniSection, "MENU_RECV_JIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &JIS", pvar->ts->UILanguageFile); + "Recv: &JIS", pvar->ts->UILanguageFile); AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdJIS, pvar->ts->UIMsg); GetI18nStr(IniSection, "MENU_RECV_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &UTF-8", pvar->ts->UILanguageFile); + "Recv: &UTF-8", pvar->ts->UILanguageFile); AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdUTF8, pvar->ts->UIMsg); GetI18nStr(IniSection, "MENU_RECV_UTF8m", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: UTF-8&m", pvar->ts->UILanguageFile); + "Recv: UTF-8&m", pvar->ts->UILanguageFile); AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdUTF8m, pvar->ts->UIMsg); } else { // IdKorean GetI18nStr(IniSection, "MENU_RECV_KS5601", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &KS5601", pvar->ts->UILanguageFile); + "Recv: &KS5601", pvar->ts->UILanguageFile); AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdSJIS, pvar->ts->UIMsg); GetI18nStr(IniSection, "MENU_RECV_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &UTF-8", pvar->ts->UILanguageFile); + "Recv: &UTF-8", pvar->ts->UILanguageFile); AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdUTF8, pvar->ts->UIMsg); } @@ -390,9 +411,6 @@ WORD val; if ((cmd > ID_MI_KANJIRECV) && (cmd <= ID_MI_KANJIRECV+IdUTF8m)) { - // \x94͈̓`\x83F\x83b\x83N\x82\xF0\x92lj\xC1 - // TTProxy\x82̃o\x81[\x83W\x83\x87\x83\x93\x83_\x83C\x83A\x83\x8D\x83O\x82\xF0\x8AJ\x82\xAD\x82ƁA\x93\x96\x8AY\x83n\x83\x93\x83h\x83\x89\x82\xAA\x8CĂ΂\xEA\x81A\x8C듮\x8D삵\x82Ă\xA2\x82\xBD\x82̂\xF0\x8FC\x90\xB3\x81B - // (2007.7.13 yutaka) val = cmd - ID_MI_KANJIRECV; pvar->cv->KanjiCodeEcho = pvar->ts->KanjiCode = val; if (pvar->UseOneSetting) { @@ -401,8 +419,7 @@ } pvar->cv->KanjiCodeSend = pvar->ts->KanjiCodeSend = val; } - pvar->NeedResetCharSet = TRUE; - SendMessage(hWin, WM_COMMAND, MAKELONG(ID_SETUP_TERMINAL, 0), 0); + CallResetCharSet(hWin); return UpdateRecvMenu(pvar->ts->KanjiCode)?1:0; } else if ((cmd > ID_MI_KANJISEND) && (cmd <= ID_MI_KANJISEND+IdUTF8)) { @@ -410,13 +427,11 @@ pvar->cv->KanjiCodeSend = pvar->ts->KanjiCodeSend = val; if (pvar->UseOneSetting) { pvar->cv->KanjiCodeEcho = pvar->ts->KanjiCode = val; - pvar->NeedResetCharSet = TRUE; - SendMessage(hWin, WM_COMMAND, MAKELONG(ID_SETUP_TERMINAL, 0), 0); + CallResetCharSet(hWin); return UpdateRecvMenu(pvar->ts->KanjiCode)?1:0; } else { - pvar->NeedResetCharSet = TRUE; - SendMessage(hWin, WM_COMMAND, MAKELONG(ID_SETUP_TERMINAL, 0), 0); + CallResetCharSet(hWin); return UpdateSendMenu(pvar->ts->KanjiCodeSend)?1:0; } } @@ -490,7 +505,7 @@ return TRUE; } -BOOL WINAPI DllMain(HANDLE hInstance, +BOOL WINAPI DllMain(HANDLE hInstance, ULONG ul_reason_for_call, LPVOID lpReserved) { @@ -513,3 +528,5 @@ } return TRUE; } + +/* vim: set ts=4 sw=4 ff=dos : */ From scmnotify @ osdn.net Sat Jan 18 03:15:13 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Sat, 18 Jan 2020 03:15:13 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0ODNdIOOCpOODs+ODh+ODs+ODiOWkiQ==?= =?utf-8?b?5pu0?= Message-ID: <1579284913.071200.99391.nullmailer@users.osdn.me> Revision: 8483 https://osdn.net/projects/ttssh2/scm/svn/commits/8483 Author: doda Date: 2020-01-18 03:15:12 +0900 (Sat, 18 Jan 2020) Log Message: ----------- インデント変更 Modified Paths: -------------- trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c -------------- next part -------------- Modified: trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c =================================================================== --- trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c 2020-01-17 18:15:05 UTC (rev 8482) +++ trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c 2020-01-17 18:15:12 UTC (rev 8483) @@ -23,145 +23,145 @@ static HANDLE hInst; /* Instance handle of TTX*.DLL */ typedef struct { - PTTSet ts; - HMENU ControlMenu; - BOOL ontop; + PTTSet ts; + HMENU ControlMenu; + BOOL ontop; } TInstVar; static TInstVar *pvar; static TInstVar InstVar; -#define GetFileMenu(menu) GetSubMenuByChildID(menu, ID_FILE_NEWCONNECTION) -#define GetEditMenu(menu) GetSubMenuByChildID(menu, ID_EDIT_COPY2) -#define GetSetupMenu(menu) GetSubMenuByChildID(menu, ID_SETUP_TERMINAL) -#define GetControlMenu(menu) GetSubMenuByChildID(menu, ID_CONTROL_RESETTERMINAL) -#define GetHelpMenu(menu) GetSubMenuByChildID(menu, ID_HELP_ABOUT) +#define GetFileMenu(menu) GetSubMenuByChildID(menu, ID_FILE_NEWCONNECTION) +#define GetEditMenu(menu) GetSubMenuByChildID(menu, ID_EDIT_COPY2) +#define GetSetupMenu(menu) GetSubMenuByChildID(menu, ID_SETUP_TERMINAL) +#define GetControlMenu(menu) GetSubMenuByChildID(menu, ID_CONTROL_RESETTERMINAL) +#define GetHelpMenu(menu) GetSubMenuByChildID(menu, ID_HELP_ABOUT) HMENU GetSubMenuByChildID(HMENU menu, UINT id) { - int i, j, items, subitems, cur_id; - HMENU m; + int i, j, items, subitems, cur_id; + HMENU m; - items = GetMenuItemCount(menu); + items = GetMenuItemCount(menu); - for (i=0; its = ts; - pvar->ontop = FALSE; + pvar->ts = ts; + pvar->ontop = FALSE; } static void PASCAL TTXModifyMenu(HMENU menu) { - UINT flag = MF_BYCOMMAND | MF_STRING | MF_ENABLED; + UINT flag = MF_BYCOMMAND | MF_STRING | MF_ENABLED; - pvar->ControlMenu = GetControlMenu(menu); - if (pvar->ontop) { - flag |= MF_CHECKED; - } + pvar->ControlMenu = GetControlMenu(menu); + if (pvar->ontop) { + flag |= MF_CHECKED; + } - GetI18nStr(IniSection, "MENU_ALWAYSONTOP", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "&Always on top", pvar->ts->UILanguageFile); - InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, - flag, ID_MENU_BASE, pvar->ts->UIMsg); - InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, - MF_BYCOMMAND | MF_SEPARATOR, 0, NULL); + GetI18nStr(IniSection, "MENU_ALWAYSONTOP", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), + "&Always on top", pvar->ts->UILanguageFile); + InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, flag, ID_MENU_BASE, pvar->ts->UIMsg); + InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, MF_BYCOMMAND | MF_SEPARATOR, 0, NULL); } static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd) { - switch (cmd) { - case ID_MENU_BASE: - if (pvar->ontop) { - pvar->ontop = FALSE; - CheckMenuItem(pvar->ControlMenu, ID_MENU_BASE, MF_BYCOMMAND | MF_UNCHECKED); - SetWindowPos(hWin, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - } - else { - pvar->ontop = TRUE; - CheckMenuItem(pvar->ControlMenu, ID_MENU_BASE, MF_BYCOMMAND | MF_CHECKED); - SetWindowPos(hWin, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - } - break; - case ID_MENU_TOP: - SetWindowPos(hWin, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - break; - case ID_MENU_BOTTOM: - SetWindowPos(hWin, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - break; - case ID_MENU_TOPMOST: - pvar->ontop = TRUE; - CheckMenuItem(pvar->ControlMenu, ID_MENU_BASE, MF_BYCOMMAND | MF_CHECKED); - SetWindowPos(hWin, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - break; - case ID_MENU_NOTOPMOST: - pvar->ontop = FALSE; - CheckMenuItem(pvar->ControlMenu, ID_MENU_BASE, MF_BYCOMMAND | MF_UNCHECKED); - SetWindowPos(hWin, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - break; - default: - return 0; - } - return 1; + switch (cmd) { + case ID_MENU_BASE: + if (pvar->ontop) { + pvar->ontop = FALSE; + CheckMenuItem(pvar->ControlMenu, ID_MENU_BASE, MF_BYCOMMAND | MF_UNCHECKED); + SetWindowPos(hWin, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + } + else { + pvar->ontop = TRUE; + CheckMenuItem(pvar->ControlMenu, ID_MENU_BASE, MF_BYCOMMAND | MF_CHECKED); + SetWindowPos(hWin, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + } + break; + case ID_MENU_TOP: + SetWindowPos(hWin, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + break; + case ID_MENU_BOTTOM: + SetWindowPos(hWin, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + break; + case ID_MENU_TOPMOST: + pvar->ontop = TRUE; + CheckMenuItem(pvar->ControlMenu, ID_MENU_BASE, MF_BYCOMMAND | MF_CHECKED); + SetWindowPos(hWin, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + break; + case ID_MENU_NOTOPMOST: + pvar->ontop = FALSE; + CheckMenuItem(pvar->ControlMenu, ID_MENU_BASE, MF_BYCOMMAND | MF_UNCHECKED); + SetWindowPos(hWin, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + break; + default: + return 0; + } + return 1; } static TTXExports Exports = { - sizeof(TTXExports), - ORDER, + sizeof(TTXExports), + ORDER, - TTXInit, - NULL, // TTXGetUIHooks, - NULL, // TTXGetSetupHooks, - NULL, // TTXOpenTCP, - NULL, // TTXCloseTCP, - NULL, // TTXSetWinSize, - TTXModifyMenu, - NULL, // TTXModifyPopupMenu, - TTXProcessCommand, - NULL, // TTXEnd + TTXInit, + NULL, // TTXGetUIHooks, + NULL, // TTXGetSetupHooks, + NULL, // TTXOpenTCP, + NULL, // TTXCloseTCP, + NULL, // TTXSetWinSize, + TTXModifyMenu, + NULL, // TTXModifyPopupMenu, + TTXProcessCommand, + NULL, // TTXEnd }; BOOL __declspec(dllexport) PASCAL TTXBind(WORD Version, TTXExports *exports) { - int size = sizeof(Exports) - sizeof(exports->size); + int size = sizeof(Exports) - sizeof(exports->size); - if (size > exports->size) { - size = exports->size; - } - memcpy((char *)exports + sizeof(exports->size), - (char *)&Exports + sizeof(exports->size), - size); - return TRUE; + if (size > exports->size) { + size = exports->size; + } + memcpy((char *)exports + sizeof(exports->size), + (char *)&Exports + sizeof(exports->size), + size); + return TRUE; } BOOL WINAPI DllMain(HANDLE hInstance, - ULONG ul_reason_for_call, - LPVOID lpReserved) + ULONG ul_reason_for_call, + LPVOID lpReserved) { - switch( ul_reason_for_call ) { - case DLL_THREAD_ATTACH: - /* do thread initialization */ - break; - case DLL_THREAD_DETACH: - /* do thread cleanup */ - break; - case DLL_PROCESS_ATTACH: - /* do process initialization */ - DoCover_IsDebuggerPresent(); - hInst = hInstance; - pvar = &InstVar; - break; - case DLL_PROCESS_DETACH: - /* do process cleanup */ - break; - } - return TRUE; + switch( ul_reason_for_call ) { + case DLL_THREAD_ATTACH: + /* do thread initialization */ + break; + case DLL_THREAD_DETACH: + /* do thread cleanup */ + break; + case DLL_PROCESS_ATTACH: + /* do process initialization */ + DoCover_IsDebuggerPresent(); + hInst = hInstance; + pvar = &InstVar; + break; + case DLL_PROCESS_DETACH: + /* do process cleanup */ + break; + } + return TRUE; } + +/* vim: set ts=4 sw=4 ff=dos : */ From scmnotify @ osdn.net Sat Jan 18 03:15:19 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Sat, 18 Jan 2020 03:15:19 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0ODRdIOODoeODi+ODpeODvOmgheebrg==?= =?utf-8?b?5ZCN44Gu5LuW6KiA6Kqe5YyW5a++5b+c?= Message-ID: <1579284919.775492.99559.nullmailer@users.osdn.me> Revision: 8484 https://osdn.net/projects/ttssh2/scm/svn/commits/8484 Author: doda Date: 2020-01-18 03:15:18 +0900 (Sat, 18 Jan 2020) Log Message: ----------- メニュー項目名の他言語化対応 以下の TTX で、UI言語ファイルとシステムのロケールが異なる時でも 文字化けせずに表示出来るようにした。 ・TTXAlwaysOnTop ・TTXKanjiMenu Modified Paths: -------------- trunk/TTXKanjiMenu/ttxkanjimenu.c trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c -------------- next part -------------- Modified: trunk/TTXKanjiMenu/ttxkanjimenu.c =================================================================== --- trunk/TTXKanjiMenu/ttxkanjimenu.c 2020-01-17 18:15:12 UTC (rev 8483) +++ trunk/TTXKanjiMenu/ttxkanjimenu.c 2020-01-17 18:15:18 UTC (rev 8484) @@ -27,6 +27,10 @@ #define IniSection "TTXKanjiMenu" #define ORDER 5000 +#define ID_MI_KANJIRECV 54009 +#define ID_MI_KANJISEND 54109 +#define ID_MI_USEONESETTING 54200 + #define UpdateRecvMenu(val) \ CheckMenuRadioItem(pvar->hmEncode, \ ID_MI_KANJIRECV + IdSJIS, \ @@ -40,6 +44,120 @@ ID_MI_KANJISEND + (val), \ MF_BYCOMMAND) +// \x83\x81\x83j\x83\x85\x81[\x8D\x80\x96ږ\xBC\x82̏\xEE\x95\xF1 +typedef struct { + int menuID; + const char *menuStr; +} KmTextInfo; + +// \x8E\xF3\x90M\x8A\xBF\x8E\x9A\x83R\x81[\x83h (\x93\xFA\x96{\x8C\xEA) +static const KmTextInfo MenuNameRecvJ[] = { + { ID_MI_KANJIRECV + IdSJIS, "Recv: &Shift_JIS" }, + { ID_MI_KANJIRECV + IdEUC, "Recv: &EUC-JP" }, + { ID_MI_KANJIRECV + IdJIS, "Recv: &JIS" }, + { ID_MI_KANJIRECV + IdUTF8, "Recv: &UTF-8" }, + { ID_MI_KANJIRECV + IdUTF8m, "Recv: UTF-8&m" } +}; + +// \x8E\xF3\x90M\x8A\xBF\x8E\x9A\x83R\x81[\x83h (\x8A؍\x91\x8C\xEA) +static const KmTextInfo MenuNameRecvK[] = { + { ID_MI_KANJIRECV + IdSJIS, "Recv: &KS5601" }, + { ID_MI_KANJIRECV + IdUTF8, "Recv: &UTF-8" }, + { ID_MI_KANJIRECV + IdUTF8m, "Recv: UTF-8&m" } +}; + +// \x91\x97\x90M\x8A\xBF\x8E\x9A\x83R\x81[\x83h (\x93\xFA\x96{\x8C\xEA) +static const KmTextInfo MenuNameSendJ[] = { + { ID_MI_KANJISEND + IdSJIS, "Send: S&hift_JIS" }, + { ID_MI_KANJISEND + IdEUC, "Send: EU&C-JP" }, + { ID_MI_KANJISEND + IdJIS, "Send: J&IS" }, + { ID_MI_KANJISEND + IdUTF8, "Send: U&TF-8" } +}; + +// \x91\x97\x90M\x8A\xBF\x8E\x9A\x83R\x81[\x83h (\x8A؍\x91\x8C\xEA) +static const KmTextInfo MenuNameSendK[] = { + { ID_MI_KANJISEND + IdSJIS, "Send: K&S5601" }, + { ID_MI_KANJISEND + IdUTF8, "Send: U&TF-8" } +}; + +// \x91\x97\x8E\xF3\x90M\x8A\xBF\x8E\x9A\x83R\x81[\x83h (\x93\xFA\x96{\x8C\xEA) +static const KmTextInfo MenuNameOneJ[] = { + { ID_MI_KANJIRECV + IdSJIS, "Recv/Send: &Shift_JIS" }, + { ID_MI_KANJIRECV + IdEUC, "Recv/Send: &EUC-JP" }, + { ID_MI_KANJIRECV + IdJIS, "Recv/Send: &JIS" }, + { ID_MI_KANJIRECV + IdUTF8, "Recv/Send: &UTF-8" }, + { ID_MI_KANJIRECV + IdUTF8m, "Recv: UTF-8&m/Send: UTF-8" } +}; + +// \x91\x97\x8E\xF3\x90M\x8A\xBF\x8E\x9A\x83R\x81[\x83h (\x8A؍\x91\x8C\xEA) +static const KmTextInfo MenuNameOneK[] = { + { ID_MI_KANJIRECV + IdSJIS, "Recv/Send: &KS5601" }, + { ID_MI_KANJIRECV + IdUTF8, "Recv/Send: &UTF-8" }, + { ID_MI_KANJIRECV + IdUTF8m, "Recv: UTF-8&m/Send: UTF-8" } +}; + +// \x83\x81\x83j\x83\x85\x81[\x8E\xA9\x91̂̍\x91\x8Dۉ\xBB\x97p\x8F\xEE\x95\xF1 (\x93\xFA\x96{\x8C\xEA) +static DlgTextInfo MenuTitleInfoJ[] = { + { -1, "MENU_KANJI" } +}; + +// \x83\x81\x83j\x83\x85\x81[\x8E\xA9\x91̂̍\x91\x8Dۉ\xBB\x97p\x8F\xEE\x95\xF1 (\x8A؍\x91\x8C\xEA) +static DlgTextInfo MenuTitleInfoK[] = { + { -1, "MENU_KANJI_K" } +}; + +// \x83\x81\x83j\x83\x85\x81[\x93\xE0\x82̊e\x8D\x80\x96ڂ̍\x91\x8Dۉ\xBB\x97p\x8F\xEE\x95\xF1 (\x91\x97\x8E\xF3\x90M\x95\xAA\x97\xA3\x8E\x9E/\x93\xFA\x96{\x8C\xEA) +static const DlgTextInfo MenuInfoSeparateJ[] = { + // \x8E\xF3\x90M + { ID_MI_KANJIRECV + IdSJIS, "MENU_RECV_SJIS" }, + { ID_MI_KANJIRECV + IdEUC, "MENU_RECV_EUCJP" }, + { ID_MI_KANJIRECV + IdJIS, "MENU_RECV_JIS" }, + { ID_MI_KANJIRECV + IdUTF8, "MENU_RECV_UTF8" }, + { ID_MI_KANJIRECV + IdUTF8m, "MENU_RECV_UTF8m" }, + // \x91\x97\x90M + { ID_MI_KANJISEND + IdSJIS, "MENU_SEND_SJIS" }, + { ID_MI_KANJISEND + IdEUC, "MENU_SEND_EUCJP" }, + { ID_MI_KANJISEND + IdJIS, "MENU_SEND_JIS" }, + { ID_MI_KANJISEND + IdUTF8, "MENU_SEND_UTF8" }, + // UseOneSetting + { ID_MI_USEONESETTING, "MENU_USE_ONE_SETTING" } +}; + +// \x83\x81\x83j\x83\x85\x81[\x93\xE0\x82̊e\x8D\x80\x96ڂ̍\x91\x8Dۉ\xBB\x97p\x8F\xEE\x95\xF1 (\x91\x97\x8E\xF3\x90M\x95\xAA\x97\xA3\x8E\x9E/\x8A؍\x91\x8C\xEA) +static const DlgTextInfo MenuInfoSeparateK[] = { + // \x8E\xF3\x90M + { ID_MI_KANJIRECV + IdSJIS, "MENU_RECV_KS5601" }, + { ID_MI_KANJIRECV + IdUTF8, "MENU_RECV_UTF8" }, + { ID_MI_KANJIRECV + IdUTF8m, "MENU_RECV_UTF8m" }, + // \x91\x97\x90M + { ID_MI_KANJISEND + IdSJIS, "MENU_SEND_KS5601" }, + { ID_MI_KANJISEND + IdUTF8, "MENU_SEND_UTF8" }, + // UseOneSetting + { ID_MI_USEONESETTING, "MENU_USE_ONE_SETTING" } +}; + +// \x83\x81\x83j\x83\x85\x81[\x93\xE0\x82̊e\x8D\x80\x96ڂ̍\x91\x8Dۉ\xBB\x97p\x8F\xEE\x95\xF1 (\x91\x97\x8E\xF3\x90M\x8B\xA4\x92ʎ\x9E/\x93\xFA\x96{\x8C\xEA) +static const DlgTextInfo MenuInfoOneJ[] = { + // \x91\x97\x8E\xF3\x90M + { ID_MI_KANJIRECV + IdSJIS, "MENU_SJIS" }, + { ID_MI_KANJIRECV + IdEUC, "MENU_EUCJP" }, + { ID_MI_KANJIRECV + IdJIS, "MENU_JIS" }, + { ID_MI_KANJIRECV + IdUTF8, "MENU_UTF8" }, + { ID_MI_KANJIRECV + IdUTF8m, "MENU_UTF8m" }, + // UseOneSetting + { ID_MI_USEONESETTING, "MENU_USE_ONE_SETTING" } +}; + +// \x83\x81\x83j\x83\x85\x81[\x93\xE0\x82̊e\x8D\x80\x96ڂ̍\x91\x8Dۉ\xBB\x97p\x8F\xEE\x95\xF1 (\x91\x97\x8E\xF3\x90M\x8B\xA4\x92ʎ\x9E/\x8A؍\x91\x8C\xEA) +static const DlgTextInfo MenuInfoOneK[] = { + // \x91\x97\x8E\xF3\x90M + { ID_MI_KANJIRECV + IdSJIS, "MENU_KS5601" }, + { ID_MI_KANJIRECV + IdUTF8, "MENU_UTF8" }, + { ID_MI_KANJIRECV + IdUTF8m, "MENU_UTF8m" }, + // UseOneSetting + { ID_MI_USEONESETTING, "MENU_USE_ONE_SETTING" } +}; + static HANDLE hInst; /* Instance handle of TTX*.DLL */ typedef struct { @@ -59,7 +177,7 @@ static TInstVar InstVar; /* - * This function is called when Tera Term starts up. + * \x8F\x89\x8A\xFA\x89\xBB */ static void PASCAL TTXInit(PTTSet ts, PComVar cv) { pvar->ts = ts; @@ -138,6 +256,9 @@ SendMessage(hWin, WM_COMMAND, MAKELONG(ID_SETUP_TERMINAL, 0), 0); } +/* + * \x90ݒ\xE8\x82̓ǂݍ\x9E\x82\xDD + */ static void PASCAL TTXKanjiMenuReadIniFile(PCHAR fn, PTTSet ts) { char buff[20]; @@ -150,6 +271,7 @@ } else { pvar->UseOneSetting = TRUE; + // UseOneSetting \x82\xAA on \x82̏ꍇ\x82́A\x91\x97\x8E\xF3\x90M\x90ݒ肪\x93\xAF\x82\xB6\x82ɂȂ\xE9\x82悤\x82ɒ\xB2\x90\xAE\x82\xB7\x82\xE9 if (pvar->ts->Language == IdJapanese) { if (pvar->ts->KanjiCode == IdUTF8m) { pvar->ts->KanjiCodeSend = IdUTF8; @@ -165,6 +287,9 @@ return; } +/* + * \x90ݒ\xE8\x82̕ۑ\xB6 + */ static void PASCAL TTXKanjiMenuWriteIniFile(PCHAR fn, PTTSet ts) { /* Call original WriteIniFile */ pvar->origWriteIniFile(fn, ts); @@ -174,6 +299,9 @@ return; } +/* + * \x90ݒ\xE8\x82̓ǂݏ\x91\x82\xAB\x82\xF0\x83t\x83b\x83N\x82\xB7\x82\xE9 + */ static void PASCAL TTXGetSetupHooks(TTXSetupHooks *hooks) { pvar->origReadIniFile = *hooks->ReadIniFile; *hooks->ReadIniFile = TTXKanjiMenuReadIniFile; @@ -181,124 +309,112 @@ *hooks->WriteIniFile = TTXKanjiMenuWriteIniFile; } -#define ID_MI_KANJIRECV 54009 -#define ID_MI_KANJISEND 54109 -#define ID_MI_USEONESETTING 54200 +/* + * \x93\xC1\x92\xE8\x82\xCCID\x82̎q\x82\xF0\x8E\x9D\x82ƒ\x81\x83j\x83\x85\x81[\x82̈ʒu\x82\xF0\x95Ԃ\xB7 + */ +static int GetMenuPosByChildId(HMENU menu, UINT id) { + UINT i, j, items, subitems, cur_id; + HMENU m; + items = GetMenuItemCount(menu); + + for (i=0; its->Language == IdJapanese) { - InsertMenu(menu, 5, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); - - GetI18nStr(IniSection, "MENU_SEND_SJIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: S&hift_JIS", pvar->ts->UILanguageFile); - InsertMenu(menu, 6, flag, ID_MI_KANJISEND+IdSJIS, pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_SEND_EUCJP", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: EU&C-JP", pvar->ts->UILanguageFile); - InsertMenu(menu, 7, flag, ID_MI_KANJISEND+IdEUC, pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_SEND_JIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: J&IS", pvar->ts->UILanguageFile); - InsertMenu(menu, 8, flag, ID_MI_KANJISEND+IdJIS, pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_SEND_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: U&TF-8", pvar->ts->UILanguageFile); - InsertMenu(menu, 9, flag, ID_MI_KANJISEND+IdUTF8, pvar->ts->UIMsg); + for (i = 0; i < _countof(MenuNameSendJ); i++) { + InsertMenu(pvar->hmEncode, ID_MI_USEONESETTING, MF_BYCOMMAND | MF_STRING, + MenuNameSendJ[i].menuID, MenuNameSendJ[i].menuStr); + } } else { // IdKorean - InsertMenu(menu, 2, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); + for (i = 0; i < _countof(MenuNameSendK); i++) { + InsertMenu(pvar->hmEncode, ID_MI_USEONESETTING, MF_BYCOMMAND | MF_STRING, + MenuNameSendK[i].menuID, MenuNameSendK[i].menuStr); + } + } - GetI18nStr(IniSection, "MENU_SEND_KS5601", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: K&S5601", pvar->ts->UILanguageFile); - InsertMenu(menu, 3, flag, ID_MI_KANJISEND+IdSJIS, pvar->ts->UIMsg); - - GetI18nStr(IniSection, "MENU_SEND_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: U&TF-8", pvar->ts->UILanguageFile); - InsertMenu(menu, 4, flag, ID_MI_KANJISEND+IdUTF8, pvar->ts->UIMsg); - } + InsertMenu(menu, ID_MI_USEONESETTING, MF_BYCOMMAND | MF_SEPARATOR, 0, NULL); } +/* + * \x91\x97\x90M\x8A\xBF\x8E\x9A\x83R\x81[\x83h\x90ݒ\xE8\x97p\x82̃\x81\x83j\x83\x85\x81[\x8D\x80\x96ڂ\xF0\x8D폜\x82\xB7\x82\xE9 + * + * UseOneSetting \x82\xAA on \x82ɂ\xB3\x82ꂽ\x8E\x9E\x82ɌĂ΂\xEA\x82\xE9 + */ static void DeleteSendKcodeMenu(HMENU menu) { + int i; + if (pvar->ts->Language == IdJapanese) { - DeleteMenu(menu, 5, MF_BYPOSITION); - DeleteMenu(menu, 5, MF_BYPOSITION); - DeleteMenu(menu, 5, MF_BYPOSITION); - DeleteMenu(menu, 5, MF_BYPOSITION); - DeleteMenu(menu, 5, MF_BYPOSITION); + for (i=0; i < _countof(MenuNameSendJ); i++) { + DeleteMenu(menu, MenuNameSendJ[i].menuID, MF_BYCOMMAND); + } + // \x8E\xF3\x90M\x83\x81\x83j\x83\x85\x81[\x82̒\xBC\x8C\xE3\x82ɗL\x82\xE9\x83Z\x83p\x83\x8C\x81[\x83^\x82\xF0\x8D폜\x82\xB7\x82\xE9 + DeleteMenu(menu, _countof(MenuNameRecvJ), MF_BYPOSITION); } else { // IdKorean - DeleteMenu(menu, 3, MF_BYPOSITION); - DeleteMenu(menu, 3, MF_BYPOSITION); - DeleteMenu(menu, 3, MF_BYPOSITION); + for (i=0; i < _countof(MenuNameSendK); i++) { + DeleteMenu(menu, MenuNameSendK[i].menuID, MF_BYCOMMAND); + } + // \x8E\xF3\x90M\x83\x81\x83j\x83\x85\x81[\x82̒\xBC\x8C\xE3\x82ɗL\x82\xE9\x83Z\x83p\x83\x8C\x81[\x83^\x82\xF0\x8D폜\x82\xB7\x82\xE9 + DeleteMenu(menu, _countof(MenuNameRecvK), MF_BYPOSITION); } } -static void UpdateRecvMenuCaption(HMENU menu, BOOL UseOneSetting) { - if (UseOneSetting) { - if (pvar->ts->Language == IdJapanese) { - GetI18nStr(IniSection, "MENU_SJIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv/Send: &Shift_JIS", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdSJIS, MF_BYCOMMAND, ID_MI_KANJIRECV+IdSJIS, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_EUCJP", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv/Send: &EUC-JP", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdEUC, MF_BYCOMMAND, ID_MI_KANJIRECV+IdEUC, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_JIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv/Send: &JIS", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdJIS, MF_BYCOMMAND, ID_MI_KANJIRECV+IdJIS, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv/Send: &UTF-8", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdUTF8, MF_BYCOMMAND, ID_MI_KANJIRECV+IdUTF8, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_UTF8m", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: UTF-8&m/Send: UTF-8", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdUTF8m, MF_BYCOMMAND, ID_MI_KANJIRECV+IdUTF8m, - pvar->ts->UIMsg); +/* + * \x83\x81\x83j\x83\x85\x81[\x8D\x80\x96ڂ̍X\x90V + * + * \x88ȉ\xBA\x82̓\xF1\x82‚ɂ‚\xA2\x82ă\x81\x83j\x83\x85\x81[\x8D\x80\x96ڂ\xF0\x8DX\x90V\x82\xB7\x82\xE9\x81B + * 1. UseOneSetting \x82̐ݒ\xE8\x82Ɋ\xEE\x82Â\xA2\x82āA\x8E\xF3\x90M\x97p\x83\x81\x83j\x83\x85\x81[\x8D\x80\x96ڂ\xF0\x8E\xF3\x90M\x90\xEA\x97p/\x91\x97\x8E\xF3\x90M\x8C\x93\x97p\x82̐؂\xE8\x91ւ\xA6\x82\xF0\x8Ds\x82\xA4 + * 2. \x83\x81\x83j\x83\x85\x81[\x8D\x80\x96ڂ̍\x91\x8Dۉ\xBB\x82\xF0\x8Ds\x82\xA4 + * + * \x92ʏ\xED\x82\xCD 1 \x82Őݒ肵\x82\xBD\x8D\x80\x96ږ\xBC\x82\xCD 2 \x82ŏ㏑\x82\xAB\x8DX\x90V\x82\xB3\x82\xEA\x82邪\x81Alng \x83t\x83@\x83C\x83\x8B\x82\xAA\x90ݒ肳\x82\xEA\x82Ă\xA2\x82Ȃ\xA2\x81A + * \x82܂\xBD\x82\xCD lng \x83t\x83@\x83C\x83\x8B\x82Ƀ\x81\x83j\x83\x85\x81[\x8D\x80\x96ږ\xBC\x82\xAA\x8A܂܂\xEA\x82Ă\xA2\x82Ȃ\xA2\x8Fꍇ\x82ւ̑Ή\x9E\x82Ƃ\xB5\x82\xC4 1 \x82\xF0\x8Ds\x82\xC1\x82Ă\xA2\x82\xE9\x81B + */ +static void UpdateMenuCaption(HMENU menu, BOOL UseOneSetting) { +#define doUpdateMenu(nameInfo, i18nInfo) { \ + UINT i, id; \ + for (i=0; i < _countof(nameInfo); i++) { \ + id = (nameInfo)[i].menuID; \ + ModifyMenu(menu, id, MF_BYCOMMAND, id, (nameInfo)[i].menuStr); \ + } \ + SetI18MenuStrs(IniSection, menu, (i18nInfo), _countof(i18nInfo), pvar->ts->UILanguageFile); \ +} + + if (pvar->ts->Language == IdJapanese) { + if (UseOneSetting) { + doUpdateMenu(MenuNameOneJ, MenuInfoOneJ); } - else { // IdKorean - GetI18nStr(IniSection, "MENU_KS5601", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv/Send: &KS5601", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdSJIS, MF_BYCOMMAND, ID_MI_KANJIRECV+IdSJIS, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv/Send: &UTF-8", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdUTF8, MF_BYCOMMAND, ID_MI_KANJIRECV+IdUTF8, - pvar->ts->UIMsg); + else { + doUpdateMenu(MenuNameRecvJ, MenuInfoSeparateJ); } } - else { - if (pvar->ts->Language == IdJapanese) { - GetI18nStr(IniSection, "MENU_RECV_SJIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &Shift_JIS", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdSJIS, MF_BYCOMMAND, ID_MI_KANJIRECV+IdSJIS, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_EUCJP", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &EUC-JP", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdEUC, MF_BYCOMMAND, ID_MI_KANJIRECV+IdEUC, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_JIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &JIS", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdJIS, MF_BYCOMMAND, ID_MI_KANJIRECV+IdJIS, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &UTF-8", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdUTF8, MF_BYCOMMAND, ID_MI_KANJIRECV+IdUTF8, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_UTF8m", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: UTF-8&m", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdUTF8m, MF_BYCOMMAND, ID_MI_KANJIRECV+IdUTF8m, - pvar->ts->UIMsg); + else { // IdKorean + if (UseOneSetting) { + doUpdateMenu(MenuNameOneK, MenuInfoOneK); } - else { // IdKorean - GetI18nStr(IniSection, "MENU_RECV_KS5601", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &KS5601", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdSJIS, MF_BYCOMMAND, ID_MI_KANJIRECV+IdSJIS, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &UTF-8", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdUTF8, MF_BYCOMMAND, ID_MI_KANJIRECV+IdUTF8, - pvar->ts->UIMsg); + else { + doUpdateMenu(MenuNameRecvK, MenuInfoSeparateK); } } } @@ -307,8 +423,6 @@ * This function is called when Tera Term creates a new menu. */ static void PASCAL TTXModifyMenu(HMENU menu) { - UINT flag = MF_ENABLED; - // \x8C\xBE\x8Cꂪ\x93\xFA\x96{\x8C\xEA\x82܂\xBD\x82͊؍\x91\x8C\xEA\x82̎\x9E\x82̂݃\x81\x83j\x83\x85\x81[\x82ɒlj\xC1\x82\xB7\x82\xE9 if (pvar->ts->Language != IdJapanese && pvar->ts->Language != IdKorean) { return; @@ -316,6 +430,7 @@ { MENUITEMINFO mi; + int pos, i; pvar->hmEncode = CreateMenu(); @@ -331,68 +446,53 @@ mi.fMask = MIIM_TYPE | MIIM_SUBMENU; mi.fType = MFT_STRING; mi.hSubMenu = pvar->hmEncode; + if (pvar->ts->Language == IdJapanese) { - GetI18nStr(IniSection, "MENU_KANJI", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "&KanjiCode", pvar->ts->UILanguageFile); + mi.dwTypeData = "&KanjiCode"; } else { // IdKorean - GetI18nStr(IniSection, "MENU_KANJI_K", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Coding(&K)", pvar->ts->UILanguageFile); + mi.dwTypeData = "Coding(&K)"; } - mi.dwTypeData = pvar->ts->UIMsg; InsertMenuItem(menu, ID_HELPMENU, FALSE, &mi); - flag = MF_STRING|MF_CHECKED; if (pvar->ts->Language == IdJapanese) { - GetI18nStr(IniSection, "MENU_RECV_SJIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &Shift_JIS", pvar->ts->UILanguageFile); - AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdSJIS, pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_EUCJP", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &EUC-JP", pvar->ts->UILanguageFile); - AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdEUC, pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_JIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &JIS", pvar->ts->UILanguageFile); - AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdJIS, pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &UTF-8", pvar->ts->UILanguageFile); - AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdUTF8, pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_UTF8m", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: UTF-8&m", pvar->ts->UILanguageFile); - AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdUTF8m, pvar->ts->UIMsg); + for (i = 0; i < _countof(MenuNameRecvJ); i++) { + AppendMenu(pvar->hmEncode, MF_STRING, MenuNameRecvJ[i].menuID, MenuNameRecvJ[i].menuStr); + } } else { // IdKorean - GetI18nStr(IniSection, "MENU_RECV_KS5601", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &KS5601", pvar->ts->UILanguageFile); - AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdSJIS, pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &UTF-8", pvar->ts->UILanguageFile); - AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdUTF8, pvar->ts->UIMsg); + for (i = 0; i < _countof(MenuNameRecvK); i++) { + AppendMenu(pvar->hmEncode, MF_STRING, MenuNameRecvK[i].menuID, MenuNameRecvK[i].menuStr); + } } + AppendMenu(pvar->hmEncode, MF_SEPARATOR, 0, NULL); + AppendMenu(pvar->hmEncode, MF_STRING, ID_MI_USEONESETTING , "Use &one setting"); + if (!pvar->UseOneSetting) { InsertSendKcodeMenu(pvar->hmEncode); } - else { - UpdateRecvMenuCaption(pvar->hmEncode, pvar->UseOneSetting); - } - AppendMenu(pvar->hmEncode, MF_SEPARATOR, 0, NULL); - GetI18nStr(IniSection, "MENU_USE_ONE_SETTING", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Use &one setting", pvar->ts->UILanguageFile); - AppendMenu(pvar->hmEncode, flag, ID_MI_USEONESETTING , pvar->ts->UIMsg); + pos = GetMenuPosByChildId(menu, ID_MI_KANJIRECV + IdSJIS); - UpdateRecvMenu(pvar->ts->KanjiCode); - if (!pvar->UseOneSetting) { - UpdateSendMenu(pvar->ts->KanjiCodeSend); + if (pos > 0) { + if (pvar->ts->Language == IdJapanese) { + MenuTitleInfoJ->nIDDlgItem = pos; + SetI18MenuStrs(IniSection, menu, MenuTitleInfoJ, _countof(MenuTitleInfoJ), pvar->ts->UILanguageFile); + } + else { + MenuTitleInfoK->nIDDlgItem = pos; + SetI18MenuStrs(IniSection, menu, MenuTitleInfoK, _countof(MenuTitleInfoK), pvar->ts->UILanguageFile); + } } - CheckMenuItem(pvar->hmEncode, ID_MI_USEONESETTING, MF_BYCOMMAND | (pvar->UseOneSetting)?MF_CHECKED:0); + UpdateMenuCaption(pvar->hmEncode, pvar->UseOneSetting); } } /* - * This function is called when Tera Term pops up a submenu menu. + * \x83\x89\x83W\x83I\x83\x81\x83j\x83\x85\x81[/\x83`\x83F\x83b\x83N\x83\x81\x83j\x83\x85\x81[\x82̏\xF3\x91Ԃ\xF0\x90ݒ\xE8\x82ɍ\x87\x82킹\x82čX\x90V\x82\xB7\x82\xE9\x81B */ static void PASCAL TTXModifyPopupMenu(HMENU menu) { // \x83\x81\x83j\x83\x85\x81[\x82\xAA\x8CĂяo\x82\xB3\x82ꂽ\x82\xE7\x81A\x8DŐV\x82̐ݒ\xE8\x82ɍX\x90V\x82\xB7\x82\xE9\x81B(2007.5.25 yutaka) @@ -439,7 +539,6 @@ if (pvar->UseOneSetting) { pvar->UseOneSetting = FALSE; InsertSendKcodeMenu(pvar->hmEncode); - CheckMenuItem(pvar->hmEncode, ID_MI_USEONESETTING, MF_BYCOMMAND); } else { pvar->UseOneSetting = TRUE; @@ -453,9 +552,8 @@ pvar->cv->KanjiCodeSend = pvar->ts->KanjiCodeSend = val; DeleteSendKcodeMenu(pvar->hmEncode); - CheckMenuItem(pvar->hmEncode, ID_MI_USEONESETTING, MF_BYCOMMAND | MF_CHECKED); } - UpdateRecvMenuCaption(pvar->hmEncode, pvar->UseOneSetting); + UpdateMenuCaption(pvar->hmEncode, pvar->UseOneSetting); return 1; } Modified: trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c =================================================================== --- trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c 2020-01-17 18:15:12 UTC (rev 8483) +++ trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c 2020-01-17 18:15:18 UTC (rev 8484) @@ -63,6 +63,10 @@ } static void PASCAL TTXModifyMenu(HMENU menu) { + static const DlgTextInfo MenuTextInfo[] = { + { ID_MENU_BASE, "MENU_ALWAYSONTOP" } + }; + UINT flag = MF_BYCOMMAND | MF_STRING | MF_ENABLED; pvar->ControlMenu = GetControlMenu(menu); @@ -70,10 +74,10 @@ flag |= MF_CHECKED; } - GetI18nStr(IniSection, "MENU_ALWAYSONTOP", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "&Always on top", pvar->ts->UILanguageFile); - InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, flag, ID_MENU_BASE, pvar->ts->UIMsg); + InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, flag, ID_MENU_BASE, "&Alwais on top"); InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, MF_BYCOMMAND | MF_SEPARATOR, 0, NULL); + + SetI18MenuStrs(IniSection, menu, MenuTextInfo, _countof(MenuTextInfo), pvar->ts->UILanguageFile); } static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd) { From scmnotify @ osdn.net Sat Jan 18 03:59:14 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Sat, 18 Jan 2020 03:59:14 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0ODVdIOmWouaVsOWQjeOCkuWkieabtCBb?= =?utf-8?q?Ttssh2-devel_4475=5D?= Message-ID: <1579287554.572298.72377.nullmailer@users.osdn.me> Revision: 8485 https://osdn.net/projects/ttssh2/scm/svn/commits/8485 Author: doda Date: 2020-01-18 03:59:14 +0900 (Sat, 18 Jan 2020) Log Message: ----------- 関数名を変更 [Ttssh2-devel 4475] ・SetI18MenuStrs() -> SetI18nMenuStrs() ・SetI18DlgStrs() -> SetI18nDlgStrs() Modified Paths: -------------- trunk/TTProxy/ProxyWSockHook.h trunk/TTXKanjiMenu/ttxkanjimenu.c trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c trunk/teraterm/common/i18n.c trunk/teraterm/common/i18n.h trunk/teraterm/common/ttlib.c trunk/teraterm/ttpcmn/ttpcmn.def trunk/ttssh2/ttxssh/auth.c trunk/ttssh2/ttxssh/fwdui.c trunk/ttssh2/ttxssh/hosts.c trunk/ttssh2/ttxssh/ttxssh.c -------------- next part -------------- Modified: trunk/TTProxy/ProxyWSockHook.h =================================================================== --- trunk/TTProxy/ProxyWSockHook.h 2020-01-17 18:15:18 UTC (rev 8484) +++ trunk/TTProxy/ProxyWSockHook.h 2020-01-17 18:59:14 UTC (rev 8485) @@ -773,7 +773,7 @@ Dialog::onInitDialog(); HWND hWnd = (HWND)this; - SetI18DlgStrs("TTProxy", hWnd, text_info, _countof(text_info), UILanguageFile); + SetI18nDlgStrs("TTProxy", hWnd, text_info, _countof(text_info), UILanguageFile); host = GetDlgItem(IDC_HOSTNAME); user = GetDlgItem(IDC_USERNAME); @@ -899,7 +899,7 @@ // { IDCANCEL, "BTN_CANCEL" }, }; HWND hWnd = HWND(this); // \x82\xA4\x82܂\xAD\x93\xAE\x82\xA9\x82Ȃ\xA2? - SetI18DlgStrs("TTProxy", hWnd, text_info, _countof(text_info), UILanguageFile); + SetI18nDlgStrs("TTProxy", hWnd, text_info, _countof(text_info), UILanguageFile); url <<= GetDlgItem(IDC_URL); type <<= GetDlgItem(IDC_TYPE); Modified: trunk/TTXKanjiMenu/ttxkanjimenu.c =================================================================== --- trunk/TTXKanjiMenu/ttxkanjimenu.c 2020-01-17 18:15:18 UTC (rev 8484) +++ trunk/TTXKanjiMenu/ttxkanjimenu.c 2020-01-17 18:59:14 UTC (rev 8485) @@ -398,7 +398,7 @@ id = (nameInfo)[i].menuID; \ ModifyMenu(menu, id, MF_BYCOMMAND, id, (nameInfo)[i].menuStr); \ } \ - SetI18MenuStrs(IniSection, menu, (i18nInfo), _countof(i18nInfo), pvar->ts->UILanguageFile); \ + SetI18nMenuStrs(IniSection, menu, (i18nInfo), _countof(i18nInfo), pvar->ts->UILanguageFile); \ } if (pvar->ts->Language == IdJapanese) { @@ -478,11 +478,11 @@ if (pos > 0) { if (pvar->ts->Language == IdJapanese) { MenuTitleInfoJ->nIDDlgItem = pos; - SetI18MenuStrs(IniSection, menu, MenuTitleInfoJ, _countof(MenuTitleInfoJ), pvar->ts->UILanguageFile); + SetI18nMenuStrs(IniSection, menu, MenuTitleInfoJ, _countof(MenuTitleInfoJ), pvar->ts->UILanguageFile); } else { MenuTitleInfoK->nIDDlgItem = pos; - SetI18MenuStrs(IniSection, menu, MenuTitleInfoK, _countof(MenuTitleInfoK), pvar->ts->UILanguageFile); + SetI18nMenuStrs(IniSection, menu, MenuTitleInfoK, _countof(MenuTitleInfoK), pvar->ts->UILanguageFile); } } Modified: trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c =================================================================== --- trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c 2020-01-17 18:15:18 UTC (rev 8484) +++ trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c 2020-01-17 18:59:14 UTC (rev 8485) @@ -77,7 +77,7 @@ InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, flag, ID_MENU_BASE, "&Alwais on top"); InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, MF_BYCOMMAND | MF_SEPARATOR, 0, NULL); - SetI18MenuStrs(IniSection, menu, MenuTextInfo, _countof(MenuTextInfo), pvar->ts->UILanguageFile); + SetI18nMenuStrs(IniSection, menu, MenuTextInfo, _countof(MenuTextInfo), pvar->ts->UILanguageFile); } static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd) { Modified: trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c 2020-01-17 18:15:18 UTC (rev 8484) +++ trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c 2020-01-17 18:59:14 UTC (rev 8485) @@ -221,7 +221,7 @@ insertMenuBeforeItem(menu, ID_HELP_ABOUT, MF_ENABLED, ID_MENUITEM, "Check &Update..."); - SetI18MenuStrs("TTXCheckUpdate", menu, MenuTextInfo, _countof(MenuTextInfo), UILanguageFile); + SetI18nMenuStrs("TTXCheckUpdate", menu, MenuTextInfo, _countof(MenuTextInfo), UILanguageFile); } static int WINAPI TTXProcessCommand(HWND hWin, WORD cmd) Modified: trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c =================================================================== --- trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c 2020-01-17 18:15:18 UTC (rev 8484) +++ trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c 2020-01-17 18:59:14 UTC (rev 8485) @@ -448,7 +448,7 @@ InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, flag, ID_MENU_CONTROL, "Rec&urring command"); InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, MF_BYCOMMAND | MF_SEPARATOR, 0, NULL); - SetI18MenuStrs(SECTION, menu, MenuTextInfo, _countof(MenuTextInfo), pvar->ts->UILanguageFile); + SetI18nMenuStrs(SECTION, menu, MenuTextInfo, _countof(MenuTextInfo), pvar->ts->UILanguageFile); } static void PASCAL TTXModifyPopupMenu(HMENU menu) { @@ -476,7 +476,7 @@ switch (msg) { case WM_INITDIALOG: - SetI18DlgStrs(SECTION, dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); + SetI18nDlgStrs(SECTION, dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); SendMessage(GetDlgItem(dlg, IDC_ENABLE), BM_SETCHECK, pvar->enable?BST_CHECKED:BST_UNCHECKED, 0); Modified: trunk/teraterm/common/i18n.c =================================================================== --- trunk/teraterm/common/i18n.c 2020-01-17 18:15:18 UTC (rev 8484) +++ trunk/teraterm/common/i18n.c 2020-01-17 18:59:14 UTC (rev 8485) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2019 TeraTerm Project + * Copyright (C) 2006-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -150,7 +150,7 @@ * \x8C\xBE\x8C\xEA\x83t\x83@\x83C\x83\x8B\x82ŕϊ\xB7\x82ł\xAB\x82\xBD\x89\xF1\x90\x94(infoCount\x88ȉ\xBA\x82̐\x94\x82ɂȂ\xE9) * */ -int WINAPI SetI18DlgStrs(const char *section, HWND hDlgWnd, +int WINAPI SetI18nDlgStrs(const char *section, HWND hDlgWnd, const DlgTextInfo *infos, size_t infoCount, const char *UILanguageFile) { size_t i; @@ -198,7 +198,7 @@ return (translatedCount); } -void WINAPI SetI18MenuStrs(const char *section, HMENU hMenu, const DlgTextInfo *infos, size_t infoCount, +void WINAPI SetI18nMenuStrs(const char *section, HMENU hMenu, const DlgTextInfo *infos, size_t infoCount, const char *UILanguageFile) { const int id_position_threshold = 1000; @@ -240,3 +240,5 @@ } } } + +/* vim: set ts=4 sw=4 ff=dos : */ Modified: trunk/teraterm/common/i18n.h =================================================================== --- trunk/teraterm/common/i18n.h 2020-01-17 18:15:18 UTC (rev 8484) +++ trunk/teraterm/common/i18n.h 2020-01-17 18:59:14 UTC (rev 8485) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2019 TeraTerm Project + * Copyright (C) 2006-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,9 +49,9 @@ DllExport void WINAPI GetI18nStrW(const char *section, const char *key, wchar_t *buf, int buf_len, const wchar_t *def, const char *iniFile); DllExport void WINAPI GetI18nStr(const char *section, const char *key, PCHAR buf, int buf_len, const char *def, const char *iniFile); DllExport int WINAPI GetI18nLogfont(const char *section, const char *key, PLOGFONTA logfont, int ppi, const char *iniFile); -DllExport int WINAPI SetI18DlgStrs(const char *section, HWND hDlgWnd, +DllExport int WINAPI SetI18nDlgStrs(const char *section, HWND hDlgWnd, const DlgTextInfo *infos, size_t infoCount, const char *UILanguageFile); -DllExport void WINAPI SetI18MenuStrs(const char *section, HMENU hMenu, +DllExport void WINAPI SetI18nMenuStrs(const char *section, HMENU hMenu, const DlgTextInfo *infos, size_t infoCount, const char *UILanguageFile); #if defined(_UNICODE) @@ -65,3 +65,4 @@ #endif #endif +/* vim: set ts=4 sw=4 ff=dos : */ Modified: trunk/teraterm/common/ttlib.c =================================================================== --- trunk/teraterm/common/ttlib.c 2020-01-17 18:15:18 UTC (rev 8484) +++ trunk/teraterm/common/ttlib.c 2020-01-17 18:59:14 UTC (rev 8485) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2006-2019 TeraTerm Project + * (C) 2006-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1870,12 +1870,12 @@ int SetDlgTexts(HWND hDlgWnd, const DlgTextInfo *infos, int infoCount, const char *UILanguageFile) { - return SetI18DlgStrs("Tera Term", hDlgWnd, infos, infoCount, UILanguageFile); + return SetI18nDlgStrs("Tera Term", hDlgWnd, infos, infoCount, UILanguageFile); } void SetDlgMenuTexts(HMENU hMenu, const DlgTextInfo *infos, int infoCount, const char *UILanguageFile) { - SetI18MenuStrs("Tera Term", hMenu, infos, infoCount, UILanguageFile); + SetI18nMenuStrs("Tera Term", hMenu, infos, infoCount, UILanguageFile); } /** @@ -2059,3 +2059,5 @@ return (int)dpiY; } } + +/* vim: set ts=4 sw=4 ff=dos : */ Modified: trunk/teraterm/ttpcmn/ttpcmn.def =================================================================== --- trunk/teraterm/ttpcmn/ttpcmn.def 2020-01-17 18:15:18 UTC (rev 8484) +++ trunk/teraterm/ttpcmn/ttpcmn.def 2020-01-17 18:59:14 UTC (rev 8485) @@ -92,6 +92,6 @@ service_name @92 get_OPENFILENAME_SIZEA @93 - SetI18DlgStrs - SetI18MenuStrs + SetI18nDlgStrs + SetI18nMenuStrs GetMessageboxFont Modified: trunk/ttssh2/ttxssh/auth.c =================================================================== --- trunk/ttssh2/ttxssh/auth.c 2020-01-17 18:15:18 UTC (rev 8484) +++ trunk/ttssh2/ttxssh/auth.c 2020-01-17 18:59:14 UTC (rev 8485) @@ -1,6 +1,6 @@ /* * Copyright (c) 1998-2001, Robert O'Callahan - * (C) 2004-2019 TeraTerm Project + * (c) 2004-2029 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -265,7 +265,7 @@ }; int default_method = pvar->session_settings.DefaultAuthMethod; - SetI18DlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); + SetI18nDlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); init_auth_machine_banner(pvar, dlg); init_password_control(pvar, dlg, IDC_SSHPASSWORD, UseControlChar); @@ -1348,7 +1348,7 @@ { IDOK, "BTN_OK" }, { IDCANCEL, "BTN_DISCONNECT" }, }; - SetI18DlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); + SetI18nDlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); init_auth_machine_banner(pvar, dlg); init_password_control(pvar, dlg, IDC_SSHPASSWORD, NULL); @@ -1500,7 +1500,7 @@ { IDC_SSHAUTHSETUP_HELP, "BTN_HELP" }, }; - SetI18DlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); + SetI18nDlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); switch (pvar->settings.DefaultAuthMethod) { case SSH_AUTH_RSA: @@ -1837,3 +1837,5 @@ AUTH_destroy_cur_cred(pvar); } + +/* vim: set ts=4 sw=4 ff=dos : */ Modified: trunk/ttssh2/ttxssh/fwdui.c =================================================================== --- trunk/ttssh2/ttxssh/fwdui.c 2020-01-17 18:15:18 UTC (rev 8484) +++ trunk/ttssh2/ttxssh/fwdui.c 2020-01-17 18:59:14 UTC (rev 8485) @@ -1,6 +1,6 @@ /* * Copyright (c) 1998-2001, Robert O'Callahan - * (C) 2004-2017 TeraTerm Project + * (C) 2004-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -510,7 +510,7 @@ { IDCANCEL, "BTN_CANCEL" }, { IDC_SSHFWDSETUP_HELP, "BTN_HELP" }, }; - SetI18DlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); + SetI18nDlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); FWD_get_request_specs(pvar, requests, num_specs); @@ -801,7 +801,7 @@ { IDOK, "BTN_OK" }, { IDCANCEL, "BTN_CANCEL" }, }; - SetI18DlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); + SetI18nDlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); switch (spec->type) { case FWD_REMOTE_TO_LOCAL: @@ -1130,3 +1130,5 @@ notify_nonfatal_error(pvar, pvar->ts->UIMsg); } } + +/* vim: set ts=4 sw=4 ff=dos : */ Modified: trunk/ttssh2/ttxssh/hosts.c =================================================================== --- trunk/ttssh2/ttxssh/hosts.c 2020-01-17 18:15:18 UTC (rev 8484) +++ trunk/ttssh2/ttxssh/hosts.c 2020-01-17 18:59:14 UTC (rev 8485) @@ -1,6 +1,6 @@ /* * Copyright (c) 1998-2001, Robert O'Callahan - * (C) 2004-2019 TeraTerm Project + * (C) 2004-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1756,7 +1756,7 @@ SetWindowLongPtr(dlg, DWLP_USER, lParam); // \x92lj\xC1\x81E\x92u\x82\xAB\x8A\xB7\x82\xA6\x82Ƃ\xE0 init_hosts_dlg \x82\xF0\x8CĂ\xF1\x82ł\xA2\x82\xE9\x82̂ŁA\x82\xBB\x82̑O\x82ɃZ\x83b\x83g\x82\xB7\x82\xE9\x95K\x97v\x82\xAA\x82\xA0\x82\xE9 - SetI18DlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); + SetI18nDlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); switch (pvar->dns_key_check) { case DNS_VERIFY_NOTFOUND: @@ -1913,7 +1913,7 @@ SetWindowLongPtr(dlg, DWLP_USER, lParam); // \x92lj\xC1\x81E\x92u\x82\xAB\x8A\xB7\x82\xA6\x82Ƃ\xE0 init_hosts_dlg \x82\xF0\x8CĂ\xF1\x82ł\xA2\x82\xE9\x82̂ŁA\x82\xBB\x82̑O\x82ɃZ\x83b\x83g\x82\xB7\x82\xE9\x95K\x97v\x82\xAA\x82\xA0\x82\xE9 - SetI18DlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); + SetI18nDlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); switch (pvar->dns_key_check) { case DNS_VERIFY_NOTFOUND: @@ -2068,7 +2068,7 @@ SetWindowLongPtr(dlg, DWLP_USER, lParam); // \x92lj\xC1\x81E\x92u\x82\xAB\x8A\xB7\x82\xA6\x82Ƃ\xE0 init_hosts_dlg \x82\xF0\x8CĂ\xF1\x82ł\xA2\x82\xE9\x82̂ŁA\x82\xBB\x82̑O\x82ɃZ\x83b\x83g\x82\xB7\x82\xE9\x95K\x97v\x82\xAA\x82\xA0\x82\xE9 - SetI18DlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); + SetI18nDlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); switch (pvar->dns_key_check) { case DNS_VERIFY_NOTFOUND: @@ -2446,3 +2446,5 @@ free(pvar->hosts_state.file_names); } } + +/* vim: set ts=4 sw=4 ff=dos : */ Modified: trunk/ttssh2/ttxssh/ttxssh.c =================================================================== --- trunk/ttssh2/ttxssh/ttxssh.c 2020-01-17 18:15:18 UTC (rev 8484) +++ trunk/ttssh2/ttxssh/ttxssh.c 2020-01-17 18:59:14 UTC (rev 8485) @@ -1324,7 +1324,7 @@ GetHNRec = (PGetHNRec) lParam; SetWindowLongPtr(dlg, DWLP_USER, lParam); - SetI18DlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); + SetI18nDlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); // \x83z\x83X\x83g\x83q\x83X\x83g\x83\x8A\x82̃`\x83F\x83b\x83N\x83{\x83b\x83N\x83X\x82\xF0\x92lj\xC1 (2005.10.21 yutaka) if (pvar->ts->HistoryList > 0) { @@ -2199,7 +2199,7 @@ /* inserts before ID_FILE_CHANGEDIR */ insertMenuBeforeItem(menu, ID_FILE_CHANGEDIR, MF_GRAYED, ID_SSHSCPMENU, "SS&H SCP..."); - SetI18MenuStrs("TTSSH", menu, MenuTextInfo, _countof(MenuTextInfo), pvar->ts->UILanguageFile); + SetI18nMenuStrs("TTSSH", menu, MenuTextInfo, _countof(MenuTextInfo), pvar->ts->UILanguageFile); } static void PASCAL TTXModifyPopupMenu(HMENU menu) { @@ -2377,7 +2377,7 @@ { IDC_FP_HASH_ALG, "DLG_ABOUT_FP_HASH_ALGORITHM" }, { IDOK, "BTN_OK" }, }; - SetI18DlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); + SetI18nDlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); // TTSSH\x82̃o\x81[\x83W\x83\x87\x83\x93\x82\xF0\x90ݒ肷\x82\xE9 (2005.2.28 yutaka) _snprintf_s(buf, sizeof(buf), _TRUNCATE, @@ -2680,7 +2680,7 @@ { IDC_LOGLEVEL, "DLG_SSHSETUP_LOGLEVEL" }, { IDC_LOGLEVEL_UNIT, "DLG_SSHSETUP_LOGLEVEL_UNIT" }, }; - SetI18DlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); + SetI18nDlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); SendMessage(compressionControl, TBM_SETRANGE, TRUE, MAKELONG(0, 9)); SendMessage(compressionControl, TBM_SETPOS, TRUE, @@ -4209,7 +4209,7 @@ { IDC_BCRYPT_KDF_ROUNDS_LABEL, "DLG_KEYGEN_BCRYPT_ROUNDS" }, { IDC_SSHKEYGENSETUP_HELP, "BTN_HELP" }, }; - SetI18DlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); + SetI18nDlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile); init_password_control(pvar, dlg, IDC_KEY_EDIT, NULL); init_password_control(pvar, dlg, IDC_CONFIRM_EDIT, NULL); @@ -5400,3 +5400,5 @@ } return TRUE; } + +/* vim: set ts=4 sw=4 ff=dos : */ From scmnotify @ osdn.net Sat Jan 18 17:11:11 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Sat, 18 Jan 2020 17:11:11 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0ODZdIOmfk+WbveiqnuODouODvOODiQ==?= =?utf-8?b?44Gn44CBVVRGLTht44Gr44OB44Kn44OD44Kv44GM5LuY44GL44Gq44GE44Gu?= =?utf-8?b?44KS5L+u5q2j44CC?= Message-ID: <1579335071.523091.9962.nullmailer@users.osdn.me> Revision: 8486 https://osdn.net/projects/ttssh2/scm/svn/commits/8486 Author: doda Date: 2020-01-18 17:11:11 +0900 (Sat, 18 Jan 2020) Log Message: ----------- 韓国語モードで、UTF-8mにチェックが付かないのを修正。 Ticket: #39928 r8484 で UTF-8m を追加したが、UTF-8m を選んでもチェックマークが付かなかった。 Revision Links: -------------- https://osdn.net/projects/ttssh2/scm/svn/commits/8484 Ticket Links: ------------ https://osdn.net/projects/ttssh2/tracker/detail/39928 Modified Paths: -------------- trunk/TTXKanjiMenu/ttxkanjimenu.c -------------- next part -------------- Modified: trunk/TTXKanjiMenu/ttxkanjimenu.c =================================================================== --- trunk/TTXKanjiMenu/ttxkanjimenu.c 2020-01-17 18:59:14 UTC (rev 8485) +++ trunk/TTXKanjiMenu/ttxkanjimenu.c 2020-01-18 08:11:11 UTC (rev 8486) @@ -34,7 +34,7 @@ #define UpdateRecvMenu(val) \ CheckMenuRadioItem(pvar->hmEncode, \ ID_MI_KANJIRECV + IdSJIS, \ - ID_MI_KANJIRECV + ((pvar->ts->Language==IdJapanese)?IdUTF8m:IdUTF8), \ + ID_MI_KANJIRECV + IdUTF8m, \ ID_MI_KANJIRECV + (val), \ MF_BYCOMMAND) #define UpdateSendMenu(val) \ From scmnotify @ osdn.net Sun Jan 19 00:16:20 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Sun, 19 Jan 2020 00:16:20 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0ODddIE1lc3NhZ2VCb3goKeOCkl9NZXNz?= =?utf-8?b?YWdlQm94Vygp44Gr44Oq44OX44Os44O844K5?= Message-ID: <1579360580.971302.13072.nullmailer@users.osdn.me> Revision: 8487 https://osdn.net/projects/ttssh2/scm/svn/commits/8487 Author: zmatsuo Date: 2020-01-19 00:16:20 +0900 (Sun, 19 Jan 2020) Log Message: ----------- MessageBox()を_MessageBoxW()にリプレース Modified Paths: -------------- trunk/teraterm/teraterm/vtwin.cpp -------------- next part -------------- Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2020-01-18 08:11:11 UTC (rev 8486) +++ trunk/teraterm/teraterm/vtwin.cpp 2020-01-18 15:16:20 UTC (rev 8487) @@ -417,7 +417,8 @@ GlobalUnlock(pSym); GlobalFree(pSym); - MessageBox(NULL, msg, "Tera Term: Application fault", MB_OK | MB_ICONEXCLAMATION); + // \x97\xE1\x8AO\x8F\x88\x97\x9D\x92\x86\x82Ȃ̂ŁAAPI\x82𒼐ڌĂяo\x82\xB7 + ::MessageBoxA(NULL, msg, "Tera Term: Application fault", MB_OK | MB_ICONEXCLAMATION); error: // return (EXCEPTION_EXECUTE_HANDLER); /* \x82\xBB\x82̂܂܃v\x83\x8D\x83Z\x83X\x82\xF0\x8FI\x97\xB9\x82\xB3\x82\xB9\x82\xE9 */ @@ -1719,10 +1720,10 @@ { // \x93ˑR\x8FI\x97\xB9\x82\xB3\x82\xB9\x82\xE9\x82Ɗ댯\x82Ȃ̂ŁA\x82\xA9\x82Ȃ炸\x83\x86\x81[\x83U\x82ɖ₢\x8D\x87\x82킹\x82\xF0\x8Fo\x82\xB7\x82悤\x82ɂ\xB7\x82\xE9\x81B // (2013.8.17 yutaka) - get_lang_msg("MSG_ALL_TERMINATE_CONF", ts.UIMsg, sizeof(ts.UIMsg), - "Terminate ALL Tera Term(s)?", ts.UILanguageFile); - if (::MessageBox(HVTWin, ts.UIMsg, "Tera Term", - MB_OKCANCEL | MB_ICONERROR | MB_DEFBUTTON2)==IDCANCEL) + wchar_t uimsg[MAX_UIMSG]; + + get_lang_msgW("MSG_ALL_TERMINATE_CONF", uimsg, _countof(uimsg), L"Terminate ALL Tera Term(s)?", ts.UILanguageFile); + if (_MessageBoxW(HVTWin, uimsg, L"Tera Term", MB_OKCANCEL | MB_ICONERROR | MB_DEFBUTTON2) == IDCANCEL) return; BroadcastClosingMessage(HVTWin); @@ -3820,7 +3821,7 @@ strncpy_s(cygterm_cfg, sizeof(cygterm_cfg), ts.HomeDir, _TRUNCATE); AppendSlash(cygterm_cfg, sizeof(cygterm_cfg)); strncat_s(cygterm_cfg, sizeof(cygterm_cfg), "cygterm.cfg", _TRUNCATE); - fp = fopen(cygterm_cfg, "r"); + fopen_s(&fp, cygterm_cfg, "r"); if (fp != NULL) { while (fgets(buf, sizeof(buf), fp) != NULL) { int len = strlen(buf); @@ -3884,13 +3885,14 @@ if (CreateProcess(NULL, Command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) == 0) { - char buf[80]; - char uimsg[MAX_UIMSG]; - get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile); - get_lang_msg("MSG_EXEC_TT_ERROR", ts.UIMsg, sizeof(ts.UIMsg), - "Can't execute Tera Term. (%d)", ts.UILanguageFile); - _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, GetLastError()); - ::MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONWARNING); + wchar_t buf[80]; + wchar_t uimsg[MAX_UIMSG]; + wchar_t uimsg2[MAX_UIMSG]; + get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile); + get_lang_msgW("MSG_EXEC_TT_ERROR", uimsg2, _countof(uimsg2), + L"Can't execute Tera Term. (%d)", ts.UILanguageFile); + _snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg2, GetLastError()); + _MessageBoxW(NULL, buf, uimsg, MB_OK | MB_ICONWARNING); } else { CloseHandle(pi.hThread); CloseHandle(pi.hProcess); @@ -3910,7 +3912,8 @@ char cygterm[MAX_PATH]; STARTUPINFO si; PROCESS_INFORMATION pi; - char uimsg[MAX_UIMSG]; + wchar_t uimsg[MAX_UIMSG]; + wchar_t uimsg2[MAX_UIMSG]; if (strlen(ts.CygwinDirectory) > 0) { if (SearchPath(ts.CygwinDirectory, "bin\\cygwin1", ".dll", sizeof(file), file, &filename) > 0) { @@ -3930,10 +3933,10 @@ } } - get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile); - get_lang_msg("MSG_FIND_CYGTERM_DIR_ERROR", ts.UIMsg, sizeof(ts.UIMsg), - "Can't find Cygwin directory.", ts.UILanguageFile); - ::MessageBox(NULL, ts.UIMsg, uimsg, MB_OK | MB_ICONWARNING); + get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile); + get_lang_msgW("MSG_FIND_CYGTERM_DIR_ERROR", uimsg2, sizeof(uimsg2), + L"Can't find Cygwin directory.", ts.UILanguageFile); + _MessageBoxW(NULL, uimsg2, uimsg, MB_OK | MB_ICONWARNING); return; found_dll:; @@ -3942,10 +3945,10 @@ if (envptr != NULL) { envbufflen = strlen(file) + strlen(envptr) + 7; // "PATH="(5) + ";"(1) + NUL(1) if ((envbuff = (char *)malloc(envbufflen)) == NULL) { - get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile); - get_lang_msg("MSG_CYGTERM_ENV_ALLOC_ERROR", ts.UIMsg, sizeof(ts.UIMsg), - "Can't allocate memory for environment variable.", ts.UILanguageFile); - ::MessageBox(NULL, ts.UIMsg, uimsg, MB_OK | MB_ICONWARNING); + get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile); + get_lang_msgW("MSG_CYGTERM_ENV_ALLOC_ERROR", uimsg2, _countof(uimsg2), + L"Can't allocate memory for environment variable.", ts.UILanguageFile); + _MessageBoxW(NULL, uimsg2, uimsg, MB_OK | MB_ICONWARNING); return; } _snprintf_s(envbuff, envbufflen, _TRUNCATE, "PATH=%s;%s", file, envptr); @@ -3952,10 +3955,10 @@ } else { envbufflen = strlen(file) + 6; // "PATH="(5) + NUL(1) if ((envbuff = (char *)malloc(envbufflen)) == NULL) { - get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile); - get_lang_msg("MSG_CYGTERM_ENV_ALLOC_ERROR", ts.UIMsg, sizeof(ts.UIMsg), - "Can't allocate memory for environment variable.", ts.UILanguageFile); - ::MessageBox(NULL, ts.UIMsg, uimsg, MB_OK | MB_ICONWARNING); + get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile); + get_lang_msgW("MSG_CYGTERM_ENV_ALLOC_ERROR", uimsg2, _countof(uimsg2), + L"Can't allocate memory for environment variable.", ts.UILanguageFile); + _MessageBoxW(NULL, uimsg2, uimsg, MB_OK | MB_ICONWARNING); return; } _snprintf_s(envbuff, envbufflen, _TRUNCATE, "PATH=%s", file); @@ -3977,10 +3980,10 @@ if (CreateProcess(NULL, cygterm, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) == 0) { - get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile); - get_lang_msg("MSG_EXEC_CYGTERM_ERROR", ts.UIMsg, sizeof(ts.UIMsg), - "Can't execute Cygterm.", ts.UILanguageFile); - ::MessageBox(NULL, ts.UIMsg, uimsg, MB_OK | MB_ICONWARNING); + get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile); + get_lang_msgW("MSG_EXEC_CYGTERM_ERROR", uimsg2, _countof(uimsg2), + L"Can't execute Cygterm.", ts.UILanguageFile); + _MessageBoxW(NULL, uimsg2, uimsg, MB_OK | MB_ICONWARNING); } else { CloseHandle(pi.hThread); CloseHandle(pi.hProcess); @@ -4003,13 +4006,14 @@ if (CreateProcess(exename, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) == 0) { - char buf[80]; - char uimsg[MAX_UIMSG]; - get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile); - get_lang_msg("MSG_EXEC_TTMENU_ERROR", ts.UIMsg, sizeof(ts.UIMsg), - "Can't execute TeraTerm Menu. (%d)", ts.UILanguageFile); - _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, GetLastError()); - ::MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONWARNING); + wchar_t buf[80]; + wchar_t uimsg[MAX_UIMSG]; + wchar_t uimsg2[MAX_UIMSG]; + get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile); + get_lang_msgW("MSG_EXEC_TTMENU_ERROR", uimsg2, _countof(uimsg2), + L"Can't execute TeraTerm Menu. (%d)", ts.UILanguageFile); + _snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg2, GetLastError()); + _MessageBoxW(NULL, buf, uimsg, MB_OK | MB_ICONWARNING); } else { CloseHandle(pi.hThread); CloseHandle(pi.hProcess); @@ -4035,13 +4039,14 @@ if (CreateProcess(NULL, LogMeTT, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) == 0) { - char buf[80]; - char uimsg[MAX_UIMSG]; - get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile); - get_lang_msg("MSG_EXEC_LOGMETT_ERROR", ts.UIMsg, sizeof(ts.UIMsg), - "Can't execute LogMeTT. (%d)", ts.UILanguageFile); - _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, GetLastError()); - ::MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONWARNING); + wchar_t buf[80]; + wchar_t uimsg[MAX_UIMSG]; + wchar_t uimsg2[MAX_UIMSG]; + get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile); + get_lang_msgW("MSG_EXEC_LOGMETT_ERROR", uimsg2, _countof(uimsg2), + L"Can't execute LogMeTT. (%d)", ts.UILanguageFile); + _snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg2, GetLastError()); + _MessageBoxW(NULL, buf, uimsg, MB_OK | MB_ICONWARNING); } else { CloseHandle(pi.hThread); CloseHandle(pi.hProcess); @@ -4127,13 +4132,14 @@ if (CreateProcess(NULL, command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) == 0) { - char buf[80]; - char uimsg[MAX_UIMSG]; - get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile); - get_lang_msg("MSG_VIEW_LOGFILE_ERROR", ts.UIMsg, sizeof(ts.UIMsg), - "Can't view logging file. (%d)", ts.UILanguageFile); - _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, GetLastError()); - ::MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONWARNING); + wchar_t buf[80]; + wchar_t uimsgW[MAX_UIMSG]; + wchar_t uimsgW2[MAX_UIMSG]; + get_lang_msgW("MSG_ERROR", uimsgW, _countof(uimsgW), L"ERROR", ts.UILanguageFile); + get_lang_msgW("MSG_VIEW_LOGFILE_ERROR", uimsgW2, _countof(uimsgW2), + L"Can't view logging file. (%d)", ts.UILanguageFile); + _snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsgW2, GetLastError()); + _MessageBoxW(NULL, buf, uimsgW, MB_OK | MB_ICONWARNING); } else { CloseHandle(pi.hThread); CloseHandle(pi.hProcess); @@ -4199,12 +4205,14 @@ if (CreateProcess(NULL, Command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) == 0) { - char buf[80]; - get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile); - get_lang_msg("MSG_EXEC_TT_ERROR", ts.UIMsg, sizeof(ts.UIMsg), - "Can't execute Tera Term. (%d)", ts.UILanguageFile); - _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, GetLastError()); - ::MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONWARNING); + wchar_t buf[80]; + wchar_t uimsgW[MAX_UIMSG]; + wchar_t uimsgW2[MAX_UIMSG]; + get_lang_msgW("MSG_ERROR", uimsgW, _countof(uimsgW), L"ERROR", ts.UILanguageFile); + get_lang_msgW("MSG_EXEC_TT_ERROR", uimsgW2, _countof(uimsgW2), + L"Can't execute Tera Term. (%d)", ts.UILanguageFile); + _snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsgW2, GetLastError()); + _MessageBoxW(NULL, buf, uimsgW, MB_OK | MB_ICONWARNING); } else { CloseHandle(pi.hThread); CloseHandle(pi.hProcess); @@ -4357,7 +4365,7 @@ data->UILanguageFile); get_lang_msgW("MSG_CANTOPEN_FILE_ERROR", message, _countof(message), L"Cannot open file", data->UILanguageFile); - MessageBoxW(hDlgWnd, message, caption, MB_TASKMODAL | MB_ICONEXCLAMATION); + _MessageBoxW(hDlgWnd, message, caption, MB_TASKMODAL | MB_ICONEXCLAMATION); free(strW); @@ -4591,9 +4599,10 @@ if ((cv.PortType==IdTCPIP) && ((ts.PortFlag & PF_CONFIRMDISCONN) != 0) && (confirm)) { - get_lang_msg("MSG_DISCONNECT_CONF", ts.UIMsg, sizeof(ts.UIMsg), - "Disconnect?", ts.UILanguageFile); - if (::MessageBox(HVTWin, ts.UIMsg, "Tera Term", + wchar_t uimsg[MAX_UIMSG]; + get_lang_msgW("MSG_DISCONNECT_CONF", uimsg, _countof(uimsg), + L"Disconnect?", ts.UILanguageFile); + if (_MessageBoxW(HVTWin, uimsg, L"Tera Term", MB_OKCANCEL | MB_ICONEXCLAMATION | MB_DEFBUTTON2)==IDCANCEL) { return; } @@ -5014,11 +5023,12 @@ // \x8F\x91\x82\xAB\x8D\x9E\x82݂ł\xAB\x82邩\x82̔\xBB\x95ʂ\xF0\x92lj\xC1 (2005.11.3 yutaka) if ((ret = _access(ts.SetupFName, 0x02)) != 0) { if (errno != ENOENT) { // \x83t\x83@\x83C\x83\x8B\x82\xAA\x82\xB7\x82łɑ\xB6\x8D݂\xB7\x82\xE9\x8Fꍇ\x82̂݃G\x83\x89\x81[\x82Ƃ\xB7\x82\xE9 (2005.12.13 yutaka) - char uimsg[MAX_UIMSG]; - get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: ERROR", ts.UILanguageFile); - get_lang_msg("MSG_SAVESETUP_PERMISSION_ERROR", ts.UIMsg, sizeof(ts.UIMsg), - "TERATERM.INI file doesn't have the writable permission.", ts.UILanguageFile); - MessageBox(ts.UIMsg, uimsg, MB_OK|MB_ICONEXCLAMATION); + wchar_t uimsg[MAX_UIMSG]; + wchar_t uimsg2[MAX_UIMSG]; + get_lang_msgW("MSG_TT_ERROR", uimsg, _countof(uimsg), L"Tera Term: ERROR", ts.UILanguageFile); + get_lang_msgW("MSG_SAVESETUP_PERMISSION_ERROR", uimsg2, _countof(uimsg2), + L"TERATERM.INI file doesn't have the writable permission.", ts.UILanguageFile); + _MessageBoxW(HVTWin, uimsg2, uimsg, MB_OK|MB_ICONEXCLAMATION); return; } } @@ -5085,8 +5095,9 @@ STARTUPINFO si; PROCESS_INFORMATION pi; BOOL ret = FALSE; - char buf[80]; - char uimsg[MAX_UIMSG]; + wchar_t buf[80]; + wchar_t uimsg[MAX_UIMSG]; + wchar_t uimsg2[MAX_UIMSG]; SetLastError(NO_ERROR); @@ -5093,11 +5104,11 @@ _snprintf_s(fullpath, sizeof(fullpath), "%s\\%s", pathname, filename); if (_access(fullpath, 0) != 0) { // \x83t\x83@\x83C\x83\x8B\x82\xAA\x91\xB6\x8D݂\xB5\x82Ȃ\xA2 DWORD no = GetLastError(); - get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile); - get_lang_msg("DLG_SETUPDIR_NOFILE_ERROR", ts.UIMsg, sizeof(ts.UIMsg), - "File does not exist.(%d)", ts.UILanguageFile); - _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, no); - ::MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONWARNING); + get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile); + get_lang_msgW("DLG_SETUPDIR_NOFILE_ERROR", uimsg2, _countof(uimsg2), + L"File does not exist.(%d)", ts.UILanguageFile); + _snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg2, no); + _MessageBoxW(NULL, buf, uimsg, MB_OK | MB_ICONWARNING); goto error; } @@ -5110,11 +5121,11 @@ if (CreateProcess(NULL, command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) == 0) { // \x8BN\x93\xAE\x8E\xB8\x94s DWORD no = GetLastError(); - get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile); - get_lang_msg("DLG_SETUPDIR_OPENFILE_ERROR", ts.UIMsg, sizeof(ts.UIMsg), - "Cannot open file.(%d)", ts.UILanguageFile); - _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, no); - ::MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONWARNING); + get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile); + get_lang_msgW("DLG_SETUPDIR_OPENFILE_ERROR", uimsg2, _countof(uimsg2), + L"Cannot open file.(%d)", ts.UILanguageFile); + _snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg2, no); + _MessageBoxW(NULL, buf, uimsg, MB_OK | MB_ICONWARNING); goto error; } else { CloseHandle(pi.hThread); From scmnotify @ osdn.net Sun Jan 19 00:16:29 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Sun, 19 Jan 2020 00:16:29 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0ODhdIGdldGVudigpIOOCkiBfZHVwZW52?= =?utf-8?b?X3MoKSDjgavnva7jgY3mj5vjgYg=?= Message-ID: <1579360589.928610.13161.nullmailer@users.osdn.me> Revision: 8488 https://osdn.net/projects/ttssh2/scm/svn/commits/8488 Author: zmatsuo Date: 2020-01-19 00:16:29 +0900 (Sun, 19 Jan 2020) Log Message: ----------- getenv() を _dupenv_s() に置き換え Modified Paths: -------------- trunk/teraterm/teraterm/vtwin.cpp -------------- next part -------------- Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2020-01-18 15:16:20 UTC (rev 8487) +++ trunk/teraterm/teraterm/vtwin.cpp 2020-01-18 15:16:29 UTC (rev 8488) @@ -3940,7 +3940,7 @@ return; found_dll:; - envptr = getenv("PATH"); + _dupenv_s(&envptr, NULL, "PATH"); file[strlen(file)-12] = '\0'; // delete "\\cygwin1.dll" if (envptr != NULL) { envbufflen = strlen(file) + strlen(envptr) + 7; // "PATH="(5) + ";"(1) + NUL(1) @@ -3949,9 +3949,11 @@ get_lang_msgW("MSG_CYGTERM_ENV_ALLOC_ERROR", uimsg2, _countof(uimsg2), L"Can't allocate memory for environment variable.", ts.UILanguageFile); _MessageBoxW(NULL, uimsg2, uimsg, MB_OK | MB_ICONWARNING); + free(envptr); return; } _snprintf_s(envbuff, envbufflen, _TRUNCATE, "PATH=%s;%s", file, envptr); + free(envptr); } else { envbufflen = strlen(file) + 6; // "PATH="(5) + NUL(1) if ((envbuff = (char *)malloc(envbufflen)) == NULL) { From scmnotify @ osdn.net Sun Jan 19 00:16:38 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Sun, 19 Jan 2020 00:16:38 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0ODldIOOCpuOCo+ODs+ODieOCpuOBrg==?= =?utf-8?b?6YCP6YGO5bqm44OE44O844Or44OB44OD44OX44KS5aSa6KiA6Kqe5YyW44GX?= =?utf-8?b?44Gf?= Message-ID: <1579360598.093946.13232.nullmailer@users.osdn.me> Revision: 8489 https://osdn.net/projects/ttssh2/scm/svn/commits/8489 Author: zmatsuo Date: 2020-01-19 00:16:37 +0900 (Sun, 19 Jan 2020) Log Message: ----------- ウィンドウの透過度ツールチップを多言語化した - vtwin.cpp 内で TCHAR を使用しなくなった Modified Paths: -------------- trunk/teraterm/teraterm/vtwin.cpp -------------- next part -------------- Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2020-01-18 15:16:29 UTC (rev 8488) +++ trunk/teraterm/teraterm/vtwin.cpp 2020-01-18 15:16:37 UTC (rev 8489) @@ -65,7 +65,6 @@ #include #include #include -#include #include #include @@ -451,7 +450,7 @@ TOKEN_ELEVATION tokenElevation; LONG lRet; HKEY hKey; - TCHAR lpData[256]; + char lpData[256]; DWORD dwDataSize; DWORD dwType; BYTE bValue; @@ -1174,11 +1173,11 @@ SetDlgMenuTexts(HelpMenu, HelpMenuTextInfo, _countof(HelpMenuTextInfo), ts.UILanguageFile); if ((ts.MenuFlag & MF_SHOWWINMENU) !=0) { - TCHAR uimsg[MAX_UIMSG]; + char uimsg[MAX_UIMSG]; WinMenu = CreatePopupMenu(); get_lang_msgT("MENU_WINDOW", uimsg, _countof(uimsg), - _T("&Window"), ts.UILanguageFile); - ::InsertMenu(hMenu, ID_HELPMENU, + "&Window", ts.UILanguageFile); + ::InsertMenuA(hMenu, ID_HELPMENU, MF_STRING | MF_ENABLED | MF_POPUP | MF_BYPOSITION, (UINT_PTR)WinMenu, uimsg); } @@ -2395,8 +2394,8 @@ if (InTitleBar) { int delta = zDelta < 0 ? -1 : 1; int newAlpha = Alpha; - TCHAR tipbuf[32]; - TCHAR uimsg[MAX_UIMSG]; + wchar_t tipbuf[32]; + wchar_t uimsg[MAX_UIMSG]; POINT tippos; newAlpha += delta * ts.MouseWheelScrollLine; @@ -2406,8 +2405,8 @@ newAlpha = 0; SetWindowAlpha(newAlpha); - get_lang_msg("TOOLTIP_TITLEBAR_OPACITY", uimsg, sizeof(uimsg), "Opacity %.1f %%", ts.UILanguageFile); - _stprintf_s(tipbuf, _countof(tipbuf), uimsg, (newAlpha / 255.0) * 100); + get_lang_msgW("TOOLTIP_TITLEBAR_OPACITY", uimsg, sizeof(uimsg), L"Opacity %.1f %%", ts.UILanguageFile); + _snwprintf_s(tipbuf, _countof(tipbuf), uimsg, (newAlpha / 255.0) * 100); tippos = TipWin->GetPos(); if (tippos.x != pt.x || From scmnotify @ osdn.net Sun Jan 19 01:12:09 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Sun, 19 Jan 2020 01:12:09 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0OTBdIFdpbmRvd+ODoeODi+ODpeODvA==?= =?utf-8?b?44KS5aSa6KiA6Kqe5YyW?= Message-ID: <1579363929.750168.20476.nullmailer@users.osdn.me> Revision: 8490 https://osdn.net/projects/ttssh2/scm/svn/commits/8490 Author: zmatsuo Date: 2020-01-19 01:12:09 +0900 (Sun, 19 Jan 2020) Log Message: ----------- Windowメニューを多言語化 - pInsertMenuW() を追加 Modified Paths: -------------- trunk/teraterm/common/compat_win.cpp trunk/teraterm/common/compat_win.h trunk/teraterm/common/layer_for_unicode.cpp trunk/teraterm/common/layer_for_unicode.h trunk/teraterm/teraterm/vtwin.cpp -------------- next part -------------- Modified: trunk/teraterm/common/compat_win.cpp =================================================================== --- trunk/teraterm/common/compat_win.cpp 2020-01-18 15:16:37 UTC (rev 8489) +++ trunk/teraterm/common/compat_win.cpp 2020-01-18 16:12:09 UTC (rev 8490) @@ -71,6 +71,9 @@ HWND (WINAPI *pHtmlHelpW)(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData); HWND (WINAPI *pHtmlHelpA)(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData); +BOOL (WINAPI *pInsertMenuW)(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); +BOOL (WINAPI *pAppendMenuW)(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); + /** * GetConsoleWindow() \x82Ɠ\xAF\x82\xB6\x93\xAE\x8D\xEC\x82\xF0\x82\xB7\x82\xE9 * https://support.microsoft.com/ja-jp/help/124103/how-to-obtain-a-console-window-handle-hwnd @@ -126,6 +129,8 @@ { "SendDlgItemMessageW", (void **)&pSendDlgItemMessageW }, { "MessageBoxW", (void **)&pMessageBoxW }, { "DialogBoxIndirectParamW", (void **)&pDialogBoxIndirectParamW }, + { "InsertMenuW", (void **)&pInsertMenuW }, + { "AppendMenuW", (void **)&pAppendMenuW }, {}, }; @@ -199,6 +204,7 @@ pSetWindowTextW = NULL; pSetDlgItemTextW = NULL; pGetDlgItemTextW = NULL; + pDialogBoxIndirectParamW = NULL; } // GetConsoleWindow\x93\xC1\x95ʏ\x88\x97\x9D Modified: trunk/teraterm/common/compat_win.h =================================================================== --- trunk/teraterm/common/compat_win.h 2020-01-18 15:16:37 UTC (rev 8489) +++ trunk/teraterm/common/compat_win.h 2020-01-18 16:12:09 UTC (rev 8490) @@ -102,6 +102,8 @@ extern INT_PTR (WINAPI *pDialogBoxIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam); extern HWND (WINAPI *pHtmlHelpW)(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData); extern HWND (WINAPI *pHtmlHelpA)(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData); +extern BOOL (WINAPI *pInsertMenuW)(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); +extern BOOL (WINAPI *pAppendMenuW)(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); #ifdef UNICODE #define pAddFontResourceEx pAddFontResourceExW Modified: trunk/teraterm/common/layer_for_unicode.cpp =================================================================== --- trunk/teraterm/common/layer_for_unicode.cpp 2020-01-18 15:16:37 UTC (rev 8489) +++ trunk/teraterm/common/layer_for_unicode.cpp 2020-01-18 16:12:09 UTC (rev 8490) @@ -316,3 +316,16 @@ free(captionA); return result; } + +BOOL _InsertMenuW(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem) +{ + if (pInsertMenuW != NULL) { + return pInsertMenuW(hMenu, uPosition, uFlags, uIDNewItem, lpNewItem); + } + + char *itemA = ToCharW(lpNewItem); + int result = InsertMenuA(hMenu, uPosition, uFlags, uIDNewItem, itemA); + free(itemA); + return result; +} + Modified: trunk/teraterm/common/layer_for_unicode.h =================================================================== --- trunk/teraterm/common/layer_for_unicode.h 2020-01-18 15:16:37 UTC (rev 8489) +++ trunk/teraterm/common/layer_for_unicode.h 2020-01-18 16:12:09 UTC (rev 8490) @@ -55,6 +55,7 @@ ATOM _RegisterClassW(const WNDCLASSW *lpWndClass); int _DrawTextW(HDC hdc, LPCWSTR lpchText, int cchText, LPRECT lprc, UINT format); int _MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType); +BOOL _InsertMenuW(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); #ifdef __cplusplus } Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2020-01-18 15:16:37 UTC (rev 8489) +++ trunk/teraterm/teraterm/vtwin.cpp 2020-01-18 16:12:09 UTC (rev 8490) @@ -1173,13 +1173,13 @@ SetDlgMenuTexts(HelpMenu, HelpMenuTextInfo, _countof(HelpMenuTextInfo), ts.UILanguageFile); if ((ts.MenuFlag & MF_SHOWWINMENU) !=0) { - char uimsg[MAX_UIMSG]; + wchar_t uimsg[MAX_UIMSG]; WinMenu = CreatePopupMenu(); - get_lang_msgT("MENU_WINDOW", uimsg, _countof(uimsg), - "&Window", ts.UILanguageFile); - ::InsertMenuA(hMenu, ID_HELPMENU, - MF_STRING | MF_ENABLED | MF_POPUP | MF_BYPOSITION, - (UINT_PTR)WinMenu, uimsg); + get_lang_msgW("MENU_WINDOW", uimsg, _countof(uimsg), + L"&Window", ts.UILanguageFile); + _InsertMenuW(hMenu, ID_HELPMENU, + MF_STRING | MF_ENABLED | MF_POPUP | MF_BYPOSITION, + (UINT_PTR)WinMenu, uimsg); } TTXModifyMenu(hMenu); /* TTPLUG */ From scmnotify @ osdn.net Mon Jan 20 11:01:25 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Mon, 20 Jan 2020 11:01:25 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0OTFdIHN2bjppZ25vcmUg5bGe5oCn44KS?= =?utf-8?b?6L+95Yqg?= Message-ID: <1579485685.910696.54616.nullmailer@users.osdn.me> Revision: 8491 https://osdn.net/projects/ttssh2/scm/svn/commits/8491 Author: doda Date: 2020-01-20 11:01:25 +0900 (Mon, 20 Jan 2020) Log Message: ----------- svn:ignore 属性を追加 Property Changed: ---------------- trunk/TTXSamples/TTXCheckUpdate/ -------------- next part -------------- Index: trunk/TTXSamples/TTXCheckUpdate =================================================================== --- trunk/TTXSamples/TTXCheckUpdate 2020-01-18 16:12:09 UTC (rev 8490) +++ trunk/TTXSamples/TTXCheckUpdate 2020-01-20 02:01:25 UTC (rev 8491) Property changes on: trunk/TTXSamples/TTXCheckUpdate ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,8 ## +[Rr]elease +[Dd]ebug +*.ncb +*.suo +*.aps +*.vcproj.*.user +*.vcxproj.*.user +*.vcxproj.user From scmnotify @ osdn.net Mon Jan 20 11:43:09 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Mon, 20 Jan 2020 11:43:09 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0OTJdIOODk+ODq+ODieaZguOBq+eUnw==?= =?utf-8?b?5oiQ44GV44KM44KL44OQ44Kk44OK44OqL+OCouODvOOCq+OCpOODluOCkg==?= =?utf-8?b?5YmK6Zmk?= Message-ID: <1579488189.168069.20180.nullmailer@users.osdn.me> Revision: 8492 https://osdn.net/projects/ttssh2/scm/svn/commits/8492 Author: doda Date: 2020-01-20 11:43:08 +0900 (Mon, 20 Jan 2020) Log Message: ----------- ビルド時に生成されるバイナリ/アーカイブを削除 誤コミットの原因となる為 Removed Paths: ------------- trunk/cygterm/cyglaunch.exe trunk/cygterm/cygterm+.tar.gz trunk/cygterm/cygterm.exe -------------- next part -------------- Deleted: trunk/cygterm/cyglaunch.exe =================================================================== (Binary files differ) Deleted: trunk/cygterm/cygterm+.tar.gz =================================================================== (Binary files differ) Deleted: trunk/cygterm/cygterm.exe =================================================================== (Binary files differ) From scmnotify @ osdn.net Tue Jan 21 09:38:13 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Tue, 21 Jan 2020 09:38:13 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0OTNdIOODm+OCueODiOODgOOCpOOCog==?= =?utf-8?b?44Ot44Kw44Gu44K144Kk44K66Kq/5pW0?= Message-ID: <1579567093.861829.138459.nullmailer@users.osdn.me> Revision: 8493 https://osdn.net/projects/ttssh2/scm/svn/commits/8493 Author: doda Date: 2020-01-21 09:38:12 +0900 (Tue, 21 Jan 2020) Log Message: ----------- ホストダイアログのサイズ調整 ML: [Ttssh2-devel 4467] 問題: 画面の拡大率やダイアログフォントの設定によっては、「新しい接続」 ダイアログの「IPバージョンの」の I の上部が欠けたりする。 対処: ダイアログ内のコントロールの位置およびサイズを調整した。 Modified Paths: -------------- trunk/ttssh2/ttxssh/ttxssh.rc -------------- next part -------------- Modified: trunk/ttssh2/ttxssh/ttxssh.rc =================================================================== --- trunk/ttssh2/ttxssh/ttxssh.rc 2020-01-20 02:43:08 UTC (rev 8492) +++ trunk/ttssh2/ttxssh/ttxssh.rc 2020-01-21 00:38:12 UTC (rev 8493) @@ -102,10 +102,10 @@ CONTROL "Other",IDC_HOSTOTHER,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,95,58,38,8 RTEXT "TCP &port#:",IDC_HOSTTCPPORTLABEL,144,30,51,8,NOT WS_GROUP EDITTEXT IDC_HOSTTCPPORT,198,28,30,12,ES_NUMBER | WS_GROUP - RTEXT "SSH &version:",IDC_SSH_VERSION_LABEL,124,46,61,8 - COMBOBOX IDC_SSH_VERSION,188,45,40,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - RTEXT "IP versio&n:",IDC_HOSTTCPPROTOCOLLABEL,126,63,56,8 - COMBOBOX IDC_HOSTTCPPROTOCOL,185,62,44,43,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + RTEXT "SSH &version:",IDC_SSH_VERSION_LABEL,129,46,61,8 + COMBOBOX IDC_SSH_VERSION,193,45,35,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + RTEXT "IP versio&n:",IDC_HOSTTCPPROTOCOLLABEL,134,63,56,8 + COMBOBOX IDC_HOSTTCPPROTOCOL,193,62,35,43,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP RTEXT "Po&rt:",IDC_HOSTCOMLABEL,58,89,34,8,NOT WS_GROUP COMBOBOX IDC_HOSTCOM,95,87,133,46,CBS_DROPDOWNLIST | WS_VSCROLL | WS_GROUP | WS_TABSTOP DEFPUSHBUTTON "OK",IDOK,60,109,32,14,WS_GROUP From scmnotify @ osdn.net Wed Jan 22 22:53:23 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Wed, 22 Jan 2020 22:53:23 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0OTRdIGNvbW1vbl9zdGF0aWMg44OX44Ot?= =?utf-8?b?44K444Kn44Kv44OI44KS6L+95Yqg?= Message-ID: <1579701203.636460.105492.nullmailer@users.osdn.me> Revision: 8494 https://osdn.net/projects/ttssh2/scm/svn/commits/8494 Author: zmatsuo Date: 2020-01-22 22:53:23 +0900 (Wed, 22 Jan 2020) Log Message: ----------- common_static プロジェクトを追加 - 各プロジェクトにスタティクにリンクされるソースをまとめたプロジェクト - layer_for_unicode などを利用しやすくする - layer_for_unicode.cpp に _AppendMenuW(), _HtmlHelpW() 追加 - comctl32.dll(lib)に依存する関数を別ソースに分離 - layer_for_unicode.cpp の一部を layer_for_unicode_comctl32.cpp に分離 - tmfc.cpp の一部を tmfc_property.cpp に分離 Modified Paths: -------------- trunk/teraterm/CMakeLists.txt trunk/teraterm/common/layer_for_unicode.cpp trunk/teraterm/common/layer_for_unicode.h trunk/teraterm/common/tmfc.cpp trunk/teraterm/ttermpro.sln trunk/teraterm/ttermpro.v16.sln Added Paths: ----------- trunk/teraterm/common/CMakeLists.txt trunk/teraterm/common/common_static.v16.vcxproj trunk/teraterm/common/common_static.v8.vcproj trunk/teraterm/common/layer_for_unicode_comctl32.cpp trunk/teraterm/common/tmfc_property.cpp -------------- next part -------------- Modified: trunk/teraterm/CMakeLists.txt =================================================================== --- trunk/teraterm/CMakeLists.txt 2020-01-21 00:38:12 UTC (rev 8493) +++ trunk/teraterm/CMakeLists.txt 2020-01-22 13:53:23 UTC (rev 8494) @@ -33,3 +33,9 @@ set_target_properties( keycode PROPERTIES FOLDER teraterm) + +add_subdirectory(common) +set_target_properties( + common_static + PROPERTIES FOLDER teraterm) + Added: trunk/teraterm/common/CMakeLists.txt =================================================================== --- trunk/teraterm/common/CMakeLists.txt (rev 0) +++ trunk/teraterm/common/CMakeLists.txt 2020-01-22 13:53:23 UTC (rev 8494) @@ -0,0 +1,27 @@ +project(teraterm) + +add_library( + common_static + STATIC + codeconv.cpp + codeconv.h + compat_win.cpp + compat_win.h + dllutil.cpp + dllutil.h + i18n.c + i18n.h + layer_for_unicode.cpp + layer_for_unicode.h + layer_for_unicode_comctl32.cpp + tmfc.cpp + tmfc.h + tmfc_frame.cpp + tmfc_property.cpp + ) + +target_include_directories( + common_static + PRIVATE + . + ) Added: trunk/teraterm/common/common_static.v16.vcxproj =================================================================== --- trunk/teraterm/common/common_static.v16.vcxproj (rev 0) +++ trunk/teraterm/common/common_static.v16.vcxproj 2020-01-22 13:53:23 UTC (rev 8494) @@ -0,0 +1,155 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + common_static + common_static + 10.0 + {AC42387D-23EC-45DB-81F9-8933C7EFA52A} + + + + StaticLibrary + v142 + false + + + StaticLibrary + v142 + false + + + + + + + + + + + + + <_ProjectFileVersion>12.0.30501.0 + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + false + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + false + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)$(ProjectName).tlb + + + + /D"_CRT_SECURE_NO_DEPRECATE" %(AdditionalOptions) + MaxSpeed + OnlyExplicitInline + $(SolutionDir)common;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreaded + true + Level3 + true + Default + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + $(SolutionDir)common;%(AdditionalIncludeDirectories) + + + setupapi.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + $(ProjectName).def + setupapi.dll;user32.dll;%(DelayLoadDLLs) + true + Windows + $(OutDir)$(ProjectName).lib + MachineX86 + false + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)$(ProjectName).tlb + + + + /D"_CRT_SECURE_NO_DEPRECATE" %(AdditionalOptions) + Disabled + $(SolutionDir)common;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDebug + Level3 + true + ProgramDatabase + Default + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + $(SolutionDir)common;%(AdditionalIncludeDirectories) + + + setupapi.lib;%(AdditionalDependencies) + true + %(AdditionalLibraryDirectories) + $(ProjectName).def + setupapi.dll;user32.dll;%(DelayLoadDLLs) + true + Windows + $(OutDir)$(ProjectName).lib + MachineX86 + false + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Added: trunk/teraterm/common/common_static.v8.vcproj =================================================================== --- trunk/teraterm/common/common_static.v8.vcproj (rev 0) +++ trunk/teraterm/common/common_static.v8.vcproj 2020-01-22 13:53:23 UTC (rev 8494) @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: trunk/teraterm/common/layer_for_unicode.cpp =================================================================== --- trunk/teraterm/common/layer_for_unicode.cpp 2020-01-21 00:38:12 UTC (rev 8493) +++ trunk/teraterm/common/layer_for_unicode.cpp 2020-01-22 13:53:23 UTC (rev 8494) @@ -142,62 +142,6 @@ return retval; } -HPROPSHEETPAGE _CreatePropertySheetPageW(LPCPROPSHEETPAGEW_V1 psp) -{ - if (pCreatePropertySheetPageW != NULL) { - return pCreatePropertySheetPageW((LPCPROPSHEETPAGEW)psp); - } - - char *titleA = ToCharW(psp->pszTitle); - - PROPSHEETPAGEA_V1 pspA; - memset(&pspA, 0, sizeof(pspA)); - pspA.dwSize = sizeof(pspA); - pspA.dwFlags = psp->dwFlags; - pspA.hInstance = psp->hInstance; - pspA.pResource = psp->pResource; - pspA.pszTitle = titleA; - pspA.pfnDlgProc = psp->pfnDlgProc; - pspA.lParam = psp->lParam; - - HPROPSHEETPAGE retval = CreatePropertySheetPageA((LPCPROPSHEETPAGEA)&pspA); - - free(titleA); - return retval; -} - -// \x83\x8A\x83\x8A\x81[\x83X\x97pSDK\x82̃w\x83b\x83_\x82\xC9 -// PROPSHEETHEADERW_V1 \x82\xAA\x82Ȃ\xA2\x82\xBD\x82\xDF -// PROPSHEETHEADERW \x82\xF0\x8Eg\x97p -// SDK: Windows Server 2003 R2 Platform SDK -// (Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1) -//INT_PTR _PropertySheetW(PROPSHEETHEADERW_V1 *psh) -INT_PTR _PropertySheetW(PROPSHEETHEADERW *psh) -{ - if (pPropertySheetW != NULL) { - return pPropertySheetW((PROPSHEETHEADERW *)psh); - } - - char *captionA = ToCharW(psh->pszCaption); - -// PROPSHEETHEADERA_V1 pshA; - PROPSHEETHEADERA pshA; - memset(&pshA, 0, sizeof(pshA)); - pshA.dwSize = sizeof(pshA); - pshA.dwFlags = psh->dwFlags; - pshA.hwndParent = psh->hwndParent; - pshA.hInstance = psh->hInstance; - pshA.pszCaption = captionA; - pshA.nPages = psh->nPages; - pshA.phpage = psh->phpage; - pshA.pfnCallback = psh->pfnCallback; - - INT_PTR retval = PropertySheetA(&pshA); - - free(captionA); - return retval; -} - HWND _CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam) { @@ -329,3 +273,27 @@ return result; } +HWND _HtmlHelpW(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData) +{ + if (pHtmlHelpW != NULL) { + return pHtmlHelpW(hwndCaller, pszFile, uCommand, dwData); + } + if (pHtmlHelpA != NULL) { + char *fileA = ToCharW(pszFile); + HWND result = pHtmlHelpA(hwndCaller, fileA, uCommand, dwData); + free(fileA); + return result; + } + return NULL; +} + +BOOL _AppendMenuW(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem) +{ + if (pAppendMenuW != NULL) { + return pAppendMenuW(hMenu, uFlags, uIDNewItem, lpNewItem); + } + char *itemA = ToCharW(lpNewItem); + BOOL result = AppendMenuA(hMenu, uFlags, uIDNewItem, itemA); + free(itemA); + return result; +} Modified: trunk/teraterm/common/layer_for_unicode.h =================================================================== --- trunk/teraterm/common/layer_for_unicode.h 2020-01-21 00:38:12 UTC (rev 8493) +++ trunk/teraterm/common/layer_for_unicode.h 2020-01-22 13:53:23 UTC (rev 8494) @@ -46,9 +46,6 @@ DWORD _GetFileAttributesW(LPCWSTR lpFileName); UINT _DragQueryFileW(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch); LRESULT _SendDlgItemMessageW(HWND hDlg, int nIDDlgItem, UINT Msg, WPARAM wParam, LPARAM lParam); -HPROPSHEETPAGE _CreatePropertySheetPageW(LPCPROPSHEETPAGEW_V1 constPropSheetPagePointer); -INT_PTR _PropertySheetW(PROPSHEETHEADERW *constPropSheetHeaderPointer); -//INT_PTR _PropertySheetW(PROPSHEETHEADERW_V1 *constPropSheetHeaderPointer); HWND _CreateWindowExW(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam); @@ -56,7 +53,14 @@ int _DrawTextW(HDC hdc, LPCWSTR lpchText, int cchText, LPRECT lprc, UINT format); int _MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType); BOOL _InsertMenuW(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); +BOOL _AppendMenuW(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); +HWND _HtmlHelpW(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData); +// Comctl32.lib +HPROPSHEETPAGE _CreatePropertySheetPageW(LPCPROPSHEETPAGEW_V1 constPropSheetPagePointer); +INT_PTR _PropertySheetW(PROPSHEETHEADERW *constPropSheetHeaderPointer); +//INT_PTR _PropertySheetW(PROPSHEETHEADERW_V1 *constPropSheetHeaderPointer); + #ifdef __cplusplus } #endif Added: trunk/teraterm/common/layer_for_unicode_comctl32.cpp =================================================================== --- trunk/teraterm/common/layer_for_unicode_comctl32.cpp (rev 0) +++ trunk/teraterm/common/layer_for_unicode_comctl32.cpp 2020-01-22 13:53:23 UTC (rev 8494) @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2019-2020 TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + /* + * W to A Wrapper + * + * API\x96\xBC\x82\xCDW\x94ł̓\xAA\x82\xC9 '_' \x82\xF0\x95t\x82\xAF\x82\xBD\x82\xE0\x82̂\xF0\x8Eg\x97p\x82\xB7\x82\xE9 + */ + +#include + +#include "codeconv.h" +#include "compat_win.h" + +#include "layer_for_unicode.h" + +HPROPSHEETPAGE _CreatePropertySheetPageW(LPCPROPSHEETPAGEW_V1 psp) +{ + if (pCreatePropertySheetPageW != NULL) { + return pCreatePropertySheetPageW((LPCPROPSHEETPAGEW)psp); + } + + char *titleA = ToCharW(psp->pszTitle); + + PROPSHEETPAGEA_V1 pspA; + memset(&pspA, 0, sizeof(pspA)); + pspA.dwSize = sizeof(pspA); + pspA.dwFlags = psp->dwFlags; + pspA.hInstance = psp->hInstance; + pspA.pResource = psp->pResource; + pspA.pszTitle = titleA; + pspA.pfnDlgProc = psp->pfnDlgProc; + pspA.lParam = psp->lParam; + + HPROPSHEETPAGE retval = CreatePropertySheetPageA((LPCPROPSHEETPAGEA)&pspA); + + free(titleA); + return retval; +} + +// \x83\x8A\x83\x8A\x81[\x83X\x97pSDK\x82̃w\x83b\x83_\x82\xC9 +// PROPSHEETHEADERW_V1 \x82\xAA\x82Ȃ\xA2\x82\xBD\x82\xDF +// PROPSHEETHEADERW \x82\xF0\x8Eg\x97p +// SDK: Windows Server 2003 R2 Platform SDK +// (Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1) +//INT_PTR _PropertySheetW(PROPSHEETHEADERW_V1 *psh) +INT_PTR _PropertySheetW(PROPSHEETHEADERW *psh) +{ + if (pPropertySheetW != NULL) { + return pPropertySheetW((PROPSHEETHEADERW *)psh); + } + + char *captionA = ToCharW(psh->pszCaption); + +// PROPSHEETHEADERA_V1 pshA; + PROPSHEETHEADERA pshA; + memset(&pshA, 0, sizeof(pshA)); + pshA.dwSize = sizeof(pshA); + pshA.dwFlags = psh->dwFlags; + pshA.hwndParent = psh->hwndParent; + pshA.hInstance = psh->hInstance; + pshA.pszCaption = captionA; + pshA.nPages = psh->nPages; + pshA.phpage = psh->phpage; + pshA.pfnCallback = psh->pfnCallback; + + INT_PTR retval = PropertySheetA(&pshA); + + free(captionA); + return retval; +} + Modified: trunk/teraterm/common/tmfc.cpp =================================================================== --- trunk/teraterm/common/tmfc.cpp 2020-01-21 00:38:12 UTC (rev 8493) +++ trunk/teraterm/common/tmfc.cpp 2020-01-22 13:53:23 UTC (rev 8494) @@ -590,6 +590,7 @@ } } +#if 0 //////////////////////////////////////// // quick hack :-( @@ -790,3 +791,4 @@ void TTCPropertySheet::OnInitDialog() { } +#endif Added: trunk/teraterm/common/tmfc_property.cpp =================================================================== --- trunk/teraterm/common/tmfc_property.cpp (rev 0) +++ trunk/teraterm/common/tmfc_property.cpp 2020-01-22 13:53:23 UTC (rev 8494) @@ -0,0 +1,243 @@ +/* + * Copyright (C) 2018-2020 TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Tera term Micro Framework class + * \x83v\x83\x8D\x83p\x83e\x83B\x83_\x83C\x83A\x83\x8D\x83O + */ +#include "tmfc.h" + +#include +#include +#include "dlglib.h" +#include "ttlib.h" +#include "layer_for_unicode.h" + +// \x83e\x83\x93\x83v\x83\x8C\x81[\x83g\x82̏\x91\x82\xAB\x8A\xB7\x82\xA6\x82\xF0\x8Ds\x82\xA4 +#define REWRITE_TEMPLATE + +//////////////////////////////////////// + +// quick hack :-( +static HINSTANCE ghInstance; +static class TTCPropertySheet *gTTCPS; + +TTCPropertyPage::TTCPropertyPage(HINSTANCE inst, int id, TTCPropertySheet *sheet) +{ + memset(&m_psp, 0, sizeof(m_psp)); + m_psp.dwSize = sizeof(m_psp); + m_psp.dwFlags = PSP_DEFAULT; + m_psp.hInstance = inst; + m_psp.pszTemplate = MAKEINTRESOURCEW(id); +#if defined(REWRITE_TEMPLATE) + m_psp.dwFlags |= PSP_DLGINDIRECT; + m_psp.pResource = TTGetDlgTemplate(inst, MAKEINTRESOURCEA(id)); +#endif + m_psp.pfnDlgProc = Proc; + m_psp.lParam = (LPARAM)this; + + m_pSheet = sheet; +} + +TTCPropertyPage::~TTCPropertyPage() +{ + free((void *)m_psp.pResource); +} + +HPROPSHEETPAGE TTCPropertyPage::CreatePropertySheetPage() +{ + return ::_CreatePropertySheetPageW(&m_psp); +} + +void TTCPropertyPage::OnInitDialog() +{ +} + +void TTCPropertyPage::OnOK() +{ +} + +BOOL TTCPropertyPage::OnCommand(WPARAM wp, LPARAM lp) +{ + return TRUE; +} + +void TTCPropertyPage::OnHScroll(UINT nSBCode, UINT nPos, HWND pScrollBar) +{ +} + +HBRUSH TTCPropertyPage::OnCtlColor(HDC hDC, HWND hWnd) +{ + return (HBRUSH)::DefWindowProc(m_hWnd, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)hWnd); +} + +void TTCPropertyPage::OnHelp() +{ +} + +UINT CALLBACK TTCPropertyPage::PropSheetPageProc(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp) +{ + return 0; +} + +INT_PTR CALLBACK TTCPropertyPage::Proc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp) +{ + TTCPropertyPage *self = (TTCPropertyPage *)::GetWindowLongPtr(hDlgWnd, DWLP_USER); + switch (msg) + { + case WM_INITDIALOG: + self = (TTCPropertyPage *)(((PROPSHEETPAGE *)lp)->lParam); + ::SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)self); + self->m_hWnd = hDlgWnd; + self->OnInitDialog(); + break; + case WM_NOTIFY: + { + NMHDR * nmhdr = (NMHDR *)lp; + switch (nmhdr->code) + { + case PSN_APPLY: + self->OnOK(); + break; + case PSN_HELP: + self->OnHelp(); + break; + default: + break; + } + break; + } + case WM_COMMAND: + self->OnCommand(wp, lp); + break; + case WM_CTLCOLORSTATIC: + return (INT_PTR)self->OnCtlColor((HDC)wp, (HWND)lp); + case WM_HSCROLL: + self->OnHScroll(LOWORD(wp), HIWORD(wp), (HWND)lp); + break; + } + return FALSE; +} + +//////////////////////////////////////// + +TTCPropertySheet::TTCPropertySheet(HINSTANCE hInstance, HWND hParentWnd) +{ + m_hInst = hInstance; + m_hWnd = 0; + m_hParentWnd = hParentWnd; + memset(&m_psh, 0, sizeof(m_psh)); + m_psh.dwSize = sizeof(m_psh); + m_psh.dwFlags = PSH_DEFAULT | PSH_NOAPPLYNOW | PSH_USECALLBACK; // | PSH_MODELESS + //m_psh.dwFlags |= PSH_PROPTITLE; // \x81u\x82̃v\x83\x8D\x83p\x83e\x83B\x81[\x81v\x82\xAA\x92lj\xC1\x82\xB3\x82\xEA\x82\xE9? + m_psh.hwndParent = hParentWnd; + m_psh.hInstance = hInstance; + m_psh.pfnCallback = PropSheetProc; +} + +TTCPropertySheet::~TTCPropertySheet() +{ +} + +INT_PTR TTCPropertySheet::DoModal() +{ + ghInstance = m_hInst; + gTTCPS = this; + return _PropertySheetW(&m_psh); + + // \x83\x82\x81[\x83_\x83\x8C\x83X\x82ɂ\xB7\x82\xE9\x82ƃ^\x83u\x82̓\xAE\x82\xAB\x82\xAA\x82\xA8\x82\xA9\x82\xB5\x82\xA2 +#if 0 + // \x83\x82\x81[\x83h\x83\x8C\x83X\x83_\x83C\x83A\x83\x8D\x83O\x83{\x83b\x83N\x83X\x82̏ꍇ\x82̓E\x83B\x83\x93\x83h\x83E\x82̃n\x83\x93\x83h\x83\x8B + m_hWnd = (HWND)::PropertySheet(&m_psh); +// ShowWindow(m_hWnd, SW_SHOW); + +// ::ModifyStyle(m_hWnd, TCS_MULTILINE, TCS_SINGLELINE, 0); + + ModalResult = 0; + HWND hDlgWnd = m_hWnd; + for(;;) { + if (ModalResult != 0) { + break; + } + MSG Msg; + BOOL quit = !::GetMessage(&Msg, nullptr, nullptr, nullptr); + if (quit) { + // QM_QUIT + PostQuitMessage(0); + return IDCANCEL; + } + if ((hDlgWnd == Msg.hwnd) || + ::SendMessage(hDlgWnd, PSM_ISDIALOGMESSAGE, nullptr, (LPARAM)&Msg)) + { + // \x83_\x83C\x83A\x83\x8D\x83O\x88ȊO\x82̏\x88\x97\x9D + ::TranslateMessage(&Msg); + ::DispatchMessage(&Msg); + } + if (!SendMessage(hDlgWnd, PSM_GETCURRENTPAGEHWND, 0, 0)) { + // \x83v\x83\x8D\x83p\x83e\x83B\x81[\x83V\x81[\x83g\x8FI\x97\xB9 + break; + } + } + return ModalResult; +#endif +} + +int CALLBACK TTCPropertySheet::PropSheetProc(HWND hWnd, UINT msg, LPARAM lp) +{ + switch (msg) { + case PSCB_PRECREATE: + { +#if defined(REWRITE_TEMPLATE) + // \x83e\x83\x93\x83v\x83\x8C\x81[\x83g\x82̓\xE0\x97e\x82\xF0\x8F\x91\x82\xAB\x8A\xB7\x82\xA6\x82\xE9 \x8A댯 + // http://home.att.ne.jp/banana/akatsuki/doc/atlwtl/atlwtl15-01/index.html + size_t PrevTemplSize; + size_t NewTemplSize; + DLGTEMPLATE *NewTempl = + TTGetNewDlgTemplate(ghInstance, (DLGTEMPLATE *)lp, + &PrevTemplSize, &NewTemplSize); + NewTempl->style &= ~DS_CONTEXTHELP; // check DLGTEMPLATEEX + memcpy((void *)lp, NewTempl, NewTemplSize); + free(NewTempl); +#endif + break; + } + case PSCB_INITIALIZED: + { + //TTCPropertySheet *self = (TTCPropertySheet *)lp; + TTCPropertySheet *self = gTTCPS; + self->m_hWnd = hWnd; + self->OnInitDialog(); + break; + } + } + return 0; +} + +void TTCPropertySheet::OnInitDialog() +{ +} Modified: trunk/teraterm/ttermpro.sln =================================================================== --- trunk/teraterm/ttermpro.sln 2020-01-21 00:38:12 UTC (rev 8493) +++ trunk/teraterm/ttermpro.sln 2020-01-22 13:53:23 UTC (rev 8494) @@ -36,6 +36,8 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "svnrev", "svnrev\svnrev.vcproj", "{80F1C3F0-A213-4D48-85C8-A265990D19A7}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common_static", "common\common_static.v8.vcproj", "{DF4E3C36-A743-4FB4-8EE9-49899E69ED32}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -74,6 +76,10 @@ {80F1C3F0-A213-4D48-85C8-A265990D19A7}.Debug|Win32.Build.0 = Debug|Win32 {80F1C3F0-A213-4D48-85C8-A265990D19A7}.Release|Win32.ActiveCfg = Release|Win32 {80F1C3F0-A213-4D48-85C8-A265990D19A7}.Release|Win32.Build.0 = Release|Win32 + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32}.Debug|Win32.ActiveCfg = Debug|Win32 + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32}.Debug|Win32.Build.0 = Debug|Win32 + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32}.Release|Win32.ActiveCfg = Release|Win32 + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: trunk/teraterm/ttermpro.v16.sln =================================================================== --- trunk/teraterm/ttermpro.v16.sln 2020-01-21 00:38:12 UTC (rev 8493) +++ trunk/teraterm/ttermpro.v16.sln 2020-01-22 13:53:23 UTC (rev 8494) @@ -1,5 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 16 +# Visual Studio Version 16 VisualStudioVersion = 16.0.28803.156 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ttermpro", "teraterm\ttermpro.v16.vcxproj", "{BC4CDBE3-6269-47A8-BD74-EEB3A6160E06}" @@ -18,6 +18,8 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "svnrev", "svnrev\svnrev.v16.vcxproj", "{80F1C3F0-A213-4D48-85C8-A265990D19A7}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common_static", "common\common_static.v16.vcxproj", "{AC42387D-23EC-45DB-81F9-8933C7EFA52A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -56,6 +58,10 @@ {80F1C3F0-A213-4D48-85C8-A265990D19A7}.Debug|Win32.Build.0 = Debug|Win32 {80F1C3F0-A213-4D48-85C8-A265990D19A7}.Release|Win32.ActiveCfg = Release|Win32 {80F1C3F0-A213-4D48-85C8-A265990D19A7}.Release|Win32.Build.0 = Release|Win32 + {AC42387D-23EC-45DB-81F9-8933C7EFA52A}.Debug|Win32.ActiveCfg = Debug|Win32 + {AC42387D-23EC-45DB-81F9-8933C7EFA52A}.Debug|Win32.Build.0 = Debug|Win32 + {AC42387D-23EC-45DB-81F9-8933C7EFA52A}.Release|Win32.ActiveCfg = Release|Win32 + {AC42387D-23EC-45DB-81F9-8933C7EFA52A}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From scmnotify @ osdn.net Wed Jan 22 22:53:34 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Wed, 22 Jan 2020 22:53:34 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0OTVdIGNvbW1vbl9zdGF0aWMg44KSIHR0?= =?utf-8?b?ZXJtcHJvIOOBi+OCieODquODs+OCrw==?= Message-ID: <1579701214.055078.105671.nullmailer@users.osdn.me> Revision: 8495 https://osdn.net/projects/ttssh2/scm/svn/commits/8495 Author: zmatsuo Date: 2020-01-22 22:53:33 +0900 (Wed, 22 Jan 2020) Log Message: ----------- common_static を ttermpro からリンク Modified Paths: -------------- trunk/teraterm/teraterm/CMakeLists.txt trunk/teraterm/teraterm/ttermpro.v16.vcxproj trunk/teraterm/teraterm/ttermpro.v16.vcxproj.filters trunk/teraterm/ttermpro.sln -------------- next part -------------- Modified: trunk/teraterm/teraterm/CMakeLists.txt =================================================================== --- trunk/teraterm/teraterm/CMakeLists.txt 2020-01-22 13:53:23 UTC (rev 8494) +++ trunk/teraterm/teraterm/CMakeLists.txt 2020-01-22 13:53:33 UTC (rev 8495) @@ -218,6 +218,7 @@ target_link_libraries( teraterm + common_static ttpcmn ttpfile ttpset @@ -227,6 +228,7 @@ # gdi32 comctl32 + comctl32 ws2_32 imagehlp delayimp Modified: trunk/teraterm/teraterm/ttermpro.v16.vcxproj =================================================================== --- trunk/teraterm/teraterm/ttermpro.v16.vcxproj 2020-01-22 13:53:23 UTC (rev 8494) +++ trunk/teraterm/teraterm/ttermpro.v16.vcxproj 2020-01-22 13:53:33 UTC (rev 8495) @@ -264,6 +264,9 @@ + + {ac42387d-23ec-45db-81f9-8933c7efa52a} + {80f1c3f0-a213-4d48-85c8-a265990d19a7} @@ -296,4 +299,4 @@ - + \ No newline at end of file Modified: trunk/teraterm/teraterm/ttermpro.v16.vcxproj.filters =================================================================== --- trunk/teraterm/teraterm/ttermpro.v16.vcxproj.filters 2020-01-22 13:53:23 UTC (rev 8494) +++ trunk/teraterm/teraterm/ttermpro.v16.vcxproj.filters 2020-01-22 13:53:33 UTC (rev 8495) @@ -205,6 +205,12 @@ ttpdlg + + Source Files + + + Source Files + @@ -364,4 +370,4 @@ dialog - + \ No newline at end of file Modified: trunk/teraterm/ttermpro.sln =================================================================== --- trunk/teraterm/ttermpro.sln 2020-01-22 13:53:23 UTC (rev 8494) +++ trunk/teraterm/ttermpro.sln 2020-01-22 13:53:33 UTC (rev 8495) @@ -2,6 +2,7 @@ # Visual Studio 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ttermpro", "teraterm\ttermpro.vcproj", "{BC4CDBE3-6269-47A8-BD74-EEB3A6160E06}" ProjectSection(ProjectDependencies) = postProject + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} = {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} {BA519362-A2C2-4B1A-905B-F00791F9038A} = {BA519362-A2C2-4B1A-905B-F00791F9038A} {5CF58947-E861-4A5C-B0B1-E85486F149CD} = {5CF58947-E861-4A5C-B0B1-E85486F149CD} {6D08053B-1C68-4A7E-8766-3553F5AF010B} = {6D08053B-1C68-4A7E-8766-3553F5AF010B} From scmnotify @ osdn.net Wed Jan 22 22:53:43 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Wed, 22 Jan 2020 22:53:43 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0OTZdIGNvbW1vbl9zdGF0aWMg44KSIHR0?= =?utf-8?b?cGNtbiDjgYvjgonjg6rjg7Pjgq8sIHdpbmRvd+ODoeODi+ODpeODvOOCkg==?= =?utf-8?b?5aSa6KiA6Kqe5YyW?= Message-ID: <1579701223.582761.105754.nullmailer@users.osdn.me> Revision: 8496 https://osdn.net/projects/ttssh2/scm/svn/commits/8496 Author: zmatsuo Date: 2020-01-22 22:53:43 +0900 (Wed, 22 Jan 2020) Log Message: ----------- common_static を ttpcmn からリンク, windowメニューを多言語化 Modified Paths: -------------- trunk/teraterm/ttermpro.sln trunk/teraterm/ttpcmn/CMakeLists.txt trunk/teraterm/ttpcmn/ttcmn.c trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters trunk/teraterm/ttpcmn/ttpcmn.vcproj -------------- next part -------------- Modified: trunk/teraterm/ttermpro.sln =================================================================== --- trunk/teraterm/ttermpro.sln 2020-01-22 13:53:33 UTC (rev 8495) +++ trunk/teraterm/ttermpro.sln 2020-01-22 13:53:43 UTC (rev 8496) @@ -14,6 +14,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "keycode", "keycode\keycode.vcproj", "{B31BF2E8-79E6-4735-BEA2-C1B4041C2D2E}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ttpcmn", "ttpcmn\ttpcmn.vcproj", "{118E0D32-5553-4F73-9927-E873C1C500E4}" + ProjectSection(ProjectDependencies) = postProject + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} = {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ttpfile", "ttpfile\ttpfile.vcproj", "{311F2B21-AEC4-4384-8209-BB83B54749B4}" ProjectSection(ProjectDependencies) = postProject Modified: trunk/teraterm/ttpcmn/CMakeLists.txt =================================================================== --- trunk/teraterm/ttpcmn/CMakeLists.txt 2020-01-22 13:53:33 UTC (rev 8495) +++ trunk/teraterm/ttpcmn/CMakeLists.txt 2020-01-22 13:53:43 UTC (rev 8496) @@ -5,7 +5,6 @@ set(COMMON_SRC ../common/teraterm.h ../common/tttypes.h - ../common/i18n.c ../common/i18n.h ../common/ttlib.c ../common/ttlib.h @@ -16,11 +15,8 @@ ../common/ttcommon.h ../common/tt_res.h ../common/codeconv.h - ../common/codeconv.cpp ../common/compat_win.h - ../common/compat_win.cpp ../common/dllutil.h - ../common/dllutil.cpp ) source_group( @@ -73,6 +69,7 @@ target_link_libraries( ttpcmn + common_static ole32 setupapi delayimp Modified: trunk/teraterm/ttpcmn/ttcmn.c =================================================================== --- trunk/teraterm/ttpcmn/ttcmn.c 2020-01-22 13:53:33 UTC (rev 8495) +++ trunk/teraterm/ttpcmn/ttcmn.c 2020-01-22 13:53:43 UTC (rev 8496) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2004-2019 TeraTerm Project + * (C) 2004-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,6 +58,7 @@ #define DllExport __declspec(dllexport) #include "ttcommon.h" +#include "layer_for_unicode.h" // TMap \x82\xF0\x8Ai\x94[\x82\xB7\x82\xE9\x83t\x83@\x83C\x83\x8B\x83}\x83b\x83s\x83\x93\x83O\x83I\x83u\x83W\x83F\x83N\x83g(\x8B\xA4\x97L\x83\x81\x83\x82\x83\x8A)\x82̖\xBC\x91O @@ -76,14 +77,6 @@ #define VTCLASSNAME _T("VTWin32") #define TEKCLASSNAME _T("TEKWin32") -#ifdef UNICODE -static HWND(WINAPI *pHtmlHelp)(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData); -#define HTMLHELP_API_NAME "HtmlHelpW" -#else -static HWND(WINAPI *pHtmlHelp)(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData); -#define HTMLHELP_API_NAME "HtmlHelpA" -#endif - enum window_style { WIN_CASCADE, WIN_STACKED, @@ -950,6 +943,7 @@ int i; char Temp[MAXPATHLEN]; HWND Hw; + wchar_t uimsg[MAX_UIMSG]; // delete all items in Window menu i = GetMenuItemCount(menu); @@ -981,39 +975,40 @@ UnregWin(Hw); } } - get_lang_msg("MENU_WINDOW_WINDOW", buf, buflen, "&Window", langFile); if (VTFlag == 1) { + static const DlgTextInfo MenuTextInfo[] = { + { ID_WINDOW_WINDOW, "MENU_WINDOW_WINDOW" }, + { ID_WINDOW_MINIMIZEALL, "MENU_WINDOW_MINIMIZEALL" }, + { ID_WINDOW_RESTOREALL, "MENU_WINDOW_RESTOREALL" }, + { ID_WINDOW_CASCADEALL, "MENU_WINDOW_CASCADE" }, + { ID_WINDOW_STACKED, "MENU_WINDOW_STACKED" }, + { ID_WINDOW_SIDEBYSIDE, "MENU_WINDOW_SIDEBYSIDE" }, + }; + AppendMenu(menu, MF_SEPARATOR, 0, NULL); - AppendMenu(menu,MF_ENABLED | MF_STRING,ID_WINDOW_WINDOW, buf); + AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_WINDOW, "&Window"); + AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_MINIMIZEALL, "&Minimize All"); + AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_RESTOREALL, "&Restore All"); + AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_CASCADEALL, "&Cascade"); + AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_STACKED, "&Stacked"); + AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_SIDEBYSIDE, "Side &by Side"); - get_lang_msg("MENU_WINDOW_MINIMIZEALL", buf, buflen, "&Minimize All", langFile); - AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_MINIMIZEALL, buf); + SetI18nMenuStrs("Tera Term", menu, MenuTextInfo, _countof(MenuTextInfo), langFile); - get_lang_msg("MENU_WINDOW_RESTOREALL", buf, buflen, "&Restore All", langFile); - AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_RESTOREALL, buf); - - get_lang_msg("MENU_WINDOW_CASCADE", buf, buflen, "&Cascade", langFile); - AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_CASCADEALL, buf); - - get_lang_msg("MENU_WINDOW_STACKED", buf, buflen, "&Stacked", langFile); - AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_STACKED, buf); - - get_lang_msg("MENU_WINDOW_SIDEBYSIDE", buf, buflen, "Side &by Side", langFile); - AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_SIDEBYSIDE, buf); - if (pm->WinUndoFlag) { if (pm->WinUndoStyle == WIN_CASCADE) - get_lang_msg("MENU_WINDOW_CASCADE_UNDO", buf, buflen, "&Undo - Cascade", langFile); + get_lang_msgW("MENU_WINDOW_CASCADE_UNDO", uimsg, _countof(uimsg), L"&Undo - Cascade", langFile); else if (pm->WinUndoStyle == WIN_STACKED) - get_lang_msg("MENU_WINDOW_STACKED_UNDO", buf, buflen, "&Undo - Stacked", langFile); + get_lang_msgW("MENU_WINDOW_STACKED_UNDO", uimsg, _countof(uimsg), L"&Undo - Stacked", langFile); else - get_lang_msg("MENU_WINDOW_SIDEBYSIDE_UNDO", buf, buflen, "&Undo - Side by Side", langFile); - AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_UNDO, buf); + get_lang_msgW("MENU_WINDOW_SIDEBYSIDE_UNDO", uimsg, _countof(uimsg), L"&Undo - Side by Side", langFile); + _AppendMenuW(menu, MF_ENABLED | MF_STRING, ID_WINDOW_UNDO, uimsg); // TODO UNICODE } } else { - AppendMenu(menu,MF_ENABLED | MF_STRING,ID_TEKWINDOW_WINDOW, buf); + get_lang_msgW("MENU_WINDOW_WINDOW", uimsg, _countof(uimsg), L"&Window", langFile); + _AppendMenuW(menu,MF_ENABLED | MF_STRING,ID_TEKWINDOW_WINDOW, uimsg); } } @@ -1171,12 +1166,9 @@ char HomeDir[MAX_PATH]; char Temp[MAX_PATH]; HWND HWin; - TCHAR HelpFN[MAX_PATH]; - TCHAR uimsg[MAX_UIMSG]; - TCHAR dllName[MAX_PATH]; - const TCHAR *HomeDirT; - const TCHAR *errorFile; - TCHAR buf[MAX_PATH]; + wchar_t HelpFN[MAX_PATH]; + wchar_t uimsg[MAX_UIMSG]; + wchar_t *HomeDirT; /* Get home directory */ if (GetModuleFileNameA(NULL,Temp,_countof(Temp)) == 0) { @@ -1183,43 +1175,29 @@ return; } ExtractDirName(Temp, HomeDir); - HomeDirT = ToTcharA(HomeDir); + HomeDirT = ToWcharA(HomeDir); - get_lang_msgT("HELPFILE", uimsg, _countof(uimsg), - _T("teraterm.chm"), UILanguageFile); + get_lang_msgW("HELPFILE", uimsg, _countof(uimsg), L"teraterm.chm", UILanguageFile); - if (pHtmlHelp == NULL) { - HINSTANCE hDll; - GetSystemDirectory(dllName, _countof(dllName)); - _tcscat_s(dllName, _countof(dllName), _T("\\hhctrl.ocx")); - hDll = LoadLibrary(dllName); - if (hDll == NULL) { - errorFile = dllName; - goto error; - } - pHtmlHelp = (void *)GetProcAddress(hDll, HTMLHELP_API_NAME); - if (pHtmlHelp == NULL) { - errorFile = dllName; - goto error; - } - } // \x83w\x83\x8B\x83v\x82̃I\x81[\x83i\x81[\x82͏\xED\x82Ƀf\x83X\x83N\x83g\x83b\x83v\x82ɂȂ\xE9 (2007.5.12 maya) HWin = GetDesktopWindow(); - _sntprintf_s(HelpFN, _countof(HelpFN), _TRUNCATE, _T("%s\\%s"), (TCHAR *)HomeDirT, uimsg); - if (pHtmlHelp != NULL && pHtmlHelp(HWin, HelpFN, Command, Data) == NULL && Command != HH_CLOSE_ALL) { - errorFile = HelpFN; + _snwprintf_s(HelpFN, _countof(HelpFN), _TRUNCATE, L"%s\\%s", HomeDirT, uimsg); + if (_HtmlHelpW(HWin, HelpFN, Command, Data) == NULL && Command != HH_CLOSE_ALL) { goto error; } goto finish; error: - get_lang_msgT("MSG_OPENHELP_ERROR", uimsg, _countof(uimsg), - _T("Can't open HTML help file(%s)."), UILanguageFile); - _sntprintf_s(buf, _countof(buf), _TRUNCATE, uimsg, HelpFN); - MessageBox(HWin, buf, _T("Tera Term: HTML help"), MB_OK | MB_ICONERROR); + { + wchar_t buf[MAX_PATH]; + get_lang_msgW("MSG_OPENHELP_ERROR", uimsg, _countof(uimsg), + L"Can't open HTML help file(%s).", UILanguageFile); + _snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg, HelpFN); + _MessageBoxW(HWin, buf, L"Tera Term: HTML help", MB_OK | MB_ICONERROR); + } finish: - free((void *)HomeDirT); + free(HomeDirT); } HWND WINAPI GetNthWin(int n) Modified: trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj =================================================================== --- trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj 2020-01-22 13:53:33 UTC (rev 8495) +++ trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj 2020-01-22 13:53:43 UTC (rev 8496) @@ -131,10 +131,6 @@ - - - - @@ -157,6 +153,11 @@ + + + {ac42387d-23ec-45db-81f9-8933c7efa52a} + + Modified: trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters =================================================================== --- trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters 2020-01-22 13:53:33 UTC (rev 8495) +++ trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters 2020-01-22 13:53:43 UTC (rev 8496) @@ -19,9 +19,6 @@ - - Source Files - Source Files @@ -34,9 +31,6 @@ Source Files - - Source Files - Source Files @@ -60,6 +54,12 @@ Source Files + + Header Files + + + Header Files + Modified: trunk/teraterm/ttpcmn/ttpcmn.vcproj =================================================================== --- trunk/teraterm/ttpcmn/ttpcmn.vcproj 2020-01-22 13:53:33 UTC (rev 8495) +++ trunk/teraterm/ttpcmn/ttpcmn.vcproj 2020-01-22 13:53:43 UTC (rev 8496) @@ -207,18 +207,10 @@ Filter="cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90" > - - - - @@ -234,14 +226,6 @@ RelativePath="..\common\ttlib.c" > - - - - + + @@ -256,6 +244,10 @@ > + + @@ -271,14 +263,6 @@ RelativePath="..\common\ttlib.h" > - - - - Revision: 8497 https://osdn.net/projects/ttssh2/scm/svn/commits/8497 Author: zmatsuo Date: 2020-01-22 22:53:52 +0900 (Wed, 22 Jan 2020) Log Message: ----------- MinGWでビルドできるよう _dupenv_s() のラッパを作成 - r8488 Revision Links: -------------- https://osdn.net/projects/ttssh2/scm/svn/commits/8488 Modified Paths: -------------- trunk/teraterm/teraterm/vtwin.cpp -------------- next part -------------- Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2020-01-22 13:53:43 UTC (rev 8496) +++ trunk/teraterm/teraterm/vtwin.cpp 2020-01-22 13:53:52 UTC (rev 8497) @@ -3898,6 +3898,19 @@ } } +static void __dupenv_s(char **envptr, size_t, const char* name) +{ +#if defined(_MSC_VER) + _dupenv_s(envptr, NULL, name); +#else + const char* s = getenv(name); + if (s == NULL) { + *envptr = NULL; + return; + } + *envptr = strdup(s); +#endif +} // // Connect to local cygwin @@ -3939,7 +3952,7 @@ return; found_dll:; - _dupenv_s(&envptr, NULL, "PATH"); + __dupenv_s(&envptr, NULL, "PATH"); file[strlen(file)-12] = '\0'; // delete "\\cygwin1.dll" if (envptr != NULL) { envbufflen = strlen(file) + strlen(envptr) + 7; // "PATH="(5) + ";"(1) + NUL(1) From scmnotify @ osdn.net Wed Jan 22 22:54:01 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Wed, 22 Jan 2020 22:54:01 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0OThdIGxheWVyX2Zvcl91bmljb2Rl44KS?= =?utf-8?b?5L2/55So44GZ44KL44KI44GG44Gr44GX44Gf?= Message-ID: <1579701241.677368.105989.nullmailer@users.osdn.me> Revision: 8498 https://osdn.net/projects/ttssh2/scm/svn/commits/8498 Author: zmatsuo Date: 2020-01-22 22:54:01 +0900 (Wed, 22 Jan 2020) Log Message: ----------- layer_for_unicodeを使用するようにした Modified Paths: -------------- trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj.filters trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c trunk/TTXSamples/TTXSamples.sln trunk/TTXSamples/TTXSamples.v16.sln -------------- next part -------------- Modified: trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt 2020-01-22 13:53:52 UTC (rev 8497) +++ trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt 2020-01-22 13:54:01 UTC (rev 8498) @@ -15,7 +15,6 @@ cJSON/cJSON.h cJSON/cJSON.c # - ../../teraterm/common/codeconv.cpp ../../teraterm/common/codeconv.h ../../teraterm/common/dlglib.h ../../teraterm/common/dlglib.c @@ -46,6 +45,7 @@ target_link_libraries( TTXCheckUpdate PRIVATE + common_static ttpcmn Wininet.lib ) Modified: trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj 2020-01-22 13:53:52 UTC (rev 8497) +++ trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj 2020-01-22 13:54:01 UTC (rev 8498) @@ -56,7 +56,7 @@ Disabled $(SolutionDir)..\teraterm\common;$(SolutionDir)..\teraterm\teraterm;$(ProjectDir)..\..\teraterm\common;$(ProjectDir)..\..\teraterm\teraterm;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;TTXENCODE_EXPORTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -75,7 +75,7 @@ $(SolutionDir)..\teraterm\common;$(SolutionDir)..\teraterm\teraterm;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;TTXENCODE_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) MultiThreaded Level3 @@ -96,7 +96,6 @@ - @@ -113,7 +112,12 @@ + + + {ac42387d-23ec-45db-81f9-8933c7efa52a} + + - \ No newline at end of file + Modified: trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj.filters =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj.filters 2020-01-22 13:53:52 UTC (rev 8497) +++ trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj.filters 2020-01-22 13:54:01 UTC (rev 8498) @@ -33,9 +33,6 @@ Source Files - - common - common Modified: trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj 2020-01-22 13:53:52 UTC (rev 8497) +++ trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj 2020-01-22 13:54:01 UTC (rev 8498) @@ -177,10 +177,6 @@ Name="common" > - - Modified: trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c 2020-01-22 13:53:52 UTC (rev 8497) +++ trunk/TTXSamples/TTXCheckUpdate/ttxcheckupdate.c 2020-01-22 13:54:01 UTC (rev 8498) @@ -13,6 +13,7 @@ #include "compat_w95.h" #include "dlglib.h" #include "i18n.h" +#include "layer_for_unicode.h" #include "resource.h" #include "parse.h" @@ -38,11 +39,11 @@ int cursor = -1; size_t i; - SendDlgItemMessageW(hDlg, IDC_COMBO1, CB_RESETCONTENT, 0, 0); + _SendDlgItemMessageW(hDlg, IDC_COMBO1, CB_RESETCONTENT, 0, 0); for (i = 0; i < pvar->versions_count; i++) { const version_one_t *v = &pvar->versions[i]; wchar_t *strW = ToWcharU8(v->version_text); - SendDlgItemMessageW(hDlg, IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM)strW); + _SendDlgItemMessageW(hDlg, IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM)strW); free(strW); if (cursor == -1 && v->version_major == version_major) { cursor = (int)i; @@ -59,7 +60,7 @@ const version_one_t *v = version; wchar_t *strW = ToWcharU8(v->text); - SetWindowTextW(GetDlgItem(hDlg, IDC_EDIT1), strW); + _SetWindowTextW(GetDlgItem(hDlg, IDC_EDIT1), strW); free(strW); if (v->url == NULL) { @@ -138,7 +139,7 @@ L" %s\n", UILanguageFile); swprintf(buf, _countof(buf), UIMsg, update_info_url); - result_mb = MessageBoxW(hWnd, buf, L"Tera Term", MB_YESNO | MB_ICONEXCLAMATION); + result_mb = _MessageBoxW(hWnd, buf, L"Tera Term", MB_YESNO | MB_ICONEXCLAMATION); if (result_mb == IDNO) { return; } @@ -147,7 +148,7 @@ swprintf(agent, _countof(agent), L"%s_%d", agent_base, pvar->ts->RunningVersion); result_bool = GetContent(update_info_url, agent, (void**)&json_raw_ptr, &json_raw_size); if (!result_bool) { - MessageBoxW(hWnd, L"access error?", L"Tera Term", MB_OK | MB_ICONEXCLAMATION); + _MessageBoxW(hWnd, L"access error?", L"Tera Term", MB_OK | MB_ICONEXCLAMATION); return; } json_size = json_raw_size + 1; @@ -162,7 +163,7 @@ /* json\x82\xF0\x83p\x81[\x83X\x82\xB7\x82\xE9 */ pvar->versions = ParseJson(json_ptr, &pvar->versions_count); if (pvar->versions == NULL) { - MessageBoxW(hWnd, L"parse error?", L"Tera Term", MB_OK | MB_ICONEXCLAMATION); + _MessageBoxW(hWnd, L"parse error?", L"Tera Term", MB_OK | MB_ICONEXCLAMATION); return; } @@ -260,11 +261,13 @@ return FALSE; } +#if 0 if (!IsWindowsNTKernel()) { // TODO Windows10\x88ȊO\x81A\x96\xA2\x8C\x9F\x8F\xD8 return FALSE; } - +#endif + size = sizeof(Exports) - sizeof(exports->size); if ((int)size > exports->size) { size = exports->size; Modified: trunk/TTXSamples/TTXSamples.sln =================================================================== --- trunk/TTXSamples/TTXSamples.sln 2020-01-22 13:53:52 UTC (rev 8497) +++ trunk/TTXSamples/TTXSamples.sln 2020-01-22 13:54:01 UTC (rev 8498) @@ -33,7 +33,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTXOutputBuffering", "TTXOutputBuffering\TTXOutputBuffering.vcproj", "{80BE71D1-BEA3-4A5D-8F13-362D6364892D}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTXCheckUpdate", "TTXCheckUpdate\TTXCheckUpdate.v8.vcproj", "{937DFA65-5709-4643-B778-482C15DEC581}" + ProjectSection(ProjectDependencies) = postProject + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} = {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} + EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common_static", "..\teraterm\common\common_static.v8.vcproj", "{DF4E3C36-A743-4FB4-8EE9-49899E69ED32}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -108,6 +113,10 @@ {937DFA65-5709-4643-B778-482C15DEC581}.Debug|Win32.Build.0 = Debug|Win32 {937DFA65-5709-4643-B778-482C15DEC581}.Release|Win32.ActiveCfg = Release|Win32 {937DFA65-5709-4643-B778-482C15DEC581}.Release|Win32.Build.0 = Release|Win32 + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32}.Debug|Win32.ActiveCfg = Debug|Win32 + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32}.Debug|Win32.Build.0 = Debug|Win32 + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32}.Release|Win32.ActiveCfg = Release|Win32 + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: trunk/TTXSamples/TTXSamples.v16.sln =================================================================== --- trunk/TTXSamples/TTXSamples.v16.sln 2020-01-22 13:53:52 UTC (rev 8497) +++ trunk/TTXSamples/TTXSamples.v16.sln 2020-01-22 13:54:01 UTC (rev 8498) @@ -36,6 +36,8 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTXCheckUpdate", "TTXCheckUpdate\TTXCheckUpdate.v16.vcxproj", "{937DFA65-5709-4643-B778-482C15DEC581}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common_static", "..\teraterm\common\common_static.v16.vcxproj", "{AC42387D-23EC-45DB-81F9-8933C7EFA52A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -110,6 +112,10 @@ {937DFA65-5709-4643-B778-482C15DEC581}.Debug|Win32.Build.0 = Debug|Win32 {937DFA65-5709-4643-B778-482C15DEC581}.Release|Win32.ActiveCfg = Release|Win32 {937DFA65-5709-4643-B778-482C15DEC581}.Release|Win32.Build.0 = Release|Win32 + {AC42387D-23EC-45DB-81F9-8933C7EFA52A}.Debug|Win32.ActiveCfg = Debug|Win32 + {AC42387D-23EC-45DB-81F9-8933C7EFA52A}.Debug|Win32.Build.0 = Debug|Win32 + {AC42387D-23EC-45DB-81F9-8933C7EFA52A}.Release|Win32.ActiveCfg = Release|Win32 + {AC42387D-23EC-45DB-81F9-8933C7EFA52A}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From scmnotify @ osdn.net Wed Jan 22 22:54:11 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Wed, 22 Jan 2020 22:54:11 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg0OTldIGNKU09O44GuZXhwb3J044KS6KGM?= =?utf-8?b?44KP44Gq44GE44KI44GG44Gr44GX44Gf?= Message-ID: <1579701251.234375.107296.nullmailer@users.osdn.me> Revision: 8499 https://osdn.net/projects/ttssh2/scm/svn/commits/8499 Author: zmatsuo Date: 2020-01-22 22:54:11 +0900 (Wed, 22 Jan 2020) Log Message: ----------- cJSONのexportを行わないようにした Modified Paths: -------------- trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj -------------- next part -------------- Modified: trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt 2020-01-22 13:54:01 UTC (rev 8498) +++ trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt 2020-01-22 13:54:11 UTC (rev 8499) @@ -35,6 +35,11 @@ PREFIX "" ) +target_compile_definitions( + TTXCheckUpdate + PRIVATE + -D CJSON_HIDE_SYMBOLS) + target_include_directories( TTXCheckUpdate PRIVATE Modified: trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj 2020-01-22 13:54:01 UTC (rev 8498) +++ trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj 2020-01-22 13:54:11 UTC (rev 8499) @@ -56,7 +56,7 @@ Disabled $(SolutionDir)..\teraterm\common;$(SolutionDir)..\teraterm\teraterm;$(ProjectDir)..\..\teraterm\common;$(ProjectDir)..\..\teraterm\teraterm;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;CJSON_HIDE_SYMBOLS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -75,7 +75,7 @@ $(SolutionDir)..\teraterm\common;$(SolutionDir)..\teraterm\teraterm;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;CJSON_HIDE_SYMBOLS;%(PreprocessorDefinitions) MultiThreaded Level3 @@ -120,4 +120,4 @@ - + \ No newline at end of file Modified: trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj 2020-01-22 13:54:01 UTC (rev 8498) +++ trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj 2020-01-22 13:54:11 UTC (rev 8499) @@ -41,7 +41,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="$(SolutionDir)..\teraterm\common;$(SolutionDir)..\teraterm\teraterm" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CJSON_HIDE_SYMBOLS" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -118,7 +118,7 @@ Revision: 8501 https://osdn.net/projects/ttssh2/scm/svn/commits/8501 Author: zmatsuo Date: 2020-01-22 22:54:32 +0900 (Wed, 22 Jan 2020) Log Message: ----------- getcontent を teraterm/common へ移動 Modified Paths: -------------- trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj trunk/teraterm/common/CMakeLists.txt trunk/teraterm/common/common_static.v16.vcxproj trunk/teraterm/common/common_static.v8.vcproj Added Paths: ----------- trunk/teraterm/common/getcontent.cpp trunk/teraterm/common/getcontent.h Removed Paths: ------------- trunk/TTXSamples/TTXCheckUpdate/getcontent.cpp trunk/TTXSamples/TTXCheckUpdate/getcontent.h -------------- next part -------------- Modified: trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt 2020-01-22 13:54:20 UTC (rev 8500) +++ trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt 2020-01-22 13:54:32 UTC (rev 8501) @@ -7,8 +7,6 @@ ttxcheckupdate.c parse.h parse.cpp - getcontent.h - getcontent.cpp resource.rc resource.h # @@ -21,6 +19,7 @@ ../../teraterm/common/dlglib_cpp.cpp ../../teraterm/common/dlglib_tmpl.cpp ../../teraterm/common/ttlib.c + ../../teraterm/common/getcontent.h ) source_group( Modified: trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj 2020-01-22 13:54:20 UTC (rev 8500) +++ trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj 2020-01-22 13:54:32 UTC (rev 8501) @@ -92,7 +92,6 @@ - @@ -102,7 +101,6 @@ - @@ -120,4 +118,4 @@ - \ No newline at end of file + Modified: trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj 2020-01-22 13:54:20 UTC (rev 8500) +++ trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj 2020-01-22 13:54:32 UTC (rev 8501) @@ -218,14 +218,6 @@ - - - - Deleted: trunk/TTXSamples/TTXCheckUpdate/getcontent.cpp =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/getcontent.cpp 2020-01-22 13:54:20 UTC (rev 8500) +++ trunk/TTXSamples/TTXCheckUpdate/getcontent.cpp 2020-01-22 13:54:32 UTC (rev 8501) @@ -1,138 +0,0 @@ - -#include -#include -#define _CRTDBG_MAP_ALLOC -#include -#include - -#if (defined(_MSC_VER) && (_MSC_VER >= 1600)) || !defined(_MSC_VER) -#include -#else -typedef unsigned char uint8_t; -#endif - -#include "codeconv.h" - -#include "getcontent.h" - -/** - * url\x82\xA9\x82\xE7\x8F\xEE\x95\xF1\x82\xF0\x8E擾\x82\xB7\x82\xE9 - * - * @param[in] url - * @param[in] agent \x83G\x81[\x83W\x83F\x83\x93\x83g\x96\xBC - * @param[in] ptr \x8E擾\x82\xB5\x82\xBD\x8F\xEE\x95\xF1 - * \x95s\x97v\x82ɂȂ\xC1\x82\xBD\x82\xE7free()\x82\xB7\x82邱\x82\xC6 - * @param[in] size \x8E擾\x82\xB5\x82\xBD\x8F\xEE\x95\xF1\x83T\x83C\x83Y - * - */ -BOOL GetContent(const wchar_t *url, const wchar_t *agent, void **ptr, size_t *size) -{ - // URL\x89\xF0\x90\xCD - size_t url_length = wcslen(url); - if (url_length == 0) { - return false; - } - URL_COMPONENTSW urlcomponents = {}; - urlcomponents.dwStructSize = sizeof(URL_COMPONENTS); - wchar_t szHostName[INTERNET_MAX_HOST_NAME_LENGTH]; - wchar_t szUrlPath[INTERNET_MAX_PATH_LENGTH]; - urlcomponents.lpszHostName = szHostName; - urlcomponents.lpszUrlPath = szUrlPath; - urlcomponents.dwHostNameLength = _countof(szHostName); - urlcomponents.dwUrlPathLength = _countof(szUrlPath); - if (InternetCrackUrlW(url, (DWORD)url_length, 0, &urlcomponents) == FALSE) { - return false; - } - INTERNET_PORT nPort = urlcomponents.nPort; - - // HTTP\x82\xA9HTTPS\x82\xA9\x82\xBB\x82\xEA\x88ȊO\x82\xA9 - DWORD dwFlags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_NO_AUTO_REDIRECT; - if (INTERNET_SCHEME_HTTP == urlcomponents.nScheme) { - // HTTP - } - else if (INTERNET_SCHEME_HTTPS == urlcomponents.nScheme) { - // HTTPS - dwFlags |= INTERNET_FLAG_SECURE; - } - else { - return false; - } - - HINTERNET hInternetOpen = NULL; - HINTERNET hInternetConnect = NULL; - HINTERNET hInternetRequest = NULL; - // try - { - hInternetOpen = InternetOpenW(agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); - if (hInternetOpen == NULL) { - goto finish; - } - - hInternetConnect = InternetConnectW(hInternetOpen, szHostName, nPort, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); - if (hInternetConnect == NULL) { - goto finish; - } - - // HTTP\x90ڑ\xB1\x82\xF0\x8AJ\x82\xAD - hInternetRequest = HttpOpenRequestW(hInternetConnect, L"GET", szUrlPath, NULL, NULL, NULL, dwFlags, 0); - if (hInternetRequest == NULL) { - // net\x90ڑ\xB1\x82\xAA\x82Ȃ\xA2? - goto finish; - } - - // HTTP\x97v\x8B\x81\x91\x97\x90M - if (HttpSendRequestW(hInternetRequest, NULL, 0, NULL, 0) == FALSE) { - goto finish; - } - - // status code - DWORD dwStatusCode; - DWORD dwLength = sizeof(DWORD); - if (!HttpQueryInfo(hInternetRequest, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwStatusCode, &dwLength, - 0)) { - goto finish; - } - if (dwStatusCode != HTTP_STATUS_OK) { - goto finish; - } - - // contents read - const size_t READBUFFER_SIZE = 4096; - uint8_t *buf_ptr = NULL; - size_t buf_size = 0; - while (1) { - uint8_t *buf_ptr_tmp = (uint8_t *)realloc(buf_ptr, buf_size + READBUFFER_SIZE); - if (buf_ptr_tmp == NULL) { - free(buf_ptr); - goto finish; - } - buf_ptr = buf_ptr_tmp; - - uint8_t *buf_ptr_read = &buf_ptr[buf_size]; - DWORD dwRead = 0; - if (!InternetReadFile(hInternetRequest, buf_ptr_read, READBUFFER_SIZE, &dwRead)) { - free(buf_ptr); - goto finish; - } - buf_size += dwRead; - buf_ptr = (uint8_t *)realloc(buf_ptr, buf_size); // fit size - if (dwRead == 0) { - break; - } - } - - *ptr = buf_ptr; - *size = buf_size; - InternetCloseHandle(hInternetRequest); - InternetCloseHandle(hInternetConnect); - InternetCloseHandle(hInternetOpen); - return true; - } - - // catch -finish: - InternetCloseHandle(hInternetRequest); - InternetCloseHandle(hInternetConnect); - InternetCloseHandle(hInternetOpen); - return false; -} Deleted: trunk/TTXSamples/TTXCheckUpdate/getcontent.h =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/getcontent.h 2020-01-22 13:54:20 UTC (rev 8500) +++ trunk/TTXSamples/TTXCheckUpdate/getcontent.h 2020-01-22 13:54:32 UTC (rev 8501) @@ -1,13 +0,0 @@ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -BOOL GetContent(const wchar_t *url, const wchar_t *agent, void **ptr, size_t *size); - -#ifdef __cplusplus -} -#endif Modified: trunk/teraterm/common/CMakeLists.txt =================================================================== --- trunk/teraterm/common/CMakeLists.txt 2020-01-22 13:54:20 UTC (rev 8500) +++ trunk/teraterm/common/CMakeLists.txt 2020-01-22 13:54:32 UTC (rev 8501) @@ -9,6 +9,8 @@ compat_win.h dllutil.cpp dllutil.h + getcontent.cpp + getcontent.h i18n.c i18n.h layer_for_unicode.cpp Modified: trunk/teraterm/common/common_static.v16.vcxproj =================================================================== --- trunk/teraterm/common/common_static.v16.vcxproj 2020-01-22 13:54:20 UTC (rev 8500) +++ trunk/teraterm/common/common_static.v16.vcxproj 2020-01-22 13:54:32 UTC (rev 8501) @@ -138,6 +138,7 @@ + @@ -147,6 +148,7 @@ + Modified: trunk/teraterm/common/common_static.v8.vcproj =================================================================== --- trunk/teraterm/common/common_static.v8.vcproj 2020-01-22 13:54:20 UTC (rev 8500) +++ trunk/teraterm/common/common_static.v8.vcproj 2020-01-22 13:54:32 UTC (rev 8501) @@ -193,6 +193,14 @@ > + + + + Copied: trunk/teraterm/common/getcontent.cpp (from rev 8500, trunk/TTXSamples/TTXCheckUpdate/getcontent.cpp) =================================================================== --- trunk/teraterm/common/getcontent.cpp (rev 0) +++ trunk/teraterm/common/getcontent.cpp 2020-01-22 13:54:32 UTC (rev 8501) @@ -0,0 +1,138 @@ + +#include +#include +#define _CRTDBG_MAP_ALLOC +#include +#include + +#if (defined(_MSC_VER) && (_MSC_VER >= 1600)) || !defined(_MSC_VER) +#include +#else +typedef unsigned char uint8_t; +#endif + +#include "codeconv.h" + +#include "getcontent.h" + +/** + * url\x82\xA9\x82\xE7\x8F\xEE\x95\xF1\x82\xF0\x8E擾\x82\xB7\x82\xE9 + * + * @param[in] url + * @param[in] agent \x83G\x81[\x83W\x83F\x83\x93\x83g\x96\xBC + * @param[in] ptr \x8E擾\x82\xB5\x82\xBD\x8F\xEE\x95\xF1 + * \x95s\x97v\x82ɂȂ\xC1\x82\xBD\x82\xE7free()\x82\xB7\x82邱\x82\xC6 + * @param[in] size \x8E擾\x82\xB5\x82\xBD\x8F\xEE\x95\xF1\x83T\x83C\x83Y + * + */ +BOOL GetContent(const wchar_t *url, const wchar_t *agent, void **ptr, size_t *size) +{ + // URL\x89\xF0\x90\xCD + size_t url_length = wcslen(url); + if (url_length == 0) { + return false; + } + URL_COMPONENTSW urlcomponents = {}; + urlcomponents.dwStructSize = sizeof(URL_COMPONENTS); + wchar_t szHostName[INTERNET_MAX_HOST_NAME_LENGTH]; + wchar_t szUrlPath[INTERNET_MAX_PATH_LENGTH]; + urlcomponents.lpszHostName = szHostName; + urlcomponents.lpszUrlPath = szUrlPath; + urlcomponents.dwHostNameLength = _countof(szHostName); + urlcomponents.dwUrlPathLength = _countof(szUrlPath); + if (InternetCrackUrlW(url, (DWORD)url_length, 0, &urlcomponents) == FALSE) { + return false; + } + INTERNET_PORT nPort = urlcomponents.nPort; + + // HTTP\x82\xA9HTTPS\x82\xA9\x82\xBB\x82\xEA\x88ȊO\x82\xA9 + DWORD dwFlags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_NO_AUTO_REDIRECT; + if (INTERNET_SCHEME_HTTP == urlcomponents.nScheme) { + // HTTP + } + else if (INTERNET_SCHEME_HTTPS == urlcomponents.nScheme) { + // HTTPS + dwFlags |= INTERNET_FLAG_SECURE; + } + else { + return false; + } + + HINTERNET hInternetOpen = NULL; + HINTERNET hInternetConnect = NULL; + HINTERNET hInternetRequest = NULL; + // try + { + hInternetOpen = InternetOpenW(agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); + if (hInternetOpen == NULL) { + goto finish; + } + + hInternetConnect = InternetConnectW(hInternetOpen, szHostName, nPort, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); + if (hInternetConnect == NULL) { + goto finish; + } + + // HTTP\x90ڑ\xB1\x82\xF0\x8AJ\x82\xAD + hInternetRequest = HttpOpenRequestW(hInternetConnect, L"GET", szUrlPath, NULL, NULL, NULL, dwFlags, 0); + if (hInternetRequest == NULL) { + // net\x90ڑ\xB1\x82\xAA\x82Ȃ\xA2? + goto finish; + } + + // HTTP\x97v\x8B\x81\x91\x97\x90M + if (HttpSendRequestW(hInternetRequest, NULL, 0, NULL, 0) == FALSE) { + goto finish; + } + + // status code + DWORD dwStatusCode; + DWORD dwLength = sizeof(DWORD); + if (!HttpQueryInfo(hInternetRequest, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwStatusCode, &dwLength, + 0)) { + goto finish; + } + if (dwStatusCode != HTTP_STATUS_OK) { + goto finish; + } + + // contents read + const size_t READBUFFER_SIZE = 4096; + uint8_t *buf_ptr = NULL; + size_t buf_size = 0; + while (1) { + uint8_t *buf_ptr_tmp = (uint8_t *)realloc(buf_ptr, buf_size + READBUFFER_SIZE); + if (buf_ptr_tmp == NULL) { + free(buf_ptr); + goto finish; + } + buf_ptr = buf_ptr_tmp; + + uint8_t *buf_ptr_read = &buf_ptr[buf_size]; + DWORD dwRead = 0; + if (!InternetReadFile(hInternetRequest, buf_ptr_read, READBUFFER_SIZE, &dwRead)) { + free(buf_ptr); + goto finish; + } + buf_size += dwRead; + buf_ptr = (uint8_t *)realloc(buf_ptr, buf_size); // fit size + if (dwRead == 0) { + break; + } + } + + *ptr = buf_ptr; + *size = buf_size; + InternetCloseHandle(hInternetRequest); + InternetCloseHandle(hInternetConnect); + InternetCloseHandle(hInternetOpen); + return true; + } + + // catch +finish: + InternetCloseHandle(hInternetRequest); + InternetCloseHandle(hInternetConnect); + InternetCloseHandle(hInternetOpen); + return false; +} Copied: trunk/teraterm/common/getcontent.h (from rev 8500, trunk/TTXSamples/TTXCheckUpdate/getcontent.h) =================================================================== --- trunk/teraterm/common/getcontent.h (rev 0) +++ trunk/teraterm/common/getcontent.h 2020-01-22 13:54:32 UTC (rev 8501) @@ -0,0 +1,13 @@ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +BOOL GetContent(const wchar_t *url, const wchar_t *agent, void **ptr, size_t *size); + +#ifdef __cplusplus +} +#endif From scmnotify @ osdn.net Wed Jan 22 22:54:21 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Wed, 22 Jan 2020 22:54:21 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MDBdIGNKU09OIOOCkiBsaWJzLyDjgbg=?= =?utf-8?b?56e75YuV?= Message-ID: <1579701261.147296.107561.nullmailer@users.osdn.me> Revision: 8500 https://osdn.net/projects/ttssh2/scm/svn/commits/8500 Author: zmatsuo Date: 2020-01-22 22:54:20 +0900 (Wed, 22 Jan 2020) Log Message: ----------- cJSON を libs/ へ移動 Modified Paths: -------------- trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj.filters trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj trunk/TTXSamples/TTXCheckUpdate/parse.cpp Added Paths: ----------- trunk/libs/cJSON/ trunk/libs/cJSON/LICENSE trunk/libs/cJSON/README.md trunk/libs/cJSON/cJSON.c trunk/libs/cJSON/cJSON.h Removed Paths: ------------- trunk/TTXSamples/TTXCheckUpdate/cJSON/LICENSE trunk/TTXSamples/TTXCheckUpdate/cJSON/README.md trunk/TTXSamples/TTXCheckUpdate/cJSON/cJSON.c trunk/TTXSamples/TTXCheckUpdate/cJSON/cJSON.h -------------- next part -------------- Modified: trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt 2020-01-22 13:54:11 UTC (rev 8499) +++ trunk/TTXSamples/TTXCheckUpdate/CMakeLists.txt 2020-01-22 13:54:20 UTC (rev 8500) @@ -12,8 +12,8 @@ resource.rc resource.h # - cJSON/cJSON.h - cJSON/cJSON.c + ../../libs/cJSON/cJSON.h + ../../libs/cJSON/cJSON.c # ../../teraterm/common/codeconv.h ../../teraterm/common/dlglib.h @@ -29,6 +29,11 @@ "teraterm\/common\/" ) +source_group( + "cJSON" + REGULAR_EXPRESSION + "..\/..\/libs\/cJSON\/" + ) set_target_properties( TTXCheckUpdate PROPERTIES @@ -43,6 +48,7 @@ target_include_directories( TTXCheckUpdate PRIVATE + ../../libs/cJSON ../../teraterm/teraterm ../../teraterm/common ) Modified: trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj 2020-01-22 13:54:11 UTC (rev 8499) +++ trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj 2020-01-22 13:54:20 UTC (rev 8500) @@ -55,7 +55,7 @@ Disabled - $(SolutionDir)..\teraterm\common;$(SolutionDir)..\teraterm\teraterm;$(ProjectDir)..\..\teraterm\common;$(ProjectDir)..\..\teraterm\teraterm;%(AdditionalIncludeDirectories) + $(SolutionDir)..\teraterm\common;$(SolutionDir)..\teraterm\teraterm;$(SolutionDir)..\libs\cJSON;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;CJSON_HIDE_SYMBOLS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -74,7 +74,7 @@ - $(SolutionDir)..\teraterm\common;$(SolutionDir)..\teraterm\teraterm;%(AdditionalIncludeDirectories) + $(SolutionDir)..\teraterm\common;$(SolutionDir)..\teraterm\teraterm;$(SolutionDir)..\libs\cJSON;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;CJSON_HIDE_SYMBOLS;%(PreprocessorDefinitions) MultiThreaded @@ -95,7 +95,7 @@ - + @@ -105,7 +105,7 @@ - + Modified: trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj.filters =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj.filters 2020-01-22 13:54:11 UTC (rev 8499) +++ trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v16.vcxproj.filters 2020-01-22 13:54:20 UTC (rev 8500) @@ -42,7 +42,7 @@ common - + cJSON @@ -62,7 +62,7 @@ common - + cJSON Modified: trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj 2020-01-22 13:54:11 UTC (rev 8499) +++ trunk/TTXSamples/TTXCheckUpdate/TTXCheckUpdate.v8.vcproj 2020-01-22 13:54:20 UTC (rev 8500) @@ -40,7 +40,7 @@ Deleted: trunk/TTXSamples/TTXCheckUpdate/cJSON/LICENSE =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/cJSON/LICENSE 2020-01-22 13:54:11 UTC (rev 8499) +++ trunk/TTXSamples/TTXCheckUpdate/cJSON/LICENSE 2020-01-22 13:54:20 UTC (rev 8500) @@ -1,20 +0,0 @@ -Copyright (c) 2009-2017 Dave Gamble and cJSON contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - Deleted: trunk/TTXSamples/TTXCheckUpdate/cJSON/README.md =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/cJSON/README.md 2020-01-22 13:54:11 UTC (rev 8499) +++ trunk/TTXSamples/TTXCheckUpdate/cJSON/README.md 2020-01-22 13:54:20 UTC (rev 8500) @@ -1,547 +0,0 @@ -# cJSON - -Ultralightweight JSON parser in ANSI C. - -## Table of contents -* [License](#license) -* [Usage](#usage) - * [Welcome to cJSON](#welcome-to-cjson) - * [Building](#building) - * [Copying the source](#copying-the-source) - * [CMake](#cmake) - * [Makefile](#makefile) - * [Including cJSON](#including-cjson) - * [Data Structure](#data-structure) - * [Working with the data structure](#working-with-the-data-structure) - * [Basic types](#basic-types) - * [Arrays](#arrays) - * [Objects](#objects) - * [Parsing JSON](#parsing-json) - * [Printing JSON](#printing-json) - * [Example](#example) - * [Printing](#printing) - * [Parsing](#parsing) - * [Caveats](#caveats) - * [Zero Character](#zero-character) - * [Character Encoding](#character-encoding) - * [C Standard](#c-standard) - * [Floating Point Numbers](#floating-point-numbers) - * [Deep Nesting Of Arrays And Objects](#deep-nesting-of-arrays-and-objects) - * [Thread Safety](#thread-safety) - * [Case Sensitivity](#case-sensitivity) - * [Duplicate Object Members](#duplicate-object-members) - * [Enjoy cJSON!](#enjoy-cjson) - -## License - -MIT License - -> Copyright (c) 2009-2017 Dave Gamble and cJSON contributors -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in -> all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -> THE SOFTWARE. - -## Usage - -### Welcome to cJSON. - -cJSON aims to be the dumbest possible parser that you can get your job done with. -It's a single file of C, and a single header file. - -JSON is described best here: http://www.json.org/ -It's like XML, but fat-free. You use it to move data around, store things, or just -generally represent your program's state. - -As a library, cJSON exists to take away as much legwork as it can, but not get in your way. -As a point of pragmatism (i.e. ignoring the truth), I'm going to say that you can use it -in one of two modes: Auto and Manual. Let's have a quick run-through. - -I lifted some JSON from this page: http://www.json.org/fatfree.html -That page inspired me to write cJSON, which is a parser that tries to share the same -philosophy as JSON itself. Simple, dumb, out of the way. - -### Building - -There are several ways to incorporate cJSON into your project. - -#### copying the source - -Because the entire library is only one C file and one header file, you can just copy `cJSON.h` and `cJSON.c` to your projects source and start using it. - -cJSON is written in ANSI C (C89) in order to support as many platforms and compilers as possible. - -#### CMake - -With CMake, cJSON supports a full blown build system. This way you get the most features. CMake with an equal or higher version than 2.8.5 is supported. With CMake it is recommended to do an out of tree build, meaning the compiled files are put in a directory separate from the source files. So in order to build cJSON with CMake on a Unix platform, make a `build` directory and run CMake inside it. - -``` -mkdir build -cd build -cmake .. -``` - -This will create a Makefile and a bunch of other files. You can then compile it: - -``` -make -``` - -And install it with `make install` if you want. By default it installs the headers `/usr/local/include/cjson` and the libraries to `/usr/local/lib`. It also installs files for pkg-config to make it easier to detect and use an existing installation of CMake. And it installs CMake config files, that can be used by other CMake based projects to discover the library. - -You can change the build process with a list of different options that you can pass to CMake. Turn them on with `On` and off with `Off`: - -* `-DENABLE_CJSON_TEST=On`: Enable building the tests. (on by default) -* `-DENABLE_CJSON_UTILS=On`: Enable building cJSON_Utils. (off by default) -* `-DENABLE_TARGET_EXPORT=On`: Enable the export of CMake targets. Turn off if it makes problems. (on by default) -* `-DENABLE_CUSTOM_COMPILER_FLAGS=On`: Enable custom compiler flags (currently for Clang, GCC and MSVC). Turn off if it makes problems. (on by default) -* `-DENABLE_VALGRIND=On`: Run tests with [valgrind](http://valgrind.org). (off by default) -* `-DENABLE_SANITIZERS=On`: Compile cJSON with [AddressSanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizer) and [UndefinedBehaviorSanitizer](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html) enabled (if possible). (off by default) -* `-DENABLE_SAFE_STACK`: Enable the [SafeStack](https://clang.llvm.org/docs/SafeStack.html) instrumentation pass. Currently only works with the Clang compiler. (off by default) -* `-DBUILD_SHARED_LIBS=On`: Build the shared libraries. (on by default) -* `-DBUILD_SHARED_AND_STATIC_LIBS=On`: Build both shared and static libraries. (off by default) -* `-DCMAKE_INSTALL_PREFIX=/usr`: Set a prefix for the installation. -* `-DENABLE_LOCALES=On`: Enable the usage of localeconv method. ( on by default ) -* `-DCJSON_OVERRIDE_BUILD_SHARED_LIBS=On`: Enable overriding the value of `BUILD_SHARED_LIBS` with `-DCJSON_BUILD_SHARED_LIBS`. - -If you are packaging cJSON for a distribution of Linux, you would probably take these steps for example: -``` -mkdir build -cd build -cmake .. -DENABLE_CJSON_UTILS=On -DENABLE_CJSON_TEST=Off -DCMAKE_INSTALL_PREFIX=/usr -make -make DESTDIR=$pkgdir install -``` - -On Windows CMake is usually used to create a Visual Studio solution file by running it inside the Developer Command Prompt for Visual Studio, for exact steps follow the official documentation from CMake and Microsoft and use the online search engine of your choice. The descriptions of the the options above still generally apply, although not all of them work on Windows. - -#### Makefile - -**NOTE:** This Method is deprecated. Use CMake if at all possible. Makefile support is limited to fixing bugs. - -If you don't have CMake available, but still have GNU make. You can use the makefile to build cJSON: - -Run this command in the directory with the source code and it will automatically compile static and shared libraries and a little test program (not the full test suite). - -``` -make all -``` - -If you want, you can install the compiled library to your system using `make install`. By default it will install the headers in `/usr/local/include/cjson` and the libraries in `/usr/local/lib`. But you can change this behavior by setting the `PREFIX` and `DESTDIR` variables: `make PREFIX=/usr DESTDIR=temp install`. And uninstall them with: `make PREFIX=/usr DESTDIR=temp uninstall`. - -### Including cJSON - -If you installed it via CMake or the Makefile, you can include cJSON like this: - -```c -#include -``` - -### Data Structure - -cJSON represents JSON data using the `cJSON` struct data type: - -```c -/* The cJSON structure: */ -typedef struct cJSON -{ - struct cJSON *next; - struct cJSON *prev; - struct cJSON *child; - int type; - char *valuestring; - /* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */ - int valueint; - double valuedouble; - char *string; -} cJSON; -``` - -An item of this type represents a JSON value. The type is stored in `type` as a bit-flag (**this means that you cannot find out the type by just comparing the value of `type`**). - -To check the type of an item, use the corresponding `cJSON_Is...` function. It does a `NULL` check followed by a type check and returns a boolean value if the item is of this type. - -The type can be one of the following: - -* `cJSON_Invalid` (check with `cJSON_IsInvalid`): Represents an invalid item that doesn't contain any value. You automatically have this type if you set the item to all zero bytes. -* `cJSON_False` (check with `cJSON_IsFalse`): Represents a `false` boolean value. You can also check for boolean values in general with `cJSON_IsBool`. -* `cJSON_True` (check with `cJSON_IsTrue`): Represents a `true` boolean value. You can also check for boolean values in general with `cJSON_IsBool`. -* `cJSON_NULL` (check with `cJSON_IsNull`): Represents a `null` value. -* `cJSON_Number` (check with `cJSON_IsNumber`): Represents a number value. The value is stored as a double in `valuedouble` and also in `valueint`. If the number is outside of the range of an integer, `INT_MAX` or `INT_MIN` are used for `valueint`. -* `cJSON_String` (check with `cJSON_IsString`): Represents a string value. It is stored in the form of a zero terminated string in `valuestring`. -* `cJSON_Array` (check with `cJSON_IsArray`): Represent an array value. This is implemented by pointing `child` to a linked list of `cJSON` items that represent the values in the array. The elements are linked together using `next` and `prev`, where the first element has `prev == NULL` and the last element `next == NULL`. -* `cJSON_Object` (check with `cJSON_IsObject`): Represents an object value. Objects are stored same way as an array, the only difference is that the items in the object store their keys in `string`. -* `cJSON_Raw` (check with `cJSON_IsRaw`): Represents any kind of JSON that is stored as a zero terminated array of characters in `valuestring`. This can be used, for example, to avoid printing the same static JSON over and over again to save performance. cJSON will never create this type when parsing. Also note that cJSON doesn't check if it is valid JSON. - -Additionally there are the following two flags: - -* `cJSON_IsReference`: Specifies that the item that `child` points to and/or `valuestring` is not owned by this item, it is only a reference. So `cJSON_Delete` and other functions will only deallocate this item, not it's children/valuestring. -* `cJSON_StringIsConst`: This means that `string` points to a constant string. This means that `cJSON_Delete` and other functions will not try to deallocate `string`. - -### Working with the data structure - -For every value type there is a `cJSON_Create...` function that can be used to create an item of that type. -All of these will allocate a `cJSON` struct that can later be deleted with `cJSON_Delete`. -Note that you have to delete them at some point, otherwise you will get a memory leak. -**Important**: If you have added an item to an array or an object already, you **mustn't** delete it with `cJSON_Delete`. Adding it to an array or object transfers its ownership so that when that array or object is deleted, it gets deleted as well. - -#### Basic types - -* **null** is created with `cJSON_CreateNull` -* **booleans** are created with `cJSON_CreateTrue`, `cJSON_CreateFalse` or `cJSON_CreateBool` -* **numbers** are created with `cJSON_CreateNumber`. This will set both `valuedouble` and `valueint`. If the number is outside of the range of an integer, `INT_MAX` or `INT_MIN` are used for `valueint` -* **strings** are created with `cJSON_CreateString` (copies the string) or with `cJSON_CreateStringReference` (directly points to the string. This means that `valuestring` won't be deleted by `cJSON_Delete` and you are responsible for it's lifetime, useful for constants) - -#### Arrays - -You can create an empty array with `cJSON_CreateArray`. `cJSON_CreateArrayReference` can be used to create an array that doesn't "own" its content, so its content doesn't get deleted by `cJSON_Delete`. - -To add items to an array, use `cJSON_AddItemToArray` to append items to the end. -Using `cJSON_AddItemReferenceToArray` an element can be added as a reference to another item, array or string. This means that `cJSON_Delete` will not delete that items `child` or `valuestring` properties, so no double frees are occurring if they are already used elsewhere. -To insert items in the middle, use `cJSON_InsertItemInArray`. It will insert an item at the given 0 based index and shift all the existing items to the right. - -If you want to take an item out of an array at a given index and continue using it, use `cJSON_DetachItemFromArray`, it will return the detached item, so be sure to assign it to a pointer, otherwise you will have a memory leak. - -Deleting items is done with `cJSON_DeleteItemFromArray`. It works like `cJSON_DetachItemFromArray`, but deletes the detached item via `cJSON_Delete`. - -You can also replace an item in an array in place. Either with `cJSON_ReplaceItemInArray` using an index or with `cJSON_ReplaceItemViaPointer` given a pointer to an element. `cJSON_ReplaceItemViaPointer` will return `0` if it fails. What this does internally is to detach the old item, delete it and insert the new item in its place. - -To get the size of an array, use `cJSON_GetArraySize`. Use `cJSON_GetArrayItem` to get an element at a given index. - -Because an array is stored as a linked list, iterating it via index is inefficient (`O(n²)`), so you can iterate over an array using the `cJSON_ArrayForEach` macro in `O(n)` time complexity. - -#### Objects - -You can create an empty object with `cJSON_CreateObject`. `cJSON_CreateObjectReference` can be used to create an object that doesn't "own" its content, so its content doesn't get deleted by `cJSON_Delete`. - -To add items to an object, use `cJSON_AddItemToObject`. Use `cJSON_AddItemToObjectCS` to add an item to an object with a name that is a constant or reference (key of the item, `string` in the `cJSON` struct), so that it doesn't get freed by `cJSON_Delete`. -Using `cJSON_AddItemReferenceToArray` an element can be added as a reference to another object, array or string. This means that `cJSON_Delete` will not delete that items `child` or `valuestring` properties, so no double frees are occurring if they are already used elsewhere. - -If you want to take an item out of an object, use `cJSON_DetachItemFromObjectCaseSensitive`, it will return the detached item, so be sure to assign it to a pointer, otherwise you will have a memory leak. - -Deleting items is done with `cJSON_DeleteItemFromObjectCaseSensitive`. It works like `cJSON_DetachItemFromObjectCaseSensitive` followed by `cJSON_Delete`. - -You can also replace an item in an object in place. Either with `cJSON_ReplaceItemInObjectCaseSensitive` using a key or with `cJSON_ReplaceItemViaPointer` given a pointer to an element. `cJSON_ReplaceItemViaPointer` will return `0` if it fails. What this does internally is to detach the old item, delete it and insert the new item in its place. - -To get the size of an object, you can use `cJSON_GetArraySize`, this works because internally objects are stored as arrays. - -If you want to access an item in an object, use `cJSON_GetObjectItemCaseSensitive`. - -To iterate over an object, you can use the `cJSON_ArrayForEach` macro the same way as for arrays. - -cJSON also provides convenient helper functions for quickly creating a new item and adding it to an object, like `cJSON_AddNullToObject`. They return a pointer to the new item or `NULL` if they failed. - -### Parsing JSON - -Given some JSON in a zero terminated string, you can parse it with `cJSON_Parse`. - -```c -cJSON *json = cJSON_Parse(string); -``` - -It will parse the JSON and allocate a tree of `cJSON` items that represents it. Once it returns, you are fully responsible for deallocating it after use with `cJSON_Delete`. - -The allocator used by `cJSON_Parse` is `malloc` and `free` by default but can be changed (globally) with `cJSON_InitHooks`. - -If an error occurs a pointer to the position of the error in the input string can be accessed using `cJSON_GetErrorPtr`. Note though that this can produce race conditions in multithreading scenarios, in that case it is better to use `cJSON_ParseWithOpts` with `return_parse_end`. -By default, characters in the input string that follow the parsed JSON will not be considered as an error. - -If you want more options, use `cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated)`. -`return_parse_end` returns a pointer to the end of the JSON in the input string or the position that an error occurs at (thereby replacing `cJSON_GetErrorPtr` in a thread safe way). `require_null_terminated`, if set to `1` will make it an error if the input string contains data after the JSON. - -### Printing JSON - -Given a tree of `cJSON` items, you can print them as a string using `cJSON_Print`. - -```c -char *string = cJSON_Print(json); -``` - -It will allocate a string and print a JSON representation of the tree into it. Once it returns, you are fully responsible for deallocating it after use with your allocator. (usually `free`, depends on what has been set with `cJSON_InitHooks`). - -`cJSON_Print` will print with whitespace for formatting. If you want to print without formatting, use `cJSON_PrintUnformatted`. - -If you have a rough idea of how big your resulting string will be, you can use `cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt)`. `fmt` is a boolean to turn formatting with whitespace on and off. `prebuffer` specifies the first buffer size to use for printing. `cJSON_Print` currently uses 256 bytes for it's first buffer size. Once printing runs out of space, a new buffer is allocated and the old gets copied over before printing is continued. - -These dynamic buffer allocations can be completely avoided by using `cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format)`. It takes a buffer to a pointer to print to and it's length. If the length is reached, printing will fail and it returns `0`. In case of success, `1` is returned. Note that you should provide 5 bytes more than is actually needed, because cJSON is not 100% accurate in estimating if the provided memory is enough. - -### Example - -In this example we want to build and parse the following JSON: - -```json -{ - "name": "Awesome 4K", - "resolutions": [ - { - "width": 1280, - "height": 720 - }, - { - "width": 1920, - "height": 1080 - }, - { - "width": 3840, - "height": 2160 - } - ] -} -``` - -#### Printing - -Let's build the above JSON and print it to a string: - -```c -//create a monitor with a list of supported resolutions -//NOTE: Returns a heap allocated string, you are required to free it after use. -char* create_monitor(void) -{ - const unsigned int resolution_numbers[3][2] = { - {1280, 720}, - {1920, 1080}, - {3840, 2160} - }; - char *string = NULL; - cJSON *name = NULL; - cJSON *resolutions = NULL; - cJSON *resolution = NULL; - cJSON *width = NULL; - cJSON *height = NULL; - size_t index = 0; - - cJSON *monitor = cJSON_CreateObject(); - if (monitor == NULL) - { - goto end; - } - - name = cJSON_CreateString("Awesome 4K"); - if (name == NULL) - { - goto end; - } - /* after creation was successful, immediately add it to the monitor, - * thereby transferring ownership of the pointer to it */ - cJSON_AddItemToObject(monitor, "name", name); - - resolutions = cJSON_CreateArray(); - if (resolutions == NULL) - { - goto end; - } - cJSON_AddItemToObject(monitor, "resolutions", resolutions); - - for (index = 0; index < (sizeof(resolution_numbers) / (2 * sizeof(int))); ++index) - { - resolution = cJSON_CreateObject(); - if (resolution == NULL) - { - goto end; - } - cJSON_AddItemToArray(resolutions, resolution); - - width = cJSON_CreateNumber(resolution_numbers[index][0]); - if (width == NULL) - { - goto end; - } - cJSON_AddItemToObject(resolution, "width", width); - - height = cJSON_CreateNumber(resolution_numbers[index][1]); - if (height == NULL) - { - goto end; - } - cJSON_AddItemToObject(resolution, "height", height); - } - - string = cJSON_Print(monitor); - if (string == NULL) - { - fprintf(stderr, "Failed to print monitor.\n"); - } - -end: - cJSON_Delete(monitor); - return string; -} -``` - -Alternatively we can use the `cJSON_Add...ToObject` helper functions to make our lifes a little easier: - -```c -//NOTE: Returns a heap allocated string, you are required to free it after use. -char *create_monitor_with_helpers(void) -{ - const unsigned int resolution_numbers[3][2] = { - {1280, 720}, - {1920, 1080}, - {3840, 2160} - }; - char *string = NULL; - cJSON *resolutions = NULL; - size_t index = 0; - - cJSON *monitor = cJSON_CreateObject(); - - if (cJSON_AddStringToObject(monitor, "name", "Awesome 4K") == NULL) - { - goto end; - } - - resolutions = cJSON_AddArrayToObject(monitor, "resolutions"); - if (resolutions == NULL) - { - goto end; - } - - for (index = 0; index < (sizeof(resolution_numbers) / (2 * sizeof(int))); ++index) - { - cJSON *resolution = cJSON_CreateObject(); - - if (cJSON_AddNumberToObject(resolution, "width", resolution_numbers[index][0]) == NULL) - { - goto end; - } - - if(cJSON_AddNumberToObject(resolution, "height", resolution_numbers[index][1]) == NULL) - { - goto end; - } - - cJSON_AddItemToArray(resolutions, resolution); - } - - string = cJSON_Print(monitor); - if (string == NULL) { - fprintf(stderr, "Failed to print monitor.\n"); - } - -end: - cJSON_Delete(monitor); - return string; -} -``` - -#### Parsing - -In this example we will parse a JSON in the above format and check if the monitor supports a Full HD resolution while printing some diagnostic output: - -```c -/* return 1 if the monitor supports full hd, 0 otherwise */ -int supports_full_hd(const char * const monitor) -{ - const cJSON *resolution = NULL; - const cJSON *resolutions = NULL; - const cJSON *name = NULL; - int status = 0; - cJSON *monitor_json = cJSON_Parse(monitor); - if (monitor_json == NULL) - { - const char *error_ptr = cJSON_GetErrorPtr(); - if (error_ptr != NULL) - { - fprintf(stderr, "Error before: %s\n", error_ptr); - } - status = 0; - goto end; - } - - name = cJSON_GetObjectItemCaseSensitive(monitor_json, "name"); - if (cJSON_IsString(name) && (name->valuestring != NULL)) - { - printf("Checking monitor \"%s\"\n", name->valuestring); - } - - resolutions = cJSON_GetObjectItemCaseSensitive(monitor_json, "resolutions"); - cJSON_ArrayForEach(resolution, resolutions) - { - cJSON *width = cJSON_GetObjectItemCaseSensitive(resolution, "width"); - cJSON *height = cJSON_GetObjectItemCaseSensitive(resolution, "height"); - - if (!cJSON_IsNumber(width) || !cJSON_IsNumber(height)) - { - status = 0; - goto end; - } - - if ((width->valuedouble == 1920) && (height->valuedouble == 1080)) - { - status = 1; - goto end; - } - } - -end: - cJSON_Delete(monitor_json); - return status; -} -``` - -Note that there are no NULL checks except for the result of `cJSON_Parse` because `cJSON_GetObjectItemCaseSensitive` checks for `NULL` inputs already, so a `NULL` value is just propagated and `cJSON_IsNumber` and `cJSON_IsString` return `0` if the input is `NULL`. - -### Caveats - -#### Zero Character - -cJSON doesn't support strings that contain the zero character `'\0'` or `\u0000`. This is impossible with the current API because strings are zero terminated. - -#### Character Encoding - -cJSON only supports UTF-8 encoded input. In most cases it doesn't reject invalid UTF-8 as input though, it just propagates it through as is. As long as the input doesn't contain invalid UTF-8, the output will always be valid UTF-8. - -#### C Standard - -cJSON is written in ANSI C (or C89, C90). If your compiler or C library doesn't follow this standard, correct behavior is not guaranteed. - -NOTE: ANSI C is not C++ therefore it shouldn't be compiled with a C++ compiler. You can compile it with a C compiler and link it with your C++ code however. Although compiling with a C++ compiler might work, correct behavior is not guaranteed. - -#### Floating Point Numbers - -cJSON does not officially support any `double` implementations other than IEEE754 double precision floating point numbers. It might still work with other implementations but bugs with these will be considered invalid. - -The maximum length of a floating point literal that cJSON supports is currently 63 characters. - -#### Deep Nesting Of Arrays And Objects - -cJSON doesn't support arrays and objects that are nested too deeply because this would result in a stack overflow. To prevent this cJSON limits the depth to `CJSON_NESTING_LIMIT` which is 1000 by default but can be changed at compile time. - -#### Thread Safety - -In general cJSON is **not thread safe**. - -However it is thread safe under the following conditions: - -* `cJSON_GetErrorPtr` is never used (the `return_parse_end` parameter of `cJSON_ParseWithOpts` can be used instead) -* `cJSON_InitHooks` is only ever called before using cJSON in any threads. -* `setlocale` is never called before all calls to cJSON functions have returned. - -#### Case Sensitivity - -When cJSON was originally created, it didn't follow the JSON standard and didn't make a distinction between uppercase and lowercase letters. If you want the correct, standard compliant, behavior, you need to use the `CaseSensitive` functions where available. - -#### Duplicate Object Members - -cJSON supports parsing and printing JSON that contains objects that have multiple members with the same name. `cJSON_GetObjectItemCaseSensitive` however will always only return the first one. - -# Enjoy cJSON! - -- Dave Gamble (original author) -- Max Bruckner (current maintainer) -- and the other [cJSON contributors](CONTRIBUTORS.md) Deleted: trunk/TTXSamples/TTXCheckUpdate/cJSON/cJSON.c =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/cJSON/cJSON.c 2020-01-22 13:54:11 UTC (rev 8499) +++ trunk/TTXSamples/TTXCheckUpdate/cJSON/cJSON.c 2020-01-22 13:54:20 UTC (rev 8500) @@ -1,2979 +0,0 @@ -/* - Copyright (c) 2009-2017 Dave Gamble and cJSON contributors - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -/* cJSON */ -/* JSON parser in C. */ - -/* disable warnings about old C89 functions in MSVC */ -#if !defined(_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) -#define _CRT_SECURE_NO_DEPRECATE -#endif - -#ifdef __GNUC__ -#pragma GCC visibility push(default) -#endif -#if defined(_MSC_VER) -#pragma warning (push) -/* disable warning about single line comments in system headers */ -#pragma warning (disable : 4001) -#endif - -#include -#include -#include -#include -#include -#include - -#ifdef ENABLE_LOCALES -#include -#endif - -#if defined(_MSC_VER) -#pragma warning (pop) -#endif -#ifdef __GNUC__ -#pragma GCC visibility pop -#endif - -#include "cJSON.h" - -/* define our own boolean type */ -#ifdef true -#undef true -#endif -#define true ((cJSON_bool)1) - -#ifdef false -#undef false -#endif -#define false ((cJSON_bool)0) - -typedef struct { - const unsigned char *json; - size_t position; -} error; -static error global_error = { NULL, 0 }; - -CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void) -{ - return (const char*) (global_error.json + global_error.position); -} - -CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item) { - if (!cJSON_IsString(item)) { - return NULL; - } - - return item->valuestring; -} - -/* This is a safeguard to prevent copy-pasters from using incompatible C and header files */ -#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 12) - #error cJSON.h and cJSON.c have different versions. Make sure that both have the same. -#endif - -CJSON_PUBLIC(const char*) cJSON_Version(void) -{ - static char version[15]; - sprintf(version, "%i.%i.%i", CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH); - - return version; -} - -/* Case insensitive string comparison, doesn't consider two NULL pointers equal though */ -static int case_insensitive_strcmp(const unsigned char *string1, const unsigned char *string2) -{ - if ((string1 == NULL) || (string2 == NULL)) - { - return 1; - } - - if (string1 == string2) - { - return 0; - } - - for(; tolower(*string1) == tolower(*string2); (void)string1++, string2++) - { - if (*string1 == '\0') - { - return 0; - } - } - - return tolower(*string1) - tolower(*string2); -} - -typedef struct internal_hooks -{ - void *(CJSON_CDECL *allocate)(size_t size); - void (CJSON_CDECL *deallocate)(void *pointer); - void *(CJSON_CDECL *reallocate)(void *pointer, size_t size); -} internal_hooks; - -#if defined(_MSC_VER) -/* work around MSVC error C2322: '...' address of dllimport '...' is not static */ -static void * CJSON_CDECL internal_malloc(size_t size) -{ - return malloc(size); -} -static void CJSON_CDECL internal_free(void *pointer) -{ - free(pointer); -} -static void * CJSON_CDECL internal_realloc(void *pointer, size_t size) -{ - return realloc(pointer, size); -} -#else -#define internal_malloc malloc -#define internal_free free -#define internal_realloc realloc -#endif - -/* strlen of character literals resolved at compile time */ -#define static_strlen(string_literal) (sizeof(string_literal) - sizeof("")) - -static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc }; - -static unsigned char* cJSON_strdup(const unsigned char* string, const internal_hooks * const hooks) -{ - size_t length = 0; - unsigned char *copy = NULL; - - if (string == NULL) - { - return NULL; - } - - length = strlen((const char*)string) + sizeof(""); - copy = (unsigned char*)hooks->allocate(length); - if (copy == NULL) - { - return NULL; - } - memcpy(copy, string, length); - - return copy; -} - -CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks) -{ - if (hooks == NULL) - { - /* Reset hooks */ - global_hooks.allocate = malloc; - global_hooks.deallocate = free; - global_hooks.reallocate = realloc; - return; - } - - global_hooks.allocate = malloc; - if (hooks->malloc_fn != NULL) - { - global_hooks.allocate = hooks->malloc_fn; - } - - global_hooks.deallocate = free; - if (hooks->free_fn != NULL) - { - global_hooks.deallocate = hooks->free_fn; - } - - /* use realloc only if both free and malloc are used */ - global_hooks.reallocate = NULL; - if ((global_hooks.allocate == malloc) && (global_hooks.deallocate == free)) - { - global_hooks.reallocate = realloc; - } -} - -/* Internal constructor. */ -static cJSON *cJSON_New_Item(const internal_hooks * const hooks) -{ - cJSON* node = (cJSON*)hooks->allocate(sizeof(cJSON)); - if (node) - { - memset(node, '\0', sizeof(cJSON)); - } - - return node; -} - -/* Delete a cJSON structure. */ -CJSON_PUBLIC(void) cJSON_Delete(cJSON *item) -{ - cJSON *next = NULL; - while (item != NULL) - { - next = item->next; - if (!(item->type & cJSON_IsReference) && (item->child != NULL)) - { - cJSON_Delete(item->child); - } - if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL)) - { - global_hooks.deallocate(item->valuestring); - } - if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) - { - global_hooks.deallocate(item->string); - } - global_hooks.deallocate(item); - item = next; - } -} - -/* get the decimal point character of the current locale */ -static unsigned char get_decimal_point(void) -{ -#ifdef ENABLE_LOCALES - struct lconv *lconv = localeconv(); - return (unsigned char) lconv->decimal_point[0]; -#else - return '.'; -#endif -} - -typedef struct -{ - const unsigned char *content; - size_t length; - size_t offset; - size_t depth; /* How deeply nested (in arrays/objects) is the input at the current offset. */ - internal_hooks hooks; -} parse_buffer; - -/* check if the given size is left to read in a given parse buffer (starting with 1) */ -#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length)) -/* check if the buffer can be accessed at the given index (starting with 0) */ -#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length)) -#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index)) -/* get a pointer to the buffer at the position */ -#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset) - -/* Parse the input text to generate a number, and populate the result into item. */ -static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer) -{ - double number = 0; - unsigned char *after_end = NULL; - unsigned char number_c_string[64]; - unsigned char decimal_point = get_decimal_point(); - size_t i = 0; - - if ((input_buffer == NULL) || (input_buffer->content == NULL)) - { - return false; - } - - /* copy the number into a temporary buffer and replace '.' with the decimal point - * of the current locale (for strtod) - * This also takes care of '\0' not necessarily being available for marking the end of the input */ - for (i = 0; (i < (sizeof(number_c_string) - 1)) && can_access_at_index(input_buffer, i); i++) - { - switch (buffer_at_offset(input_buffer)[i]) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '+': - case '-': - case 'e': - case 'E': - number_c_string[i] = buffer_at_offset(input_buffer)[i]; - break; - - case '.': - number_c_string[i] = decimal_point; - break; - - default: - goto loop_end; - } - } -loop_end: - number_c_string[i] = '\0'; - - number = strtod((const char*)number_c_string, (char**)&after_end); - if (number_c_string == after_end) - { - return false; /* parse_error */ - } - - item->valuedouble = number; - - /* use saturation in case of overflow */ - if (number >= INT_MAX) - { - item->valueint = INT_MAX; - } - else if (number <= (double)INT_MIN) - { - item->valueint = INT_MIN; - } - else - { - item->valueint = (int)number; - } - - item->type = cJSON_Number; - - input_buffer->offset += (size_t)(after_end - number_c_string); - return true; -} - -/* don't ask me, but the original cJSON_SetNumberValue returns an integer or double */ -CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number) -{ - if (number >= INT_MAX) - { - object->valueint = INT_MAX; - } - else if (number <= (double)INT_MIN) - { - object->valueint = INT_MIN; - } - else - { - object->valueint = (int)number; - } - - return object->valuedouble = number; -} - -typedef struct -{ - unsigned char *buffer; - size_t length; - size_t offset; - size_t depth; /* current nesting depth (for formatted printing) */ - cJSON_bool noalloc; - cJSON_bool format; /* is this print a formatted print */ - internal_hooks hooks; -} printbuffer; - -/* realloc printbuffer if necessary to have at least "needed" bytes more */ -static unsigned char* ensure(printbuffer * const p, size_t needed) -{ - unsigned char *newbuffer = NULL; - size_t newsize = 0; - - if ((p == NULL) || (p->buffer == NULL)) - { - return NULL; - } - - if ((p->length > 0) && (p->offset >= p->length)) - { - /* make sure that offset is valid */ - return NULL; - } - - if (needed > INT_MAX) - { - /* sizes bigger than INT_MAX are currently not supported */ - return NULL; - } - - needed += p->offset + 1; - if (needed <= p->length) - { - return p->buffer + p->offset; - } - - if (p->noalloc) { - return NULL; - } - - /* calculate new buffer size */ - if (needed > (INT_MAX / 2)) - { - /* overflow of int, use INT_MAX if possible */ - if (needed <= INT_MAX) - { - newsize = INT_MAX; - } - else - { - return NULL; - } - } - else - { - newsize = needed * 2; - } - - if (p->hooks.reallocate != NULL) - { - /* reallocate with realloc if available */ - newbuffer = (unsigned char*)p->hooks.reallocate(p->buffer, newsize); - if (newbuffer == NULL) - { - p->hooks.deallocate(p->buffer); - p->length = 0; - p->buffer = NULL; - - return NULL; - } - } - else - { - /* otherwise reallocate manually */ - newbuffer = (unsigned char*)p->hooks.allocate(newsize); - if (!newbuffer) - { - p->hooks.deallocate(p->buffer); - p->length = 0; - p->buffer = NULL; - - return NULL; - } - if (newbuffer) - { - memcpy(newbuffer, p->buffer, p->offset + 1); - } - p->hooks.deallocate(p->buffer); - } - p->length = newsize; - p->buffer = newbuffer; - - return newbuffer + p->offset; -} - -/* calculate the new length of the string in a printbuffer and update the offset */ -static void update_offset(printbuffer * const buffer) -{ - const unsigned char *buffer_pointer = NULL; - if ((buffer == NULL) || (buffer->buffer == NULL)) - { - return; - } - buffer_pointer = buffer->buffer + buffer->offset; - - buffer->offset += strlen((const char*)buffer_pointer); -} - -/* securely comparison of floating-point variables */ -static cJSON_bool compare_double(double a, double b) -{ - return (fabs(a - b) <= CJSON_DOUBLE_PRECISION); -} - -/* Render the number nicely from the given item into a string. */ -static cJSON_bool print_number(const cJSON * const item, printbuffer * const output_buffer) -{ - unsigned char *output_pointer = NULL; - double d = item->valuedouble; - int length = 0; - size_t i = 0; - unsigned char number_buffer[26] = {0}; /* temporary buffer to print the number into */ - unsigned char decimal_point = get_decimal_point(); - double test = 0.0; - - if (output_buffer == NULL) - { - return false; - } - - /* This checks for NaN and Infinity */ - if (!compare_double(d * 0, 0)) - { - length = sprintf((char*)number_buffer, "null"); - } - else - { - /* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */ - length = sprintf((char*)number_buffer, "%1.15g", d); - - /* Check whether the original double can be recovered */ - if ((sscanf((char*)number_buffer, "%lg", &test) != 1) || !compare_double((double)test, d)) - { - /* If not, print with 17 decimal places of precision */ - length = sprintf((char*)number_buffer, "%1.17g", d); - } - } - - /* sprintf failed or buffer overrun occurred */ - if ((length < 0) || (length > (int)(sizeof(number_buffer) - 1))) - { - return false; - } - - /* reserve appropriate space in the output */ - output_pointer = ensure(output_buffer, (size_t)length + sizeof("")); - if (output_pointer == NULL) - { - return false; - } - - /* copy the printed number to the output and replace locale - * dependent decimal point with '.' */ - for (i = 0; i < ((size_t)length); i++) - { - if (number_buffer[i] == decimal_point) - { - output_pointer[i] = '.'; - continue; - } - - output_pointer[i] = number_buffer[i]; - } - output_pointer[i] = '\0'; - - output_buffer->offset += (size_t)length; - - return true; -} - -/* parse 4 digit hexadecimal number */ -static unsigned parse_hex4(const unsigned char * const input) -{ - unsigned int h = 0; - size_t i = 0; - - for (i = 0; i < 4; i++) - { - /* parse digit */ - if ((input[i] >= '0') && (input[i] <= '9')) - { - h += (unsigned int) input[i] - '0'; - } - else if ((input[i] >= 'A') && (input[i] <= 'F')) - { - h += (unsigned int) 10 + input[i] - 'A'; - } - else if ((input[i] >= 'a') && (input[i] <= 'f')) - { - h += (unsigned int) 10 + input[i] - 'a'; - } - else /* invalid */ - { - return 0; - } - - if (i < 3) - { - /* shift left to make place for the next nibble */ - h = h << 4; - } - } - - return h; -} - -/* converts a UTF-16 literal to UTF-8 - * A literal can be one or two sequences of the form \uXXXX */ -static unsigned char utf16_literal_to_utf8(const unsigned char * const input_pointer, const unsigned char * const input_end, unsigned char **output_pointer) -{ - long unsigned int codepoint = 0; - unsigned int first_code = 0; - const unsigned char *first_sequence = input_pointer; - unsigned char utf8_length = 0; - unsigned char utf8_position = 0; - unsigned char sequence_length = 0; - unsigned char first_byte_mark = 0; - - if ((input_end - first_sequence) < 6) - { - /* input ends unexpectedly */ - goto fail; - } - - /* get the first utf16 sequence */ - first_code = parse_hex4(first_sequence + 2); - - /* check that the code is valid */ - if (((first_code >= 0xDC00) && (first_code <= 0xDFFF))) - { - goto fail; - } - - /* UTF16 surrogate pair */ - if ((first_code >= 0xD800) && (first_code <= 0xDBFF)) - { - const unsigned char *second_sequence = first_sequence + 6; - unsigned int second_code = 0; - sequence_length = 12; /* \uXXXX\uXXXX */ - - if ((input_end - second_sequence) < 6) - { - /* input ends unexpectedly */ - goto fail; - } - - if ((second_sequence[0] != '\\') || (second_sequence[1] != 'u')) - { - /* missing second half of the surrogate pair */ - goto fail; - } - - /* get the second utf16 sequence */ - second_code = parse_hex4(second_sequence + 2); - /* check that the code is valid */ - if ((second_code < 0xDC00) || (second_code > 0xDFFF)) - { - /* invalid second half of the surrogate pair */ - goto fail; - } - - - /* calculate the unicode codepoint from the surrogate pair */ - codepoint = 0x10000 + (((first_code & 0x3FF) << 10) | (second_code & 0x3FF)); - } - else - { - sequence_length = 6; /* \uXXXX */ - codepoint = first_code; - } - - /* encode as UTF-8 - * takes at maximum 4 bytes to encode: - * 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */ - if (codepoint < 0x80) - { - /* normal ascii, encoding 0xxxxxxx */ - utf8_length = 1; - } - else if (codepoint < 0x800) - { - /* two bytes, encoding 110xxxxx 10xxxxxx */ - utf8_length = 2; - first_byte_mark = 0xC0; /* 11000000 */ - } - else if (codepoint < 0x10000) - { - /* three bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx */ - utf8_length = 3; - first_byte_mark = 0xE0; /* 11100000 */ - } - else if (codepoint <= 0x10FFFF) - { - /* four bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx 10xxxxxx */ - utf8_length = 4; - first_byte_mark = 0xF0; /* 11110000 */ - } - else - { - /* invalid unicode codepoint */ - goto fail; - } - - /* encode as utf8 */ - for (utf8_position = (unsigned char)(utf8_length - 1); utf8_position > 0; utf8_position--) - { - /* 10xxxxxx */ - (*output_pointer)[utf8_position] = (unsigned char)((codepoint | 0x80) & 0xBF); - codepoint >>= 6; - } - /* encode first byte */ - if (utf8_length > 1) - { - (*output_pointer)[0] = (unsigned char)((codepoint | first_byte_mark) & 0xFF); - } - else - { - (*output_pointer)[0] = (unsigned char)(codepoint & 0x7F); - } - - *output_pointer += utf8_length; - - return sequence_length; - -fail: - return 0; -} - -/* Parse the input text into an unescaped cinput, and populate item. */ -static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_buffer) -{ - const unsigned char *input_pointer = buffer_at_offset(input_buffer) + 1; - const unsigned char *input_end = buffer_at_offset(input_buffer) + 1; - unsigned char *output_pointer = NULL; - unsigned char *output = NULL; - - /* not a string */ - if (buffer_at_offset(input_buffer)[0] != '\"') - { - goto fail; - } - - { - /* calculate approximate size of the output (overestimate) */ - size_t allocation_length = 0; - size_t skipped_bytes = 0; - while (((size_t)(input_end - input_buffer->content) < input_buffer->length) && (*input_end != '\"')) - { - /* is escape sequence */ - if (input_end[0] == '\\') - { - if ((size_t)(input_end + 1 - input_buffer->content) >= input_buffer->length) - { - /* prevent buffer overflow when last input character is a backslash */ - goto fail; - } - skipped_bytes++; - input_end++; - } - input_end++; - } - if (((size_t)(input_end - input_buffer->content) >= input_buffer->length) || (*input_end != '\"')) - { - goto fail; /* string ended unexpectedly */ - } - - /* This is at most how much we need for the output */ - allocation_length = (size_t) (input_end - buffer_at_offset(input_buffer)) - skipped_bytes; - output = (unsigned char*)input_buffer->hooks.allocate(allocation_length + sizeof("")); - if (output == NULL) - { - goto fail; /* allocation failure */ - } - } - - output_pointer = output; - /* loop through the string literal */ - while (input_pointer < input_end) - { - if (*input_pointer != '\\') - { - *output_pointer++ = *input_pointer++; - } - /* escape sequence */ - else - { - unsigned char sequence_length = 2; - if ((input_end - input_pointer) < 1) - { - goto fail; - } - - switch (input_pointer[1]) - { - case 'b': - *output_pointer++ = '\b'; - break; - case 'f': - *output_pointer++ = '\f'; - break; - case 'n': - *output_pointer++ = '\n'; - break; - case 'r': - *output_pointer++ = '\r'; - break; - case 't': - *output_pointer++ = '\t'; - break; - case '\"': - case '\\': - case '/': - *output_pointer++ = input_pointer[1]; - break; - - /* UTF-16 literal */ - case 'u': - sequence_length = utf16_literal_to_utf8(input_pointer, input_end, &output_pointer); - if (sequence_length == 0) - { - /* failed to convert UTF16-literal to UTF-8 */ - goto fail; - } - break; - - default: - goto fail; - } - input_pointer += sequence_length; - } - } - - /* zero terminate the output */ - *output_pointer = '\0'; - - item->type = cJSON_String; - item->valuestring = (char*)output; - - input_buffer->offset = (size_t) (input_end - input_buffer->content); - input_buffer->offset++; - - return true; - -fail: - if (output != NULL) - { - input_buffer->hooks.deallocate(output); - } - - if (input_pointer != NULL) - { - input_buffer->offset = (size_t)(input_pointer - input_buffer->content); - } - - return false; -} - -/* Render the cstring provided to an escaped version that can be printed. */ -static cJSON_bool print_string_ptr(const unsigned char * const input, printbuffer * const output_buffer) -{ - const unsigned char *input_pointer = NULL; - unsigned char *output = NULL; - unsigned char *output_pointer = NULL; - size_t output_length = 0; - /* numbers of additional characters needed for escaping */ - size_t escape_characters = 0; - - if (output_buffer == NULL) - { - return false; - } - - /* empty string */ - if (input == NULL) - { - output = ensure(output_buffer, sizeof("\"\"")); - if (output == NULL) - { - return false; - } - strcpy((char*)output, "\"\""); - - return true; - } - - /* set "flag" to 1 if something needs to be escaped */ - for (input_pointer = input; *input_pointer; input_pointer++) - { - switch (*input_pointer) - { - case '\"': - case '\\': - case '\b': - case '\f': - case '\n': - case '\r': - case '\t': - /* one character escape sequence */ - escape_characters++; - break; - default: - if (*input_pointer < 32) - { - /* UTF-16 escape sequence uXXXX */ - escape_characters += 5; - } - break; - } - } - output_length = (size_t)(input_pointer - input) + escape_characters; - - output = ensure(output_buffer, output_length + sizeof("\"\"")); - if (output == NULL) - { - return false; - } - - /* no characters have to be escaped */ - if (escape_characters == 0) - { - output[0] = '\"'; - memcpy(output + 1, input, output_length); - output[output_length + 1] = '\"'; - output[output_length + 2] = '\0'; - - return true; - } - - output[0] = '\"'; - output_pointer = output + 1; - /* copy the string */ - for (input_pointer = input; *input_pointer != '\0'; (void)input_pointer++, output_pointer++) - { - if ((*input_pointer > 31) && (*input_pointer != '\"') && (*input_pointer != '\\')) - { - /* normal character, copy */ - *output_pointer = *input_pointer; - } - else - { - /* character needs to be escaped */ - *output_pointer++ = '\\'; - switch (*input_pointer) - { - case '\\': - *output_pointer = '\\'; - break; - case '\"': - *output_pointer = '\"'; - break; - case '\b': - *output_pointer = 'b'; - break; - case '\f': - *output_pointer = 'f'; - break; - case '\n': - *output_pointer = 'n'; - break; - case '\r': - *output_pointer = 'r'; - break; - case '\t': - *output_pointer = 't'; - break; - default: - /* escape and print as unicode codepoint */ - sprintf((char*)output_pointer, "u%04x", *input_pointer); - output_pointer += 4; - break; - } - } - } - output[output_length + 1] = '\"'; - output[output_length + 2] = '\0'; - - return true; -} - -/* Invoke print_string_ptr (which is useful) on an item. */ -static cJSON_bool print_string(const cJSON * const item, printbuffer * const p) -{ - return print_string_ptr((unsigned char*)item->valuestring, p); -} - -/* Predeclare these prototypes. */ -static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer); -static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer); -static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer); -static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer); -static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer); -static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer); - -/* Utility to jump whitespace and cr/lf */ -static parse_buffer *buffer_skip_whitespace(parse_buffer * const buffer) -{ - if ((buffer == NULL) || (buffer->content == NULL)) - { - return NULL; - } - - while (can_access_at_index(buffer, 0) && (buffer_at_offset(buffer)[0] <= 32)) - { - buffer->offset++; - } - - if (buffer->offset == buffer->length) - { - buffer->offset--; - } - - return buffer; -} - -/* skip the UTF-8 BOM (byte order mark) if it is at the beginning of a buffer */ -static parse_buffer *skip_utf8_bom(parse_buffer * const buffer) -{ - if ((buffer == NULL) || (buffer->content == NULL) || (buffer->offset != 0)) - { - return NULL; - } - - if (can_access_at_index(buffer, 4) && (strncmp((const char*)buffer_at_offset(buffer), "\xEF\xBB\xBF", 3) == 0)) - { - buffer->offset += 3; - } - - return buffer; -} - -/* Parse an object - create a new root, and populate. */ -CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated) -{ - parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } }; - cJSON *item = NULL; - - /* reset error position */ - global_error.json = NULL; - global_error.position = 0; - - if (value == NULL) - { - goto fail; - } - - buffer.content = (const unsigned char*)value; - buffer.length = strlen((const char*)value) + sizeof(""); - buffer.offset = 0; - buffer.hooks = global_hooks; - - item = cJSON_New_Item(&global_hooks); - if (item == NULL) /* memory fail */ - { - goto fail; - } - - if (!parse_value(item, buffer_skip_whitespace(skip_utf8_bom(&buffer)))) - { - /* parse failure. ep is set. */ - goto fail; - } - - /* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */ - if (require_null_terminated) - { - buffer_skip_whitespace(&buffer); - if ((buffer.offset >= buffer.length) || buffer_at_offset(&buffer)[0] != '\0') - { - goto fail; - } - } - if (return_parse_end) - { - *return_parse_end = (const char*)buffer_at_offset(&buffer); - } - - return item; - -fail: - if (item != NULL) - { - cJSON_Delete(item); - } - - if (value != NULL) - { - error local_error; - local_error.json = (const unsigned char*)value; - local_error.position = 0; - - if (buffer.offset < buffer.length) - { - local_error.position = buffer.offset; - } - else if (buffer.length > 0) - { - local_error.position = buffer.length - 1; - } - - if (return_parse_end != NULL) - { - *return_parse_end = (const char*)local_error.json + local_error.position; - } - - global_error = local_error; - } - - return NULL; -} - -/* Default options for cJSON_Parse */ -CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value) -{ - return cJSON_ParseWithOpts(value, 0, 0); -} - -#define cjson_min(a, b) ((a < b) ? a : b) - -static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks) -{ - static const size_t default_buffer_size = 256; - printbuffer buffer[1]; - unsigned char *printed = NULL; - - memset(buffer, 0, sizeof(buffer)); - - /* create buffer */ - buffer->buffer = (unsigned char*) hooks->allocate(default_buffer_size); - buffer->length = default_buffer_size; - buffer->format = format; - buffer->hooks = *hooks; - if (buffer->buffer == NULL) - { - goto fail; - } - - /* print the value */ - if (!print_value(item, buffer)) - { - goto fail; - } - update_offset(buffer); - - /* check if reallocate is available */ - if (hooks->reallocate != NULL) - { - printed = (unsigned char*) hooks->reallocate(buffer->buffer, buffer->offset + 1); - if (printed == NULL) { - goto fail; - } - buffer->buffer = NULL; - } - else /* otherwise copy the JSON over to a new buffer */ - { - printed = (unsigned char*) hooks->allocate(buffer->offset + 1); - if (printed == NULL) - { - goto fail; - } - memcpy(printed, buffer->buffer, cjson_min(buffer->length, buffer->offset + 1)); - printed[buffer->offset] = '\0'; /* just to be sure */ - - /* free the buffer */ - hooks->deallocate(buffer->buffer); - } - - return printed; - -fail: - if (buffer->buffer != NULL) - { - hooks->deallocate(buffer->buffer); - } - - if (printed != NULL) - { - hooks->deallocate(printed); - } - - return NULL; -} - -/* Render a cJSON item/entity/structure to text. */ -CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item) -{ - return (char*)print(item, true, &global_hooks); -} - -CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item) -{ - return (char*)print(item, false, &global_hooks); -} - -CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt) -{ - printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }; - - if (prebuffer < 0) - { - return NULL; - } - - p.buffer = (unsigned char*)global_hooks.allocate((size_t)prebuffer); - if (!p.buffer) - { - return NULL; - } - - p.length = (size_t)prebuffer; - p.offset = 0; - p.noalloc = false; - p.format = fmt; - p.hooks = global_hooks; - - if (!print_value(item, &p)) - { - global_hooks.deallocate(p.buffer); - return NULL; - } - - return (char*)p.buffer; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format) -{ - printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }; - - if ((length < 0) || (buffer == NULL)) - { - return false; - } - - p.buffer = (unsigned char*)buffer; - p.length = (size_t)length; - p.offset = 0; - p.noalloc = true; - p.format = format; - p.hooks = global_hooks; - - return print_value(item, &p); -} - -/* Parser core - when encountering text, process appropriately. */ -static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer) -{ - if ((input_buffer == NULL) || (input_buffer->content == NULL)) - { - return false; /* no input */ - } - - /* parse the different types of values */ - /* null */ - if (can_read(input_buffer, 4) && (strncmp((const char*)buffer_at_offset(input_buffer), "null", 4) == 0)) - { - item->type = cJSON_NULL; - input_buffer->offset += 4; - return true; - } - /* false */ - if (can_read(input_buffer, 5) && (strncmp((const char*)buffer_at_offset(input_buffer), "false", 5) == 0)) - { - item->type = cJSON_False; - input_buffer->offset += 5; - return true; - } - /* true */ - if (can_read(input_buffer, 4) && (strncmp((const char*)buffer_at_offset(input_buffer), "true", 4) == 0)) - { - item->type = cJSON_True; - item->valueint = 1; - input_buffer->offset += 4; - return true; - } - /* string */ - if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '\"')) - { - return parse_string(item, input_buffer); - } - /* number */ - if (can_access_at_index(input_buffer, 0) && ((buffer_at_offset(input_buffer)[0] == '-') || ((buffer_at_offset(input_buffer)[0] >= '0') && (buffer_at_offset(input_buffer)[0] <= '9')))) - { - return parse_number(item, input_buffer); - } - /* array */ - if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '[')) - { - return parse_array(item, input_buffer); - } - /* object */ - if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '{')) - { - return parse_object(item, input_buffer); - } - - return false; -} - -/* Render a value to text. */ -static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer) -{ - unsigned char *output = NULL; - - if ((item == NULL) || (output_buffer == NULL)) - { - return false; - } - - switch ((item->type) & 0xFF) - { - case cJSON_NULL: - output = ensure(output_buffer, 5); - if (output == NULL) - { - return false; - } - strcpy((char*)output, "null"); - return true; - - case cJSON_False: - output = ensure(output_buffer, 6); - if (output == NULL) - { - return false; - } - strcpy((char*)output, "false"); - return true; - - case cJSON_True: - output = ensure(output_buffer, 5); - if (output == NULL) - { - return false; - } - strcpy((char*)output, "true"); - return true; - - case cJSON_Number: - return print_number(item, output_buffer); - - case cJSON_Raw: - { - size_t raw_length = 0; - if (item->valuestring == NULL) - { - return false; - } - - raw_length = strlen(item->valuestring) + sizeof(""); - output = ensure(output_buffer, raw_length); - if (output == NULL) - { - return false; - } - memcpy(output, item->valuestring, raw_length); - return true; - } - - case cJSON_String: - return print_string(item, output_buffer); - - case cJSON_Array: - return print_array(item, output_buffer); - - case cJSON_Object: - return print_object(item, output_buffer); - - default: - return false; - } -} - -/* Build an array from input text. */ -static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer) -{ - cJSON *head = NULL; /* head of the linked list */ - cJSON *current_item = NULL; - - if (input_buffer->depth >= CJSON_NESTING_LIMIT) - { - return false; /* to deeply nested */ - } - input_buffer->depth++; - - if (buffer_at_offset(input_buffer)[0] != '[') - { - /* not an array */ - goto fail; - } - - input_buffer->offset++; - buffer_skip_whitespace(input_buffer); - if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ']')) - { - /* empty array */ - goto success; - } - - /* check if we skipped to the end of the buffer */ - if (cannot_access_at_index(input_buffer, 0)) - { - input_buffer->offset--; - goto fail; - } - - /* step back to character in front of the first element */ - input_buffer->offset--; - /* loop through the comma separated array elements */ - do - { - /* allocate next item */ - cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks)); - if (new_item == NULL) - { - goto fail; /* allocation failure */ - } - - /* attach next item to list */ - if (head == NULL) - { - /* start the linked list */ - current_item = head = new_item; - } - else - { - /* add to the end and advance */ - current_item->next = new_item; - new_item->prev = current_item; - current_item = new_item; - } - - /* parse next value */ - input_buffer->offset++; - buffer_skip_whitespace(input_buffer); - if (!parse_value(current_item, input_buffer)) - { - goto fail; /* failed to parse value */ - } - buffer_skip_whitespace(input_buffer); - } - while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ',')); - - if (cannot_access_at_index(input_buffer, 0) || buffer_at_offset(input_buffer)[0] != ']') - { - goto fail; /* expected end of array */ - } - -success: - input_buffer->depth--; - - item->type = cJSON_Array; - item->child = head; - - input_buffer->offset++; - - return true; - -fail: - if (head != NULL) - { - cJSON_Delete(head); - } - - return false; -} - -/* Render an array to text */ -static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer) -{ - unsigned char *output_pointer = NULL; - size_t length = 0; - cJSON *current_element = item->child; - - if (output_buffer == NULL) - { - return false; - } - - /* Compose the output array. */ - /* opening square bracket */ - output_pointer = ensure(output_buffer, 1); - if (output_pointer == NULL) - { - return false; - } - - *output_pointer = '['; - output_buffer->offset++; - output_buffer->depth++; - - while (current_element != NULL) - { - if (!print_value(current_element, output_buffer)) - { - return false; - } - update_offset(output_buffer); - if (current_element->next) - { - length = (size_t) (output_buffer->format ? 2 : 1); - output_pointer = ensure(output_buffer, length + 1); - if (output_pointer == NULL) - { - return false; - } - *output_pointer++ = ','; - if(output_buffer->format) - { - *output_pointer++ = ' '; - } - *output_pointer = '\0'; - output_buffer->offset += length; - } - current_element = current_element->next; - } - - output_pointer = ensure(output_buffer, 2); - if (output_pointer == NULL) - { - return false; - } - *output_pointer++ = ']'; - *output_pointer = '\0'; - output_buffer->depth--; - - return true; -} - -/* Build an object from the text. */ -static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer) -{ - cJSON *head = NULL; /* linked list head */ - cJSON *current_item = NULL; - - if (input_buffer->depth >= CJSON_NESTING_LIMIT) - { - return false; /* to deeply nested */ - } - input_buffer->depth++; - - if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '{')) - { - goto fail; /* not an object */ - } - - input_buffer->offset++; - buffer_skip_whitespace(input_buffer); - if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '}')) - { - goto success; /* empty object */ - } - - /* check if we skipped to the end of the buffer */ - if (cannot_access_at_index(input_buffer, 0)) - { - input_buffer->offset--; - goto fail; - } - - /* step back to character in front of the first element */ - input_buffer->offset--; - /* loop through the comma separated array elements */ - do - { - /* allocate next item */ - cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks)); - if (new_item == NULL) - { - goto fail; /* allocation failure */ - } - - /* attach next item to list */ - if (head == NULL) - { - /* start the linked list */ - current_item = head = new_item; - } - else - { - /* add to the end and advance */ - current_item->next = new_item; - new_item->prev = current_item; - current_item = new_item; - } - - /* parse the name of the child */ - input_buffer->offset++; - buffer_skip_whitespace(input_buffer); - if (!parse_string(current_item, input_buffer)) - { - goto fail; /* failed to parse name */ - } - buffer_skip_whitespace(input_buffer); - - /* swap valuestring and string, because we parsed the name */ - current_item->string = current_item->valuestring; - current_item->valuestring = NULL; - - if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != ':')) - { - goto fail; /* invalid object */ - } - - /* parse the value */ - input_buffer->offset++; - buffer_skip_whitespace(input_buffer); - if (!parse_value(current_item, input_buffer)) - { - goto fail; /* failed to parse value */ - } - buffer_skip_whitespace(input_buffer); - } - while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ',')); - - if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '}')) - { - goto fail; /* expected end of object */ - } - -success: - input_buffer->depth--; - - item->type = cJSON_Object; - item->child = head; - - input_buffer->offset++; - return true; - -fail: - if (head != NULL) - { - cJSON_Delete(head); - } - - return false; -} - -/* Render an object to text. */ -static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer) -{ - unsigned char *output_pointer = NULL; - size_t length = 0; - cJSON *current_item = item->child; - - if (output_buffer == NULL) - { - return false; - } - - /* Compose the output: */ - length = (size_t) (output_buffer->format ? 2 : 1); /* fmt: {\n */ - output_pointer = ensure(output_buffer, length + 1); - if (output_pointer == NULL) - { - return false; - } - - *output_pointer++ = '{'; - output_buffer->depth++; - if (output_buffer->format) - { - *output_pointer++ = '\n'; - } - output_buffer->offset += length; - - while (current_item) - { - if (output_buffer->format) - { - size_t i; - output_pointer = ensure(output_buffer, output_buffer->depth); - if (output_pointer == NULL) - { - return false; - } - for (i = 0; i < output_buffer->depth; i++) - { - *output_pointer++ = '\t'; - } - output_buffer->offset += output_buffer->depth; - } - - /* print key */ - if (!print_string_ptr((unsigned char*)current_item->string, output_buffer)) - { - return false; - } - update_offset(output_buffer); - - length = (size_t) (output_buffer->format ? 2 : 1); - output_pointer = ensure(output_buffer, length); - if (output_pointer == NULL) - { - return false; - } - *output_pointer++ = ':'; - if (output_buffer->format) - { - *output_pointer++ = '\t'; - } - output_buffer->offset += length; - - /* print value */ - if (!print_value(current_item, output_buffer)) - { - return false; - } - update_offset(output_buffer); - - /* print comma if not last */ - length = ((size_t)(output_buffer->format ? 1 : 0) + (size_t)(current_item->next ? 1 : 0)); - output_pointer = ensure(output_buffer, length + 1); - if (output_pointer == NULL) - { - return false; - } - if (current_item->next) - { - *output_pointer++ = ','; - } - - if (output_buffer->format) - { - *output_pointer++ = '\n'; - } - *output_pointer = '\0'; - output_buffer->offset += length; - - current_item = current_item->next; - } - - output_pointer = ensure(output_buffer, output_buffer->format ? (output_buffer->depth + 1) : 2); - if (output_pointer == NULL) - { - return false; - } - if (output_buffer->format) - { - size_t i; - for (i = 0; i < (output_buffer->depth - 1); i++) - { - *output_pointer++ = '\t'; - } - } - *output_pointer++ = '}'; - *output_pointer = '\0'; - output_buffer->depth--; - - return true; -} - -/* Get Array size/item / object item. */ -CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array) -{ - cJSON *child = NULL; - size_t size = 0; - - if (array == NULL) - { - return 0; - } - - child = array->child; - - while(child != NULL) - { - size++; - child = child->next; - } - - /* FIXME: Can overflow here. Cannot be fixed without breaking the API */ - - return (int)size; -} - -static cJSON* get_array_item(const cJSON *array, size_t index) -{ - cJSON *current_child = NULL; - - if (array == NULL) - { - return NULL; - } - - current_child = array->child; - while ((current_child != NULL) && (index > 0)) - { - index--; - current_child = current_child->next; - } - - return current_child; -} - -CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index) -{ - if (index < 0) - { - return NULL; - } - - return get_array_item(array, (size_t)index); -} - -static cJSON *get_object_item(const cJSON * const object, const char * const name, const cJSON_bool case_sensitive) -{ - cJSON *current_element = NULL; - - if ((object == NULL) || (name == NULL)) - { - return NULL; - } - - current_element = object->child; - if (case_sensitive) - { - while ((current_element != NULL) && (current_element->string != NULL) && (strcmp(name, current_element->string) != 0)) - { - current_element = current_element->next; - } - } - else - { - while ((current_element != NULL) && (case_insensitive_strcmp((const unsigned char*)name, (const unsigned char*)(current_element->string)) != 0)) - { - current_element = current_element->next; - } - } - - if ((current_element == NULL) || (current_element->string == NULL)) { - return NULL; - } - - return current_element; -} - -CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string) -{ - return get_object_item(object, string, false); -} - -CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string) -{ - return get_object_item(object, string, true); -} - -CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string) -{ - return cJSON_GetObjectItem(object, string) ? 1 : 0; -} - -/* Utility for array list handling. */ -static void suffix_object(cJSON *prev, cJSON *item) -{ - prev->next = item; - item->prev = prev; -} - -/* Utility for handling references. */ -static cJSON *create_reference(const cJSON *item, const internal_hooks * const hooks) -{ - cJSON *reference = NULL; - if (item == NULL) - { - return NULL; - } - - reference = cJSON_New_Item(hooks); - if (reference == NULL) - { - return NULL; - } - - memcpy(reference, item, sizeof(cJSON)); - reference->string = NULL; - reference->type |= cJSON_IsReference; - reference->next = reference->prev = NULL; - return reference; -} - -static cJSON_bool add_item_to_array(cJSON *array, cJSON *item) -{ - cJSON *child = NULL; - - if ((item == NULL) || (array == NULL)) - { - return false; - } - - child = array->child; - - if (child == NULL) - { - /* list is empty, start new one */ - array->child = item; - } - else - { - /* append to the end */ - while (child->next) - { - child = child->next; - } - suffix_object(child, item); - } - - return true; -} - -/* Add item to array/object. */ -CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item) -{ - add_item_to_array(array, item); -} - -#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)))) - #pragma GCC diagnostic push -#endif -#ifdef __GNUC__ -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif -/* helper function to cast away const */ -static void* cast_away_const(const void* string) -{ - return (void*)string; -} -#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)))) - #pragma GCC diagnostic pop -#endif - - -static cJSON_bool add_item_to_object(cJSON * const object, const char * const string, cJSON * const item, const internal_hooks * const hooks, const cJSON_bool constant_key) -{ - char *new_key = NULL; - int new_type = cJSON_Invalid; - - if ((object == NULL) || (string == NULL) || (item == NULL)) - { - return false; - } - - if (constant_key) - { - new_key = (char*)cast_away_const(string); - new_type = item->type | cJSON_StringIsConst; - } - else - { - new_key = (char*)cJSON_strdup((const unsigned char*)string, hooks); - if (new_key == NULL) - { - return false; - } - - new_type = item->type & ~cJSON_StringIsConst; - } - - if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) - { - hooks->deallocate(item->string); - } - - item->string = new_key; - item->type = new_type; - - return add_item_to_array(object, item); -} - -CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item) -{ - add_item_to_object(object, string, item, &global_hooks, false); -} - -/* Add an item to an object with constant string as key */ -CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item) -{ - add_item_to_object(object, string, item, &global_hooks, true); -} - -CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) -{ - if (array == NULL) - { - return; - } - - add_item_to_array(array, create_reference(item, &global_hooks)); -} - -CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item) -{ - if ((object == NULL) || (string == NULL)) - { - return; - } - - add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false); -} - -CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name) -{ - cJSON *null = cJSON_CreateNull(); - if (add_item_to_object(object, name, null, &global_hooks, false)) - { - return null; - } - - cJSON_Delete(null); - return NULL; -} - -CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name) -{ - cJSON *true_item = cJSON_CreateTrue(); - if (add_item_to_object(object, name, true_item, &global_hooks, false)) - { - return true_item; - } - - cJSON_Delete(true_item); - return NULL; -} - -CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name) -{ - cJSON *false_item = cJSON_CreateFalse(); - if (add_item_to_object(object, name, false_item, &global_hooks, false)) - { - return false_item; - } - - cJSON_Delete(false_item); - return NULL; -} - -CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean) -{ - cJSON *bool_item = cJSON_CreateBool(boolean); - if (add_item_to_object(object, name, bool_item, &global_hooks, false)) - { - return bool_item; - } - - cJSON_Delete(bool_item); - return NULL; -} - -CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number) -{ - cJSON *number_item = cJSON_CreateNumber(number); - if (add_item_to_object(object, name, number_item, &global_hooks, false)) - { - return number_item; - } - - cJSON_Delete(number_item); - return NULL; -} - -CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string) -{ - cJSON *string_item = cJSON_CreateString(string); - if (add_item_to_object(object, name, string_item, &global_hooks, false)) - { - return string_item; - } - - cJSON_Delete(string_item); - return NULL; -} - -CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw) -{ - cJSON *raw_item = cJSON_CreateRaw(raw); - if (add_item_to_object(object, name, raw_item, &global_hooks, false)) - { - return raw_item; - } - - cJSON_Delete(raw_item); - return NULL; -} - -CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name) -{ - cJSON *object_item = cJSON_CreateObject(); - if (add_item_to_object(object, name, object_item, &global_hooks, false)) - { - return object_item; - } - - cJSON_Delete(object_item); - return NULL; -} - -CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name) -{ - cJSON *array = cJSON_CreateArray(); - if (add_item_to_object(object, name, array, &global_hooks, false)) - { - return array; - } - - cJSON_Delete(array); - return NULL; -} - -CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item) -{ - if ((parent == NULL) || (item == NULL)) - { - return NULL; - } - - if (item->prev != NULL) - { - /* not the first element */ - item->prev->next = item->next; - } - if (item->next != NULL) - { - /* not the last element */ - item->next->prev = item->prev; - } - - if (item == parent->child) - { - /* first element */ - parent->child = item->next; - } - /* make sure the detached item doesn't point anywhere anymore */ - item->prev = NULL; - item->next = NULL; - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which) -{ - if (which < 0) - { - return NULL; - } - - return cJSON_DetachItemViaPointer(array, get_array_item(array, (size_t)which)); -} - -CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which) -{ - cJSON_Delete(cJSON_DetachItemFromArray(array, which)); -} - -CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string) -{ - cJSON *to_detach = cJSON_GetObjectItem(object, string); - - return cJSON_DetachItemViaPointer(object, to_detach); -} - -CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string) -{ - cJSON *to_detach = cJSON_GetObjectItemCaseSensitive(object, string); - - return cJSON_DetachItemViaPointer(object, to_detach); -} - -CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string) -{ - cJSON_Delete(cJSON_DetachItemFromObject(object, string)); -} - -CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string) -{ - cJSON_Delete(cJSON_DetachItemFromObjectCaseSensitive(object, string)); -} - -/* Replace array/object items with new ones. */ -CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem) -{ - cJSON *after_inserted = NULL; - - if (which < 0) - { - return; - } - - after_inserted = get_array_item(array, (size_t)which); - if (after_inserted == NULL) - { - add_item_to_array(array, newitem); - return; - } - - newitem->next = after_inserted; - newitem->prev = after_inserted->prev; - after_inserted->prev = newitem; - if (after_inserted == array->child) - { - array->child = newitem; - } - else - { - newitem->prev->next = newitem; - } -} - -CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement) -{ - if ((parent == NULL) || (replacement == NULL) || (item == NULL)) - { - return false; - } - - if (replacement == item) - { - return true; - } - - replacement->next = item->next; - replacement->prev = item->prev; - - if (replacement->next != NULL) - { - replacement->next->prev = replacement; - } - if (replacement->prev != NULL) - { - replacement->prev->next = replacement; - } - if (parent->child == item) - { - parent->child = replacement; - } - - item->next = NULL; - item->prev = NULL; - cJSON_Delete(item); - - return true; -} - -CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem) -{ - if (which < 0) - { - return; - } - - cJSON_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which), newitem); -} - -static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive) -{ - if ((replacement == NULL) || (string == NULL)) - { - return false; - } - - /* replace the name in the replacement */ - if (!(replacement->type & cJSON_StringIsConst) && (replacement->string != NULL)) - { - cJSON_free(replacement->string); - } - replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); - replacement->type &= ~cJSON_StringIsConst; - - cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement); - - return true; -} - -CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem) -{ - replace_item_in_object(object, string, newitem, false); -} - -CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem) -{ - replace_item_in_object(object, string, newitem, true); -} - -/* Create basic types: */ -CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if(item) - { - item->type = cJSON_NULL; - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if(item) - { - item->type = cJSON_True; - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if(item) - { - item->type = cJSON_False; - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if(item) - { - item->type = boolean ? cJSON_True : cJSON_False; - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if(item) - { - item->type = cJSON_Number; - item->valuedouble = num; - - /* use saturation in case of overflow */ - if (num >= INT_MAX) - { - item->valueint = INT_MAX; - } - else if (num <= (double)INT_MIN) - { - item->valueint = INT_MIN; - } - else - { - item->valueint = (int)num; - } - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if(item) - { - item->type = cJSON_String; - item->valuestring = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); - if(!item->valuestring) - { - cJSON_Delete(item); - return NULL; - } - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if (item != NULL) - { - item->type = cJSON_String | cJSON_IsReference; - item->valuestring = (char*)cast_away_const(string); - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if (item != NULL) { - item->type = cJSON_Object | cJSON_IsReference; - item->child = (cJSON*)cast_away_const(child); - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child) { - cJSON *item = cJSON_New_Item(&global_hooks); - if (item != NULL) { - item->type = cJSON_Array | cJSON_IsReference; - item->child = (cJSON*)cast_away_const(child); - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if(item) - { - item->type = cJSON_Raw; - item->valuestring = (char*)cJSON_strdup((const unsigned char*)raw, &global_hooks); - if(!item->valuestring) - { - cJSON_Delete(item); - return NULL; - } - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if(item) - { - item->type=cJSON_Array; - } - - return item; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void) -{ - cJSON *item = cJSON_New_Item(&global_hooks); - if (item) - { - item->type = cJSON_Object; - } - - return item; -} - -/* Create Arrays: */ -CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count) -{ - size_t i = 0; - cJSON *n = NULL; - cJSON *p = NULL; - cJSON *a = NULL; - - if ((count < 0) || (numbers == NULL)) - { - return NULL; - } - - a = cJSON_CreateArray(); - for(i = 0; a && (i < (size_t)count); i++) - { - n = cJSON_CreateNumber(numbers[i]); - if (!n) - { - cJSON_Delete(a); - return NULL; - } - if(!i) - { - a->child = n; - } - else - { - suffix_object(p, n); - } - p = n; - } - - return a; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count) -{ - size_t i = 0; - cJSON *n = NULL; - cJSON *p = NULL; - cJSON *a = NULL; - - if ((count < 0) || (numbers == NULL)) - { - return NULL; - } - - a = cJSON_CreateArray(); - - for(i = 0; a && (i < (size_t)count); i++) - { - n = cJSON_CreateNumber((double)numbers[i]); - if(!n) - { - cJSON_Delete(a); - return NULL; - } - if(!i) - { - a->child = n; - } - else - { - suffix_object(p, n); - } - p = n; - } - - return a; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count) -{ - size_t i = 0; - cJSON *n = NULL; - cJSON *p = NULL; - cJSON *a = NULL; - - if ((count < 0) || (numbers == NULL)) - { - return NULL; - } - - a = cJSON_CreateArray(); - - for(i = 0;a && (i < (size_t)count); i++) - { - n = cJSON_CreateNumber(numbers[i]); - if(!n) - { - cJSON_Delete(a); - return NULL; - } - if(!i) - { - a->child = n; - } - else - { - suffix_object(p, n); - } - p = n; - } - - return a; -} - -CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count) -{ - size_t i = 0; - cJSON *n = NULL; - cJSON *p = NULL; - cJSON *a = NULL; - - if ((count < 0) || (strings == NULL)) - { - return NULL; - } - - a = cJSON_CreateArray(); - - for (i = 0; a && (i < (size_t)count); i++) - { - n = cJSON_CreateString(strings[i]); - if(!n) - { - cJSON_Delete(a); - return NULL; - } - if(!i) - { - a->child = n; - } - else - { - suffix_object(p,n); - } - p = n; - } - - return a; -} - -/* Duplication */ -CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse) -{ - cJSON *newitem = NULL; - cJSON *child = NULL; - cJSON *next = NULL; - cJSON *newchild = NULL; - - /* Bail on bad ptr */ - if (!item) - { - goto fail; - } - /* Create new item */ - newitem = cJSON_New_Item(&global_hooks); - if (!newitem) - { - goto fail; - } - /* Copy over all vars */ - newitem->type = item->type & (~cJSON_IsReference); - newitem->valueint = item->valueint; - newitem->valuedouble = item->valuedouble; - if (item->valuestring) - { - newitem->valuestring = (char*)cJSON_strdup((unsigned char*)item->valuestring, &global_hooks); - if (!newitem->valuestring) - { - goto fail; - } - } - if (item->string) - { - newitem->string = (item->type&cJSON_StringIsConst) ? item->string : (char*)cJSON_strdup((unsigned char*)item->string, &global_hooks); - if (!newitem->string) - { - goto fail; - } - } - /* If non-recursive, then we're done! */ - if (!recurse) - { - return newitem; - } - /* Walk the ->next chain for the child. */ - child = item->child; - while (child != NULL) - { - newchild = cJSON_Duplicate(child, true); /* Duplicate (with recurse) each item in the ->next chain */ - if (!newchild) - { - goto fail; - } - if (next != NULL) - { - /* If newitem->child already set, then crosswire ->prev and ->next and move on */ - next->next = newchild; - newchild->prev = next; - next = newchild; - } - else - { - /* Set newitem->child and move to it */ - newitem->child = newchild; - next = newchild; - } - child = child->next; - } - - return newitem; - -fail: - if (newitem != NULL) - { - cJSON_Delete(newitem); - } - - return NULL; -} - -static void skip_oneline_comment(char **input) -{ - *input += static_strlen("//"); - - for (; (*input)[0] != '\0'; ++(*input)) - { - if ((*input)[0] == '\n') { - *input += static_strlen("\n"); - return; - } - } -} - -static void skip_multiline_comment(char **input) -{ - *input += static_strlen("/*"); - - for (; (*input)[0] != '\0'; ++(*input)) - { - if (((*input)[0] == '*') && ((*input)[1] == '/')) - { - *input += static_strlen("*/"); - return; - } - } -} - -static void minify_string(char **input, char **output) { - (*output)[0] = (*input)[0]; - *input += static_strlen("\""); - *output += static_strlen("\""); - - - for (; (*input)[0] != '\0'; (void)++(*input), ++(*output)) { - (*output)[0] = (*input)[0]; - - if ((*input)[0] == '\"') { - (*output)[0] = '\"'; - *input += static_strlen("\""); - *output += static_strlen("\""); - return; - } else if (((*input)[0] == '\\') && ((*input)[1] == '\"')) { - (*output)[1] = (*input)[1]; - *input += static_strlen("\""); - *output += static_strlen("\""); - } - } -} - -CJSON_PUBLIC(void) cJSON_Minify(char *json) -{ - char *into = json; - - if (json == NULL) - { - return; - } - - while (json[0] != '\0') - { - switch (json[0]) - { - case ' ': - case '\t': - case '\r': - case '\n': - json++; - break; - - case '/': - if (json[1] == '/') - { - skip_oneline_comment(&json); - } - else if (json[1] == '*') - { - skip_multiline_comment(&json); - } else { - json++; - } - break; - - case '\"': - minify_string(&json, (char**)&into); - break; - - default: - into[0] = json[0]; - json++; - into++; - } - } - - /* and null-terminate. */ - *into = '\0'; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xFF) == cJSON_Invalid; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xFF) == cJSON_False; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xff) == cJSON_True; -} - - -CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & (cJSON_True | cJSON_False)) != 0; -} -CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xFF) == cJSON_NULL; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xFF) == cJSON_Number; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xFF) == cJSON_String; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xFF) == cJSON_Array; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xFF) == cJSON_Object; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item) -{ - if (item == NULL) - { - return false; - } - - return (item->type & 0xFF) == cJSON_Raw; -} - -CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive) -{ - if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF)) || cJSON_IsInvalid(a)) - { - return false; - } - - /* check if type is valid */ - switch (a->type & 0xFF) - { - case cJSON_False: - case cJSON_True: - case cJSON_NULL: - case cJSON_Number: - case cJSON_String: - case cJSON_Raw: - case cJSON_Array: - case cJSON_Object: - break; - - default: - return false; - } - - /* identical objects are equal */ - if (a == b) - { - return true; - } - - switch (a->type & 0xFF) - { - /* in these cases and equal type is enough */ - case cJSON_False: - case cJSON_True: - case cJSON_NULL: - return true; - - case cJSON_Number: - if (compare_double(a->valuedouble, b->valuedouble)) - { - return true; - } - return false; - - case cJSON_String: - case cJSON_Raw: - if ((a->valuestring == NULL) || (b->valuestring == NULL)) - { - return false; - } - if (strcmp(a->valuestring, b->valuestring) == 0) - { - return true; - } - - return false; - - case cJSON_Array: - { - cJSON *a_element = a->child; - cJSON *b_element = b->child; - - for (; (a_element != NULL) && (b_element != NULL);) - { - if (!cJSON_Compare(a_element, b_element, case_sensitive)) - { - return false; - } - - a_element = a_element->next; - b_element = b_element->next; - } - - /* one of the arrays is longer than the other */ - if (a_element != b_element) { - return false; - } - - return true; - } - - case cJSON_Object: - { - cJSON *a_element = NULL; - cJSON *b_element = NULL; - cJSON_ArrayForEach(a_element, a) - { - /* TODO This has O(n^2) runtime, which is horrible! */ - b_element = get_object_item(b, a_element->string, case_sensitive); - if (b_element == NULL) - { - return false; - } - - if (!cJSON_Compare(a_element, b_element, case_sensitive)) - { - return false; - } - } - - /* doing this twice, once on a and b to prevent true comparison if a subset of b - * TODO: Do this the proper way, this is just a fix for now */ - cJSON_ArrayForEach(b_element, b) - { - a_element = get_object_item(a, b_element->string, case_sensitive); - if (a_element == NULL) - { - return false; - } - - if (!cJSON_Compare(b_element, a_element, case_sensitive)) - { - return false; - } - } - - return true; - } - - default: - return false; - } -} - -CJSON_PUBLIC(void *) cJSON_malloc(size_t size) -{ - return global_hooks.allocate(size); -} - -CJSON_PUBLIC(void) cJSON_free(void *object) -{ - global_hooks.deallocate(object); -} Deleted: trunk/TTXSamples/TTXCheckUpdate/cJSON/cJSON.h =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/cJSON/cJSON.h 2020-01-22 13:54:11 UTC (rev 8499) +++ trunk/TTXSamples/TTXCheckUpdate/cJSON/cJSON.h 2020-01-22 13:54:20 UTC (rev 8500) @@ -1,293 +0,0 @@ -/* - Copyright (c) 2009-2017 Dave Gamble and cJSON contributors - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -#ifndef cJSON__h -#define cJSON__h - -#ifdef __cplusplus -extern "C" -{ -#endif - -#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32)) -#define __WINDOWS__ -#endif - -#ifdef __WINDOWS__ - -/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options: - -CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols -CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default) -CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol - -For *nix builds that support visibility attribute, you can define similar behavior by - -setting default visibility to hidden by adding --fvisibility=hidden (for gcc) -or --xldscope=hidden (for sun cc) -to CFLAGS - -then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does - -*/ - -#define CJSON_CDECL __cdecl -#define CJSON_STDCALL __stdcall - -/* export symbols by default, this is necessary for copy pasting the C and header file */ -#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS) -#define CJSON_EXPORT_SYMBOLS -#endif - -#if defined(CJSON_HIDE_SYMBOLS) -#define CJSON_PUBLIC(type) type CJSON_STDCALL -#elif defined(CJSON_EXPORT_SYMBOLS) -#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL -#elif defined(CJSON_IMPORT_SYMBOLS) -#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL -#endif -#else /* !__WINDOWS__ */ -#define CJSON_CDECL -#define CJSON_STDCALL - -#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY) -#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type -#else -#define CJSON_PUBLIC(type) type -#endif -#endif - -/* project version */ -#define CJSON_VERSION_MAJOR 1 -#define CJSON_VERSION_MINOR 7 -#define CJSON_VERSION_PATCH 12 - -#include - -/* cJSON Types: */ -#define cJSON_Invalid (0) -#define cJSON_False (1 << 0) -#define cJSON_True (1 << 1) -#define cJSON_NULL (1 << 2) -#define cJSON_Number (1 << 3) -#define cJSON_String (1 << 4) -#define cJSON_Array (1 << 5) -#define cJSON_Object (1 << 6) -#define cJSON_Raw (1 << 7) /* raw json */ - -#define cJSON_IsReference 256 -#define cJSON_StringIsConst 512 - -/* The cJSON structure: */ -typedef struct cJSON -{ - /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */ - struct cJSON *next; - struct cJSON *prev; - /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */ - struct cJSON *child; - - /* The type of the item, as above. */ - int type; - - /* The item's string, if type==cJSON_String and type == cJSON_Raw */ - char *valuestring; - /* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */ - int valueint; - /* The item's number, if type==cJSON_Number */ - double valuedouble; - - /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */ - char *string; -} cJSON; - -typedef struct cJSON_Hooks -{ - /* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */ - void *(CJSON_CDECL *malloc_fn)(size_t sz); - void (CJSON_CDECL *free_fn)(void *ptr); -} cJSON_Hooks; - -typedef int cJSON_bool; - -/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them. - * This is to prevent stack overflows. */ -#ifndef CJSON_NESTING_LIMIT -#define CJSON_NESTING_LIMIT 1000 -#endif - -/* Precision of double variables comparison */ -#ifndef CJSON_DOUBLE_PRECISION -#define CJSON_DOUBLE_PRECISION .0000000000000001 -#endif - -/* returns the version of cJSON as a string */ -CJSON_PUBLIC(const char*) cJSON_Version(void); - -/* Supply malloc, realloc and free functions to cJSON */ -CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks); - -/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */ -/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */ -CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value); -/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */ -/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */ -CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated); - -/* Render a cJSON entity to text for transfer/storage. */ -CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item); -/* Render a cJSON entity to text for transfer/storage without any formatting. */ -CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item); -/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */ -CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt); -/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */ -/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */ -CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format); -/* Delete a cJSON entity and all subentities. */ -CJSON_PUBLIC(void) cJSON_Delete(cJSON *item); - -/* Returns the number of items in an array (or object). */ -CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array); -/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */ -CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index); -/* Get item "string" from object. Case insensitive. */ -CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string); -CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string); -CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string); -/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */ -CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void); - -/* Check if the item is a string and return its valuestring */ -CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item); - -/* These functions check the type of an item */ -CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item); -CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item); - -/* These calls create a cJSON item of the appropriate type. */ -CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void); -CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void); -CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void); -CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean); -CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num); -CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string); -/* raw json */ -CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw); -CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void); -CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void); - -/* Create a string where valuestring references a string so - * it will not be freed by cJSON_Delete */ -CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string); -/* Create an object/array that only references it's elements so - * they will not be freed by cJSON_Delete */ -CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child); -CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child); - -/* These utilities create an Array of count items. - * The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.*/ -CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count); -CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count); -CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count); -CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count); - -/* Append item to the specified array/object. */ -CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item); -CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item); -/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object. - * WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before - * writing to `item->string` */ -CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item); -/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */ -CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); -CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item); - -/* Remove/Detach items from Arrays/Objects. */ -CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item); -CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which); -CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which); -CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string); -CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string); -CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string); -CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string); - -/* Update array items. */ -CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */ -CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement); -CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem); -CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem); -CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem); - -/* Duplicate a cJSON item */ -CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse); -/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will - * need to be released. With recurse!=0, it will duplicate any children connected to the item. - * The item->next and ->prev pointers are always zero on return from Duplicate. */ -/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal. - * case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */ -CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive); - -/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings. - * The input pointer json cannot point to a read-only address area, such as a string constant, - * but should point to a readable and writable adress area. */ -CJSON_PUBLIC(void) cJSON_Minify(char *json); - -/* Helper functions for creating and adding items to an object at the same time. - * They return the added item or NULL on failure. */ -CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name); -CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name); -CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name); -CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean); -CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number); -CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string); -CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw); -CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name); -CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name); - -/* When assigning an integer value, it needs to be propagated to valuedouble too. */ -#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number)) -/* helper for the cJSON_SetNumberValue macro */ -CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number); -#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number)) - -/* Macro for iterating over an array or object */ -#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next) - -/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */ -CJSON_PUBLIC(void *) cJSON_malloc(size_t size); -CJSON_PUBLIC(void) cJSON_free(void *object); - -#ifdef __cplusplus -} -#endif - -#endif Modified: trunk/TTXSamples/TTXCheckUpdate/parse.cpp =================================================================== --- trunk/TTXSamples/TTXCheckUpdate/parse.cpp 2020-01-22 13:54:11 UTC (rev 8499) +++ trunk/TTXSamples/TTXCheckUpdate/parse.cpp 2020-01-22 13:54:20 UTC (rev 8500) @@ -3,7 +3,7 @@ #include #include -#include "cJSON/cJSON.h" +#include "cJSON.h" #include "codeconv.h" Copied: trunk/libs/cJSON/LICENSE (from rev 8499, trunk/TTXSamples/TTXCheckUpdate/cJSON/LICENSE) =================================================================== --- trunk/libs/cJSON/LICENSE (rev 0) +++ trunk/libs/cJSON/LICENSE 2020-01-22 13:54:20 UTC (rev 8500) @@ -0,0 +1,20 @@ +Copyright (c) 2009-2017 Dave Gamble and cJSON contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + Copied: trunk/libs/cJSON/README.md (from rev 8499, trunk/TTXSamples/TTXCheckUpdate/cJSON/README.md) =================================================================== --- trunk/libs/cJSON/README.md (rev 0) +++ trunk/libs/cJSON/README.md 2020-01-22 13:54:20 UTC (rev 8500) @@ -0,0 +1,547 @@ +# cJSON + +Ultralightweight JSON parser in ANSI C. + +## Table of contents +* [License](#license) +* [Usage](#usage) + * [Welcome to cJSON](#welcome-to-cjson) + * [Building](#building) + * [Copying the source](#copying-the-source) + * [CMake](#cmake) + * [Makefile](#makefile) + * [Including cJSON](#including-cjson) + * [Data Structure](#data-structure) + * [Working with the data structure](#working-with-the-data-structure) + * [Basic types](#basic-types) + * [Arrays](#arrays) + * [Objects](#objects) + * [Parsing JSON](#parsing-json) + * [Printing JSON](#printing-json) + * [Example](#example) + * [Printing](#printing) + * [Parsing](#parsing) + * [Caveats](#caveats) + * [Zero Character](#zero-character) + * [Character Encoding](#character-encoding) + * [C Standard](#c-standard) + * [Floating Point Numbers](#floating-point-numbers) + * [Deep Nesting Of Arrays And Objects](#deep-nesting-of-arrays-and-objects) + * [Thread Safety](#thread-safety) + * [Case Sensitivity](#case-sensitivity) + * [Duplicate Object Members](#duplicate-object-members) + * [Enjoy cJSON!](#enjoy-cjson) + +## License + +MIT License + +> Copyright (c) 2009-2017 Dave Gamble and cJSON contributors +> +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in +> all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +> THE SOFTWARE. + +## Usage + +### Welcome to cJSON. + +cJSON aims to be the dumbest possible parser that you can get your job done with. +It's a single file of C, and a single header file. + +JSON is described best here: http://www.json.org/ +It's like XML, but fat-free. You use it to move data around, store things, or just +generally represent your program's state. + +As a library, cJSON exists to take away as much legwork as it can, but not get in your way. +As a point of pragmatism (i.e. ignoring the truth), I'm going to say that you can use it +in one of two modes: Auto and Manual. Let's have a quick run-through. + +I lifted some JSON from this page: http://www.json.org/fatfree.html +That page inspired me to write cJSON, which is a parser that tries to share the same +philosophy as JSON itself. Simple, dumb, out of the way. + +### Building + +There are several ways to incorporate cJSON into your project. + +#### copying the source + +Because the entire library is only one C file and one header file, you can just copy `cJSON.h` and `cJSON.c` to your projects source and start using it. + +cJSON is written in ANSI C (C89) in order to support as many platforms and compilers as possible. + +#### CMake + +With CMake, cJSON supports a full blown build system. This way you get the most features. CMake with an equal or higher version than 2.8.5 is supported. With CMake it is recommended to do an out of tree build, meaning the compiled files are put in a directory separate from the source files. So in order to build cJSON with CMake on a Unix platform, make a `build` directory and run CMake inside it. + +``` +mkdir build +cd build +cmake .. +``` + +This will create a Makefile and a bunch of other files. You can then compile it: + +``` +make +``` + +And install it with `make install` if you want. By default it installs the headers `/usr/local/include/cjson` and the libraries to `/usr/local/lib`. It also installs files for pkg-config to make it easier to detect and use an existing installation of CMake. And it installs CMake config files, that can be used by other CMake based projects to discover the library. + +You can change the build process with a list of different options that you can pass to CMake. Turn them on with `On` and off with `Off`: + +* `-DENABLE_CJSON_TEST=On`: Enable building the tests. (on by default) +* `-DENABLE_CJSON_UTILS=On`: Enable building cJSON_Utils. (off by default) +* `-DENABLE_TARGET_EXPORT=On`: Enable the export of CMake targets. Turn off if it makes problems. (on by default) +* `-DENABLE_CUSTOM_COMPILER_FLAGS=On`: Enable custom compiler flags (currently for Clang, GCC and MSVC). Turn off if it makes problems. (on by default) +* `-DENABLE_VALGRIND=On`: Run tests with [valgrind](http://valgrind.org). (off by default) +* `-DENABLE_SANITIZERS=On`: Compile cJSON with [AddressSanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizer) and [UndefinedBehaviorSanitizer](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html) enabled (if possible). (off by default) +* `-DENABLE_SAFE_STACK`: Enable the [SafeStack](https://clang.llvm.org/docs/SafeStack.html) instrumentation pass. Currently only works with the Clang compiler. (off by default) +* `-DBUILD_SHARED_LIBS=On`: Build the shared libraries. (on by default) +* `-DBUILD_SHARED_AND_STATIC_LIBS=On`: Build both shared and static libraries. (off by default) +* `-DCMAKE_INSTALL_PREFIX=/usr`: Set a prefix for the installation. +* `-DENABLE_LOCALES=On`: Enable the usage of localeconv method. ( on by default ) +* `-DCJSON_OVERRIDE_BUILD_SHARED_LIBS=On`: Enable overriding the value of `BUILD_SHARED_LIBS` with `-DCJSON_BUILD_SHARED_LIBS`. + +If you are packaging cJSON for a distribution of Linux, you would probably take these steps for example: +``` +mkdir build +cd build +cmake .. -DENABLE_CJSON_UTILS=On -DENABLE_CJSON_TEST=Off -DCMAKE_INSTALL_PREFIX=/usr +make +make DESTDIR=$pkgdir install +``` + +On Windows CMake is usually used to create a Visual Studio solution file by running it inside the Developer Command Prompt for Visual Studio, for exact steps follow the official documentation from CMake and Microsoft and use the online search engine of your choice. The descriptions of the the options above still generally apply, although not all of them work on Windows. + +#### Makefile + +**NOTE:** This Method is deprecated. Use CMake if at all possible. Makefile support is limited to fixing bugs. + +If you don't have CMake available, but still have GNU make. You can use the makefile to build cJSON: + +Run this command in the directory with the source code and it will automatically compile static and shared libraries and a little test program (not the full test suite). + +``` +make all +``` + +If you want, you can install the compiled library to your system using `make install`. By default it will install the headers in `/usr/local/include/cjson` and the libraries in `/usr/local/lib`. But you can change this behavior by setting the `PREFIX` and `DESTDIR` variables: `make PREFIX=/usr DESTDIR=temp install`. And uninstall them with: `make PREFIX=/usr DESTDIR=temp uninstall`. + +### Including cJSON + +If you installed it via CMake or the Makefile, you can include cJSON like this: + +```c +#include +``` + +### Data Structure + +cJSON represents JSON data using the `cJSON` struct data type: + +```c +/* The cJSON structure: */ +typedef struct cJSON +{ + struct cJSON *next; + struct cJSON *prev; + struct cJSON *child; + int type; + char *valuestring; + /* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */ + int valueint; + double valuedouble; + char *string; +} cJSON; +``` + +An item of this type represents a JSON value. The type is stored in `type` as a bit-flag (**this means that you cannot find out the type by just comparing the value of `type`**). + +To check the type of an item, use the corresponding `cJSON_Is...` function. It does a `NULL` check followed by a type check and returns a boolean value if the item is of this type. + +The type can be one of the following: + +* `cJSON_Invalid` (check with `cJSON_IsInvalid`): Represents an invalid item that doesn't contain any value. You automatically have this type if you set the item to all zero bytes. +* `cJSON_False` (check with `cJSON_IsFalse`): Represents a `false` boolean value. You can also check for boolean values in general with `cJSON_IsBool`. +* `cJSON_True` (check with `cJSON_IsTrue`): Represents a `true` boolean value. You can also check for boolean values in general with `cJSON_IsBool`. +* `cJSON_NULL` (check with `cJSON_IsNull`): Represents a `null` value. +* `cJSON_Number` (check with `cJSON_IsNumber`): Represents a number value. The value is stored as a double in `valuedouble` and also in `valueint`. If the number is outside of the range of an integer, `INT_MAX` or `INT_MIN` are used for `valueint`. +* `cJSON_String` (check with `cJSON_IsString`): Represents a string value. It is stored in the form of a zero terminated string in `valuestring`. +* `cJSON_Array` (check with `cJSON_IsArray`): Represent an array value. This is implemented by pointing `child` to a linked list of `cJSON` items that represent the values in the array. The elements are linked together using `next` and `prev`, where the first element has `prev == NULL` and the last element `next == NULL`. +* `cJSON_Object` (check with `cJSON_IsObject`): Represents an object value. Objects are stored same way as an array, the only difference is that the items in the object store their keys in `string`. +* `cJSON_Raw` (check with `cJSON_IsRaw`): Represents any kind of JSON that is stored as a zero terminated array of characters in `valuestring`. This can be used, for example, to avoid printing the same static JSON over and over again to save performance. cJSON will never create this type when parsing. Also note that cJSON doesn't check if it is valid JSON. + +Additionally there are the following two flags: + +* `cJSON_IsReference`: Specifies that the item that `child` points to and/or `valuestring` is not owned by this item, it is only a reference. So `cJSON_Delete` and other functions will only deallocate this item, not it's children/valuestring. +* `cJSON_StringIsConst`: This means that `string` points to a constant string. This means that `cJSON_Delete` and other functions will not try to deallocate `string`. + +### Working with the data structure + +For every value type there is a `cJSON_Create...` function that can be used to create an item of that type. +All of these will allocate a `cJSON` struct that can later be deleted with `cJSON_Delete`. +Note that you have to delete them at some point, otherwise you will get a memory leak. +**Important**: If you have added an item to an array or an object already, you **mustn't** delete it with `cJSON_Delete`. Adding it to an array or object transfers its ownership so that when that array or object is deleted, it gets deleted as well. + +#### Basic types + +* **null** is created with `cJSON_CreateNull` +* **booleans** are created with `cJSON_CreateTrue`, `cJSON_CreateFalse` or `cJSON_CreateBool` +* **numbers** are created with `cJSON_CreateNumber`. This will set both `valuedouble` and `valueint`. If the number is outside of the range of an integer, `INT_MAX` or `INT_MIN` are used for `valueint` +* **strings** are created with `cJSON_CreateString` (copies the string) or with `cJSON_CreateStringReference` (directly points to the string. This means that `valuestring` won't be deleted by `cJSON_Delete` and you are responsible for it's lifetime, useful for constants) + +#### Arrays + +You can create an empty array with `cJSON_CreateArray`. `cJSON_CreateArrayReference` can be used to create an array that doesn't "own" its content, so its content doesn't get deleted by `cJSON_Delete`. + +To add items to an array, use `cJSON_AddItemToArray` to append items to the end. +Using `cJSON_AddItemReferenceToArray` an element can be added as a reference to another item, array or string. This means that `cJSON_Delete` will not delete that items `child` or `valuestring` properties, so no double frees are occurring if they are already used elsewhere. +To insert items in the middle, use `cJSON_InsertItemInArray`. It will insert an item at the given 0 based index and shift all the existing items to the right. + +If you want to take an item out of an array at a given index and continue using it, use `cJSON_DetachItemFromArray`, it will return the detached item, so be sure to assign it to a pointer, otherwise you will have a memory leak. + +Deleting items is done with `cJSON_DeleteItemFromArray`. It works like `cJSON_DetachItemFromArray`, but deletes the detached item via `cJSON_Delete`. + +You can also replace an item in an array in place. Either with `cJSON_ReplaceItemInArray` using an index or with `cJSON_ReplaceItemViaPointer` given a pointer to an element. `cJSON_ReplaceItemViaPointer` will return `0` if it fails. What this does internally is to detach the old item, delete it and insert the new item in its place. + +To get the size of an array, use `cJSON_GetArraySize`. Use `cJSON_GetArrayItem` to get an element at a given index. + +Because an array is stored as a linked list, iterating it via index is inefficient (`O(n²)`), so you can iterate over an array using the `cJSON_ArrayForEach` macro in `O(n)` time complexity. + +#### Objects + +You can create an empty object with `cJSON_CreateObject`. `cJSON_CreateObjectReference` can be used to create an object that doesn't "own" its content, so its content doesn't get deleted by `cJSON_Delete`. + +To add items to an object, use `cJSON_AddItemToObject`. Use `cJSON_AddItemToObjectCS` to add an item to an object with a name that is a constant or reference (key of the item, `string` in the `cJSON` struct), so that it doesn't get freed by `cJSON_Delete`. +Using `cJSON_AddItemReferenceToArray` an element can be added as a reference to another object, array or string. This means that `cJSON_Delete` will not delete that items `child` or `valuestring` properties, so no double frees are occurring if they are already used elsewhere. + +If you want to take an item out of an object, use `cJSON_DetachItemFromObjectCaseSensitive`, it will return the detached item, so be sure to assign it to a pointer, otherwise you will have a memory leak. + +Deleting items is done with `cJSON_DeleteItemFromObjectCaseSensitive`. It works like `cJSON_DetachItemFromObjectCaseSensitive` followed by `cJSON_Delete`. + +You can also replace an item in an object in place. Either with `cJSON_ReplaceItemInObjectCaseSensitive` using a key or with `cJSON_ReplaceItemViaPointer` given a pointer to an element. `cJSON_ReplaceItemViaPointer` will return `0` if it fails. What this does internally is to detach the old item, delete it and insert the new item in its place. + +To get the size of an object, you can use `cJSON_GetArraySize`, this works because internally objects are stored as arrays. + +If you want to access an item in an object, use `cJSON_GetObjectItemCaseSensitive`. + +To iterate over an object, you can use the `cJSON_ArrayForEach` macro the same way as for arrays. + +cJSON also provides convenient helper functions for quickly creating a new item and adding it to an object, like `cJSON_AddNullToObject`. They return a pointer to the new item or `NULL` if they failed. + +### Parsing JSON + +Given some JSON in a zero terminated string, you can parse it with `cJSON_Parse`. + +```c +cJSON *json = cJSON_Parse(string); +``` + +It will parse the JSON and allocate a tree of `cJSON` items that represents it. Once it returns, you are fully responsible for deallocating it after use with `cJSON_Delete`. + +The allocator used by `cJSON_Parse` is `malloc` and `free` by default but can be changed (globally) with `cJSON_InitHooks`. + +If an error occurs a pointer to the position of the error in the input string can be accessed using `cJSON_GetErrorPtr`. Note though that this can produce race conditions in multithreading scenarios, in that case it is better to use `cJSON_ParseWithOpts` with `return_parse_end`. +By default, characters in the input string that follow the parsed JSON will not be considered as an error. + +If you want more options, use `cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated)`. +`return_parse_end` returns a pointer to the end of the JSON in the input string or the position that an error occurs at (thereby replacing `cJSON_GetErrorPtr` in a thread safe way). `require_null_terminated`, if set to `1` will make it an error if the input string contains data after the JSON. + +### Printing JSON + +Given a tree of `cJSON` items, you can print them as a string using `cJSON_Print`. + +```c +char *string = cJSON_Print(json); +``` + +It will allocate a string and print a JSON representation of the tree into it. Once it returns, you are fully responsible for deallocating it after use with your allocator. (usually `free`, depends on what has been set with `cJSON_InitHooks`). + +`cJSON_Print` will print with whitespace for formatting. If you want to print without formatting, use `cJSON_PrintUnformatted`. + +If you have a rough idea of how big your resulting string will be, you can use `cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt)`. `fmt` is a boolean to turn formatting with whitespace on and off. `prebuffer` specifies the first buffer size to use for printing. `cJSON_Print` currently uses 256 bytes for it's first buffer size. Once printing runs out of space, a new buffer is allocated and the old gets copied over before printing is continued. + +These dynamic buffer allocations can be completely avoided by using `cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format)`. It takes a buffer to a pointer to print to and it's length. If the length is reached, printing will fail and it returns `0`. In case of success, `1` is returned. Note that you should provide 5 bytes more than is actually needed, because cJSON is not 100% accurate in estimating if the provided memory is enough. + +### Example + +In this example we want to build and parse the following JSON: + +```json +{ + "name": "Awesome 4K", + "resolutions": [ + { + "width": 1280, + "height": 720 + }, + { + "width": 1920, + "height": 1080 + }, + { + "width": 3840, + "height": 2160 + } + ] +} +``` + +#### Printing + +Let's build the above JSON and print it to a string: + +```c +//create a monitor with a list of supported resolutions +//NOTE: Returns a heap allocated string, you are required to free it after use. +char* create_monitor(void) +{ + const unsigned int resolution_numbers[3][2] = { + {1280, 720}, + {1920, 1080}, + {3840, 2160} + }; + char *string = NULL; + cJSON *name = NULL; + cJSON *resolutions = NULL; + cJSON *resolution = NULL; + cJSON *width = NULL; + cJSON *height = NULL; + size_t index = 0; + + cJSON *monitor = cJSON_CreateObject(); + if (monitor == NULL) + { + goto end; + } + + name = cJSON_CreateString("Awesome 4K"); + if (name == NULL) + { + goto end; + } + /* after creation was successful, immediately add it to the monitor, + * thereby transferring ownership of the pointer to it */ + cJSON_AddItemToObject(monitor, "name", name); + + resolutions = cJSON_CreateArray(); + if (resolutions == NULL) + { + goto end; + } + cJSON_AddItemToObject(monitor, "resolutions", resolutions); + + for (index = 0; index < (sizeof(resolution_numbers) / (2 * sizeof(int))); ++index) + { + resolution = cJSON_CreateObject(); + if (resolution == NULL) + { + goto end; + } + cJSON_AddItemToArray(resolutions, resolution); + + width = cJSON_CreateNumber(resolution_numbers[index][0]); + if (width == NULL) + { + goto end; + } + cJSON_AddItemToObject(resolution, "width", width); + + height = cJSON_CreateNumber(resolution_numbers[index][1]); + if (height == NULL) + { + goto end; + } + cJSON_AddItemToObject(resolution, "height", height); + } + + string = cJSON_Print(monitor); + if (string == NULL) + { + fprintf(stderr, "Failed to print monitor.\n"); + } + +end: + cJSON_Delete(monitor); + return string; +} +``` + +Alternatively we can use the `cJSON_Add...ToObject` helper functions to make our lifes a little easier: + +```c +//NOTE: Returns a heap allocated string, you are required to free it after use. +char *create_monitor_with_helpers(void) +{ + const unsigned int resolution_numbers[3][2] = { + {1280, 720}, + {1920, 1080}, + {3840, 2160} + }; + char *string = NULL; + cJSON *resolutions = NULL; + size_t index = 0; + + cJSON *monitor = cJSON_CreateObject(); + + if (cJSON_AddStringToObject(monitor, "name", "Awesome 4K") == NULL) + { + goto end; + } + + resolutions = cJSON_AddArrayToObject(monitor, "resolutions"); + if (resolutions == NULL) + { + goto end; + } + + for (index = 0; index < (sizeof(resolution_numbers) / (2 * sizeof(int))); ++index) + { + cJSON *resolution = cJSON_CreateObject(); + + if (cJSON_AddNumberToObject(resolution, "width", resolution_numbers[index][0]) == NULL) + { + goto end; + } + + if(cJSON_AddNumberToObject(resolution, "height", resolution_numbers[index][1]) == NULL) + { + goto end; + } + + cJSON_AddItemToArray(resolutions, resolution); + } + + string = cJSON_Print(monitor); + if (string == NULL) { + fprintf(stderr, "Failed to print monitor.\n"); + } + +end: + cJSON_Delete(monitor); + return string; +} +``` + +#### Parsing + +In this example we will parse a JSON in the above format and check if the monitor supports a Full HD resolution while printing some diagnostic output: + +```c +/* return 1 if the monitor supports full hd, 0 otherwise */ +int supports_full_hd(const char * const monitor) +{ + const cJSON *resolution = NULL; + const cJSON *resolutions = NULL; + const cJSON *name = NULL; + int status = 0; + cJSON *monitor_json = cJSON_Parse(monitor); + if (monitor_json == NULL) + { + const char *error_ptr = cJSON_GetErrorPtr(); + if (error_ptr != NULL) + { + fprintf(stderr, "Error before: %s\n", error_ptr); + } + status = 0; + goto end; + } + + name = cJSON_GetObjectItemCaseSensitive(monitor_json, "name"); + if (cJSON_IsString(name) && (name->valuestring != NULL)) + { + printf("Checking monitor \"%s\"\n", name->valuestring); + } + + resolutions = cJSON_GetObjectItemCaseSensitive(monitor_json, "resolutions"); + cJSON_ArrayForEach(resolution, resolutions) + { + cJSON *width = cJSON_GetObjectItemCaseSensitive(resolution, "width"); + cJSON *height = cJSON_GetObjectItemCaseSensitive(resolution, "height"); + + if (!cJSON_IsNumber(width) || !cJSON_IsNumber(height)) + { + status = 0; + goto end; + } + + if ((width->valuedouble == 1920) && (height->valuedouble == 1080)) + { + status = 1; + goto end; + } + } + +end: + cJSON_Delete(monitor_json); + return status; +} +``` + +Note that there are no NULL checks except for the result of `cJSON_Parse` because `cJSON_GetObjectItemCaseSensitive` checks for `NULL` inputs already, so a `NULL` value is just propagated and `cJSON_IsNumber` and `cJSON_IsString` return `0` if the input is `NULL`. + +### Caveats + +#### Zero Character + +cJSON doesn't support strings that contain the zero character `'\0'` or `\u0000`. This is impossible with the current API because strings are zero terminated. + +#### Character Encoding + +cJSON only supports UTF-8 encoded input. In most cases it doesn't reject invalid UTF-8 as input though, it just propagates it through as is. As long as the input doesn't contain invalid UTF-8, the output will always be valid UTF-8. + +#### C Standard + +cJSON is written in ANSI C (or C89, C90). If your compiler or C library doesn't follow this standard, correct behavior is not guaranteed. + +NOTE: ANSI C is not C++ therefore it shouldn't be compiled with a C++ compiler. You can compile it with a C compiler and link it with your C++ code however. Although compiling with a C++ compiler might work, correct behavior is not guaranteed. + +#### Floating Point Numbers + +cJSON does not officially support any `double` implementations other than IEEE754 double precision floating point numbers. It might still work with other implementations but bugs with these will be considered invalid. + +The maximum length of a floating point literal that cJSON supports is currently 63 characters. + +#### Deep Nesting Of Arrays And Objects + +cJSON doesn't support arrays and objects that are nested too deeply because this would result in a stack overflow. To prevent this cJSON limits the depth to `CJSON_NESTING_LIMIT` which is 1000 by default but can be changed at compile time. + +#### Thread Safety + +In general cJSON is **not thread safe**. + +However it is thread safe under the following conditions: + +* `cJSON_GetErrorPtr` is never used (the `return_parse_end` parameter of `cJSON_ParseWithOpts` can be used instead) +* `cJSON_InitHooks` is only ever called before using cJSON in any threads. +* `setlocale` is never called before all calls to cJSON functions have returned. + +#### Case Sensitivity + +When cJSON was originally created, it didn't follow the JSON standard and didn't make a distinction between uppercase and lowercase letters. If you want the correct, standard compliant, behavior, you need to use the `CaseSensitive` functions where available. + +#### Duplicate Object Members + +cJSON supports parsing and printing JSON that contains objects that have multiple members with the same name. `cJSON_GetObjectItemCaseSensitive` however will always only return the first one. + +# Enjoy cJSON! + +- Dave Gamble (original author) +- Max Bruckner (current maintainer) +- and the other [cJSON contributors](CONTRIBUTORS.md) Copied: trunk/libs/cJSON/cJSON.c (from rev 8499, trunk/TTXSamples/TTXCheckUpdate/cJSON/cJSON.c) =================================================================== --- trunk/libs/cJSON/cJSON.c (rev 0) +++ trunk/libs/cJSON/cJSON.c 2020-01-22 13:54:20 UTC (rev 8500) @@ -0,0 +1,2979 @@ +/* + Copyright (c) 2009-2017 Dave Gamble and cJSON contributors + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/* cJSON */ +/* JSON parser in C. */ + +/* disable warnings about old C89 functions in MSVC */ +#if !defined(_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) +#define _CRT_SECURE_NO_DEPRECATE +#endif + +#ifdef __GNUC__ +#pragma GCC visibility push(default) +#endif +#if defined(_MSC_VER) +#pragma warning (push) +/* disable warning about single line comments in system headers */ +#pragma warning (disable : 4001) +#endif + +#include +#include +#include +#include +#include +#include + +#ifdef ENABLE_LOCALES +#include +#endif + +#if defined(_MSC_VER) +#pragma warning (pop) +#endif +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + +#include "cJSON.h" + +/* define our own boolean type */ +#ifdef true +#undef true +#endif +#define true ((cJSON_bool)1) + +#ifdef false +#undef false +#endif +#define false ((cJSON_bool)0) + +typedef struct { + const unsigned char *json; + size_t position; +} error; +static error global_error = { NULL, 0 }; + +CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void) +{ + return (const char*) (global_error.json + global_error.position); +} + +CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item) { + if (!cJSON_IsString(item)) { + return NULL; + } + + return item->valuestring; +} + +/* This is a safeguard to prevent copy-pasters from using incompatible C and header files */ +#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 12) + #error cJSON.h and cJSON.c have different versions. Make sure that both have the same. +#endif + +CJSON_PUBLIC(const char*) cJSON_Version(void) +{ + static char version[15]; + sprintf(version, "%i.%i.%i", CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH); + + return version; +} + +/* Case insensitive string comparison, doesn't consider two NULL pointers equal though */ +static int case_insensitive_strcmp(const unsigned char *string1, const unsigned char *string2) +{ + if ((string1 == NULL) || (string2 == NULL)) + { + return 1; + } + + if (string1 == string2) + { + return 0; + } + + for(; tolower(*string1) == tolower(*string2); (void)string1++, string2++) + { + if (*string1 == '\0') + { + return 0; + } + } + + return tolower(*string1) - tolower(*string2); +} + +typedef struct internal_hooks +{ + void *(CJSON_CDECL *allocate)(size_t size); + void (CJSON_CDECL *deallocate)(void *pointer); + void *(CJSON_CDECL *reallocate)(void *pointer, size_t size); +} internal_hooks; + +#if defined(_MSC_VER) +/* work around MSVC error C2322: '...' address of dllimport '...' is not static */ +static void * CJSON_CDECL internal_malloc(size_t size) +{ + return malloc(size); +} +static void CJSON_CDECL internal_free(void *pointer) +{ + free(pointer); +} +static void * CJSON_CDECL internal_realloc(void *pointer, size_t size) +{ + return realloc(pointer, size); +} +#else +#define internal_malloc malloc +#define internal_free free +#define internal_realloc realloc +#endif + +/* strlen of character literals resolved at compile time */ +#define static_strlen(string_literal) (sizeof(string_literal) - sizeof("")) + +static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc }; + +static unsigned char* cJSON_strdup(const unsigned char* string, const internal_hooks * const hooks) +{ + size_t length = 0; + unsigned char *copy = NULL; + + if (string == NULL) + { + return NULL; + } + + length = strlen((const char*)string) + sizeof(""); + copy = (unsigned char*)hooks->allocate(length); + if (copy == NULL) + { + return NULL; + } + memcpy(copy, string, length); + + return copy; +} + +CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks) +{ + if (hooks == NULL) + { + /* Reset hooks */ + global_hooks.allocate = malloc; + global_hooks.deallocate = free; + global_hooks.reallocate = realloc; + return; + } + + global_hooks.allocate = malloc; + if (hooks->malloc_fn != NULL) + { + global_hooks.allocate = hooks->malloc_fn; + } + + global_hooks.deallocate = free; + if (hooks->free_fn != NULL) + { + global_hooks.deallocate = hooks->free_fn; + } + + /* use realloc only if both free and malloc are used */ + global_hooks.reallocate = NULL; + if ((global_hooks.allocate == malloc) && (global_hooks.deallocate == free)) + { + global_hooks.reallocate = realloc; + } +} + +/* Internal constructor. */ +static cJSON *cJSON_New_Item(const internal_hooks * const hooks) +{ + cJSON* node = (cJSON*)hooks->allocate(sizeof(cJSON)); + if (node) + { + memset(node, '\0', sizeof(cJSON)); + } + + return node; +} + +/* Delete a cJSON structure. */ +CJSON_PUBLIC(void) cJSON_Delete(cJSON *item) +{ + cJSON *next = NULL; + while (item != NULL) + { + next = item->next; + if (!(item->type & cJSON_IsReference) && (item->child != NULL)) + { + cJSON_Delete(item->child); + } + if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL)) + { + global_hooks.deallocate(item->valuestring); + } + if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) + { + global_hooks.deallocate(item->string); + } + global_hooks.deallocate(item); + item = next; + } +} + +/* get the decimal point character of the current locale */ +static unsigned char get_decimal_point(void) +{ +#ifdef ENABLE_LOCALES + struct lconv *lconv = localeconv(); + return (unsigned char) lconv->decimal_point[0]; +#else + return '.'; +#endif +} + +typedef struct +{ + const unsigned char *content; + size_t length; + size_t offset; + size_t depth; /* How deeply nested (in arrays/objects) is the input at the current offset. */ + internal_hooks hooks; +} parse_buffer; + +/* check if the given size is left to read in a given parse buffer (starting with 1) */ +#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length)) +/* check if the buffer can be accessed at the given index (starting with 0) */ +#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length)) +#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index)) +/* get a pointer to the buffer at the position */ +#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset) + +/* Parse the input text to generate a number, and populate the result into item. */ +static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer) +{ + double number = 0; + unsigned char *after_end = NULL; + unsigned char number_c_string[64]; + unsigned char decimal_point = get_decimal_point(); + size_t i = 0; + + if ((input_buffer == NULL) || (input_buffer->content == NULL)) + { + return false; + } + + /* copy the number into a temporary buffer and replace '.' with the decimal point + * of the current locale (for strtod) + * This also takes care of '\0' not necessarily being available for marking the end of the input */ + for (i = 0; (i < (sizeof(number_c_string) - 1)) && can_access_at_index(input_buffer, i); i++) + { + switch (buffer_at_offset(input_buffer)[i]) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '+': + case '-': + case 'e': + case 'E': + number_c_string[i] = buffer_at_offset(input_buffer)[i]; + break; + + case '.': + number_c_string[i] = decimal_point; + break; + + default: + goto loop_end; + } + } +loop_end: + number_c_string[i] = '\0'; + + number = strtod((const char*)number_c_string, (char**)&after_end); + if (number_c_string == after_end) + { + return false; /* parse_error */ + } + + item->valuedouble = number; + + /* use saturation in case of overflow */ + if (number >= INT_MAX) + { + item->valueint = INT_MAX; + } + else if (number <= (double)INT_MIN) + { + item->valueint = INT_MIN; + } + else + { + item->valueint = (int)number; + } + + item->type = cJSON_Number; + + input_buffer->offset += (size_t)(after_end - number_c_string); + return true; +} + +/* don't ask me, but the original cJSON_SetNumberValue returns an integer or double */ +CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number) +{ + if (number >= INT_MAX) + { + object->valueint = INT_MAX; + } + else if (number <= (double)INT_MIN) + { + object->valueint = INT_MIN; + } + else + { + object->valueint = (int)number; + } + + return object->valuedouble = number; +} + +typedef struct +{ + unsigned char *buffer; + size_t length; + size_t offset; + size_t depth; /* current nesting depth (for formatted printing) */ + cJSON_bool noalloc; + cJSON_bool format; /* is this print a formatted print */ + internal_hooks hooks; +} printbuffer; + +/* realloc printbuffer if necessary to have at least "needed" bytes more */ +static unsigned char* ensure(printbuffer * const p, size_t needed) +{ + unsigned char *newbuffer = NULL; + size_t newsize = 0; + + if ((p == NULL) || (p->buffer == NULL)) + { + return NULL; + } + + if ((p->length > 0) && (p->offset >= p->length)) + { + /* make sure that offset is valid */ + return NULL; + } + + if (needed > INT_MAX) + { + /* sizes bigger than INT_MAX are currently not supported */ + return NULL; + } + + needed += p->offset + 1; + if (needed <= p->length) + { + return p->buffer + p->offset; + } + + if (p->noalloc) { + return NULL; + } + + /* calculate new buffer size */ + if (needed > (INT_MAX / 2)) + { + /* overflow of int, use INT_MAX if possible */ + if (needed <= INT_MAX) + { + newsize = INT_MAX; + } + else + { + return NULL; + } + } + else + { + newsize = needed * 2; + } + + if (p->hooks.reallocate != NULL) + { + /* reallocate with realloc if available */ + newbuffer = (unsigned char*)p->hooks.reallocate(p->buffer, newsize); + if (newbuffer == NULL) + { + p->hooks.deallocate(p->buffer); + p->length = 0; + p->buffer = NULL; + + return NULL; + } + } + else + { + /* otherwise reallocate manually */ + newbuffer = (unsigned char*)p->hooks.allocate(newsize); + if (!newbuffer) + { + p->hooks.deallocate(p->buffer); + p->length = 0; + p->buffer = NULL; + + return NULL; + } + if (newbuffer) + { + memcpy(newbuffer, p->buffer, p->offset + 1); + } + p->hooks.deallocate(p->buffer); + } + p->length = newsize; + p->buffer = newbuffer; + + return newbuffer + p->offset; +} + +/* calculate the new length of the string in a printbuffer and update the offset */ +static void update_offset(printbuffer * const buffer) +{ + const unsigned char *buffer_pointer = NULL; + if ((buffer == NULL) || (buffer->buffer == NULL)) + { + return; + } + buffer_pointer = buffer->buffer + buffer->offset; + + buffer->offset += strlen((const char*)buffer_pointer); +} + +/* securely comparison of floating-point variables */ +static cJSON_bool compare_double(double a, double b) +{ + return (fabs(a - b) <= CJSON_DOUBLE_PRECISION); +} + +/* Render the number nicely from the given item into a string. */ +static cJSON_bool print_number(const cJSON * const item, printbuffer * const output_buffer) +{ + unsigned char *output_pointer = NULL; + double d = item->valuedouble; + int length = 0; + size_t i = 0; + unsigned char number_buffer[26] = {0}; /* temporary buffer to print the number into */ + unsigned char decimal_point = get_decimal_point(); + double test = 0.0; + + if (output_buffer == NULL) + { + return false; + } + + /* This checks for NaN and Infinity */ + if (!compare_double(d * 0, 0)) + { + length = sprintf((char*)number_buffer, "null"); + } + else + { + /* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */ + length = sprintf((char*)number_buffer, "%1.15g", d); + + /* Check whether the original double can be recovered */ + if ((sscanf((char*)number_buffer, "%lg", &test) != 1) || !compare_double((double)test, d)) + { + /* If not, print with 17 decimal places of precision */ + length = sprintf((char*)number_buffer, "%1.17g", d); + } + } + + /* sprintf failed or buffer overrun occurred */ + if ((length < 0) || (length > (int)(sizeof(number_buffer) - 1))) + { + return false; + } + + /* reserve appropriate space in the output */ + output_pointer = ensure(output_buffer, (size_t)length + sizeof("")); + if (output_pointer == NULL) + { + return false; + } + + /* copy the printed number to the output and replace locale + * dependent decimal point with '.' */ + for (i = 0; i < ((size_t)length); i++) + { + if (number_buffer[i] == decimal_point) + { + output_pointer[i] = '.'; + continue; + } + + output_pointer[i] = number_buffer[i]; + } + output_pointer[i] = '\0'; + + output_buffer->offset += (size_t)length; + + return true; +} + +/* parse 4 digit hexadecimal number */ +static unsigned parse_hex4(const unsigned char * const input) +{ + unsigned int h = 0; + size_t i = 0; + + for (i = 0; i < 4; i++) + { + /* parse digit */ + if ((input[i] >= '0') && (input[i] <= '9')) + { + h += (unsigned int) input[i] - '0'; + } + else if ((input[i] >= 'A') && (input[i] <= 'F')) + { + h += (unsigned int) 10 + input[i] - 'A'; + } + else if ((input[i] >= 'a') && (input[i] <= 'f')) + { + h += (unsigned int) 10 + input[i] - 'a'; + } + else /* invalid */ + { + return 0; + } + + if (i < 3) + { + /* shift left to make place for the next nibble */ + h = h << 4; + } + } + + return h; +} + +/* converts a UTF-16 literal to UTF-8 + * A literal can be one or two sequences of the form \uXXXX */ +static unsigned char utf16_literal_to_utf8(const unsigned char * const input_pointer, const unsigned char * const input_end, unsigned char **output_pointer) +{ + long unsigned int codepoint = 0; + unsigned int first_code = 0; + const unsigned char *first_sequence = input_pointer; + unsigned char utf8_length = 0; + unsigned char utf8_position = 0; + unsigned char sequence_length = 0; + unsigned char first_byte_mark = 0; + + if ((input_end - first_sequence) < 6) + { + /* input ends unexpectedly */ + goto fail; + } + + /* get the first utf16 sequence */ + first_code = parse_hex4(first_sequence + 2); + + /* check that the code is valid */ + if (((first_code >= 0xDC00) && (first_code <= 0xDFFF))) + { + goto fail; + } + + /* UTF16 surrogate pair */ + if ((first_code >= 0xD800) && (first_code <= 0xDBFF)) + { + const unsigned char *second_sequence = first_sequence + 6; + unsigned int second_code = 0; + sequence_length = 12; /* \uXXXX\uXXXX */ + + if ((input_end - second_sequence) < 6) + { + /* input ends unexpectedly */ + goto fail; + } + + if ((second_sequence[0] != '\\') || (second_sequence[1] != 'u')) + { + /* missing second half of the surrogate pair */ + goto fail; + } + + /* get the second utf16 sequence */ + second_code = parse_hex4(second_sequence + 2); + /* check that the code is valid */ + if ((second_code < 0xDC00) || (second_code > 0xDFFF)) + { + /* invalid second half of the surrogate pair */ + goto fail; + } + + + /* calculate the unicode codepoint from the surrogate pair */ + codepoint = 0x10000 + (((first_code & 0x3FF) << 10) | (second_code & 0x3FF)); + } + else + { + sequence_length = 6; /* \uXXXX */ + codepoint = first_code; + } + + /* encode as UTF-8 + * takes at maximum 4 bytes to encode: + * 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */ + if (codepoint < 0x80) + { + /* normal ascii, encoding 0xxxxxxx */ + utf8_length = 1; + } + else if (codepoint < 0x800) + { + /* two bytes, encoding 110xxxxx 10xxxxxx */ + utf8_length = 2; + first_byte_mark = 0xC0; /* 11000000 */ + } + else if (codepoint < 0x10000) + { + /* three bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx */ + utf8_length = 3; + first_byte_mark = 0xE0; /* 11100000 */ + } + else if (codepoint <= 0x10FFFF) + { + /* four bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx 10xxxxxx */ + utf8_length = 4; + first_byte_mark = 0xF0; /* 11110000 */ + } + else + { + /* invalid unicode codepoint */ + goto fail; + } + + /* encode as utf8 */ + for (utf8_position = (unsigned char)(utf8_length - 1); utf8_position > 0; utf8_position--) + { + /* 10xxxxxx */ + (*output_pointer)[utf8_position] = (unsigned char)((codepoint | 0x80) & 0xBF); + codepoint >>= 6; + } + /* encode first byte */ + if (utf8_length > 1) + { + (*output_pointer)[0] = (unsigned char)((codepoint | first_byte_mark) & 0xFF); + } + else + { + (*output_pointer)[0] = (unsigned char)(codepoint & 0x7F); + } + + *output_pointer += utf8_length; + + return sequence_length; + +fail: + return 0; +} + +/* Parse the input text into an unescaped cinput, and populate item. */ +static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_buffer) +{ + const unsigned char *input_pointer = buffer_at_offset(input_buffer) + 1; + const unsigned char *input_end = buffer_at_offset(input_buffer) + 1; + unsigned char *output_pointer = NULL; + unsigned char *output = NULL; + + /* not a string */ + if (buffer_at_offset(input_buffer)[0] != '\"') + { + goto fail; + } + + { + /* calculate approximate size of the output (overestimate) */ + size_t allocation_length = 0; + size_t skipped_bytes = 0; + while (((size_t)(input_end - input_buffer->content) < input_buffer->length) && (*input_end != '\"')) + { + /* is escape sequence */ + if (input_end[0] == '\\') + { + if ((size_t)(input_end + 1 - input_buffer->content) >= input_buffer->length) + { + /* prevent buffer overflow when last input character is a backslash */ + goto fail; + } + skipped_bytes++; + input_end++; + } + input_end++; + } + if (((size_t)(input_end - input_buffer->content) >= input_buffer->length) || (*input_end != '\"')) + { + goto fail; /* string ended unexpectedly */ + } + + /* This is at most how much we need for the output */ + allocation_length = (size_t) (input_end - buffer_at_offset(input_buffer)) - skipped_bytes; + output = (unsigned char*)input_buffer->hooks.allocate(allocation_length + sizeof("")); + if (output == NULL) + { + goto fail; /* allocation failure */ + } + } + + output_pointer = output; + /* loop through the string literal */ + while (input_pointer < input_end) + { + if (*input_pointer != '\\') + { + *output_pointer++ = *input_pointer++; + } + /* escape sequence */ + else + { + unsigned char sequence_length = 2; + if ((input_end - input_pointer) < 1) + { + goto fail; + } + + switch (input_pointer[1]) + { + case 'b': + *output_pointer++ = '\b'; + break; + case 'f': + *output_pointer++ = '\f'; + break; + case 'n': + *output_pointer++ = '\n'; + break; + case 'r': + *output_pointer++ = '\r'; + break; + case 't': + *output_pointer++ = '\t'; + break; + case '\"': + case '\\': + case '/': + *output_pointer++ = input_pointer[1]; + break; + + /* UTF-16 literal */ + case 'u': + sequence_length = utf16_literal_to_utf8(input_pointer, input_end, &output_pointer); + if (sequence_length == 0) + { + /* failed to convert UTF16-literal to UTF-8 */ + goto fail; + } + break; + + default: + goto fail; + } + input_pointer += sequence_length; + } + } + + /* zero terminate the output */ + *output_pointer = '\0'; + + item->type = cJSON_String; + item->valuestring = (char*)output; + + input_buffer->offset = (size_t) (input_end - input_buffer->content); + input_buffer->offset++; + + return true; + +fail: + if (output != NULL) + { + input_buffer->hooks.deallocate(output); + } + + if (input_pointer != NULL) + { + input_buffer->offset = (size_t)(input_pointer - input_buffer->content); + } + + return false; +} + +/* Render the cstring provided to an escaped version that can be printed. */ +static cJSON_bool print_string_ptr(const unsigned char * const input, printbuffer * const output_buffer) +{ + const unsigned char *input_pointer = NULL; + unsigned char *output = NULL; + unsigned char *output_pointer = NULL; + size_t output_length = 0; + /* numbers of additional characters needed for escaping */ + size_t escape_characters = 0; + + if (output_buffer == NULL) + { + return false; + } + + /* empty string */ + if (input == NULL) + { + output = ensure(output_buffer, sizeof("\"\"")); + if (output == NULL) + { + return false; + } + strcpy((char*)output, "\"\""); + + return true; + } + + /* set "flag" to 1 if something needs to be escaped */ + for (input_pointer = input; *input_pointer; input_pointer++) + { + switch (*input_pointer) + { + case '\"': + case '\\': + case '\b': + case '\f': + case '\n': + case '\r': + case '\t': + /* one character escape sequence */ + escape_characters++; + break; + default: + if (*input_pointer < 32) + { + /* UTF-16 escape sequence uXXXX */ + escape_characters += 5; + } + break; + } + } + output_length = (size_t)(input_pointer - input) + escape_characters; + + output = ensure(output_buffer, output_length + sizeof("\"\"")); + if (output == NULL) + { + return false; + } + + /* no characters have to be escaped */ + if (escape_characters == 0) + { + output[0] = '\"'; + memcpy(output + 1, input, output_length); + output[output_length + 1] = '\"'; + output[output_length + 2] = '\0'; + + return true; + } + + output[0] = '\"'; + output_pointer = output + 1; + /* copy the string */ + for (input_pointer = input; *input_pointer != '\0'; (void)input_pointer++, output_pointer++) + { + if ((*input_pointer > 31) && (*input_pointer != '\"') && (*input_pointer != '\\')) + { + /* normal character, copy */ + *output_pointer = *input_pointer; + } + else + { + /* character needs to be escaped */ + *output_pointer++ = '\\'; + switch (*input_pointer) + { + case '\\': + *output_pointer = '\\'; + break; + case '\"': + *output_pointer = '\"'; + break; + case '\b': + *output_pointer = 'b'; + break; + case '\f': + *output_pointer = 'f'; + break; + case '\n': + *output_pointer = 'n'; + break; + case '\r': + *output_pointer = 'r'; + break; + case '\t': + *output_pointer = 't'; + break; + default: + /* escape and print as unicode codepoint */ + sprintf((char*)output_pointer, "u%04x", *input_pointer); + output_pointer += 4; + break; + } + } + } + output[output_length + 1] = '\"'; + output[output_length + 2] = '\0'; + + return true; +} + +/* Invoke print_string_ptr (which is useful) on an item. */ +static cJSON_bool print_string(const cJSON * const item, printbuffer * const p) +{ + return print_string_ptr((unsigned char*)item->valuestring, p); +} + +/* Predeclare these prototypes. */ +static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer); +static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer); +static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer); +static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer); +static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer); +static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer); + +/* Utility to jump whitespace and cr/lf */ +static parse_buffer *buffer_skip_whitespace(parse_buffer * const buffer) +{ + if ((buffer == NULL) || (buffer->content == NULL)) + { + return NULL; + } + + while (can_access_at_index(buffer, 0) && (buffer_at_offset(buffer)[0] <= 32)) + { + buffer->offset++; + } + + if (buffer->offset == buffer->length) + { + buffer->offset--; + } + + return buffer; +} + +/* skip the UTF-8 BOM (byte order mark) if it is at the beginning of a buffer */ +static parse_buffer *skip_utf8_bom(parse_buffer * const buffer) +{ + if ((buffer == NULL) || (buffer->content == NULL) || (buffer->offset != 0)) + { + return NULL; + } + + if (can_access_at_index(buffer, 4) && (strncmp((const char*)buffer_at_offset(buffer), "\xEF\xBB\xBF", 3) == 0)) + { + buffer->offset += 3; + } + + return buffer; +} + +/* Parse an object - create a new root, and populate. */ +CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated) +{ + parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } }; + cJSON *item = NULL; + + /* reset error position */ + global_error.json = NULL; + global_error.position = 0; + + if (value == NULL) + { + goto fail; + } + + buffer.content = (const unsigned char*)value; + buffer.length = strlen((const char*)value) + sizeof(""); + buffer.offset = 0; + buffer.hooks = global_hooks; + + item = cJSON_New_Item(&global_hooks); + if (item == NULL) /* memory fail */ + { + goto fail; + } + + if (!parse_value(item, buffer_skip_whitespace(skip_utf8_bom(&buffer)))) + { + /* parse failure. ep is set. */ + goto fail; + } + + /* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */ + if (require_null_terminated) + { + buffer_skip_whitespace(&buffer); + if ((buffer.offset >= buffer.length) || buffer_at_offset(&buffer)[0] != '\0') + { + goto fail; + } + } + if (return_parse_end) + { + *return_parse_end = (const char*)buffer_at_offset(&buffer); + } + + return item; + +fail: + if (item != NULL) + { + cJSON_Delete(item); + } + + if (value != NULL) + { + error local_error; + local_error.json = (const unsigned char*)value; + local_error.position = 0; + + if (buffer.offset < buffer.length) + { + local_error.position = buffer.offset; + } + else if (buffer.length > 0) + { + local_error.position = buffer.length - 1; + } + + if (return_parse_end != NULL) + { + *return_parse_end = (const char*)local_error.json + local_error.position; + } + + global_error = local_error; + } + + return NULL; +} + +/* Default options for cJSON_Parse */ +CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value) +{ + return cJSON_ParseWithOpts(value, 0, 0); +} + +#define cjson_min(a, b) ((a < b) ? a : b) + +static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks) +{ + static const size_t default_buffer_size = 256; + printbuffer buffer[1]; + unsigned char *printed = NULL; + + memset(buffer, 0, sizeof(buffer)); + + /* create buffer */ + buffer->buffer = (unsigned char*) hooks->allocate(default_buffer_size); + buffer->length = default_buffer_size; + buffer->format = format; + buffer->hooks = *hooks; + if (buffer->buffer == NULL) + { + goto fail; + } + + /* print the value */ + if (!print_value(item, buffer)) + { + goto fail; + } + update_offset(buffer); + + /* check if reallocate is available */ + if (hooks->reallocate != NULL) + { + printed = (unsigned char*) hooks->reallocate(buffer->buffer, buffer->offset + 1); + if (printed == NULL) { + goto fail; + } + buffer->buffer = NULL; + } + else /* otherwise copy the JSON over to a new buffer */ + { + printed = (unsigned char*) hooks->allocate(buffer->offset + 1); + if (printed == NULL) + { + goto fail; + } + memcpy(printed, buffer->buffer, cjson_min(buffer->length, buffer->offset + 1)); + printed[buffer->offset] = '\0'; /* just to be sure */ + + /* free the buffer */ + hooks->deallocate(buffer->buffer); + } + + return printed; + +fail: + if (buffer->buffer != NULL) + { + hooks->deallocate(buffer->buffer); + } + + if (printed != NULL) + { + hooks->deallocate(printed); + } + + return NULL; +} + +/* Render a cJSON item/entity/structure to text. */ +CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item) +{ + return (char*)print(item, true, &global_hooks); +} + +CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item) +{ + return (char*)print(item, false, &global_hooks); +} + +CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt) +{ + printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }; + + if (prebuffer < 0) + { + return NULL; + } + + p.buffer = (unsigned char*)global_hooks.allocate((size_t)prebuffer); + if (!p.buffer) + { + return NULL; + } + + p.length = (size_t)prebuffer; + p.offset = 0; + p.noalloc = false; + p.format = fmt; + p.hooks = global_hooks; + + if (!print_value(item, &p)) + { + global_hooks.deallocate(p.buffer); + return NULL; + } + + return (char*)p.buffer; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format) +{ + printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }; + + if ((length < 0) || (buffer == NULL)) + { + return false; + } + + p.buffer = (unsigned char*)buffer; + p.length = (size_t)length; + p.offset = 0; + p.noalloc = true; + p.format = format; + p.hooks = global_hooks; + + return print_value(item, &p); +} + +/* Parser core - when encountering text, process appropriately. */ +static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer) +{ + if ((input_buffer == NULL) || (input_buffer->content == NULL)) + { + return false; /* no input */ + } + + /* parse the different types of values */ + /* null */ + if (can_read(input_buffer, 4) && (strncmp((const char*)buffer_at_offset(input_buffer), "null", 4) == 0)) + { + item->type = cJSON_NULL; + input_buffer->offset += 4; + return true; + } + /* false */ + if (can_read(input_buffer, 5) && (strncmp((const char*)buffer_at_offset(input_buffer), "false", 5) == 0)) + { + item->type = cJSON_False; + input_buffer->offset += 5; + return true; + } + /* true */ + if (can_read(input_buffer, 4) && (strncmp((const char*)buffer_at_offset(input_buffer), "true", 4) == 0)) + { + item->type = cJSON_True; + item->valueint = 1; + input_buffer->offset += 4; + return true; + } + /* string */ + if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '\"')) + { + return parse_string(item, input_buffer); + } + /* number */ + if (can_access_at_index(input_buffer, 0) && ((buffer_at_offset(input_buffer)[0] == '-') || ((buffer_at_offset(input_buffer)[0] >= '0') && (buffer_at_offset(input_buffer)[0] <= '9')))) + { + return parse_number(item, input_buffer); + } + /* array */ + if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '[')) + { + return parse_array(item, input_buffer); + } + /* object */ + if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '{')) + { + return parse_object(item, input_buffer); + } + + return false; +} + +/* Render a value to text. */ +static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer) +{ + unsigned char *output = NULL; + + if ((item == NULL) || (output_buffer == NULL)) + { + return false; + } + + switch ((item->type) & 0xFF) + { + case cJSON_NULL: + output = ensure(output_buffer, 5); + if (output == NULL) + { + return false; + } + strcpy((char*)output, "null"); + return true; + + case cJSON_False: + output = ensure(output_buffer, 6); + if (output == NULL) + { + return false; + } + strcpy((char*)output, "false"); + return true; + + case cJSON_True: + output = ensure(output_buffer, 5); + if (output == NULL) + { + return false; + } + strcpy((char*)output, "true"); + return true; + + case cJSON_Number: + return print_number(item, output_buffer); + + case cJSON_Raw: + { + size_t raw_length = 0; + if (item->valuestring == NULL) + { + return false; + } + + raw_length = strlen(item->valuestring) + sizeof(""); + output = ensure(output_buffer, raw_length); + if (output == NULL) + { + return false; + } + memcpy(output, item->valuestring, raw_length); + return true; + } + + case cJSON_String: + return print_string(item, output_buffer); + + case cJSON_Array: + return print_array(item, output_buffer); + + case cJSON_Object: + return print_object(item, output_buffer); + + default: + return false; + } +} + +/* Build an array from input text. */ +static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer) +{ + cJSON *head = NULL; /* head of the linked list */ + cJSON *current_item = NULL; + + if (input_buffer->depth >= CJSON_NESTING_LIMIT) + { + return false; /* to deeply nested */ + } + input_buffer->depth++; + + if (buffer_at_offset(input_buffer)[0] != '[') + { + /* not an array */ + goto fail; + } + + input_buffer->offset++; + buffer_skip_whitespace(input_buffer); + if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ']')) + { + /* empty array */ + goto success; + } + + /* check if we skipped to the end of the buffer */ + if (cannot_access_at_index(input_buffer, 0)) + { + input_buffer->offset--; + goto fail; + } + + /* step back to character in front of the first element */ + input_buffer->offset--; + /* loop through the comma separated array elements */ + do + { + /* allocate next item */ + cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks)); + if (new_item == NULL) + { + goto fail; /* allocation failure */ + } + + /* attach next item to list */ + if (head == NULL) + { + /* start the linked list */ + current_item = head = new_item; + } + else + { + /* add to the end and advance */ + current_item->next = new_item; + new_item->prev = current_item; + current_item = new_item; + } + + /* parse next value */ + input_buffer->offset++; + buffer_skip_whitespace(input_buffer); + if (!parse_value(current_item, input_buffer)) + { + goto fail; /* failed to parse value */ + } + buffer_skip_whitespace(input_buffer); + } + while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ',')); + + if (cannot_access_at_index(input_buffer, 0) || buffer_at_offset(input_buffer)[0] != ']') + { + goto fail; /* expected end of array */ + } + +success: + input_buffer->depth--; + + item->type = cJSON_Array; + item->child = head; + + input_buffer->offset++; + + return true; + +fail: + if (head != NULL) + { + cJSON_Delete(head); + } + + return false; +} + +/* Render an array to text */ +static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer) +{ + unsigned char *output_pointer = NULL; + size_t length = 0; + cJSON *current_element = item->child; + + if (output_buffer == NULL) + { + return false; + } + + /* Compose the output array. */ + /* opening square bracket */ + output_pointer = ensure(output_buffer, 1); + if (output_pointer == NULL) + { + return false; + } + + *output_pointer = '['; + output_buffer->offset++; + output_buffer->depth++; + + while (current_element != NULL) + { + if (!print_value(current_element, output_buffer)) + { + return false; + } + update_offset(output_buffer); + if (current_element->next) + { + length = (size_t) (output_buffer->format ? 2 : 1); + output_pointer = ensure(output_buffer, length + 1); + if (output_pointer == NULL) + { + return false; + } + *output_pointer++ = ','; + if(output_buffer->format) + { + *output_pointer++ = ' '; + } + *output_pointer = '\0'; + output_buffer->offset += length; + } + current_element = current_element->next; + } + + output_pointer = ensure(output_buffer, 2); + if (output_pointer == NULL) + { + return false; + } + *output_pointer++ = ']'; + *output_pointer = '\0'; + output_buffer->depth--; + + return true; +} + +/* Build an object from the text. */ +static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer) +{ + cJSON *head = NULL; /* linked list head */ + cJSON *current_item = NULL; + + if (input_buffer->depth >= CJSON_NESTING_LIMIT) + { + return false; /* to deeply nested */ + } + input_buffer->depth++; + + if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '{')) + { + goto fail; /* not an object */ + } + + input_buffer->offset++; + buffer_skip_whitespace(input_buffer); + if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '}')) + { + goto success; /* empty object */ + } + + /* check if we skipped to the end of the buffer */ + if (cannot_access_at_index(input_buffer, 0)) + { + input_buffer->offset--; + goto fail; + } + + /* step back to character in front of the first element */ + input_buffer->offset--; + /* loop through the comma separated array elements */ + do + { + /* allocate next item */ + cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks)); + if (new_item == NULL) + { + goto fail; /* allocation failure */ + } + + /* attach next item to list */ + if (head == NULL) + { + /* start the linked list */ + current_item = head = new_item; + } + else + { + /* add to the end and advance */ + current_item->next = new_item; + new_item->prev = current_item; + current_item = new_item; + } + + /* parse the name of the child */ + input_buffer->offset++; + buffer_skip_whitespace(input_buffer); + if (!parse_string(current_item, input_buffer)) + { + goto fail; /* failed to parse name */ + } + buffer_skip_whitespace(input_buffer); + + /* swap valuestring and string, because we parsed the name */ + current_item->string = current_item->valuestring; + current_item->valuestring = NULL; + + if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != ':')) + { + goto fail; /* invalid object */ + } + + /* parse the value */ + input_buffer->offset++; + buffer_skip_whitespace(input_buffer); + if (!parse_value(current_item, input_buffer)) + { + goto fail; /* failed to parse value */ + } + buffer_skip_whitespace(input_buffer); + } + while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ',')); + + if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '}')) + { + goto fail; /* expected end of object */ + } + +success: + input_buffer->depth--; + + item->type = cJSON_Object; + item->child = head; + + input_buffer->offset++; + return true; + +fail: + if (head != NULL) + { + cJSON_Delete(head); + } + + return false; +} + +/* Render an object to text. */ +static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer) +{ + unsigned char *output_pointer = NULL; + size_t length = 0; + cJSON *current_item = item->child; + + if (output_buffer == NULL) + { + return false; + } + + /* Compose the output: */ + length = (size_t) (output_buffer->format ? 2 : 1); /* fmt: {\n */ + output_pointer = ensure(output_buffer, length + 1); + if (output_pointer == NULL) + { + return false; + } + + *output_pointer++ = '{'; + output_buffer->depth++; + if (output_buffer->format) + { + *output_pointer++ = '\n'; + } + output_buffer->offset += length; + + while (current_item) + { + if (output_buffer->format) + { + size_t i; + output_pointer = ensure(output_buffer, output_buffer->depth); + if (output_pointer == NULL) + { + return false; + } + for (i = 0; i < output_buffer->depth; i++) + { + *output_pointer++ = '\t'; + } + output_buffer->offset += output_buffer->depth; + } + + /* print key */ + if (!print_string_ptr((unsigned char*)current_item->string, output_buffer)) + { + return false; + } + update_offset(output_buffer); + + length = (size_t) (output_buffer->format ? 2 : 1); + output_pointer = ensure(output_buffer, length); + if (output_pointer == NULL) + { + return false; + } + *output_pointer++ = ':'; + if (output_buffer->format) + { + *output_pointer++ = '\t'; + } + output_buffer->offset += length; + + /* print value */ + if (!print_value(current_item, output_buffer)) + { + return false; + } + update_offset(output_buffer); + + /* print comma if not last */ + length = ((size_t)(output_buffer->format ? 1 : 0) + (size_t)(current_item->next ? 1 : 0)); + output_pointer = ensure(output_buffer, length + 1); + if (output_pointer == NULL) + { + return false; + } + if (current_item->next) + { + *output_pointer++ = ','; + } + + if (output_buffer->format) + { + *output_pointer++ = '\n'; + } + *output_pointer = '\0'; + output_buffer->offset += length; + + current_item = current_item->next; + } + + output_pointer = ensure(output_buffer, output_buffer->format ? (output_buffer->depth + 1) : 2); + if (output_pointer == NULL) + { + return false; + } + if (output_buffer->format) + { + size_t i; + for (i = 0; i < (output_buffer->depth - 1); i++) + { + *output_pointer++ = '\t'; + } + } + *output_pointer++ = '}'; + *output_pointer = '\0'; + output_buffer->depth--; + + return true; +} + +/* Get Array size/item / object item. */ +CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array) +{ + cJSON *child = NULL; + size_t size = 0; + + if (array == NULL) + { + return 0; + } + + child = array->child; + + while(child != NULL) + { + size++; + child = child->next; + } + + /* FIXME: Can overflow here. Cannot be fixed without breaking the API */ + + return (int)size; +} + +static cJSON* get_array_item(const cJSON *array, size_t index) +{ + cJSON *current_child = NULL; + + if (array == NULL) + { + return NULL; + } + + current_child = array->child; + while ((current_child != NULL) && (index > 0)) + { + index--; + current_child = current_child->next; + } + + return current_child; +} + +CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index) +{ + if (index < 0) + { + return NULL; + } + + return get_array_item(array, (size_t)index); +} + +static cJSON *get_object_item(const cJSON * const object, const char * const name, const cJSON_bool case_sensitive) +{ + cJSON *current_element = NULL; + + if ((object == NULL) || (name == NULL)) + { + return NULL; + } + + current_element = object->child; + if (case_sensitive) + { + while ((current_element != NULL) && (current_element->string != NULL) && (strcmp(name, current_element->string) != 0)) + { + current_element = current_element->next; + } + } + else + { + while ((current_element != NULL) && (case_insensitive_strcmp((const unsigned char*)name, (const unsigned char*)(current_element->string)) != 0)) + { + current_element = current_element->next; + } + } + + if ((current_element == NULL) || (current_element->string == NULL)) { + return NULL; + } + + return current_element; +} + +CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string) +{ + return get_object_item(object, string, false); +} + +CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string) +{ + return get_object_item(object, string, true); +} + +CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string) +{ + return cJSON_GetObjectItem(object, string) ? 1 : 0; +} + +/* Utility for array list handling. */ +static void suffix_object(cJSON *prev, cJSON *item) +{ + prev->next = item; + item->prev = prev; +} + +/* Utility for handling references. */ +static cJSON *create_reference(const cJSON *item, const internal_hooks * const hooks) +{ + cJSON *reference = NULL; + if (item == NULL) + { + return NULL; + } + + reference = cJSON_New_Item(hooks); + if (reference == NULL) + { + return NULL; + } + + memcpy(reference, item, sizeof(cJSON)); + reference->string = NULL; + reference->type |= cJSON_IsReference; + reference->next = reference->prev = NULL; + return reference; +} + +static cJSON_bool add_item_to_array(cJSON *array, cJSON *item) +{ + cJSON *child = NULL; + + if ((item == NULL) || (array == NULL)) + { + return false; + } + + child = array->child; + + if (child == NULL) + { + /* list is empty, start new one */ + array->child = item; + } + else + { + /* append to the end */ + while (child->next) + { + child = child->next; + } + suffix_object(child, item); + } + + return true; +} + +/* Add item to array/object. */ +CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item) +{ + add_item_to_array(array, item); +} + +#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)))) + #pragma GCC diagnostic push +#endif +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wcast-qual" +#endif +/* helper function to cast away const */ +static void* cast_away_const(const void* string) +{ + return (void*)string; +} +#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)))) + #pragma GCC diagnostic pop +#endif + + +static cJSON_bool add_item_to_object(cJSON * const object, const char * const string, cJSON * const item, const internal_hooks * const hooks, const cJSON_bool constant_key) +{ + char *new_key = NULL; + int new_type = cJSON_Invalid; + + if ((object == NULL) || (string == NULL) || (item == NULL)) + { + return false; + } + + if (constant_key) + { + new_key = (char*)cast_away_const(string); + new_type = item->type | cJSON_StringIsConst; + } + else + { + new_key = (char*)cJSON_strdup((const unsigned char*)string, hooks); + if (new_key == NULL) + { + return false; + } + + new_type = item->type & ~cJSON_StringIsConst; + } + + if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) + { + hooks->deallocate(item->string); + } + + item->string = new_key; + item->type = new_type; + + return add_item_to_array(object, item); +} + +CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item) +{ + add_item_to_object(object, string, item, &global_hooks, false); +} + +/* Add an item to an object with constant string as key */ +CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item) +{ + add_item_to_object(object, string, item, &global_hooks, true); +} + +CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) +{ + if (array == NULL) + { + return; + } + + add_item_to_array(array, create_reference(item, &global_hooks)); +} + +CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item) +{ + if ((object == NULL) || (string == NULL)) + { + return; + } + + add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false); +} + +CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name) +{ + cJSON *null = cJSON_CreateNull(); + if (add_item_to_object(object, name, null, &global_hooks, false)) + { + return null; + } + + cJSON_Delete(null); + return NULL; +} + +CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name) +{ + cJSON *true_item = cJSON_CreateTrue(); + if (add_item_to_object(object, name, true_item, &global_hooks, false)) + { + return true_item; + } + + cJSON_Delete(true_item); + return NULL; +} + +CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name) +{ + cJSON *false_item = cJSON_CreateFalse(); + if (add_item_to_object(object, name, false_item, &global_hooks, false)) + { + return false_item; + } + + cJSON_Delete(false_item); + return NULL; +} + +CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean) +{ + cJSON *bool_item = cJSON_CreateBool(boolean); + if (add_item_to_object(object, name, bool_item, &global_hooks, false)) + { + return bool_item; + } + + cJSON_Delete(bool_item); + return NULL; +} + +CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number) +{ + cJSON *number_item = cJSON_CreateNumber(number); + if (add_item_to_object(object, name, number_item, &global_hooks, false)) + { + return number_item; + } + + cJSON_Delete(number_item); + return NULL; +} + +CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string) +{ + cJSON *string_item = cJSON_CreateString(string); + if (add_item_to_object(object, name, string_item, &global_hooks, false)) + { + return string_item; + } + + cJSON_Delete(string_item); + return NULL; +} + +CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw) +{ + cJSON *raw_item = cJSON_CreateRaw(raw); + if (add_item_to_object(object, name, raw_item, &global_hooks, false)) + { + return raw_item; + } + + cJSON_Delete(raw_item); + return NULL; +} + +CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name) +{ + cJSON *object_item = cJSON_CreateObject(); + if (add_item_to_object(object, name, object_item, &global_hooks, false)) + { + return object_item; + } + + cJSON_Delete(object_item); + return NULL; +} + +CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name) +{ + cJSON *array = cJSON_CreateArray(); + if (add_item_to_object(object, name, array, &global_hooks, false)) + { + return array; + } + + cJSON_Delete(array); + return NULL; +} + +CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item) +{ + if ((parent == NULL) || (item == NULL)) + { + return NULL; + } + + if (item->prev != NULL) + { + /* not the first element */ + item->prev->next = item->next; + } + if (item->next != NULL) + { + /* not the last element */ + item->next->prev = item->prev; + } + + if (item == parent->child) + { + /* first element */ + parent->child = item->next; + } + /* make sure the detached item doesn't point anywhere anymore */ + item->prev = NULL; + item->next = NULL; + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which) +{ + if (which < 0) + { + return NULL; + } + + return cJSON_DetachItemViaPointer(array, get_array_item(array, (size_t)which)); +} + +CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which) +{ + cJSON_Delete(cJSON_DetachItemFromArray(array, which)); +} + +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string) +{ + cJSON *to_detach = cJSON_GetObjectItem(object, string); + + return cJSON_DetachItemViaPointer(object, to_detach); +} + +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string) +{ + cJSON *to_detach = cJSON_GetObjectItemCaseSensitive(object, string); + + return cJSON_DetachItemViaPointer(object, to_detach); +} + +CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string) +{ + cJSON_Delete(cJSON_DetachItemFromObject(object, string)); +} + +CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string) +{ + cJSON_Delete(cJSON_DetachItemFromObjectCaseSensitive(object, string)); +} + +/* Replace array/object items with new ones. */ +CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem) +{ + cJSON *after_inserted = NULL; + + if (which < 0) + { + return; + } + + after_inserted = get_array_item(array, (size_t)which); + if (after_inserted == NULL) + { + add_item_to_array(array, newitem); + return; + } + + newitem->next = after_inserted; + newitem->prev = after_inserted->prev; + after_inserted->prev = newitem; + if (after_inserted == array->child) + { + array->child = newitem; + } + else + { + newitem->prev->next = newitem; + } +} + +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement) +{ + if ((parent == NULL) || (replacement == NULL) || (item == NULL)) + { + return false; + } + + if (replacement == item) + { + return true; + } + + replacement->next = item->next; + replacement->prev = item->prev; + + if (replacement->next != NULL) + { + replacement->next->prev = replacement; + } + if (replacement->prev != NULL) + { + replacement->prev->next = replacement; + } + if (parent->child == item) + { + parent->child = replacement; + } + + item->next = NULL; + item->prev = NULL; + cJSON_Delete(item); + + return true; +} + +CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem) +{ + if (which < 0) + { + return; + } + + cJSON_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which), newitem); +} + +static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive) +{ + if ((replacement == NULL) || (string == NULL)) + { + return false; + } + + /* replace the name in the replacement */ + if (!(replacement->type & cJSON_StringIsConst) && (replacement->string != NULL)) + { + cJSON_free(replacement->string); + } + replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); + replacement->type &= ~cJSON_StringIsConst; + + cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement); + + return true; +} + +CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem) +{ + replace_item_in_object(object, string, newitem, false); +} + +CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem) +{ + replace_item_in_object(object, string, newitem, true); +} + +/* Create basic types: */ +CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) + { + item->type = cJSON_NULL; + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) + { + item->type = cJSON_True; + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) + { + item->type = cJSON_False; + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) + { + item->type = boolean ? cJSON_True : cJSON_False; + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) + { + item->type = cJSON_Number; + item->valuedouble = num; + + /* use saturation in case of overflow */ + if (num >= INT_MAX) + { + item->valueint = INT_MAX; + } + else if (num <= (double)INT_MIN) + { + item->valueint = INT_MIN; + } + else + { + item->valueint = (int)num; + } + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) + { + item->type = cJSON_String; + item->valuestring = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); + if(!item->valuestring) + { + cJSON_Delete(item); + return NULL; + } + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if (item != NULL) + { + item->type = cJSON_String | cJSON_IsReference; + item->valuestring = (char*)cast_away_const(string); + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if (item != NULL) { + item->type = cJSON_Object | cJSON_IsReference; + item->child = (cJSON*)cast_away_const(child); + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child) { + cJSON *item = cJSON_New_Item(&global_hooks); + if (item != NULL) { + item->type = cJSON_Array | cJSON_IsReference; + item->child = (cJSON*)cast_away_const(child); + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) + { + item->type = cJSON_Raw; + item->valuestring = (char*)cJSON_strdup((const unsigned char*)raw, &global_hooks); + if(!item->valuestring) + { + cJSON_Delete(item); + return NULL; + } + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if(item) + { + item->type=cJSON_Array; + } + + return item; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void) +{ + cJSON *item = cJSON_New_Item(&global_hooks); + if (item) + { + item->type = cJSON_Object; + } + + return item; +} + +/* Create Arrays: */ +CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count) +{ + size_t i = 0; + cJSON *n = NULL; + cJSON *p = NULL; + cJSON *a = NULL; + + if ((count < 0) || (numbers == NULL)) + { + return NULL; + } + + a = cJSON_CreateArray(); + for(i = 0; a && (i < (size_t)count); i++) + { + n = cJSON_CreateNumber(numbers[i]); + if (!n) + { + cJSON_Delete(a); + return NULL; + } + if(!i) + { + a->child = n; + } + else + { + suffix_object(p, n); + } + p = n; + } + + return a; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count) +{ + size_t i = 0; + cJSON *n = NULL; + cJSON *p = NULL; + cJSON *a = NULL; + + if ((count < 0) || (numbers == NULL)) + { + return NULL; + } + + a = cJSON_CreateArray(); + + for(i = 0; a && (i < (size_t)count); i++) + { + n = cJSON_CreateNumber((double)numbers[i]); + if(!n) + { + cJSON_Delete(a); + return NULL; + } + if(!i) + { + a->child = n; + } + else + { + suffix_object(p, n); + } + p = n; + } + + return a; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count) +{ + size_t i = 0; + cJSON *n = NULL; + cJSON *p = NULL; + cJSON *a = NULL; + + if ((count < 0) || (numbers == NULL)) + { + return NULL; + } + + a = cJSON_CreateArray(); + + for(i = 0;a && (i < (size_t)count); i++) + { + n = cJSON_CreateNumber(numbers[i]); + if(!n) + { + cJSON_Delete(a); + return NULL; + } + if(!i) + { + a->child = n; + } + else + { + suffix_object(p, n); + } + p = n; + } + + return a; +} + +CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count) +{ + size_t i = 0; + cJSON *n = NULL; + cJSON *p = NULL; + cJSON *a = NULL; + + if ((count < 0) || (strings == NULL)) + { + return NULL; + } + + a = cJSON_CreateArray(); + + for (i = 0; a && (i < (size_t)count); i++) + { + n = cJSON_CreateString(strings[i]); + if(!n) + { + cJSON_Delete(a); + return NULL; + } + if(!i) + { + a->child = n; + } + else + { + suffix_object(p,n); + } + p = n; + } + + return a; +} + +/* Duplication */ +CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse) +{ + cJSON *newitem = NULL; + cJSON *child = NULL; + cJSON *next = NULL; + cJSON *newchild = NULL; + + /* Bail on bad ptr */ + if (!item) + { + goto fail; + } + /* Create new item */ + newitem = cJSON_New_Item(&global_hooks); + if (!newitem) + { + goto fail; + } + /* Copy over all vars */ + newitem->type = item->type & (~cJSON_IsReference); + newitem->valueint = item->valueint; + newitem->valuedouble = item->valuedouble; + if (item->valuestring) + { + newitem->valuestring = (char*)cJSON_strdup((unsigned char*)item->valuestring, &global_hooks); + if (!newitem->valuestring) + { + goto fail; + } + } + if (item->string) + { + newitem->string = (item->type&cJSON_StringIsConst) ? item->string : (char*)cJSON_strdup((unsigned char*)item->string, &global_hooks); + if (!newitem->string) + { + goto fail; + } + } + /* If non-recursive, then we're done! */ + if (!recurse) + { + return newitem; + } + /* Walk the ->next chain for the child. */ + child = item->child; + while (child != NULL) + { + newchild = cJSON_Duplicate(child, true); /* Duplicate (with recurse) each item in the ->next chain */ + if (!newchild) + { + goto fail; + } + if (next != NULL) + { + /* If newitem->child already set, then crosswire ->prev and ->next and move on */ + next->next = newchild; + newchild->prev = next; + next = newchild; + } + else + { + /* Set newitem->child and move to it */ + newitem->child = newchild; + next = newchild; + } + child = child->next; + } + + return newitem; + +fail: + if (newitem != NULL) + { + cJSON_Delete(newitem); + } + + return NULL; +} + +static void skip_oneline_comment(char **input) +{ + *input += static_strlen("//"); + + for (; (*input)[0] != '\0'; ++(*input)) + { + if ((*input)[0] == '\n') { + *input += static_strlen("\n"); + return; + } + } +} + +static void skip_multiline_comment(char **input) +{ + *input += static_strlen("/*"); + + for (; (*input)[0] != '\0'; ++(*input)) + { + if (((*input)[0] == '*') && ((*input)[1] == '/')) + { + *input += static_strlen("*/"); + return; + } + } +} + +static void minify_string(char **input, char **output) { + (*output)[0] = (*input)[0]; + *input += static_strlen("\""); + *output += static_strlen("\""); + + + for (; (*input)[0] != '\0'; (void)++(*input), ++(*output)) { + (*output)[0] = (*input)[0]; + + if ((*input)[0] == '\"') { + (*output)[0] = '\"'; + *input += static_strlen("\""); + *output += static_strlen("\""); + return; + } else if (((*input)[0] == '\\') && ((*input)[1] == '\"')) { + (*output)[1] = (*input)[1]; + *input += static_strlen("\""); + *output += static_strlen("\""); + } + } +} + +CJSON_PUBLIC(void) cJSON_Minify(char *json) +{ + char *into = json; + + if (json == NULL) + { + return; + } + + while (json[0] != '\0') + { + switch (json[0]) + { + case ' ': + case '\t': + case '\r': + case '\n': + json++; + break; + + case '/': + if (json[1] == '/') + { + skip_oneline_comment(&json); + } + else if (json[1] == '*') + { + skip_multiline_comment(&json); + } else { + json++; + } + break; + + case '\"': + minify_string(&json, (char**)&into); + break; + + default: + into[0] = json[0]; + json++; + into++; + } + } + + /* and null-terminate. */ + *into = '\0'; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xFF) == cJSON_Invalid; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xFF) == cJSON_False; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xff) == cJSON_True; +} + + +CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & (cJSON_True | cJSON_False)) != 0; +} +CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xFF) == cJSON_NULL; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xFF) == cJSON_Number; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xFF) == cJSON_String; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xFF) == cJSON_Array; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xFF) == cJSON_Object; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item) +{ + if (item == NULL) + { + return false; + } + + return (item->type & 0xFF) == cJSON_Raw; +} + +CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive) +{ + if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF)) || cJSON_IsInvalid(a)) + { + return false; + } + + /* check if type is valid */ + switch (a->type & 0xFF) + { + case cJSON_False: + case cJSON_True: + case cJSON_NULL: + case cJSON_Number: + case cJSON_String: + case cJSON_Raw: + case cJSON_Array: + case cJSON_Object: + break; + + default: + return false; + } + + /* identical objects are equal */ + if (a == b) + { + return true; + } + + switch (a->type & 0xFF) + { + /* in these cases and equal type is enough */ + case cJSON_False: + case cJSON_True: + case cJSON_NULL: + return true; + + case cJSON_Number: + if (compare_double(a->valuedouble, b->valuedouble)) + { + return true; + } + return false; + + case cJSON_String: + case cJSON_Raw: + if ((a->valuestring == NULL) || (b->valuestring == NULL)) + { + return false; + } + if (strcmp(a->valuestring, b->valuestring) == 0) + { + return true; + } + + return false; + + case cJSON_Array: + { + cJSON *a_element = a->child; + cJSON *b_element = b->child; + + for (; (a_element != NULL) && (b_element != NULL);) + { + if (!cJSON_Compare(a_element, b_element, case_sensitive)) + { + return false; + } + + a_element = a_element->next; + b_element = b_element->next; + } + + /* one of the arrays is longer than the other */ + if (a_element != b_element) { + return false; + } + + return true; + } + + case cJSON_Object: + { + cJSON *a_element = NULL; + cJSON *b_element = NULL; + cJSON_ArrayForEach(a_element, a) + { + /* TODO This has O(n^2) runtime, which is horrible! */ + b_element = get_object_item(b, a_element->string, case_sensitive); + if (b_element == NULL) + { + return false; + } + + if (!cJSON_Compare(a_element, b_element, case_sensitive)) + { + return false; + } + } + + /* doing this twice, once on a and b to prevent true comparison if a subset of b + * TODO: Do this the proper way, this is just a fix for now */ + cJSON_ArrayForEach(b_element, b) + { + a_element = get_object_item(a, b_element->string, case_sensitive); + if (a_element == NULL) + { + return false; + } + + if (!cJSON_Compare(b_element, a_element, case_sensitive)) + { + return false; + } + } + + return true; + } + + default: + return false; + } +} + +CJSON_PUBLIC(void *) cJSON_malloc(size_t size) +{ + return global_hooks.allocate(size); +} + +CJSON_PUBLIC(void) cJSON_free(void *object) +{ + global_hooks.deallocate(object); +} Copied: trunk/libs/cJSON/cJSON.h (from rev 8499, trunk/TTXSamples/TTXCheckUpdate/cJSON/cJSON.h) =================================================================== --- trunk/libs/cJSON/cJSON.h (rev 0) +++ trunk/libs/cJSON/cJSON.h 2020-01-22 13:54:20 UTC (rev 8500) @@ -0,0 +1,293 @@ +/* + Copyright (c) 2009-2017 Dave Gamble and cJSON contributors + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#ifndef cJSON__h +#define cJSON__h + +#ifdef __cplusplus +extern "C" +{ +#endif + +#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32)) +#define __WINDOWS__ +#endif + +#ifdef __WINDOWS__ + +/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options: + +CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols +CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default) +CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol + +For *nix builds that support visibility attribute, you can define similar behavior by + +setting default visibility to hidden by adding +-fvisibility=hidden (for gcc) +or +-xldscope=hidden (for sun cc) +to CFLAGS + +then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does + +*/ + +#define CJSON_CDECL __cdecl +#define CJSON_STDCALL __stdcall + +/* export symbols by default, this is necessary for copy pasting the C and header file */ +#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS) +#define CJSON_EXPORT_SYMBOLS +#endif + +#if defined(CJSON_HIDE_SYMBOLS) +#define CJSON_PUBLIC(type) type CJSON_STDCALL +#elif defined(CJSON_EXPORT_SYMBOLS) +#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL +#elif defined(CJSON_IMPORT_SYMBOLS) +#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL +#endif +#else /* !__WINDOWS__ */ +#define CJSON_CDECL +#define CJSON_STDCALL + +#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY) +#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type +#else +#define CJSON_PUBLIC(type) type +#endif +#endif + +/* project version */ +#define CJSON_VERSION_MAJOR 1 +#define CJSON_VERSION_MINOR 7 +#define CJSON_VERSION_PATCH 12 + +#include + +/* cJSON Types: */ +#define cJSON_Invalid (0) +#define cJSON_False (1 << 0) +#define cJSON_True (1 << 1) +#define cJSON_NULL (1 << 2) +#define cJSON_Number (1 << 3) +#define cJSON_String (1 << 4) +#define cJSON_Array (1 << 5) +#define cJSON_Object (1 << 6) +#define cJSON_Raw (1 << 7) /* raw json */ + +#define cJSON_IsReference 256 +#define cJSON_StringIsConst 512 + +/* The cJSON structure: */ +typedef struct cJSON +{ + /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */ + struct cJSON *next; + struct cJSON *prev; + /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */ + struct cJSON *child; + + /* The type of the item, as above. */ + int type; + + /* The item's string, if type==cJSON_String and type == cJSON_Raw */ + char *valuestring; + /* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */ + int valueint; + /* The item's number, if type==cJSON_Number */ + double valuedouble; + + /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */ + char *string; +} cJSON; + +typedef struct cJSON_Hooks +{ + /* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */ + void *(CJSON_CDECL *malloc_fn)(size_t sz); + void (CJSON_CDECL *free_fn)(void *ptr); +} cJSON_Hooks; + +typedef int cJSON_bool; + +/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them. + * This is to prevent stack overflows. */ +#ifndef CJSON_NESTING_LIMIT +#define CJSON_NESTING_LIMIT 1000 +#endif + +/* Precision of double variables comparison */ +#ifndef CJSON_DOUBLE_PRECISION +#define CJSON_DOUBLE_PRECISION .0000000000000001 +#endif + +/* returns the version of cJSON as a string */ +CJSON_PUBLIC(const char*) cJSON_Version(void); + +/* Supply malloc, realloc and free functions to cJSON */ +CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks); + +/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */ +/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */ +CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value); +/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */ +/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */ +CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated); + +/* Render a cJSON entity to text for transfer/storage. */ +CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item); +/* Render a cJSON entity to text for transfer/storage without any formatting. */ +CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item); +/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */ +CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt); +/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */ +/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */ +CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format); +/* Delete a cJSON entity and all subentities. */ +CJSON_PUBLIC(void) cJSON_Delete(cJSON *item); + +/* Returns the number of items in an array (or object). */ +CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array); +/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */ +CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index); +/* Get item "string" from object. Case insensitive. */ +CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string); +CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string); +CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string); +/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */ +CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void); + +/* Check if the item is a string and return its valuestring */ +CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item); + +/* These functions check the type of an item */ +CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item); +CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item); + +/* These calls create a cJSON item of the appropriate type. */ +CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void); +CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void); +CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void); +CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean); +CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num); +CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string); +/* raw json */ +CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw); +CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void); +CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void); + +/* Create a string where valuestring references a string so + * it will not be freed by cJSON_Delete */ +CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string); +/* Create an object/array that only references it's elements so + * they will not be freed by cJSON_Delete */ +CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child); +CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child); + +/* These utilities create an Array of count items. + * The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.*/ +CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count); +CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count); +CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count); +CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count); + +/* Append item to the specified array/object. */ +CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item); +CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item); +/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object. + * WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before + * writing to `item->string` */ +CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item); +/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */ +CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); +CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item); + +/* Remove/Detach items from Arrays/Objects. */ +CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item); +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which); +CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which); +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string); +CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string); +CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string); +CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string); + +/* Update array items. */ +CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */ +CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement); +CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem); +CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem); +CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem); + +/* Duplicate a cJSON item */ +CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse); +/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will + * need to be released. With recurse!=0, it will duplicate any children connected to the item. + * The item->next and ->prev pointers are always zero on return from Duplicate. */ +/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal. + * case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */ +CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive); + +/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings. + * The input pointer json cannot point to a read-only address area, such as a string constant, + * but should point to a readable and writable adress area. */ +CJSON_PUBLIC(void) cJSON_Minify(char *json); + +/* Helper functions for creating and adding items to an object at the same time. + * They return the added item or NULL on failure. */ +CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name); +CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name); +CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name); +CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean); +CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number); +CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string); +CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw); +CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name); +CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name); + +/* When assigning an integer value, it needs to be propagated to valuedouble too. */ +#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number)) +/* helper for the cJSON_SetNumberValue macro */ +CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number); +#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number)) + +/* Macro for iterating over an array or object */ +#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next) + +/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */ +CJSON_PUBLIC(void *) cJSON_malloc(size_t size); +CJSON_PUBLIC(void) cJSON_free(void *object); + +#ifdef __cplusplus +} +#endif + +#endif From scmnotify @ osdn.net Fri Jan 24 14:53:05 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 24 Jan 2020 14:53:05 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MDJdIHN2bjppZ25vcmUg5bGe5oCn44KS?= =?utf-8?b?6L+95Yqg?= Message-ID: <1579845185.257439.42407.nullmailer@users.osdn.me> Revision: 8502 https://osdn.net/projects/ttssh2/scm/svn/commits/8502 Author: doda Date: 2020-01-24 14:53:04 +0900 (Fri, 24 Jan 2020) Log Message: ----------- svn:ignore 属性を追加 Property Changed: ---------------- trunk/teraterm/common/ -------------- next part -------------- Index: trunk/teraterm/common =================================================================== --- trunk/teraterm/common 2020-01-22 13:54:32 UTC (rev 8501) +++ trunk/teraterm/common 2020-01-24 05:53:04 UTC (rev 8502) Property changes on: trunk/teraterm/common ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,8 ## +[Rr]elease +[Dd]ebug +*.ncb +*.suo +*.aps +*.vcproj.*.user +*.vcxproj.*.user +*.vcxproj.user From scmnotify @ osdn.net Mon Jan 27 00:13:29 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Mon, 27 Jan 2020 00:13:29 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MDNdIFRUWFByb3h544OX44Op44Kw44Kk?= =?utf-8?b?44Oz44Gu44OA44Kk44Ki44Ot44Kw44KS5aSa6KiA6Kqe5YyW?= Message-ID: <1580051609.772601.141394.nullmailer@users.osdn.me> Revision: 8503 https://osdn.net/projects/ttssh2/scm/svn/commits/8503 Author: zmatsuo Date: 2020-01-27 00:13:29 +0900 (Mon, 27 Jan 2020) Log Message: ----------- TTXProxyプラグインのダイアログを多言語化 - うまく動作していなかった - 不正なHWNDに対して文字を設定しようとして失敗していた Modified Paths: -------------- trunk/TTProxy/ProxyWSockHook.h -------------- next part -------------- Modified: trunk/TTProxy/ProxyWSockHook.h =================================================================== --- trunk/TTProxy/ProxyWSockHook.h 2020-01-24 05:53:04 UTC (rev 8502) +++ trunk/TTProxy/ProxyWSockHook.h 2020-01-26 15:13:29 UTC (rev 8503) @@ -772,7 +772,7 @@ Dialog::onInitDialog(); - HWND hWnd = (HWND)this; + HWND hWnd = HWND(*this); SetI18nDlgStrs("TTProxy", hWnd, text_info, _countof(text_info), UILanguageFile); host = GetDlgItem(IDC_HOSTNAME); @@ -898,7 +898,7 @@ // { IDOK, "BTN_OK" }, // { IDCANCEL, "BTN_CANCEL" }, }; - HWND hWnd = HWND(this); // \x82\xA4\x82܂\xAD\x93\xAE\x82\xA9\x82Ȃ\xA2? + HWND hWnd = HWND(*this); SetI18nDlgStrs("TTProxy", hWnd, text_info, _countof(text_info), UILanguageFile); url <<= GetDlgItem(IDC_URL); From scmnotify @ osdn.net Mon Jan 27 00:13:39 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Mon, 27 Jan 2020 00:13:39 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MDRdIOODnuODq+ODgeODouODi+OCvw==?= =?utf-8?b?6Zai6YCj44GuQVBJ44KS55u05o6l5ZG844Gw44Gq44GE44KI44GG44Gr44GX?= =?utf-8?b?44Gf?= Message-ID: <1580051619.364979.141533.nullmailer@users.osdn.me> Revision: 8504 https://osdn.net/projects/ttssh2/scm/svn/commits/8504 Author: zmatsuo Date: 2020-01-27 00:13:39 +0900 (Mon, 27 Jan 2020) Log Message: ----------- マルチモニタ関連のAPIを直接呼ばないようにした - MonitorFromWindow(), MonitorFromPoint(), GetMonitorInfo() - pMonitorFromWindow(), pMonitorFromPoint(), pGetMonitorInfoA() を追加 - 使用しなくなった GetMonitorLeftmost() を削除 Modified Paths: -------------- trunk/teraterm/common/compat_win.cpp trunk/teraterm/common/compat_win.h trunk/teraterm/common/ttlib.c trunk/teraterm/teraterm/clipboarddlg.cpp trunk/teraterm/teraterm/sizetip.c trunk/teraterm/ttpmacro/macrodlgbase.h trunk/teraterm/ttpmacro/ttmlib.c trunk/teraterm/ttpmacro/ttmlib.h -------------- next part -------------- Modified: trunk/teraterm/common/compat_win.cpp =================================================================== --- trunk/teraterm/common/compat_win.cpp 2020-01-26 15:13:29 UTC (rev 8503) +++ trunk/teraterm/common/compat_win.cpp 2020-01-26 15:13:39 UTC (rev 8504) @@ -74,6 +74,10 @@ BOOL (WINAPI *pInsertMenuW)(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); BOOL (WINAPI *pAppendMenuW)(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); +HMONITOR (WINAPI *pMonitorFromWindow)(HWND hwnd, DWORD dwFlags); +HMONITOR (WINAPI *pMonitorFromPoint)(POINT pt, DWORD dwFlags); +BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR hMonitor, LPMONITORINFO lpmi); + /** * GetConsoleWindow() \x82Ɠ\xAF\x82\xB6\x93\xAE\x8D\xEC\x82\xF0\x82\xB7\x82\xE9 * https://support.microsoft.com/ja-jp/help/124103/how-to-obtain-a-console-window-handle-hwnd @@ -131,6 +135,9 @@ { "DialogBoxIndirectParamW", (void **)&pDialogBoxIndirectParamW }, { "InsertMenuW", (void **)&pInsertMenuW }, { "AppendMenuW", (void **)&pAppendMenuW }, + { "MonitorFromWindow", (void **)&pMonitorFromWindow }, + { "MonitorFromPoint", (void **)&pMonitorFromPoint }, + { "GetMonitorInfoA", (void **)&pGetMonitorInfoA }, {}, }; Modified: trunk/teraterm/common/compat_win.h =================================================================== --- trunk/teraterm/common/compat_win.h 2020-01-26 15:13:29 UTC (rev 8503) +++ trunk/teraterm/common/compat_win.h 2020-01-26 15:13:39 UTC (rev 8504) @@ -104,7 +104,11 @@ extern HWND (WINAPI *pHtmlHelpA)(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData); extern BOOL (WINAPI *pInsertMenuW)(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); extern BOOL (WINAPI *pAppendMenuW)(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); +extern HMONITOR (WINAPI *pMonitorFromWindow)(HWND hwnd, DWORD dwFlags); +extern HMONITOR (WINAPI *pMonitorFromPoint)(POINT pt, DWORD dwFlags); +extern BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR hMonitor, LPMONITORINFO lpmi); + #ifdef UNICODE #define pAddFontResourceEx pAddFontResourceExW #define pRemoveFontResourceEx pRemoveFontResourceExW Modified: trunk/teraterm/common/ttlib.c =================================================================== --- trunk/teraterm/common/ttlib.c 2020-01-26 15:13:29 UTC (rev 8503) +++ trunk/teraterm/common/ttlib.c 2020-01-26 15:13:39 UTC (rev 8504) @@ -1902,12 +1902,12 @@ */ void GetDesktopRect(HWND hWnd, RECT *rect) { - if (HasMultiMonitorSupport()) { + if (pMonitorFromWindow != NULL) { // \x83}\x83\x8B\x83`\x83\x82\x83j\x83^\x82\xAA\x83T\x83|\x81[\x83g\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9\x8Fꍇ MONITORINFO monitorInfo; - HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); + HMONITOR hMonitor = pMonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); monitorInfo.cbSize = sizeof(MONITORINFO); - GetMonitorInfo(hMonitor, &monitorInfo); + pGetMonitorInfoA(hMonitor, &monitorInfo); *rect = monitorInfo.rcWork; } else { // \x83}\x83\x8B\x83`\x83\x82\x83j\x83^\x82\xAA\x83T\x83|\x81[\x83g\x82\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xA2\x8Fꍇ @@ -2035,14 +2035,6 @@ */ int GetMonitorDpiFromWindow(HWND hWnd) { - static HRESULT (__stdcall *pGetDpiForMonitor)(HMONITOR hmonitor, int/*enum MONITOR_DPI_TYPE*/ dpiType, UINT *dpiX, UINT *dpiY); - static HMODULE hDll; - if (hDll == NULL) { - hDll = LoadLibraryA("Shcore.dll"); - if (hDll != NULL) { - pGetDpiForMonitor = (void *)GetProcAddress(hDll, "GetDpiForMonitor"); - } - } if (pGetDpiForMonitor == NULL) { // \x83_\x83C\x83A\x83\x8D\x83O\x93\xE0\x82ł͎\xA9\x93\xAE\x83X\x83P\x81[\x83\x8A\x83\x93\x83O\x82\xAA\x8C\xF8\x82\xA2\x82Ă\xA2\x82\xE9\x82̂\xC5 // \x8F\xED\x82\xC996\x82\xF0\x95Ԃ\xB7\x82悤\x82\xBE @@ -2054,7 +2046,7 @@ } else { UINT dpiX; UINT dpiY; - HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); + HMONITOR hMonitor = pMonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); pGetDpiForMonitor(hMonitor, 0 /*0=MDT_EFFECTIVE_DPI*/, &dpiX, &dpiY); return (int)dpiY; } Modified: trunk/teraterm/teraterm/clipboarddlg.cpp =================================================================== --- trunk/teraterm/teraterm/clipboarddlg.cpp 2020-01-26 15:13:29 UTC (rev 8503) +++ trunk/teraterm/teraterm/clipboarddlg.cpp 2020-01-26 15:13:39 UTC (rev 8504) @@ -1,5 +1,5 @@ /* - * (C) 2019 TeraTerm Project + * (C) 2019-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -44,6 +44,7 @@ #include "layer_for_unicode.h" #include "tt_res.h" #include "clipboarddlg.h" +#include "compat_win.h" static INT_PTR CALLBACK OnClipboardDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp) { @@ -104,7 +105,7 @@ // \x83L\x83\x83\x83\x8C\x83b\x83g\x82\xAA\x89\xE6\x96ʂ\xA9\x82\xE7\x82͂ݏo\x82\xB5\x82Ă\xA2\x82\xE9\x82Ƃ\xAB\x82ɓ\\x82\xE8\x95t\x82\xAF\x82\xF0\x82\xB7\x82\xE9\x82\xC6 // \x8Am\x94F\x83E\x83C\x83\x93\x83h\x83E\x82\xAA\x8C\xA9\x82\xA6\x82\xE9\x82Ƃ\xB1\x82\xEB\x82ɕ\\x8E\xA6\x82\xB3\x82\xEA\x82Ȃ\xA2\x82\xB1\x82Ƃ\xAA\x82\xA0\x82\xE9\x81B // \x83E\x83C\x83\x93\x83h\x83E\x82\xA9\x82\xE7\x82͂ݏo\x82\xB5\x82\xBD\x8Fꍇ\x82ɒ\xB2\x90߂\xB7\x82\xE9 (2008.4.24 maya) - if (!HasMultiMonitorSupport()) { + if (pMonitorFromPoint == NULL) { // NT4.0, 95 \x82̓}\x83\x8B\x83`\x83\x82\x83j\x83^API\x82ɔ\xF1\x91Ή\x9E SystemParametersInfo(SPI_GETWORKAREA, 0, &rc_dsk, 0); } @@ -115,10 +116,10 @@ pt.x = p.x; pt.y = p.y; - hm = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); + hm = pMonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); mi.cbSize = sizeof(MONITORINFO); - GetMonitorInfo(hm, &mi); + pGetMonitorInfoA(hm, &mi); rc_dsk = mi.rcWork; } GetWindowRect(hDlgWnd, &rc_dlg); Modified: trunk/teraterm/teraterm/sizetip.c =================================================================== --- trunk/teraterm/teraterm/sizetip.c 2020-01-26 15:13:29 UTC (rev 8503) +++ trunk/teraterm/teraterm/sizetip.c 2020-01-26 15:13:39 UTC (rev 8504) @@ -31,6 +31,7 @@ #include "tttypes.h" #include "ttlib.h" #include "ttwinman.h" +#include "compat_win.h" #include #include @@ -60,20 +61,20 @@ ix = point->x; iy = point->y; - hm = MonitorFromPoint(*point, MONITOR_DEFAULTTONULL); + hm = pMonitorFromPoint(*point, MONITOR_DEFAULTTONULL); if (hm == NULL) { if (NearestMonitor) { // \x8Dł\xE0\x8B߂\xA2\x83\x82\x83j\x83^\x82ɕ\\x8E\xA6\x82\xB7\x82\xE9 - hm = MonitorFromPoint(*point, MONITOR_DEFAULTTONEAREST); + hm = pMonitorFromPoint(*point, MONITOR_DEFAULTTONEAREST); } else { // \x83X\x83N\x83\x8A\x81[\x83\x93\x82\xA9\x82\xE7\x82͂ݏo\x82\xB5\x82Ă\xA2\x82\xE9\x8Fꍇ\x82̓}\x83E\x83X\x82̂\xA0\x82郂\x83j\x83^\x82ɕ\\x8E\xA6\x82\xB7\x82\xE9 GetCursorPos(point); - hm = MonitorFromPoint(*point, MONITOR_DEFAULTTONEAREST); + hm = pMonitorFromPoint(*point, MONITOR_DEFAULTTONEAREST); } } mi.cbSize = sizeof(MONITORINFO); - GetMonitorInfo(hm, &mi); + pGetMonitorInfoA(hm, &mi); if (ix < mi.rcMonitor.left + FrameWidth) { ix = mi.rcMonitor.left + FrameWidth; } Modified: trunk/teraterm/ttpmacro/macrodlgbase.h =================================================================== --- trunk/teraterm/ttpmacro/macrodlgbase.h 2020-01-26 15:13:29 UTC (rev 8503) +++ trunk/teraterm/ttpmacro/macrodlgbase.h 2020-01-26 15:13:39 UTC (rev 8504) @@ -95,7 +95,6 @@ */ BOOL IsValidPos() { - // return !(PosX <= GetMonitorLeftmost(PosX, PosY) - 100); return !((PosX == CW_USEDEFAULT) || (PosY == CW_USEDEFAULT)); } }; Modified: trunk/teraterm/ttpmacro/ttmlib.c =================================================================== --- trunk/teraterm/ttpmacro/ttmlib.c 2020-01-26 15:13:29 UTC (rev 8503) +++ trunk/teraterm/ttpmacro/ttmlib.c 2020-01-26 15:13:39 UTC (rev 8504) @@ -198,27 +198,6 @@ return 0; } -int GetMonitorLeftmost(int PosX, int PosY) -{ - if (!HasMultiMonitorSupport()) { - // // NT4.0, 95 \x82̓}\x83\x8B\x83`\x83\x82\x83j\x83^API\x82ɔ\xF1\x91Ή\x9E - return 0; - } - else { - HMONITOR hm; - POINT pt; - MONITORINFO mi; - - pt.x = PosX; - pt.y = PosY; - hm = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); - - mi.cbSize = sizeof(MONITORINFO); - GetMonitorInfo(hm, &mi); - return mi.rcWork.left; - } -} - void BringupWindow(HWND hWnd) { DWORD thisThreadId; Modified: trunk/teraterm/ttpmacro/ttmlib.h =================================================================== --- trunk/teraterm/ttpmacro/ttmlib.h 2020-01-26 15:13:29 UTC (rev 8503) +++ trunk/teraterm/ttpmacro/ttmlib.h 2020-01-26 15:13:39 UTC (rev 8504) @@ -44,7 +44,6 @@ void TTMSetDir(PCHAR Dir); int GetAbsPath(PCHAR FName, int destlen); int GetSpecialFolder(PCHAR dest, int dest_len, PCHAR type); -int GetMonitorLeftmost(int PosX, int PosY); void BringupWindow(HWND hWnd); int MessageBoxHaltScript(HWND hWnd); From scmnotify @ osdn.net Mon Jan 27 00:13:45 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Mon, 27 Jan 2020 00:13:45 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MDVdIDl444Gn44GvIFVuaWNvZGUgQVBJ?= =?utf-8?b?IOOCkuS9v+eUqOOBl+OBquOBhA==?= Message-ID: <1580051625.968673.141723.nullmailer@users.osdn.me> Revision: 8505 https://osdn.net/projects/ttssh2/scm/svn/commits/8505 Author: zmatsuo Date: 2020-01-27 00:13:45 +0900 (Mon, 27 Jan 2020) Log Message: ----------- 9xでは Unicode API を使用しない - CreateWindowExW(), RegisterClassW() を使用しない(compat_win.cpp) - DrawTextW() を使用しない(layer_for_unicode.cpp) - ANSI API を使用するようにした Modified Paths: -------------- trunk/teraterm/common/compat_win.cpp trunk/teraterm/common/layer_for_unicode.cpp -------------- next part -------------- Modified: trunk/teraterm/common/compat_win.cpp =================================================================== --- trunk/teraterm/common/compat_win.cpp 2020-01-26 15:13:39 UTC (rev 8504) +++ trunk/teraterm/common/compat_win.cpp 2020-01-26 15:13:45 UTC (rev 8505) @@ -212,6 +212,8 @@ pSetDlgItemTextW = NULL; pGetDlgItemTextW = NULL; pDialogBoxIndirectParamW = NULL; + pCreateWindowExW = NULL; + pRegisterClassW = NULL; } // GetConsoleWindow\x93\xC1\x95ʏ\x88\x97\x9D Modified: trunk/teraterm/common/layer_for_unicode.cpp =================================================================== --- trunk/teraterm/common/layer_for_unicode.cpp 2020-01-26 15:13:39 UTC (rev 8504) +++ trunk/teraterm/common/layer_for_unicode.cpp 2020-01-26 15:13:45 UTC (rev 8505) @@ -232,7 +232,13 @@ } /** - * TODO:9x\x8Cn\x82\xC5DrawTextW\x82\xAA\x8Eg\x82\xA6\x82\xE9? + * @param[in] hdc + * @param[in] lpchText \x95\xB6\x8E\x9A\x97\xF1 + * @param[in] cchText \x95\xB6\x8E\x9A\x90\x94(-1\x82̂Ƃ\xABlpchText\x82̕\xB6\x8E\x9A\x97\xF1\x92\xB7) + * @param[in] lprc \x95\\x8E\xA6rect + * @param[in] format + * + * TODO:9x\x8Cn\x82\xC5DrawTextW\x82\xAA\x90\xB3\x82\xB5\x82\xAD\x93\xAE\x8D삷\x82\xE9? */ int _DrawTextW(HDC hdc, LPCWSTR lpchText, int cchText, LPRECT lprc, UINT format) { @@ -240,9 +246,10 @@ return DrawTextW(hdc, lpchText, cchText, lprc, format); } - char *strA = ToCharW(lpchText); - int strA_len = (int)strlen(strA); - int result = DrawTextA(hdc, strA, strA_len, lprc, format); + int strW_len = (cchText == -1) ? 0 : cchText; + size_t strA_len; + char *strA = _WideCharToMultiByte(lpchText, strW_len, CP_ACP, &strA_len); + int result = DrawTextA(hdc, strA, (int)strA_len, lprc, format); free(strA); return result; } From scmnotify @ osdn.net Mon Jan 27 00:13:52 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Mon, 27 Jan 2020 00:13:52 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MDZdIHRpcHdpbi5jcHAsaCDjgacgVENI?= =?utf-8?b?QVIg44Gr5L6d5a2Y44GX44Gq44GE44KI44GG44Gr44GX44Gf?= Message-ID: <1580051632.463705.141812.nullmailer@users.osdn.me> Revision: 8506 https://osdn.net/projects/ttssh2/scm/svn/commits/8506 Author: zmatsuo Date: 2020-01-27 00:13:52 +0900 (Mon, 27 Jan 2020) Log Message: ----------- tipwin.cpp,h で TCHAR に依存しないようにした Modified Paths: -------------- trunk/teraterm/common/tipwin.cpp trunk/teraterm/common/tipwin.h trunk/teraterm/teraterm/sizetip.c trunk/teraterm/ttpdlg/ttdlg.c trunk/ttssh2/ttxssh/auth.c -------------- next part -------------- Modified: trunk/teraterm/common/tipwin.cpp =================================================================== --- trunk/teraterm/common/tipwin.cpp 2020-01-26 15:13:45 UTC (rev 8505) +++ trunk/teraterm/common/tipwin.cpp 2020-01-26 15:13:52 UTC (rev 8506) @@ -359,6 +359,16 @@ return (TipWin*)tipwin; } +TipWin *TipWinCreateW(HINSTANCE hInstance, HWND src, int cx, int cy, const wchar_t *str) +{ + CTipWin* tipwin = new CTipWin(hInstance); + tipwin->Create(src); + tipwin->SetText(str); + tipwin->SetPos(cx, cy); + tipwin->SetVisible(TRUE); + return (TipWin*)tipwin; +} + /* * \x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x83c\x81[\x83\x8B\x83`\x83b\x83v\x82ɕ`\x89悵\x82\xBD\x8E\x9E\x82̉\xA1\x82Əc\x82̃T\x83C\x83Y\x82\xF0\x8E擾\x82\xB7\x82\xE9\x81B * @@ -369,7 +379,7 @@ * width * height */ -void TipWinGetTextWidthHeight(HWND src, const TCHAR *str, int *width, int *height) +void TipWinGetTextWidthHeight(HWND src, const char *str, int *width, int *height) { LOGFONTA logfont; HFONT tip_font; @@ -379,7 +389,7 @@ size_t str_len; /* \x95\xB6\x8E\x9A\x97\xF1\x82̒\xB7\x82\xB3\x82\xF0\x8Cv\x8EZ\x82\xB7\x82\xE9 */ - str_len = _tcslen(str); + str_len = strlen(str); /* DPI\x82\xF0\x8E擾\x82\xB7\x82\xE9 */ uDpi = GetMonitorDpiFromWindow(src); @@ -404,6 +414,51 @@ DeleteObject(tip_font); } +/* + * \x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x83c\x81[\x83\x8B\x83`\x83b\x83v\x82ɕ`\x89悵\x82\xBD\x8E\x9E\x82̉\xA1\x82Əc\x82̃T\x83C\x83Y\x82\xF0\x8E擾\x82\xB7\x82\xE9\x81B + * + * [in] + * src + * str + * [out] + * width + * height + */ +void TipWinGetTextWidthHeightW(HWND src, const wchar_t *str, int *width, int *height) +{ + LOGFONTA logfont; + HFONT tip_font; + UINT uDpi; + HDC hdc; + RECT str_rect; + size_t str_len; + + /* \x95\xB6\x8E\x9A\x97\xF1\x82̒\xB7\x82\xB3\x82\xF0\x8Cv\x8EZ\x82\xB7\x82\xE9 */ + str_len = wcslen(str); + + /* DPI\x82\xF0\x8E擾\x82\xB7\x82\xE9 */ + uDpi = GetMonitorDpiFromWindow(src); + + /* \x83t\x83H\x83\x93\x83g\x82𐶐\xAC\x82\xB7\x82\xE9 */ + GetMessageboxFont(&logfont); + logfont.lfWidth = MulDiv(logfont.lfWidth, uDpi, 96); + logfont.lfHeight = MulDiv(logfont.lfHeight, uDpi, 96); + tip_font = CreateFontIndirect(&logfont); + + /* \x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x95`\x89悵\x82ăT\x83C\x83Y\x82\xF0\x8B\x81\x82߂\xE9 */ + hdc = CreateCompatibleDC(NULL); + SelectObject(hdc, tip_font); + str_rect.top = 0; + str_rect.left = 0; + _DrawTextW(hdc, str, (int)str_len, &str_rect, DT_LEFT|DT_CALCRECT); + *width = str_rect.right - str_rect.left; + *height = str_rect.bottom - str_rect.top; + DeleteDC(hdc); + + /* \x83t\x83H\x83\x93\x83g\x82\xF0\x94j\x8A\xFC\x82\xB7\x82\xE9 */ + DeleteObject(tip_font); +} + void TipWinGetPos(TipWin *tWin, int *x, int *y) { CTipWin* tipwin = (CTipWin*) tWin; Modified: trunk/teraterm/common/tipwin.h =================================================================== --- trunk/teraterm/common/tipwin.h 2020-01-26 15:13:45 UTC (rev 8505) +++ trunk/teraterm/common/tipwin.h 2020-01-26 15:13:52 UTC (rev 8506) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 TeraTerm Project + * Copyright (C) 2018-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,7 +29,6 @@ #ifndef _H_TIPWIN #define _H_TIPWIN #include -#include #ifdef __cplusplus extern "C" { @@ -45,7 +44,6 @@ void TipWinSetTextA(TipWin *tWin, const char *text); void TipWinSetTextW(TipWin *tWin, const wchar_t *text); void TipWinDestroy(TipWin *tWin); -void TipWinGetTextWidthHeight(HWND src, const TCHAR *str, int *width, int *height); void TipWinGetPos(TipWin *tWin, int *x, int *y); void TipWinSetPos(TipWin *tWin, int x, int y); void TipWinSetHideTimer(TipWin *tWin, int ms); @@ -53,13 +51,8 @@ int TipWinIsExists(TipWin *tWin); int TipWinIsVisible(TipWin *tWin); -#if !defined(_UNICODE) -#define TipWinCreateT(p1, p2, p3, p4, p5) TipWinCreateA(p1, p2, p3, p4, p5) -#define TipWinSetText(p1, p2) TipWinSetTextA(p1, p2) -#else -#define TipWinCreateT(p1, p2, p3, p4, p5) TipWinCreateW(p1, p2, p3, p4, p5) -#define TipWinSetText(p1, p2) TipWinSetTextW(p1, p2) -#endif +void TipWinGetTextWidthHeight(HWND src, const char *str, int *width, int *height); +void TipWinGetTextWidthHeightW(HWND src, const wchar_t *str, int *width, int *height); #ifdef __cplusplus } Modified: trunk/teraterm/teraterm/sizetip.c =================================================================== --- trunk/teraterm/teraterm/sizetip.c 2020-01-26 15:13:45 UTC (rev 8505) +++ trunk/teraterm/teraterm/sizetip.c 2020-01-26 15:13:52 UTC (rev 8506) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2019 TeraTerm Project + * Copyright (C) 2008-2020 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,7 +35,6 @@ #include #include -#include #include "tipwin.h" @@ -111,7 +110,7 @@ */ void UpdateSizeTip(HWND src, int cx, int cy, UINT fwSide, int newX, int newY) { - TCHAR str[32]; + char str[32]; int tooltip_movable = 0; if (!tip_enabled) @@ -118,7 +117,7 @@ return; /* Generate the tip text */ - _stprintf_s(str, _countof(str), _T("%dx%d"), cx, cy); + _snprintf_s(str, _countof(str), _TRUNCATE, "%dx%d", cx, cy); // \x83E\x83B\x83\x93\x83h\x83E\x82̉E\x81A\x89E\x89\xBA\x81A\x89\xBA\x82\xF0\x92͂񂾏ꍇ\x82́A\x83c\x81[\x83\x8B\x83`\x83b\x83v\x82\xF0\x8D\xB6\x8F\xE3\x8B\xF7\x82ɔz\x92u\x82\xB7\x82\xE9\x81B // \x82\xBB\x82\xEA\x82\xE7\x88ȊO\x82̓\x8A\x83T\x83C\x83Y\x8C\xE3\x82̍\xB6\x8F\xE3\x8B\xF7\x82ɔz\x92u\x82\xB7\x82\xE9\x81B @@ -145,21 +144,14 @@ cx = point.x; cy = point.y; - SizeTip = TipWinCreateT(NULL, src, cx, cy, str); - - //OutputDebugPrintf("Created: (%d,%d)\n", cx, cy); - + SizeTip = TipWinCreateA(NULL, src, cx, cy, str); } else { /* Tip already exists, just set the text */ - TipWinSetText(SizeTip, str); - //SetWindowText(tip_wnd, str); + TipWinSetTextA(SizeTip, str); - //OutputDebugPrintf("Updated: (%d,%d)\n", cx, cy); - // \x83E\x83B\x83\x93\x83h\x83E\x82̍\xB6\x8Fオ\x88ړ\xAE\x82\xB7\x82\xE9\x8Fꍇ if (tooltip_movable) { TipWinSetPos(SizeTip, newX + TIP_WIN_FRAME_WIDTH*2, newY + TIP_WIN_FRAME_WIDTH*2); - //OutputDebugPrintf("Moved: (%d,%d)\n", newX, newY); } } } Modified: trunk/teraterm/ttpdlg/ttdlg.c =================================================================== --- trunk/teraterm/ttpdlg/ttdlg.c 2020-01-26 15:13:45 UTC (rev 8505) +++ trunk/teraterm/ttpdlg/ttdlg.c 2020-01-26 15:13:52 UTC (rev 8506) @@ -1310,7 +1310,7 @@ if (!TipWinIsVisible(g_SerialDlgSpeedTip)) TipWinSetVisible(g_SerialDlgSpeedTip, TRUE); - TipWinSetText(g_SerialDlgSpeedTip, str); + TipWinSetTextA(g_SerialDlgSpeedTip, str); TipWinSetPos(g_SerialDlgSpeedTip, cx, cy); TipWinSetHideTimer(g_SerialDlgSpeedTip, tooltip_timeout); Modified: trunk/ttssh2/ttxssh/auth.c =================================================================== --- trunk/ttssh2/ttxssh/auth.c 2020-01-26 15:13:45 UTC (rev 8505) +++ trunk/ttssh2/ttxssh/auth.c 2020-01-26 15:13:52 UTC (rev 8506) @@ -44,6 +44,7 @@ #endif #include #include +#include #include "resource.h" #include "keyfiles.h" @@ -121,7 +122,7 @@ _tcscat_s(uimsg, _countof(uimsg), pvar->ts->UIMsg); } GetWindowRect(control, &rect); - data->tipwin = TipWinCreateT(hInst, control, rect.left, rect.bottom, uimsg); + data->tipwin = TipWinCreateA(hInst, control, rect.left, rect.bottom, uimsg); } return 0; From scmnotify @ osdn.net Mon Jan 27 00:13:58 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Mon, 27 Jan 2020 00:13:58 +0900 Subject: [Ttssh2-commit] =?utf-8?q?=5B8507=5D_layer=5Ffor=5Funicode_?= =?utf-8?b?44KS44Oq44Oz44Kv44GZ44KL44Go6Ieq5YuV55qE44Gr5Yid5pyf5YyW?= Message-ID: <1580051638.788773.141891.nullmailer@users.osdn.me> Revision: 8507 https://osdn.net/projects/ttssh2/scm/svn/commits/8507 Author: zmatsuo Date: 2020-01-27 00:13:58 +0900 (Mon, 27 Jan 2020) Log Message: ----------- layer_for_unicode をリンクすると自動的に初期化 - APIアドレスの初期化を自動的に行うようにした Modified Paths: -------------- trunk/teraterm/common/dllutil.cpp trunk/teraterm/common/layer_for_unicode.cpp -------------- next part -------------- Modified: trunk/teraterm/common/dllutil.cpp =================================================================== --- trunk/teraterm/common/dllutil.cpp 2020-01-26 15:13:52 UTC (rev 8506) +++ trunk/teraterm/common/dllutil.cpp 2020-01-26 15:13:58 UTC (rev 8507) @@ -260,6 +260,9 @@ void DLLInit() { + if (HandleListCount != 0) { + return; // \x8F\x89\x8A\xFA\x89\xBB\x8Dς\xDD + } HandleList = NULL; HandleListCount = 0; SetupLoadLibraryPath(); @@ -268,6 +271,9 @@ void DLLExit() { int i; + if (HandleListCount == 0) { + return; // \x96\xA2\x8Eg\x97p + } for (i = 0; i < HandleListCount; i++) { HandleList_t *p = &HandleList[i]; if (p->LoadFlag != DLL_GET_MODULE_HANDLE) { Modified: trunk/teraterm/common/layer_for_unicode.cpp =================================================================== --- trunk/teraterm/common/layer_for_unicode.cpp 2020-01-26 15:13:52 UTC (rev 8506) +++ trunk/teraterm/common/layer_for_unicode.cpp 2020-01-26 15:13:58 UTC (rev 8507) @@ -36,10 +36,24 @@ #include "codeconv.h" #include "compat_win.h" +#include "dllutil.h" #include "ttlib.h" // for IsWindowsNTKernel() #include "layer_for_unicode.h" +class Initializer { +public: + Initializer() { + DLLInit(); + WinCompatInit(); + } + ~Initializer() { + DLLExit(); + } +}; + +static Initializer initializer; + BOOL _SetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPCWSTR lpString) { if (pSetDlgItemTextW != NULL) { From scmnotify @ osdn.net Mon Jan 27 00:14:04 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Mon, 27 Jan 2020 00:14:04 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MDhdIOODgOOCpOOCouODreOCsOOBrg==?= =?utf-8?b?44K144Kk44K66KiI566X5YmN44Gr44K544OG44O844K/44K544OQ44O844KS?= =?utf-8?b?6L+95Yqg?= Message-ID: <1580051644.585457.143036.nullmailer@users.osdn.me> Revision: 8508 https://osdn.net/projects/ttssh2/scm/svn/commits/8508 Author: zmatsuo Date: 2020-01-27 00:14:04 +0900 (Mon, 27 Jan 2020) Log Message: ----------- ダイアログのサイズ計算前にステータスバーを追加 - switchで意図しないリサイズ処理を行わないようにした - デスクトップ領域取得関数を追加 Modified Paths: -------------- trunk/teraterm/teraterm/clipboarddlg.cpp -------------- next part -------------- Modified: trunk/teraterm/teraterm/clipboarddlg.cpp =================================================================== --- trunk/teraterm/teraterm/clipboarddlg.cpp 2020-01-26 15:13:58 UTC (rev 8507) +++ trunk/teraterm/teraterm/clipboarddlg.cpp 2020-01-26 15:14:04 UTC (rev 8508) @@ -46,6 +46,28 @@ #include "clipboarddlg.h" #include "compat_win.h" +static void GetDesktopRectFromPoint(POINT p, RECT *rect) +{ + if (pMonitorFromPoint == NULL) { + // NT4.0, 95 \x82̓}\x83\x8B\x83`\x83\x82\x83j\x83^API\x82ɔ\xF1\x91Ή\x9E + SystemParametersInfo(SPI_GETWORKAREA, 0, rect, 0); + } + else { + // \x83}\x83\x8B\x83`\x83\x82\x83j\x83^\x82\xAA\x83T\x83|\x81[\x83g\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9\x8Fꍇ + HMONITOR hm; + POINT pt; + MONITORINFO mi; + + pt.x = p.x; + pt.y = p.y; + hm = pMonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); + + mi.cbSize = sizeof(MONITORINFO); + pGetMonitorInfoA(hm, &mi); + *rect = mi.rcWork; + } +} + static INT_PTR CALLBACK OnClipboardDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp) { static const DlgTextInfo TextInfos[] = { @@ -75,6 +97,12 @@ SetDlgItemTextA(hDlgWnd, IDC_EDIT, data->strA_ptr); } + // \x83\x8A\x83T\x83C\x83Y\x83A\x83C\x83R\x83\x93\x82\xF0\x89E\x89\xBA\x82ɕ\\x8E\xA6\x82\xB3\x82\xB9\x82\xBD\x82\xA2\x82̂ŁA\x83X\x83e\x81[\x83^\x83X\x83o\x81[\x82\xF0\x95t\x82\xAF\x82\xE9\x81B + InitCommonControls(); + hStatus = CreateStatusWindow( + WS_CHILD | WS_VISIBLE | + CCS_BOTTOM | SBARS_SIZEGRIP, NULL, hDlgWnd, 1); + if (ActiveWin == IdVT) { // VT Window /* * Caret off \x8E\x9E\x82\xC9 GetCaretPos() \x82Ő\xB3\x8Am\x82ȏꏊ\x82\xAA\x8E\xE6\x82\xEA\x82Ȃ\xA2\x82̂ŁA @@ -105,23 +133,8 @@ // \x83L\x83\x83\x83\x8C\x83b\x83g\x82\xAA\x89\xE6\x96ʂ\xA9\x82\xE7\x82͂ݏo\x82\xB5\x82Ă\xA2\x82\xE9\x82Ƃ\xAB\x82ɓ\\x82\xE8\x95t\x82\xAF\x82\xF0\x82\xB7\x82\xE9\x82\xC6 // \x8Am\x94F\x83E\x83C\x83\x93\x83h\x83E\x82\xAA\x8C\xA9\x82\xA6\x82\xE9\x82Ƃ\xB1\x82\xEB\x82ɕ\\x8E\xA6\x82\xB3\x82\xEA\x82Ȃ\xA2\x82\xB1\x82Ƃ\xAA\x82\xA0\x82\xE9\x81B // \x83E\x83C\x83\x93\x83h\x83E\x82\xA9\x82\xE7\x82͂ݏo\x82\xB5\x82\xBD\x8Fꍇ\x82ɒ\xB2\x90߂\xB7\x82\xE9 (2008.4.24 maya) - if (pMonitorFromPoint == NULL) { - // NT4.0, 95 \x82̓}\x83\x8B\x83`\x83\x82\x83j\x83^API\x82ɔ\xF1\x91Ή\x9E - SystemParametersInfo(SPI_GETWORKAREA, 0, &rc_dsk, 0); - } - else { - HMONITOR hm; - POINT pt; - MONITORINFO mi; + GetDesktopRectFromPoint(p, &rc_dsk); - pt.x = p.x; - pt.y = p.y; - hm = pMonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); - - mi.cbSize = sizeof(MONITORINFO); - pGetMonitorInfoA(hm, &mi); - rc_dsk = mi.rcWork; - } GetWindowRect(hDlgWnd, &rc_dlg); dlg_height = rc_dlg.bottom-rc_dlg.top; dlg_width = rc_dlg.right-rc_dlg.left; @@ -163,12 +176,6 @@ ts.PasteDialogSize.cx, ts.PasteDialogSize.cy, SWP_NOZORDER | SWP_NOMOVE); - // \x83\x8A\x83T\x83C\x83Y\x83A\x83C\x83R\x83\x93\x82\xF0\x89E\x89\xBA\x82ɕ\\x8E\xA6\x82\xB3\x82\xB9\x82\xBD\x82\xA2\x82̂ŁA\x83X\x83e\x81[\x83^\x83X\x83o\x81[\x82\xF0\x95t\x82\xAF\x82\xE9\x81B - InitCommonControls(); - hStatus = CreateStatusWindow( - WS_CHILD | WS_VISIBLE | - CCS_BOTTOM | SBARS_SIZEGRIP, NULL, hDlgWnd, 1); - return TRUE; case WM_COMMAND: @@ -200,6 +207,7 @@ default: return FALSE; } + return TRUE; case WM_SIZE: { From scmnotify @ osdn.net Thu Jan 30 00:21:56 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Thu, 30 Jan 2020 00:21:56 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MDldIOODl+ODreOCuOOCp+OCr+ODiA==?= =?utf-8?b?44OV44Kh44Kk44Or5L+u5q2jIGNtYWtl?= Message-ID: <1580311316.730857.135896.nullmailer@users.osdn.me> Revision: 8509 https://osdn.net/projects/ttssh2/scm/svn/commits/8509 Author: zmatsuo Date: 2020-01-30 00:21:56 +0900 (Thu, 30 Jan 2020) Log Message: ----------- プロジェクトファイル修正 cmake Modified Paths: -------------- trunk/TTProxy/CMakeLists.txt trunk/TTXSamples/TTXRecurringCommand/CMakeLists.txt trunk/TTXSamples/TTXViewMode/CMakeLists.txt trunk/teraterm/ttpcmn/CMakeLists.txt trunk/teraterm/ttpfile/CMakeLists.txt trunk/teraterm/ttpset/CMakeLists.txt trunk/teraterm/ttptek/CMakeLists.txt -------------- next part -------------- Modified: trunk/TTProxy/CMakeLists.txt =================================================================== --- trunk/TTProxy/CMakeLists.txt 2020-01-26 15:14:04 UTC (rev 8508) +++ trunk/TTProxy/CMakeLists.txt 2020-01-29 15:21:56 UTC (rev 8509) @@ -102,6 +102,8 @@ target_link_libraries( ttproxy + PRIVATE + common_static ttpcmn # ws2_32 Modified: trunk/TTXSamples/TTXRecurringCommand/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXRecurringCommand/CMakeLists.txt 2020-01-26 15:14:04 UTC (rev 8508) +++ trunk/TTXSamples/TTXRecurringCommand/CMakeLists.txt 2020-01-29 15:21:56 UTC (rev 8509) @@ -42,6 +42,8 @@ target_link_libraries( TTXRecurringCommand + PRIVATE + common_static ttpcmn # gdi32 Modified: trunk/TTXSamples/TTXViewMode/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXViewMode/CMakeLists.txt 2020-01-26 15:14:04 UTC (rev 8508) +++ trunk/TTXSamples/TTXViewMode/CMakeLists.txt 2020-01-29 15:21:56 UTC (rev 8509) @@ -44,6 +44,8 @@ target_link_libraries( TTXViewMode + PRIVATE + common_static ttpcmn # gdi32 Modified: trunk/teraterm/ttpcmn/CMakeLists.txt =================================================================== --- trunk/teraterm/ttpcmn/CMakeLists.txt 2020-01-26 15:14:04 UTC (rev 8508) +++ trunk/teraterm/ttpcmn/CMakeLists.txt 2020-01-29 15:21:56 UTC (rev 8509) @@ -69,6 +69,7 @@ target_link_libraries( ttpcmn + PRIVATE common_static ole32 setupapi Modified: trunk/teraterm/ttpfile/CMakeLists.txt =================================================================== --- trunk/teraterm/ttpfile/CMakeLists.txt 2020-01-26 15:14:04 UTC (rev 8508) +++ trunk/teraterm/ttpfile/CMakeLists.txt 2020-01-29 15:21:56 UTC (rev 8509) @@ -61,6 +61,8 @@ target_link_libraries( ttpfile + PRIVATE + common_static ttpcmn # gdi32 @@ -67,11 +69,6 @@ comdlg32 ) -add_dependencies( - ttpfile - ttpcmn - ) - install( TARGETS ttpfile RUNTIME Modified: trunk/teraterm/ttpset/CMakeLists.txt =================================================================== --- trunk/teraterm/ttpset/CMakeLists.txt 2020-01-26 15:14:04 UTC (rev 8508) +++ trunk/teraterm/ttpset/CMakeLists.txt 2020-01-29 15:21:56 UTC (rev 8509) @@ -41,16 +41,13 @@ target_link_libraries( ttpset + PRIVATE + common_static ttpcmn # gdi32 ) -add_dependencies( - ttpset - ttpcmn - ) - install( TARGETS ttpset RUNTIME Modified: trunk/teraterm/ttptek/CMakeLists.txt =================================================================== --- trunk/teraterm/ttptek/CMakeLists.txt 2020-01-26 15:14:04 UTC (rev 8508) +++ trunk/teraterm/ttptek/CMakeLists.txt 2020-01-29 15:21:56 UTC (rev 8509) @@ -46,6 +46,8 @@ target_link_libraries( ttptek + PRIVATE + common_static ttpcmn # iphlpapi @@ -52,11 +54,6 @@ gdi32 ) -add_dependencies( - ttptek - ttpcmn - ) - install( TARGETS ttptek RUNTIME From scmnotify @ osdn.net Thu Jan 30 00:22:08 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Thu, 30 Jan 2020 00:22:08 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MTBdIOODl+ODreOCuOOCp+OCr+ODiA==?= =?utf-8?b?44OV44Kh44Kk44Or5L+u5q2jIHZzMjAxOQ==?= Message-ID: <1580311328.777140.137103.nullmailer@users.osdn.me> Revision: 8510 https://osdn.net/projects/ttssh2/scm/svn/commits/8510 Author: zmatsuo Date: 2020-01-30 00:22:08 +0900 (Thu, 30 Jan 2020) Log Message: ----------- プロジェクトファイル修正 vs2019 Modified Paths: -------------- trunk/TTProxy/TTProxy.v16.sln trunk/TTProxy/TTProxy.v16.vcxproj trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.v16.vcxproj trunk/TTXSamples/TTXViewMode/TTXViewMode.v16.vcxproj trunk/teraterm/ttpfile/ttpfile.v16.vcxproj trunk/teraterm/ttpfile/ttpfile.v16.vcxproj.filters trunk/teraterm/ttpset/ttpset.v16.vcxproj trunk/teraterm/ttptek/ttptek.v16.vcxproj -------------- next part -------------- Modified: trunk/TTProxy/TTProxy.v16.sln =================================================================== --- trunk/TTProxy/TTProxy.v16.sln 2020-01-29 15:21:56 UTC (rev 8509) +++ trunk/TTProxy/TTProxy.v16.sln 2020-01-29 15:22:08 UTC (rev 8510) @@ -1,10 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 16 +# Visual Studio Version 16 VisualStudioVersion = 16.0.28803.156 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTProxy", "TTProxy.v16.vcxproj", "{C4DE5FDF-DB00-4C73-9D4F-359BFCA3F2FB}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common_static", "..\teraterm\common\common_static.v16.vcxproj", "{AC42387D-23EC-45DB-81F9-8933C7EFA52A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -15,8 +17,15 @@ {C4DE5FDF-DB00-4C73-9D4F-359BFCA3F2FB}.Debug|Win32.Build.0 = Debug|Win32 {C4DE5FDF-DB00-4C73-9D4F-359BFCA3F2FB}.Release|Win32.ActiveCfg = Release|Win32 {C4DE5FDF-DB00-4C73-9D4F-359BFCA3F2FB}.Release|Win32.Build.0 = Release|Win32 + {AC42387D-23EC-45DB-81F9-8933C7EFA52A}.Debug|Win32.ActiveCfg = Debug|Win32 + {AC42387D-23EC-45DB-81F9-8933C7EFA52A}.Debug|Win32.Build.0 = Debug|Win32 + {AC42387D-23EC-45DB-81F9-8933C7EFA52A}.Release|Win32.ActiveCfg = Release|Win32 + {AC42387D-23EC-45DB-81F9-8933C7EFA52A}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A4DEB4C3-85FB-401C-BEFD-469E0A10C041} + EndGlobalSection EndGlobal Modified: trunk/TTProxy/TTProxy.v16.vcxproj =================================================================== --- trunk/TTProxy/TTProxy.v16.vcxproj 2020-01-29 15:21:56 UTC (rev 8509) +++ trunk/TTProxy/TTProxy.v16.vcxproj 2020-01-29 15:22:08 UTC (rev 8510) @@ -202,6 +202,11 @@ + + + {ac42387d-23ec-45db-81f9-8933c7efa52a} + + Modified: trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.v16.vcxproj =================================================================== --- trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.v16.vcxproj 2020-01-29 15:21:56 UTC (rev 8509) +++ trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.v16.vcxproj 2020-01-29 15:22:08 UTC (rev 8510) @@ -109,6 +109,11 @@ + + + {ac42387d-23ec-45db-81f9-8933c7efa52a} + + Modified: trunk/TTXSamples/TTXViewMode/TTXViewMode.v16.vcxproj =================================================================== --- trunk/TTXSamples/TTXViewMode/TTXViewMode.v16.vcxproj 2020-01-29 15:21:56 UTC (rev 8509) +++ trunk/TTXSamples/TTXViewMode/TTXViewMode.v16.vcxproj 2020-01-29 15:22:08 UTC (rev 8510) @@ -109,6 +109,11 @@ + + + {ac42387d-23ec-45db-81f9-8933c7efa52a} + + Modified: trunk/teraterm/ttpfile/ttpfile.v16.vcxproj =================================================================== --- trunk/teraterm/ttpfile/ttpfile.v16.vcxproj 2020-01-29 15:21:56 UTC (rev 8509) +++ trunk/teraterm/ttpfile/ttpfile.v16.vcxproj 2020-01-29 15:22:08 UTC (rev 8510) @@ -167,6 +167,9 @@ + + {ac42387d-23ec-45db-81f9-8933c7efa52a} + {118e0d32-5553-4f73-9927-e873c1c500e4} false Modified: trunk/teraterm/ttpfile/ttpfile.v16.vcxproj.filters =================================================================== --- trunk/teraterm/ttpfile/ttpfile.v16.vcxproj.filters 2020-01-29 15:21:56 UTC (rev 8509) +++ trunk/teraterm/ttpfile/ttpfile.v16.vcxproj.filters 2020-01-29 15:22:08 UTC (rev 8510) @@ -52,6 +52,12 @@ Source Files + + Source Files + + + Source Files + Modified: trunk/teraterm/ttpset/ttpset.v16.vcxproj =================================================================== --- trunk/teraterm/ttpset/ttpset.v16.vcxproj 2020-01-29 15:21:56 UTC (rev 8509) +++ trunk/teraterm/ttpset/ttpset.v16.vcxproj 2020-01-29 15:22:08 UTC (rev 8510) @@ -147,6 +147,9 @@ + + {ac42387d-23ec-45db-81f9-8933c7efa52a} + {118e0d32-5553-4f73-9927-e873c1c500e4} false @@ -155,4 +158,4 @@ - + \ No newline at end of file Modified: trunk/teraterm/ttptek/ttptek.v16.vcxproj =================================================================== --- trunk/teraterm/ttptek/ttptek.v16.vcxproj 2020-01-29 15:21:56 UTC (rev 8509) +++ trunk/teraterm/ttptek/ttptek.v16.vcxproj 2020-01-29 15:22:08 UTC (rev 8510) @@ -143,6 +143,9 @@ + + {ac42387d-23ec-45db-81f9-8933c7efa52a} + {118e0d32-5553-4f73-9927-e873c1c500e4} false @@ -151,4 +154,4 @@ - + \ No newline at end of file From scmnotify @ osdn.net Thu Jan 30 00:22:19 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Thu, 30 Jan 2020 00:22:19 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MTFdIOODl+ODreOCuOOCp+OCr+ODiA==?= =?utf-8?b?44OV44Kh44Kk44Or5L+u5q2jIHZzMjAwOA==?= Message-ID: <1580311339.288405.137367.nullmailer@users.osdn.me> Revision: 8511 https://osdn.net/projects/ttssh2/scm/svn/commits/8511 Author: zmatsuo Date: 2020-01-30 00:22:19 +0900 (Thu, 30 Jan 2020) Log Message: ----------- プロジェクトファイル修正 vs2008 Modified Paths: -------------- trunk/TTProxy/TTProxy.sln trunk/TTXSamples/TTXSamples.sln trunk/teraterm/ttermpro.sln -------------- next part -------------- Modified: trunk/TTProxy/TTProxy.sln =================================================================== --- trunk/TTProxy/TTProxy.sln 2020-01-29 15:22:08 UTC (rev 8510) +++ trunk/TTProxy/TTProxy.sln 2020-01-29 15:22:19 UTC (rev 8511) @@ -2,7 +2,12 @@ Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTProxy", "TTProxy.vcproj", "{C4DE5FDF-DB00-4C73-9D4F-359BFCA3F2FB}" + ProjectSection(ProjectDependencies) = postProject + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} = {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} + EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common_static", "..\teraterm\common\common_static.v8.vcproj", "{DF4E3C36-A743-4FB4-8EE9-49899E69ED32}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -13,6 +18,10 @@ {C4DE5FDF-DB00-4C73-9D4F-359BFCA3F2FB}.Debug|Win32.Build.0 = Debug|Win32 {C4DE5FDF-DB00-4C73-9D4F-359BFCA3F2FB}.Release|Win32.ActiveCfg = Release|Win32 {C4DE5FDF-DB00-4C73-9D4F-359BFCA3F2FB}.Release|Win32.Build.0 = Release|Win32 + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32}.Debug|Win32.ActiveCfg = Debug|Win32 + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32}.Debug|Win32.Build.0 = Debug|Win32 + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32}.Release|Win32.ActiveCfg = Release|Win32 + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: trunk/TTXSamples/TTXSamples.sln =================================================================== --- trunk/TTXSamples/TTXSamples.sln 2020-01-29 15:22:08 UTC (rev 8510) +++ trunk/TTXSamples/TTXSamples.sln 2020-01-29 15:22:19 UTC (rev 8511) @@ -17,6 +17,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTXKcodeChange", "TTXKcodeChange\TTXKcodeChange.vcproj", "{2E487F50-84E4-404D-A7E1-F9FA4A72BC25}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTXViewMode", "TTXViewMode\TTXViewMode.vcproj", "{2296FB66-3FA4-4136-8252-ABECEEAC2D70}" + ProjectSection(ProjectDependencies) = postProject + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} = {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTXCopyIniFile", "TTXCopyIniFile\TTXCopyIniFile.vcproj", "{2B2B8D6E-4A84-49DD-8291-46172FCE422A}" EndProject @@ -27,6 +30,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTXCommandLineOpt", "TTXCommandLineOpt\TTXCommandLineOpt.vcproj", "{EE8BFC38-7000-42F1-BBC3-17F19855918A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTXRecurringCommand", "TTXRecurringCommand\TTXRecurringCommand.vcproj", "{3C656364-FAEA-41D2-B227-52187D3C2529}" + ProjectSection(ProjectDependencies) = postProject + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} = {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTXShowCommandLine", "TTXShowCommandLine\TTXShowCommandLine.vcproj", "{80ED9927-27F9-473A-802C-FB10DEB5ECC6}" EndProject Modified: trunk/teraterm/ttermpro.sln =================================================================== --- trunk/teraterm/ttermpro.sln 2020-01-29 15:22:08 UTC (rev 8510) +++ trunk/teraterm/ttermpro.sln 2020-01-29 15:22:19 UTC (rev 8511) @@ -21,6 +21,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ttpfile", "ttpfile\ttpfile.vcproj", "{311F2B21-AEC4-4384-8209-BB83B54749B4}" ProjectSection(ProjectDependencies) = postProject {118E0D32-5553-4F73-9927-E873C1C500E4} = {118E0D32-5553-4F73-9927-E873C1C500E4} + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} = {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ttpmacro", "ttpmacro\ttpmacro.vcproj", "{BA519362-A2C2-4B1A-905B-F00791F9038A}" @@ -30,11 +31,13 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ttpset", "ttpset\ttpset.vcproj", "{5CF58947-E861-4A5C-B0B1-E85486F149CD}" ProjectSection(ProjectDependencies) = postProject + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} = {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} {118E0D32-5553-4F73-9927-E873C1C500E4} = {118E0D32-5553-4F73-9927-E873C1C500E4} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ttptek", "ttptek\ttptek.vcproj", "{6D08053B-1C68-4A7E-8766-3553F5AF010B}" ProjectSection(ProjectDependencies) = postProject + {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} = {DF4E3C36-A743-4FB4-8EE9-49899E69ED32} {118E0D32-5553-4F73-9927-E873C1C500E4} = {118E0D32-5553-4F73-9927-E873C1C500E4} EndProjectSection EndProject From scmnotify @ osdn.net Thu Jan 30 19:10:42 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Thu, 30 Jan 2020 19:10:42 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MTJdIOiqpOWtl+OCkuS/ruatow==?= Message-ID: <1580379042.965451.93349.nullmailer@users.osdn.me> Revision: 8512 https://osdn.net/projects/ttssh2/scm/svn/commits/8512 Author: doda Date: 2020-01-30 19:10:41 +0900 (Thu, 30 Jan 2020) Log Message: ----------- 誤字を修正 Ticket: #39965 問題: ヘルプファイルに誤字が有る 対応: 誤字を修正した Ticket Links: ------------ https://osdn.net/projects/ttssh2/tracker/detail/39965 Modified Paths: -------------- trunk/doc/en/html/about/ctrlseq.html trunk/doc/en/html/menu/setup-additional.html trunk/doc/en/html/menu/setup-serialport.html trunk/doc/en/html/reference/develop.txt trunk/doc/en/html/usage/tips/vim.html trunk/doc/en/teraterm.hhc -------------- next part -------------- Modified: trunk/doc/en/html/about/ctrlseq.html =================================================================== --- trunk/doc/en/html/about/ctrlseq.html 2020-01-29 15:22:19 UTC (rev 8511) +++ trunk/doc/en/html/about/ctrlseq.html 2020-01-30 10:10:41 UTC (rev 8512) @@ -949,9 +949,9 @@ 15 Change TEK Window's text color to Pt. Format of Pt is same as OSC 4's spec. 16 Change TEK Window's background color to Pt. Format of Pt is same as OSC 4's spec. - + - + 52 Clipboard access.
 Pt = Pc ; Pd
@@ -973,9 +973,9 @@
 
  115 		Reset TEK Window's text color. 
  116 		Reset TEK Window's background color. 
-
+
 
-
+
 
 
 

SOS Sequence

Modified: trunk/doc/en/html/menu/setup-additional.html =================================================================== --- trunk/doc/en/html/menu/setup-additional.html 2020-01-29 15:22:19 UTC (rev 8511) +++ trunk/doc/en/html/menu/setup-additional.html 2020-01-30 10:10:41 UTC (rev 8512) @@ -285,7 +285,7 @@
Mixed ThemeFile to Background
When the Eterm look-feel feature is enabled, you can specify whether to mix the wallpaper and the image of theme file.
- Howerver, this option can not be used with Background Image at the same time.
+ However, this option can not be used with Background Image at the same time.
Background Image
@@ -498,7 +498,7 @@
Configure CygTerm settings. Please refer to CygTerm+ setup file for details.

- NOTE: The cygterm.cfg file is automatically updated after configuration on version 4.88 or ealier, + NOTE: The cygterm.cfg file is automatically updated after configuration on version 4.88 or earlier, however the file is not automatically updated on version 4.89 or later.
Please do Setup - Save Setup to update the cygterm.cfg file.

Modified: trunk/doc/en/html/menu/setup-serialport.html =================================================================== --- trunk/doc/en/html/menu/setup-serialport.html 2020-01-29 15:22:19 UTC (rev 8511) +++ trunk/doc/en/html/menu/setup-serialport.html 2020-01-30 10:10:41 UTC (rev 8512) @@ -17,7 +17,7 @@
OK button
- The label of OK button is changed refering to the connection state.
+ The label of OK button is changed according to the connection state.
Connect with New window ... Serial connection is launched with new window since TCP/IP connection is using.
New open ... Serial connection starts.
Close and New open ... Current COM port is closed and serial connection starts with new COM port.
@@ -26,7 +26,7 @@
Cancel button
- Discards the setting change and close the dialog. + Discards the setting change and closes the dialog.
Help button
Modified: trunk/doc/en/html/reference/develop.txt =================================================================== --- trunk/doc/en/html/reference/develop.txt 2020-01-29 15:22:19 UTC (rev 8511) +++ trunk/doc/en/html/reference/develop.txt 2020-01-30 10:10:41 UTC (rev 8512) @@ -57,8 +57,8 @@ - SFMT 1.5.1 (http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html) -* Notice for SVN commiter -- SVN repository for commiter is followings: +* Notice for SVN committer +- SVN repository for committer is the following: svn+ssh://svn.osdn.net/svnroot/ttssh2/trunk - Should not edit checkout file in copying directory. @@ -235,7 +235,7 @@ * How to build HTML help file To build HTML help file is shown in the following step: - 1. Intall HTML Help Workshop from below site: + 1. Install HTML Help Workshop from below site: http://www.microsoft.com/en-us/download/details.aspx?id=21138 2. Copy document files with batch file on command prompt. Modified: trunk/doc/en/html/usage/tips/vim.html =================================================================== --- trunk/doc/en/html/usage/tips/vim.html 2020-01-29 15:22:19 UTC (rev 8511) +++ trunk/doc/en/html/usage/tips/vim.html 2020-01-30 10:10:41 UTC (rev 8512) @@ -65,7 +65,7 @@

Auto indent can be disabled on pasting from clipboard

-NOTE: When text is pasted by using Vim 8.0.0238 or later , auto indent and completion are disabled not below configuration becasue the vim editor supports Bracketed Paste Mode.
+NOTE: When text is pasted by using Vim 8.0.0238 or later, auto indent and completion are disabled not below configuration because the vim editor supports Bracketed Paste Mode.
However, when tmux is used, below configuration is needed because Bracketed Paste Mode is not enabled.

Modified: trunk/doc/en/teraterm.hhc =================================================================== --- trunk/doc/en/teraterm.hhc 2020-01-29 15:22:19 UTC (rev 8511) +++ trunk/doc/en/teraterm.hhc 2020-01-30 10:10:41 UTC (rev 8512) @@ -386,7 +386,7 @@
  • - +
      From scmnotify @ osdn.net Thu Jan 30 19:10:47 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Thu, 30 Jan 2020 19:10:47 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MTNdIOODoeODi+ODpeODvOmgheebrg==?= =?utf-8?b?44Gu6Kqk5a2X44KS5L+u5q2j?= Message-ID: <1580379047.734937.93446.nullmailer@users.osdn.me> Revision: 8513 https://osdn.net/projects/ttssh2/scm/svn/commits/8513 Author: doda Date: 2020-01-30 19:10:47 +0900 (Thu, 30 Jan 2020) Log Message: ----------- メニュー項目の誤字を修正 Ticket: #39967 問題: TTXAlwaysOnTop のメニュー項目に誤字がある 対処: 誤字を修正した Ticket Links: ------------ https://osdn.net/projects/ttssh2/tracker/detail/39967 Modified Paths: -------------- trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c -------------- next part -------------- Modified: trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c =================================================================== --- trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c 2020-01-30 10:10:41 UTC (rev 8512) +++ trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c 2020-01-30 10:10:47 UTC (rev 8513) @@ -74,7 +74,7 @@ flag |= MF_CHECKED; } - InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, flag, ID_MENU_BASE, "&Alwais on top"); + InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, flag, ID_MENU_BASE, "&Always on top"); InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, MF_BYCOMMAND | MF_SEPARATOR, 0, NULL); SetI18nMenuStrs(IniSection, menu, MenuTextInfo, _countof(MenuTextInfo), pvar->ts->UILanguageFile); From scmnotify @ osdn.net Thu Jan 30 19:17:48 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Thu, 30 Jan 2020 19:17:48 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MTRdIOiqpOWtl+OCkuS/ruatow==?= Message-ID: <1580379468.333068.114448.nullmailer@users.osdn.me> Revision: 8514 https://osdn.net/projects/ttssh2/scm/svn/commits/8514 Author: doda Date: 2020-01-30 19:17:47 +0900 (Thu, 30 Jan 2020) Log Message: ----------- 誤字を修正 Ticket: #39965 問題: ヘルプファイルに誤字が有る 対応: 誤字を修正した Ticket Links: ------------ https://osdn.net/projects/ttssh2/tracker/detail/39965 Modified Paths: -------------- branches/4-stable/doc/en/html/about/ctrlseq.html branches/4-stable/doc/en/html/menu/setup-additional.html branches/4-stable/doc/en/html/menu/setup-serialport.html branches/4-stable/doc/en/html/reference/develop.txt branches/4-stable/doc/en/html/usage/tips/vim.html branches/4-stable/doc/en/teraterm.hhc -------------- next part -------------- Modified: branches/4-stable/doc/en/html/about/ctrlseq.html =================================================================== --- branches/4-stable/doc/en/html/about/ctrlseq.html 2020-01-30 10:10:47 UTC (rev 8513) +++ branches/4-stable/doc/en/html/about/ctrlseq.html 2020-01-30 10:17:47 UTC (rev 8514) @@ -949,9 +949,9 @@ 15 Change TEK Window's text color to Pt. Format of Pt is same as OSC 4's spec. 16 Change TEK Window's background color to Pt. Format of Pt is same as OSC 4's spec. - + - + 52 Clipboard access.
       Pt = Pc ; Pd
      @@ -973,9 +973,9 @@
       
        115 		Reset TEK Window's text color. 
        116 		Reset TEK Window's background color. 
      -
      +
       
      -
      +
       
       
       

      SOS Sequence

      Modified: branches/4-stable/doc/en/html/menu/setup-additional.html =================================================================== --- branches/4-stable/doc/en/html/menu/setup-additional.html 2020-01-30 10:10:47 UTC (rev 8513) +++ branches/4-stable/doc/en/html/menu/setup-additional.html 2020-01-30 10:17:47 UTC (rev 8514) @@ -285,7 +285,7 @@
      Mixed ThemeFile to Background
      When the Eterm look-feel feature is enabled, you can specify whether to mix the wallpaper and the image of theme file.
      - Howerver, this option can not be used with Background Image at the same time.
      + However, this option can not be used with Background Image at the same time.
      Background Image
      @@ -498,7 +498,7 @@
      Configure CygTerm settings. Please refer to CygTerm+ setup file for details.

      - NOTE: The cygterm.cfg file is automatically updated after configuration on version 4.88 or ealier, + NOTE: The cygterm.cfg file is automatically updated after configuration on version 4.88 or earlier, however the file is not automatically updated on version 4.89 or later.
      Please do Setup - Save Setup to update the cygterm.cfg file.

      Modified: branches/4-stable/doc/en/html/menu/setup-serialport.html =================================================================== --- branches/4-stable/doc/en/html/menu/setup-serialport.html 2020-01-30 10:10:47 UTC (rev 8513) +++ branches/4-stable/doc/en/html/menu/setup-serialport.html 2020-01-30 10:17:47 UTC (rev 8514) @@ -17,7 +17,7 @@
      OK button
      - The label of OK button is changed refering to the connection state.
      + The label of OK button is changed according to the connection state.
      Connect with New window ... Serial connection is launched with new window since TCP/IP connection is using.
      New open ... Serial connection starts.
      Close and New open ... Current COM port is closed and serial connection starts with new COM port.
      @@ -26,7 +26,7 @@
      Cancel button
      - Discards the setting change and close the dialog. + Discards the setting change and closes the dialog.
      Help button
      Modified: branches/4-stable/doc/en/html/reference/develop.txt =================================================================== --- branches/4-stable/doc/en/html/reference/develop.txt 2020-01-30 10:10:47 UTC (rev 8513) +++ branches/4-stable/doc/en/html/reference/develop.txt 2020-01-30 10:17:47 UTC (rev 8514) @@ -57,8 +57,8 @@ - SFMT 1.5.1 (http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html) -* Notice for SVN commiter -- SVN repository for commiter is followings: +* Notice for SVN committer +- SVN repository for committer is the following: svn+ssh://svn.osdn.net/svnroot/ttssh2/trunk - Should not edit checkout file in copying directory. @@ -235,7 +235,7 @@ * How to build HTML help file To build HTML help file is shown in the following step: - 1. Intall HTML Help Workshop from below site: + 1. Install HTML Help Workshop from below site: http://www.microsoft.com/en-us/download/details.aspx?id=21138 2. Copy document files with batch file on command prompt. Modified: branches/4-stable/doc/en/html/usage/tips/vim.html =================================================================== --- branches/4-stable/doc/en/html/usage/tips/vim.html 2020-01-30 10:10:47 UTC (rev 8513) +++ branches/4-stable/doc/en/html/usage/tips/vim.html 2020-01-30 10:17:47 UTC (rev 8514) @@ -65,7 +65,7 @@

      Auto indent can be disabled on pasting from clipboard

      -NOTE: When text is pasted by using Vim 8.0.0238 or later , auto indent and completion are disabled not below configuration becasue the vim editor supports Bracketed Paste Mode.
      +NOTE: When text is pasted by using Vim 8.0.0238 or later, auto indent and completion are disabled not below configuration because the vim editor supports Bracketed Paste Mode.
      However, when tmux is used, below configuration is needed because Bracketed Paste Mode is not enabled.

      Modified: branches/4-stable/doc/en/teraterm.hhc =================================================================== --- branches/4-stable/doc/en/teraterm.hhc 2020-01-30 10:10:47 UTC (rev 8513) +++ branches/4-stable/doc/en/teraterm.hhc 2020-01-30 10:17:47 UTC (rev 8514) @@ -386,7 +386,7 @@
    • - +
        From scmnotify @ osdn.net Thu Jan 30 19:17:52 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Thu, 30 Jan 2020 19:17:52 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MTVdIOODk+ODq+ODieaZguOBq+eUnw==?= =?utf-8?b?5oiQ44GV44KM44KL44OQ44Kk44OK44OqL+OCouODvOOCq+OCpOODluOCkg==?= =?utf-8?b?5YmK6Zmk?= Message-ID: <1580379472.943337.115131.nullmailer@users.osdn.me> Revision: 8515 https://osdn.net/projects/ttssh2/scm/svn/commits/8515 Author: doda Date: 2020-01-30 19:17:52 +0900 (Thu, 30 Jan 2020) Log Message: ----------- ビルド時に生成されるバイナリ/アーカイブを削除 誤コミットの原因となる為 Removed Paths: ------------- branches/4-stable/cygterm/cyglaunch.exe branches/4-stable/cygterm/cygterm+.tar.gz branches/4-stable/cygterm/cygterm.exe -------------- next part -------------- Deleted: branches/4-stable/cygterm/cyglaunch.exe =================================================================== (Binary files differ) Deleted: branches/4-stable/cygterm/cygterm+.tar.gz =================================================================== (Binary files differ) Deleted: branches/4-stable/cygterm/cygterm.exe =================================================================== (Binary files differ) From scmnotify @ osdn.net Fri Jan 31 08:42:36 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 31 Jan 2020 08:42:36 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MTZdIE9wZW5IZWxwKCkg44Oq44OV44Kh?= =?utf-8?b?44Kv44K/44Oq44Oz44Kw?= Message-ID: <1580427756.665334.105064.nullmailer@users.osdn.me> Revision: 8516 https://osdn.net/projects/ttssh2/scm/svn/commits/8516 Author: zmatsuo Date: 2020-01-31 08:42:36 +0900 (Fri, 31 Jan 2020) Log Message: ----------- OpenHelp() リファクタリング Modified Paths: -------------- trunk/teraterm/ttpcmn/ttcmn.c -------------- next part -------------- Modified: trunk/teraterm/ttpcmn/ttcmn.c =================================================================== --- trunk/teraterm/ttpcmn/ttcmn.c 2020-01-30 10:17:52 UTC (rev 8515) +++ trunk/teraterm/ttpcmn/ttcmn.c 2020-01-30 23:42:36 UTC (rev 8516) @@ -1168,7 +1168,7 @@ HWND HWin; wchar_t HelpFN[MAX_PATH]; wchar_t uimsg[MAX_UIMSG]; - wchar_t *HomeDirT; + wchar_t *HomeDirW; /* Get home directory */ if (GetModuleFileNameA(NULL,Temp,_countof(Temp)) == 0) { @@ -1175,29 +1175,22 @@ return; } ExtractDirName(Temp, HomeDir); - HomeDirT = ToWcharA(HomeDir); - + HomeDirW = ToWcharA(HomeDir); get_lang_msgW("HELPFILE", uimsg, _countof(uimsg), L"teraterm.chm", UILanguageFile); + _snwprintf_s(HelpFN, _countof(HelpFN), _TRUNCATE, L"%s\\%s", HomeDirW, uimsg); + free(HomeDirW); // \x83w\x83\x8B\x83v\x82̃I\x81[\x83i\x81[\x82͏\xED\x82Ƀf\x83X\x83N\x83g\x83b\x83v\x82ɂȂ\xE9 (2007.5.12 maya) HWin = GetDesktopWindow(); - _snwprintf_s(HelpFN, _countof(HelpFN), _TRUNCATE, L"%s\\%s", HomeDirT, uimsg); if (_HtmlHelpW(HWin, HelpFN, Command, Data) == NULL && Command != HH_CLOSE_ALL) { - goto error; - } - goto finish; - -error: - { + // \x83w\x83\x8B\x83v\x82\xAA\x8AJ\x82\xAF\x82Ȃ\xA9\x82\xC1\x82\xBD wchar_t buf[MAX_PATH]; get_lang_msgW("MSG_OPENHELP_ERROR", uimsg, _countof(uimsg), L"Can't open HTML help file(%s).", UILanguageFile); _snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg, HelpFN); _MessageBoxW(HWin, buf, L"Tera Term: HTML help", MB_OK | MB_ICONERROR); + return; } - -finish: - free(HomeDirT); } HWND WINAPI GetNthWin(int n) From scmnotify @ osdn.net Fri Jan 31 08:42:44 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 31 Jan 2020 08:42:44 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MTddIOODnuODq+ODgeODouODi+OCvw==?= =?utf-8?b?6Zai6YCj44GuQVBJ44KS55u05o6l5ZG844Gw44Gq44GE44KI44GG44Gr44GX?= =?utf-8?b?44Gf?= Message-ID: <1580427764.518284.105185.nullmailer@users.osdn.me> Revision: 8517 https://osdn.net/projects/ttssh2/scm/svn/commits/8517 Author: zmatsuo Date: 2020-01-31 08:42:44 +0900 (Fri, 31 Jan 2020) Log Message: ----------- マルチモニタ関連のAPIを直接呼ばないようにした - まだ使用している箇所があったので修正 - pMonitorFromRect(), pGetMonitorInfoA() - r8504 Revision Links: -------------- https://osdn.net/projects/ttssh2/scm/svn/commits/8504 Modified Paths: -------------- trunk/teraterm/common/compat_win.cpp trunk/teraterm/common/compat_win.h trunk/teraterm/ttpcmn/ttcmn.c -------------- next part -------------- Modified: trunk/teraterm/common/compat_win.cpp =================================================================== --- trunk/teraterm/common/compat_win.cpp 2020-01-30 23:42:36 UTC (rev 8516) +++ trunk/teraterm/common/compat_win.cpp 2020-01-30 23:42:44 UTC (rev 8517) @@ -61,7 +61,6 @@ BOOL (WINAPI *pRemoveFontResourceExA)(LPCSTR name, DWORD fl, PVOID pdv); BOOL (WINAPI *pRemoveFontResourceExW)(LPCWSTR name, DWORD fl, PVOID pdv); HRESULT (WINAPI *pGetDpiForMonitor)(HMONITOR hmonitor, MONITOR_DPI_TYPE dpiType, UINT *dpiX, UINT *dpiY); -HMONITOR (WINAPI *pMonitorFromRect)(LPCRECT lprc, DWORD dwFlags); BOOL (WINAPI *pAdjustWindowRectEx)(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle); BOOL (WINAPI *pAdjustWindowRectExForDpi)(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi); HWND (WINAPI *pGetConsoleWindow)(void); @@ -76,6 +75,7 @@ HMONITOR (WINAPI *pMonitorFromWindow)(HWND hwnd, DWORD dwFlags); HMONITOR (WINAPI *pMonitorFromPoint)(POINT pt, DWORD dwFlags); +HMONITOR (WINAPI *pMonitorFromRect)(LPCRECT lprc, DWORD dwFlags); BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR hMonitor, LPMONITORINFO lpmi); /** Modified: trunk/teraterm/common/compat_win.h =================================================================== --- trunk/teraterm/common/compat_win.h 2020-01-30 23:42:36 UTC (rev 8516) +++ trunk/teraterm/common/compat_win.h 2020-01-30 23:42:44 UTC (rev 8517) @@ -106,6 +106,7 @@ extern BOOL (WINAPI *pAppendMenuW)(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); extern HMONITOR (WINAPI *pMonitorFromWindow)(HWND hwnd, DWORD dwFlags); extern HMONITOR (WINAPI *pMonitorFromPoint)(POINT pt, DWORD dwFlags); +extern HMONITOR (WINAPI *pMonitorFromRect)(LPCRECT lprc, DWORD dwFlags); extern BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR hMonitor, LPMONITORINFO lpmi); Modified: trunk/teraterm/ttpcmn/ttcmn.c =================================================================== --- trunk/teraterm/ttpcmn/ttcmn.c 2020-01-30 23:42:36 UTC (rev 8516) +++ trunk/teraterm/ttpcmn/ttcmn.c 2020-01-30 23:42:44 UTC (rev 8517) @@ -1098,8 +1098,6 @@ int i; WINDOWPLACEMENT rc0; RECT rc; - HMONITOR hMonitor; - MONITORINFO mi; int stat = SW_RESTORE; int multi_mon = 0; @@ -1120,9 +1118,11 @@ // NT4.0, 95 \x82̓}\x83\x8B\x83`\x83\x82\x83j\x83^API\x82ɔ\xF1\x91Ή\x9E if (multi_mon) { // \x91Ώۃ\x82\x83j\x83^\x82̏\xEE\x95\xF1\x82\xF0\x8E擾 - hMonitor = MonitorFromRect(&rc, MONITOR_DEFAULTTONEAREST); + HMONITOR hMonitor; + MONITORINFO mi; + hMonitor = pMonitorFromRect(&rc, MONITOR_DEFAULTTONEAREST); mi.cbSize = sizeof(MONITORINFO); - GetMonitorInfo(hMonitor, &mi); + pGetMonitorInfoA(hMonitor, &mi); // \x88ʒu\x95␳\x81i\x95\x9C\x8C\xB3\x91O\x8C\xE3\x82ʼn𑜓x\x82\xAA\x95ς\xED\x82\xC1\x82Ă\xA2\x82\xE9\x8Fꍇ\x82ւ̑΍\xF4\x81j if (rc.right > mi.rcMonitor.right) { From scmnotify @ osdn.net Fri Jan 31 08:42:48 2020 From: scmnotify @ osdn.net (scmnotify @ osdn.net) Date: Fri, 31 Jan 2020 08:42:48 +0900 Subject: [Ttssh2-commit] =?utf-8?b?Wzg1MThdIFRTUEVDSUFMMS5UVEYg44Gu44Ot?= =?utf-8?b?44O844OJ44KSIGxheWVyIGZvciB1bmljb2RlIOOCkuS9v+eUqOOBmeOCiw==?= =?utf-8?b?44KI44GG44Gr44GX44Gf?= Message-ID: <1580427768.096729.105277.nullmailer@users.osdn.me> Revision: 8518 https://osdn.net/projects/ttssh2/scm/svn/commits/8518 Author: zmatsuo Date: 2020-01-31 08:42:47 +0900 (Fri, 31 Jan 2020) Log Message: ----------- TSPECIAL1.TTF のロードを layer for unicode を使用するようにした Modified Paths: -------------- trunk/teraterm/common/compat_win.cpp trunk/teraterm/common/compat_win.h trunk/teraterm/common/layer_for_unicode.cpp trunk/teraterm/common/layer_for_unicode.h trunk/teraterm/teraterm/teraterm.cpp -------------- next part -------------- Modified: trunk/teraterm/common/compat_win.cpp =================================================================== --- trunk/teraterm/common/compat_win.cpp 2020-01-30 23:42:44 UTC (rev 8517) +++ trunk/teraterm/common/compat_win.cpp 2020-01-30 23:42:47 UTC (rev 8518) @@ -56,10 +56,6 @@ BOOL (WINAPI *pIsValidDpiAwarenessContext)(DPI_AWARENESS_CONTEXT dpiContext); UINT (WINAPI *pGetDpiForWindow)(HWND hwnd); BOOL (WINAPI *pSetLayeredWindowAttributes)(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags); -int (WINAPI *pAddFontResourceExA)(LPCSTR name, DWORD fl, PVOID res); -int (WINAPI *pAddFontResourceExW)(LPCWSTR name, DWORD fl, PVOID res); -BOOL (WINAPI *pRemoveFontResourceExA)(LPCSTR name, DWORD fl, PVOID pdv); -BOOL (WINAPI *pRemoveFontResourceExW)(LPCWSTR name, DWORD fl, PVOID pdv); HRESULT (WINAPI *pGetDpiForMonitor)(HMONITOR hmonitor, MONITOR_DPI_TYPE dpiType, UINT *dpiX, UINT *dpiY); BOOL (WINAPI *pAdjustWindowRectEx)(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle); BOOL (WINAPI *pAdjustWindowRectExForDpi)(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi); @@ -67,6 +63,11 @@ int (WINAPI *pMessageBoxW)(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType); INT_PTR (WINAPI *pDialogBoxIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam); +// gdi32.lib +int (WINAPI *pAddFontResourceExW)(LPCWSTR name, DWORD fl, PVOID res); +BOOL (WINAPI *pRemoveFontResourceExW)(LPCWSTR name, DWORD fl, PVOID pdv); + +// htmlhelp.ocx HWND (WINAPI *pHtmlHelpW)(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData); HWND (WINAPI *pHtmlHelpA)(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData); @@ -147,8 +148,6 @@ }; static const APIInfo Lists_gdi32[] = { - { "AddFontResourceExA", (void **)&pAddFontResourceExA }, - { "RemoveFontResourceExA", (void **)&pRemoveFontResourceExA }, { "AddFontResourceExW", (void **)&pAddFontResourceExW }, { "RemoveFontResourceExW", (void **)&pRemoveFontResourceExW }, {}, Modified: trunk/teraterm/common/compat_win.h =================================================================== --- trunk/teraterm/common/compat_win.h 2020-01-30 23:42:44 UTC (rev 8517) +++ trunk/teraterm/common/compat_win.h 2020-01-30 23:42:47 UTC (rev 8518) @@ -93,9 +93,7 @@ extern BOOL (WINAPI *pAdjustWindowRectEx)(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle); extern BOOL (WINAPI *pAdjustWindowRectExForDpi)(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi); extern BOOL (WINAPI *pSetLayeredWindowAttributes)(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags); -extern int (WINAPI *pAddFontResourceExA)(LPCSTR name, DWORD fl, PVOID res); extern int (WINAPI *pAddFontResourceExW)(LPCWSTR name, DWORD fl, PVOID res); -extern BOOL (WINAPI *pRemoveFontResourceExA)(LPCSTR name, DWORD fl, PVOID pdv); extern BOOL (WINAPI *pRemoveFontResourceExW)(LPCWSTR name, DWORD fl, PVOID pdv); extern HWND (WINAPI *pGetConsoleWindow)(void); extern int (WINAPI *pMessageBoxW)(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType); @@ -110,14 +108,6 @@ extern BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR hMonitor, LPMONITORINFO lpmi); -#ifdef UNICODE -#define pAddFontResourceEx pAddFontResourceExW -#define pRemoveFontResourceEx pRemoveFontResourceExW -#else -#define pAddFontResourceEx pAddFontResourceExA -#define pRemoveFontResourceEx pRemoveFontResourceExA -#endif // !UNICODE - void WinCompatInit(); #ifdef __cplusplus Modified: trunk/teraterm/common/layer_for_unicode.cpp =================================================================== --- trunk/teraterm/common/layer_for_unicode.cpp 2020-01-30 23:42:44 UTC (rev 8517) +++ trunk/teraterm/common/layer_for_unicode.cpp 2020-01-30 23:42:47 UTC (rev 8518) @@ -318,3 +318,37 @@ free(itemA); return result; } + +int _AddFontResourceExW(LPCWSTR name, DWORD fl, PVOID res) +{ + if (pAddFontResourceExW != NULL) { + /* Windows 2000\x88ȍ~\x82͎g\x82\xA6\x82\xE9\x82͂\xB8 */ + return pAddFontResourceExW(name, fl, res); + } + return 0; +} + +BOOL _RemoveFontResourceExW(LPCWSTR name, DWORD fl, PVOID pdv) +{ + if (pRemoveFontResourceExW != NULL) { + /* Windows 2000\x88ȍ~\x82͎g\x82\xA6\x82\xE9\x82͂\xB8 */ + return pRemoveFontResourceExW(name, fl, pdv); + } + return FALSE; +} + +int _AddFontResourceW(LPCWSTR lpFileName) +{ + char *filenameA = ToCharW(lpFileName); + int result = AddFontResourceA(filenameA); + free(filenameA); + return result; +} + +BOOL _RemoveFontResourceW(LPCWSTR lpFileName) +{ + char *filenameA = ToCharW(lpFileName); + int result = RemoveFontResourceA(filenameA); + free(filenameA); + return result; +} Modified: trunk/teraterm/common/layer_for_unicode.h =================================================================== --- trunk/teraterm/common/layer_for_unicode.h 2020-01-30 23:42:44 UTC (rev 8517) +++ trunk/teraterm/common/layer_for_unicode.h 2020-01-30 23:42:47 UTC (rev 8518) @@ -56,6 +56,12 @@ BOOL _AppendMenuW(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); HWND _HtmlHelpW(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData); +// gdi32.lib +int _AddFontResourceW(LPCWSTR lpFileName); +BOOL _RemoveFontResourceW(LPCWSTR lpFileName); +int _AddFontResourceExW(LPCWSTR name, DWORD fl, PVOID res); +BOOL _RemoveFontResourceExW(LPCWSTR name, DWORD fl, PVOID pdv); + // Comctl32.lib HPROPSHEETPAGE _CreatePropertySheetPageW(LPCPROPSHEETPAGEW_V1 constPropSheetPagePointer); INT_PTR _PropertySheetW(PROPSHEETHEADERW *constPropSheetHeaderPointer); Modified: trunk/teraterm/teraterm/teraterm.cpp =================================================================== --- trunk/teraterm/teraterm/teraterm.cpp 2020-01-30 23:42:44 UTC (rev 8517) +++ trunk/teraterm/teraterm/teraterm.cpp 2020-01-30 23:42:47 UTC (rev 8518) @@ -59,6 +59,7 @@ #if UNICODE_INTERNAL_BUFF #include "sendmem.h" #endif +#include "layer_for_unicode.h" #if defined(_DEBUG) && defined(_MSC_VER) #define new ::new(_NORMAL_BLOCK, __FILE__, __LINE__) @@ -65,45 +66,46 @@ #endif static BOOL AddFontFlag; -static TCHAR TSpecialFont[MAX_PATH]; +static wchar_t TSpecialFont[MAX_PATH]; static CVTWindow* pVTWin; static void LoadSpecialFont() { - if (!IsExistFontA("Tera Special", SYMBOL_CHARSET, TRUE)) { - int r; + if (IsExistFontA("Tera Special", SYMBOL_CHARSET, TRUE)) { + // \x82\xB7\x82łɑ\xB6\x8D݂\xB7\x82\xE9\x82̂Ń\x8D\x81[\x83h\x82\xB5\x82Ȃ\xA2 + return; + } - if (GetModuleFileName(NULL, TSpecialFont,_countof(TSpecialFont)) == 0) { - AddFontFlag = FALSE; - return; - } - *_tcsrchr(TSpecialFont, _T('\\')) = 0; - _tcscat_s(TSpecialFont, _T("\\TSPECIAL1.TTF")); + if (GetModuleFileNameW(NULL, TSpecialFont, _countof(TSpecialFont)) == 0) { + AddFontFlag = FALSE; + return; + } + *wcsrchr(TSpecialFont, L'\\') = 0; + wcscat_s(TSpecialFont, L"\\TSPECIAL1.TTF"); - if (pAddFontResourceEx != NULL) { - // teraterm.exe\x82݂̂ŗL\x8C\xF8\x82ȃt\x83H\x83\x93\x83g\x82ƂȂ\xE9\x81B - // remove\x82\xB5\x82Ȃ\xAD\x82Ă\xE0\x8FI\x97\xB9\x82\xB7\x82\xE9\x82\xC6OS\x82\xA9\x82\xE7\x82Ȃ\xAD\x82Ȃ\xE9 - r = pAddFontResourceEx(TSpecialFont, FR_PRIVATE, NULL); - } else { - // \x83V\x83X\x83e\x83\x80\x91S\x91̂Ŏg\x82\xA6\x82\xE9\x83t\x83H\x83\x93\x83g\x82ƂȂ\xE9 - // remove\x82\xB5\x82Ȃ\xA2\x82\xC6OS\x82\xAA\x92͂񂾂܂܂ƂȂ\xE9 - r = AddFontResource(TSpecialFont); - } - if (r != 0) { - AddFontFlag = TRUE; - } + // teraterm.exe\x82݂̂ŗL\x8C\xF8\x82ȃt\x83H\x83\x93\x83g\x82ƂȂ\xE9\x81B + // remove\x82\xB5\x82Ȃ\xAD\x82Ă\xE0\x8FI\x97\xB9\x82\xB7\x82\xE9\x82\xC6OS\x82\xA9\x82\xE7\x82Ȃ\xAD\x82Ȃ\xE9 + int r = _AddFontResourceExW(TSpecialFont, FR_PRIVATE, NULL); + if (r == 0) { + // AddFontResourceEx() \x82\xAA\x8Eg\x82\xA6\x82Ȃ\xA9\x82\xC1\x82\xBD + // \x83V\x83X\x83e\x83\x80\x91S\x91̂Ŏg\x82\xA6\x82\xE9\x83t\x83H\x83\x93\x83g\x82ƂȂ\xE9 + // remove\x82\xB5\x82Ȃ\xA2\x82\xC6OS\x82\xAA\x92͂񂾂܂܂ƂȂ\xE9 + r = _AddFontResourceW(TSpecialFont); } + if (r != 0) { + AddFontFlag = TRUE; + } } static void UnloadSpecialFont() { - if (AddFontFlag) { - if (pRemoveFontResourceEx != NULL) { - pRemoveFontResourceEx(TSpecialFont, FR_PRIVATE, NULL); - } else { - RemoveFontResource(TSpecialFont); - } + if (!AddFontFlag) { + return; } + int r = _RemoveFontResourceExW(TSpecialFont, FR_PRIVATE, NULL); + if (r == 0) { + _RemoveFontResourceW(TSpecialFont); + } } static void init()