ホーム » 2017 (ページ 3)

年別アーカイブ: 2017

2024年5月
 1234
567891011
12131415161718
19202122232425
262728293031  

カテゴリー

アーカイブ

ブログ統計情報

  • 82,382 アクセス


DS115j std::tostringstream

DS115j で,次の様なコードの str が “123” にならない(”0″ になる).


 {
   double checkValue = 123 ;
   tstring str ;
   std::tostringstream strBuf ;
   {
     strBuf << checkValue ;
     str = strBuf.str() ;
     }
   // …
   }


sprintf を利用することで対応.
 {
   std::string str ;
   tstring fmt = _T(“%.”) + ::To_tstring(p) + _T(“f”) ;
   str.resize(512,0) ;
   sprintf(&str[0],fmt.c_str(),v) ;
   // …
   }

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

文字列の連結

C++ tstring  strS = str1 + str2 ;
CString strM = str3 + str4 ;
JavaScript var str = str1 + str2 ;
VBScript Dim str As String
str = str1 & str2
PHP $str = $str1 . $str2 ;
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

DS115j Web での日本語

DS115j の標準出力をブラウザで表示すると,日本語部分が表示できない.


コードはこんな感じ.

  #include	"i_DrawLg.hxx"
  #include	<iostream>
  int	_tmain	(int argc,TCHAR* argv[])
  {
	_tsetlocale(LC_ALL,_T("")) ;
	tstring	orgCode1 = _T("ostrstream-%E3%81%AE%E5%88%A9%E7%94%A8%E3%81%A7%E3%83%A1%E3%83%A2%E3%83%AA%E3%83%AA%E3%83%BC%E3%82%AF/") ;
	tstring	orgCode2 = _T("url=http%3A%2F%2Fiwao.synology.me%2Fwordpress%2Fdev%2F2011%2F12%2F01%2Fvirtual-pc-%25E3%2581%258C%25E9%2581%2585%25E3%2581%2584%2F&usg=AFQ") ;
	tstring	deco_1_1 = ::PL_Decode_url(orgCode1) ;
	tstring	deco_2_1 = ::PL_Decode_url(orgCode2) ;
	tstring	deco_1_2 = ::PL_Decode_url(deco_1_1) ;
	tstring	deco_2_2 = ::PL_Decode_url(deco_2_1) ;
	std::tout <<    tstring(orgCode1.c_str()) << std::endl ;
	std::tout <<  ::UTF8_To(deco_1_1.c_str()) << std::endl ;
	std::tout <<  ::UTF8_To(deco_1_2.c_str()) << std::endl ;
	std::tout <<    tstring(orgCode2.c_str()) << std::endl ;
	std::tout <<  ::UTF8_To(deco_2_1.c_str()) << std::endl ;
	std::tout <<  ::UTF8_To(deco_2_2.c_str()) << std::endl ;
	return	0 ;
	}

コンソールでの出力 Iwao@DS115j:~/www/T_php/temp/test/DecodeU$ Iwao@DS115j:~/www/T_php/temp/test/DecodeU$ php index.php <pre> ostrstream-%E3%81%AE%E5%88%A9%E7%94%A8%E3%81%A7%E3%83%A1%E3%83%A2%E3%83%AA%E3%83%AA%E3%83%BC%E3%82%AF/ ostrstream-の利用でメモリリーク/ ostrstream-の利用でメモリリーク/ url=http%3A%2F%2Fiwao.synology.me%2Fwordpress%2Fdev%2F2011%2F12%2F01%2Fvirtual-pc-%25E3%2581%258C%25E9%2581%2585%25E3%2581%2584%2F&usg=AFQ url=http://iwao.synology.me/wordpress/dev/2011/12/01/virtual-pc-%E3%81%8C%E9%81%85%E3%81%84/&usg=AFQ url=http://iwao.synology.me/wordpress/dev/2011/12/01/virtual-pc-が遅い/&usg=AFQ </pre> Iwao@DS115j:~/www/T_php/temp/test/DecodeU$
ブラウザでの出力 ostrstream-%E3%81%AE%E5%88%A9%E7%94%A8%E3%81%A7%E3%83%A1%E3%83%A2%E3%83%AA%E3%83%AA%E3%83%BC%E3%82%AF/ ostrstream- ostrstream- url=http%3A%2F%2Fiwao.synology.me%2Fwordpress%2Fdev%2F2011%2F12%2F01%2Fvirtual-pc-%25E3%2581%258C%25E9%2581%2585%25E3%2581%2584%2F&usg=AFQ url=http://iwao.synology.me/wordpress/dev/2011/12/01/virtual-pc-%E3%81%8C%E9%81%85%E3%81%84/&usg=AFQ url=http://iwao.synology.me/wordpress/dev/2011/12/01/virtual-pc-

どこかの設定の問題とは思うが,場所がわからない.
それとも,変換がかかる部分を NOP とすべきか?


2017/06/02
Linux の場合 UTF8 となっていると思うので,::UTF8_To をしなくても良いはず.
Windows の場合は,tstring への変換(UTF8 から S-JIS または UTF16)が必要.
UTF8_To を _MSC_VER で振り分ける様に修正.


と思ってやって,上のコードではクリアしたが,
他にもうまくないコードがある様で,drawlog.htm が途中で切れている.
(/tmp/…/i_Tools.tmp/…/dump.txt は意図したデータで出力されている)


html 出力 (HtmOut::Export) の ::SaveUTF8 から呼んでいる ::To_UTF8 も同様に修正.
Windows の場合は,tstring (S-JIS または UTF16)から UTF8 の変換が必要.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

php post , get の全ての引数を取得

$_REQUEST , $_GET など.

function  get_request_str () {
  $req ;
  foreach ($_REQUEST as $key => $value) {
   $req = $req . "$key=$value" . " " ;
   }
  return $req ;
  }
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Synology g++ DrawLog.cpp

前回 mac 上で動作する様にしたものを DS115j に.
CPATH などの設定も mac と同じ様な感じで指定.


php から呼び出し,実行ファイルが起動していることは確認できていた.
 DSM の「リソース モニタ」-「プロセス」で確認.
が,結果が正しく表示されない.
ssh で接続しての起動では正しく動作している.
原因は,デバッグ用にデータをダンプしていたディレクトリのアクセス権の設定.
書き込み可能にして OK

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

HVL-S3 追加

HVL-S3 を追加.本当は HVL-DR が欲しかったが,ちょっと高いので…


HDL-AHW を持っているので,「DiXiM Digital TV plus for I-O DATA」で再生.
  この AP が不安定なのは AHW と同様だが,他は特に問題ない.
AHW からの「コンテンツの操作」は他の機器と同様.

HVL-S での「コンテンツの操作」の「他から…」はできないみたい.
  コンテンツのチェック欄がない.
  「持ち出せる番組」にあるものはチェック欄がある.


2017/06/06
Z2 などでの再生は OK .
REC-ON HVTR-BCTX3 付属のテレキングプレイでは再生できないみたい.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

g++ DrawLog.cpp

今まで xcode を利用していたが,他の PC からビルドするために…


コードは次の様なもの.ほとんどの動作はi_DrawLG.hxx 内に.
 // カレントのファイルを成型してファイルに出力
 #include “i_DrawLg.hxx”
 #include <iostream>
 int _tmain (int argc,TCHAR* argv[])
 {
   _tsetlocale(LC_ALL,_T(“”)) ;
   {
    std::tout << ::GetCWD() << std::endl ;
    }
   tstring logPath = _T("./") ;
   #ifdef _WIN32
     logPath = ::Get_i_Tools_tmp() ;
   #endif
   ::PL_DrawLog(logPath) ;
   return 0 ;
   }
 //———————–
 #include "MessBar.cxx"


次の様に -I で指定すれば,include が機能するのは知っていたが…
 g++ DrawLog.cpp -I/Users/…/__CPR_ -I/Users/…/__Iwao
環境変数を利用する様に
 export CPATH=/Users/…/__CPR_
 export CPATH=/Users/…/__Iwao:$CPATH
これらをスクリプトファイルに登録.
 呼出し元にも反映させるには bash env.sh ではなく
  source env.sh とする必要があるらしい.
sh ファイルを MIFES で編集していて,微妙にうまく動作していない.
 原因は改行コードで,「LF」で保存.
これで g++ DrawLog.cpp としてビルドできる様になった.


実行すると,Segmentation fault: 11.
xcode でもテストしてなかったのでデバッグすると,
 readdir で EXC_BAD_ACCESS .
ここは _WIN32 では通らないのでデバッグが不十分な部分.
 原因は,与えているファイルが
  ディレクトリでなかった.
  ファイルが存在していなかったこと.
コードを修正して OK .

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Synology NAS で gcc

2022/06
https://dev.mish.work/wordpress/2022/06/15/ds116-entware/


2022/03
https://dev.mish.work/wordpress/2022/03/13/ds220-setup-4-opkg/


ssh などで接続した DS115j 上で, gcc などを使える様にするために…
ipkg や Opkg が必要らしい.
Install on Synology NAS
日本語で説明されている所があったので,参考にさせてもらった.
 2016/06/29 Synology DS216j Entware-ng 導入


g++ でコンパイルして ./a.out を生成.
exec.php を開くと,
php から a.out の呼び出し


ASUSTOR NAS
QNAP NAS

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Web + exe

最終的に目指したい所は,
IIS+PHP 環境で exe を呼び出し
参考にさせてもらったのは,
第3回 極めてシンプルなCGIを体験する.


C:\...\Iwao>"C:\...\testCGI2\DmpSVG.exe"
Content-Type: text/html
 
<?xml version="1.0" encoding="UTF-8"?>
<svg  xmlns="http://www.w3.org/2000/svg"  >
    <rect x="15" y="10" width="70" height="40" stroke="blue" fill="white" />
    </svg>
 
C:\...\Iwao>

mac で,
先ず,php から ls の呼び出し.
exec_ls.php

 <?php
  system('ls') ;

ターミナルで実行(php exec_ls.php)すると,
ターミナルで php exec_ls.php
php から a.out の呼び出し.
main.cpp

 #include <iostream>
 int main() {
  	std::cout  <<  "hello c++ php"  <<  std::endl ;
  	return 0 ;
  	}

g++ main.cpp としてコンパイル.
exec.php
 <?php
  system('./a.out') ;

ターミナルで php から a.out の呼び出し
ターミナルから php -S 127.0.0.1:8000 などとしておくと,
php から a.out の呼び出し


DS115j で,
php から ls の呼び出しまでは同様.
Iwao@DS115j:~/www/T_php/temp/test$
Iwao@DS115j:~/www/T_php/temp/test$ ls
exec_ls.php index.php main.cpp
Iwao@DS115j:~/www/T_php/temp/test$
Iwao@DS115j:~/www/T_php/temp/test$ php exec_ls.php
exec_ls.php
index.php
main.cpp
Iwao@DS115j:~/www/T_php/temp/test$
Iwao@DS115j:~/www/T_php/temp/test$

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Synology php

PHP 5.6 7.0
itl.mydns.jp/I****/phpinfo.php 5.6.30 7.0.16
itl.mydns.jp/~I***/phpinfo.php 5.6.30 5.6.30
itl.mydns.jp/~i_**/phpinfo.php  500  500
php -v 5.6.11 5.6.11
mac php -v 5.5.38
_SERVER[“SERVER_SOFTWARE”] 2.2 2.4 Nginx
itl.mydns.jp/I****/phpinfo.php 2.2.31 2.4.25 1.11.10
itl.mydns.jp/~I***/phpinfo.php 2.2.32 2.2.31 2.2.31
mac httpd -v 2.4.18
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

T5400 が…

離れていて戻ってくると T5400 が,

DSC_0192

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

PHP が動かなくなっている

Synology のパーソナルウェブサイトで PHP が動かなくなった?

先日までは動作していたと思う.
アップデートで設定が変わってしまったのか?


2017/05/10
DSM と Web Station のアップデートがあったので更新したら直った?

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

3D Builder 0x80510018

データにより,3D Builder の読込で 0x80510018 エラーに.

以前の 3mf 出力では,テクスチャファイル名を数字と ‘_’ にしていたが,
 先日他の 3D 形式の関係で,7 bit の文字の範囲に変更した.
どうもこれがいけなかったみたいで,
 3mf で出力する時は,newName.Format(_T(“Tex_%03d.png”),tIndex+1) に修正.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Synology NAS で CGI

今度は,CGI.
以前少しやってみたが,500 Internal Server Error となりそのままとなっていた.


cgi の先頭行の指定が怪しいと察しはついていたので検索すると,
通常は「#!/usr/bin/perl」か「#!/usr/local/bin/perl」とのこと.
それぞれのフォルダを見ると,
Iwao@DS115j:/usr/bin$
Iwao@DS115j:/usr/bin$ ls pe*
perl perror
Iwao@DS115j:/usr/bin$
Iwao@DS115j:/usr/bin$ cd /usr/local/bin/
Iwao@DS115j:/usr/local/bin$
Iwao@DS115j:/usr/local/bin$ ls pe*
perl perl5.24.0 perlbug perldoc perlivp perlthanks
Iwao@DS115j:/usr/local/bin$


さらに検索すると,改行の問題とのこと.
「#!/usr/bin/perl –」の様に後ろに “–” を付ければ良いらしい.
または,’LF’ にすれば良いみたい.
‘CR’ として試すと,”–” の有無に関係なく 502 Bad Gateway となってしまう.
また文字コードは,UTF-8 などを使用すると思うが,「BOM なし」の必要がある.


2021/01/03
SVG を出力するコード.

#!/usr/bin/perl --

print	"Content-type: text/html\n";
print	"\n";
print	"<!DOCTYPE html>\n";
print	"<html>\n";
print	"<head>\n";
print	"	<meta charset=\"utf-8\">\n";
print	"	<title>SVG</title>\n";
print	"	</head>\n";
print	"<body>\n";
print	"	<svg  viewBox=\"0 0 100 100 \"  xmlns=\"http://www.w3.org/2000/svg\" >\n";
print	"		<rect x=\"15\" y=\"10\" width=\"70\" height=\"40\" stroke=\"blue\" fill=\"white\" />\n";
print	"		</svg>\n";
print	"	</body>\n";
print	"</html>\n";

cgi draw_rect svg
/i_Tools/…/cgi/drawrect.cgi


更に cpp として書いたコード.
g++ drawrect.cpp として出来上がった a.out を rect_cpp.cgi としてコピー.
drawrect.cpp
/i_Tools/…/cgi/rect_cpp.cgi


https://jml.mish.work/index.php/various/nas/synology-nas.html

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Synology PHP データ保存

ログを保存するコードで,
Warning: fopen(/…/Log/20170412.txt):
failed to open stream:
Permission denied in /…/log.php on line 24


どこの設定が影響しているのかが不明だが,
//itl.mydns.jp/3D_Data/ は OK .
//itl.mydns.jp/~i_Tools/ はうまく動作しない.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

現在の時刻を文字列に

C++
 time_t tim_v = ::time(NULL) ;
 struct stm = ::localtime(&tim_v) ;
 tstring buff ;
 size_t size = 255 ;
 buff.resize(size+1,0) ;
 ::_tcsftime(&buff[0],size,_T(“%Y/%m/%d %H:%M:%S”),&stm) ;
 tstring str = buff.c_str() ;

MFC
 CString str = CTime::GetCurrentTime().Format(_T(“%Y/%m/%d %H:%M:%S”)) ;

JavaScript
 var time = new Date() ;
 var y_ = time.getFullYear() ;
 var m_ = time.getMonth() + 1 ;
 var d_ = time.getDate() ;
 var hh = time.getHours() ;
 var mm = time.getMinutes() ;
 var ss = time.getSeconds() ;
 var str= (y_+”/”+m_+”/”+d_+” “+hh+”:”+mm+”:”+ss) ;

PHP
 date_default_timezone_set(‘Asia/Tokyo’) ;
 $str = date(“Y/m/d H:i:s”) ;

timefmt.hxx

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

コンソール AP で MFC

コンソール AP で,MFC(AfxWin.h など)に依存したコードを利用


新しく書いたものは,次の様なコードで可能.

  #include	"EnhMetaF.hxx"
  #include	"i_trace.hxx"
  
  int _tmain(int argc, TCHAR* argv[])
  {
    	_tsetlocale(LC_ALL,_T("")) ;
    	{
      		EnhMetaF	emf ;
      		CMetaFileDC*	mfdc = emf.GetDC() ;
      		mfdc->Rectangle(10,10,30,20) ;
    		}
    	return 0 ;
    	}

古いコードは,うまく対応できてないので…

  #undef  	_CONSOLE
  #include	<AfxWin.h>
  #include	<AfxExt.h>
  #include	<AfxCmn.h>
  #ifdef	_WIN32
  #define  	_WINDOWS
  #endif
  #include	"MessCon.hxx"
  #include	"MessBar.hxx"
  #ifdef	MessageBar
    #undef	MessageBar
    #define	MessageBar	MessageCon
    #undef	I_SUPPORT_MESSAGE_MFC
  #endif
  #include	"MessWrap.hxx"
  // ...
  int _tmain(int argc, TCHAR* argv[])
  {
    	#ifdef	_MFC_VER
    	if (!::AfxWinInit(::GetModuleHandle(NULL),NULL,::GetCommandLine(),0)) {
      		return	1 ;
      		}
    	#else
    	_tsetlocale(LC_ALL,_T("")) ;
    	#endif
    //	...
    	}

undef の幾つかは,自コードの対応のために必要.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

ubuntu 環境の再設定

mac 上の仮想マシンに入れた ubuntu
暫く使ってなかったので,LAN 環境などが当時の古いまま.
ubuntu は昨日更新して 16.04 LTS .
外にアクセスするルートは DHCP が使えるが,もう一つの LAN はDHCP サーバがない.
Win PC や mac からは特に問題なく使えてたが,ubuntu は安定しない?
IP を固定することで対応.
「接続を編集する…」-「編集」-「IPv4設定」で,169.254.xx.xx ,255.255.0.0 と指定.


WSS,WD Cloud,DS115j などにアクセス可能となった.
IIS など Web サーバは,IP でないと接続できないものもあり.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Xcode include

MFC や Windows に依存しないコードのテスト.
今 mac に入っているのは,Xcode Version 6.4.


Project Navigator で,対象のプロジェクトを選択.
検索の所に Search と入力して絞り込み.
Header Search Paths の /Applications/… となっている所をダブルクリック.
「+」で,/Users/Iwao/Public/Dropbox/Develop/_.SRC/__CPR_ などを追加.


VC では,「アクティブプロジェクトに設定」や「スタートアッププロジェクトの設定」にあたるもの.
ビルドや実行対象の変更は,メニューの「Product」-「Scheme」にある.
 以前と変わった?

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

EnumFilesTree で無限ループ

フォルダ以下の全てのファイルを列挙する関数

v_tstring	EnumFilesTree	(LPCTSTR path)
{
	v_tstring	foundFiles = ::EnumFiles(path) ;
	v_tstring	foundFolds = ::ExtractFolders(foundFiles) ;
	for (size_t index=0 ; index<foundFolds.size() ; index++) {
		tstring		subFold = foundFolds[index] ;
		v_tstring	chFiles = ::EnumFiles(subFold.c_str()) ;
		v_tstring	chFolds = ::ExtractFolders(chFiles) ;
		foundFolds.insert(foundFolds.end(),chFolds.begin(),chFolds.end()) ;
		foundFiles.insert(foundFiles.end(),chFiles.begin(),chFiles.end()) ;
		}
	return	foundFiles ;
	}

今まで特に問題なく動作していたが,
先週末 VC 14 i3DV のデバッグ版を実行すると無限ループに.
Release 版や,VC 12 のデバッグ版などでは OK .


昨日は,別の PC 環境だったため再現せず.


今日デバッガを使用して調査すると,
 フォルダの「作成日時」が正しくない.
 /wordpress/dev/2016/09/15/
そのため,_wstat64 が正しく帰ってこない.


v_tstring	EnumFiles	(LPCTSTR path_,const bool skipDot=true)
{
	tstring	path = ::Path_DelLastSP(path_) ;
	if (!File_IsDirectory(path.c_str()))	{
		path = ::Path_GetDir(path) ;
		}
	v_tstring	foundFiles ;
	#if		defined	__GNUC__
		foundFiles = ::EnumFiles_GNUC	(path,skipDot) ;
	#elif	defined	_MFC_VER
		foundFiles = ::EnumFiles_MFC	(path,skipDot) ;
	#elif	defined	_MSC_VER
		foundFiles = ::EnumFiles_MSC	(path,skipDot) ;
	#endif
	return	foundFiles ;
	}

ここの,File_IsDirectory(…) で,stat を利用している.


次の様に ::GetFileAttributes(…) の判断を追加.

	if (!::File_IsDirectory(path.c_str()))	{
		#if	(_MSC_VER == 1900)
		{
			if (!::FA_Is_Directory(path)) {
				path = ::Path_GetDir(path) ;
				}
			}
		#else
		{
			path = ::Path_GetDir(path) ;
			}
		#endif
		}

enumfile.hxx

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.