[Ttssh2-commit] [5166] logrotate マクロコマンドのサイズに、KB / MB指定をできるようにした。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2013年 3月 23日 (土) 20:04:58 JST


Revision: 5166
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5166
Author:   yutakapon
Date:     2013-03-23 20:04:58 +0900 (Sat, 23 Mar 2013)
Log Message:
-----------
logrotate マクロコマンドのサイズに、KB/MB指定をできるようにした。

Modified Paths:
--------------
    trunk/doc/en/html/macro/command/logrotate.html
    trunk/doc/ja/html/macro/command/logrotate.html
    trunk/teraterm/ttpmacro/ttl.c

-------------- next part --------------
Modified: trunk/doc/en/html/macro/command/logrotate.html
===================================================================
--- trunk/doc/en/html/macro/command/logrotate.html	2013-03-23 10:39:50 UTC (rev 5165)
+++ trunk/doc/en/html/macro/command/logrotate.html	2013-03-23 11:04:58 UTC (rev 5166)
@@ -18,7 +18,7 @@
 </p>
 
 <pre class="macro-syntax">
-logrotate 'size' &lt;size&gt;
+logrotate 'size' '&lt;size&gt;'
 logrotate 'rotate' &lt;count&gt;
 logrotate 'halt'
 </pre>
@@ -28,7 +28,9 @@
 <dl>
 	<dt class="macro">'size' &lt;size&gt;</dt>
 	<dd>When a log file size is over &lt;size&gt; byte, the log file is be rotated.<br>
-	    The &lt;size&gt; value must be larger than 128.</dd>
+	    The &lt;size&gt; value must be larger than 128.<br>
+	    If the &lt;size&gt; is followed by K, the size is assumed to be in kilobytes.
+	    If the M is used, the size is in megabytes.</dd>
 
 	<dt class="macro">'rotate' &lt;count&gt;</dt>
 	<dd>Log files are rotated &lt;count&gt; times before being removed.<br>
@@ -47,7 +49,7 @@
 logopen 'teraterm_sample.log' 0 0
 
 ; Start log rotation
-logrotate 'size' 2048
+logrotate 'size' '32K'
 logrotate 'rotate' 3
 
 pause 600

Modified: trunk/doc/ja/html/macro/command/logrotate.html
===================================================================
--- trunk/doc/ja/html/macro/command/logrotate.html	2013-03-23 10:39:50 UTC (rev 5165)
+++ trunk/doc/ja/html/macro/command/logrotate.html	2013-03-23 11:04:58 UTC (rev 5166)
@@ -18,7 +18,7 @@
 </p>
 
 <pre class="macro-syntax">
-logrotate 'size' &lt;size&gt;
+logrotate 'size' '&lt;size&gt;'
 logrotate 'rotate' &lt;count&gt;
 logrotate 'halt'
 </pre>
@@ -27,9 +27,10 @@
 <h2>\x83p\x83\x89\x83\x81\x81[\x83^</h2>
 
 <dl>
-	<dt class="macro">'size' &lt;size&gt;</dt>
+	<dt class="macro">'size' '&lt;size&gt;'</dt>
 	<dd>\x83\x8D\x83O\x82̃T\x83C\x83Y\x82\xAA&lt;size&gt;\x83o\x83C\x83g\x82𒴂\xA6\x82Ă\xA2\x82\xEA\x82΁A\x83\x8D\x81[\x83e\x81[\x83V\x83\x87\x83\x93\x82\xF0\x8Ds\x82\xA4\x81B<br>
-	    &lt;size&gt;\x82\xCD128\x88ȏ\xE3\x82ł\xA0\x82邱\x82ƁB</dd>
+	    &lt;size&gt;\x82\xCD128\x88ȏ\xE3\x82ł\xA0\x82邱\x82ƁB<br>
+	    \x96\x96\x94\xF6\x82\xC9"K"\x82\xAA\x82\xA0\x82\xE9\x82ƃL\x83\x8D\x83o\x83C\x83g\x92P\x88ʁA"M"\x82\xAA\x82\xA0\x82\xE9\x82ƃ\x81\x83K\x83o\x83C\x83g\x92P\x88ʂɂȂ\xE9\x81B</dd>
 
 	<dt class="macro">'rotate' &lt;count&gt;</dt>
 	<dd>\x83\x8D\x83O\x83t\x83@\x83C\x83\x8B\x82̐\xA2\x91\xE3\x82\xF0&lt;count&gt;\x82ɂ\xB7\x82\xE9\x81B<br>
@@ -49,7 +50,7 @@
 logopen 'teraterm_sample.log' 0 0
 
 ; Start log rotation
-logrotate 'size' 2048
+logrotate 'size' '32K'
 logrotate 'rotate' 3
 
 pause 600

Modified: trunk/teraterm/ttpmacro/ttl.c
===================================================================
--- trunk/teraterm/ttpmacro/ttl.c	2013-03-23 10:39:50 UTC (rev 5165)
+++ trunk/teraterm/ttpmacro/ttl.c	2013-03-23 11:04:58 UTC (rev 5166)
@@ -2871,8 +2871,9 @@
 {
 	WORD Err;
 	char Str[MaxStrLen];
+	char Str2[MaxStrLen];
 	char buf[MaxStrLen*2];
-	int size, num;
+	int size, num, len;
 
 	Err = 0;
 	GetStrVal(Str, &Err);
@@ -2885,7 +2886,23 @@
 		if (CheckParameterGiven()) {
 			Err = 0;
 			size = 0;
-			GetIntVal(&size, &Err);
+			GetStrVal(Str2, &Err);
+			if (Err == 0) {
+				len = strlen(Str2);
+				if (isdigit(Str2[len-1])) {
+					num = 1;
+				} else if (Str2[len-1] == 'K') {
+					Str2[len-1] = 0;
+					num = 1024;
+				} else if (Str2[len-1] == 'M') {
+					Str2[len-1] = 0;
+					num = 1024*1024;
+				} else {
+					Err = ErrSyntax;
+				}
+				size = atoi(Str2) * num;
+			}
+
 			if (size < 128)
 				Err = ErrSyntax;
 			if (Err == 0)



Ttssh2-commit メーリングリストの案内
Back to archive index