• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得windowscocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

oga's tools


Commit MetaInfo

Revision050f74886b78aa8d0f2ed65901dbfb305d65aefe (tree)
Zeit2019-06-09 15:51:39
Autoroga <hyperoga@gmai...>
Commiteroga

Log Message

Merge branch 'master' of git.pf.sourceforge.jp:/gitroot/h/hy/hyperoga/ogatool

Conflicts:
cal.c

V1.92+V1.92->V1.93

Ändern Zusammenfassung

Diff

--- a/Makefile.win_mingw
+++ b/Makefile.win_mingw
@@ -51,9 +51,10 @@ TARGETS = $(VP)/age.exe $(VP)/cal.exe $(VP)/cgrep.exe $(VP)/csv2nocr.exe \
5151 $(VP)/midana.exe $(VP)/lanck.exe $(VP)/sysinfdsrv.exe $(VP)/findwin.exe \
5252 $(VP)/getsysm.exe $(VP)/midiapi.exe $(VP)/play.exe $(VP)/sendevt.exe \
5353 $(VP)/shutdown.exe $(VP)/sysperf.exe $(VP)/winmidisample.exe \
54- $(VP)/dgclient.exe $(VP)/dgserver.exe
54+ $(VP)/dgclient.exe $(VP)/dgserver.exe $(VP)/netpf.exe \
55+ $(VP)/netpf_send.exe
5556
56-TARGETS_MS = $(VP)/cpuid.exe $(VP)/ctrain.exe $(VP)/df.exe $(VP)/lsc.exe $(VP)/miscclient.exe $(VP)/miscserver.exe $(VP)/netpf.exe $(VP)/sndtimer.exe $(VP)/sysinfd.exe $(VP)/regsv.exe $(VP)/sysinfd_win.exe $(VP)/pcap_test.exe $(VP)/joytest.exe $(VP)/icmpsnd.exe $(VP)/getver.exe $(VP)/dxshow.exe $(VP)/clip.exe $(VP)/readevt.exe $(VP)/midic.exe
57+TARGETS_MS = $(VP)/cpuid.exe $(VP)/ctrain.exe $(VP)/df.exe $(VP)/lsc.exe $(VP)/miscclient.exe $(VP)/miscserver.exe $(VP)/sndtimer.exe $(VP)/sysinfd.exe $(VP)/regsv.exe $(VP)/sysinfd_win.exe $(VP)/pcap_test.exe $(VP)/joytest.exe $(VP)/icmpsnd.exe $(VP)/getver.exe $(VP)/dxshow.exe $(VP)/clip.exe $(VP)/readevt.exe $(VP)/midic.exe
5758
5859 all: $(TARGETS)
5960
@@ -210,6 +211,9 @@ $(VP)/mkindex.exe : mkindex.c
210211 $(VP)/netpf.exe : netpf.c
211212 $(CC) $? $(NOLOGO) -o $@ -DDOS
212213
214+$(VP)/netpf_send.exe : netpf_send.c
215+ $(CC) $? $(NOLOGO) -o $@ -DDOS
216+
213217 $(VP)/othello2.exe : othello2.c
214218 $(CC) $? $(NOLOGO) -o $@
215219
--- a/Makefile.win_vc6
+++ b/Makefile.win_vc6
@@ -19,8 +19,10 @@ CPP = cl
1919 NOLOGO = -nologo
2020 OOPT = /O2
2121 MTOPT = /MT
22-PSDKLIB=C:\MSPlatformSDK\Lib
23-PSDKINC=C:\MSPlatformSDK\Include
22+#PSDKLIB=C:\MSPlatformSDK\Lib
23+#PSDKINC=C:\MSPlatformSDK\Include
24+PSDKLIB=C:\MSPSDK\Lib
25+PSDKINC=C:\MSPSDK\Include
2426 DXSDKINC=C:\DirectXSDK_June2010\Include
2527
2628 #XLIB = -L/usr/X11R6/lib
--- a/cal.c
+++ b/cal.c
@@ -18,7 +18,8 @@
1818 * 2014.02.11 V1.86 support NT cmmand prompt
1919 * 2014.11.03 V1.90 support variable holiday
2020 * 2014.11.03 V1.91 fix NT usage color
21- * 2019.06.09 V1.92 append new birthday of tennou (2/23)
21+ * 2015.04.13 V1.92 fix continuation substitute holiday, add -holidump
22+ * 2019.06.09 V1.93 append new birthday of tennou (2/23)
2223 *
2324 * X68000 : default
2425 * HI-UX : -DX_H3050R -D_HIUX_SOURCE
@@ -53,7 +54,7 @@
5354 #include <time.h>
5455 #endif
5556
56-#define VER "1.92"
57+#define VER "1.93"
5758 #define MAX_ENT 2000
5859
5960 #ifdef DOS
@@ -75,6 +76,7 @@ void add_holiday(); /* V1.90-A */
7576 void adjust_holiday(); /* V1.90-A */
7677 void backup_color(); /* V1.91-A */
7778 void restore_color(); /* V1.91-A */
79+void dump_holiday(); /* V1.92-A */
7880
7981 #if defined(X_H3050R) || defined(DOS) || defined(LINUX)
8082 int _iocs_bindateget();
@@ -108,6 +110,8 @@ int holi[MAX_ENT*3]; /* holiday table V1.90-C */
108110 * 月,日,適用開始年,適用終了年,第n,曜日(1:月曜)
109111 *
110112 * (注)国民の祝日の制定は1948/7/20施行
113+ * 固定休日は第n, 曜日は0,0
114+ * 複雑な計算の春分の日、秋分の日はadjust_holiday()内で設定
111115 */
112116 holidat_t new_holi[] = {
113117 1, 1, 1949, 9999, 0, 0, /* 元日 固定(1949-) */
@@ -116,9 +120,9 @@ holidat_t new_holi[] = {
116120 1, 15, 2000, 9999, 2, 1, /* 成人の日 2000年からHappyMonday適用 */
117121
118122 2, 11, 1967, 9999, 0, 0, /* 建国記念の日 固定(1967-) */
119- 2, 23, 2020, 9999, 0, 0, /* 天皇誕生日3 固定(2020-) 令和 */
123+ 2, 23, 2020, 9999, 0, 0, /* 天皇誕生日3 固定(2020-) 令和 V1.93-A */
120124
121- /* 天皇誕生日1(1949-1988), 緑の日(1989-2006) 昭和の日(2007-) */
125+ /* 天皇誕生日1(1949-1988), 緑の日(1989-2006) 昭和の日(2007-) */
122126 4, 29, 1949, 9999, 0, 0, /* 昭和の日 固定(1949-) */
123127
124128 5, 3, 1949, 9999, 0, 0, /* 憲法記念日 固定(1949-) */
@@ -142,7 +146,7 @@ holidat_t new_holi[] = {
142146
143147 11, 23, 1948, 9999, 0, 0, /* 勤労感謝の日 固定(1948-) */
144148
145- 12, 23, 1989, 2018, 0, 0 /* 天皇誕生日2 固定(1989-2018) 平成 */
149+ 12, 23, 1989, 2018, 0, 0 /* 天皇誕生日2 固定(1989-2018) 平成 V1.93-C */
146150 };
147151 /* V1.90-A end */
148152
@@ -186,6 +190,8 @@ char *b[];
186190 {
187191 int year = 0, month = 0, cur_flg = 0;
188192 int xdate;
193+ int hdf = 0; /* holiday dump (secret opt) V1.92-A */
194+ int shift = 0; /* shift arg V1.92-A */
189195 char *dt=(char *)&xdate;
190196
191197 backup_color(); /* for dos V1.91-A */
@@ -195,6 +201,13 @@ char *b[];
195201 exit(1);
196202 }
197203
204+ /* V1.92-A start */
205+ if (a > 1 && strcmp(b[1],"-holidump") == 0) {
206+ /* usage: cal -holidump [[month] year] */
207+ hdf = 1;
208+ }
209+ /* V1.92-A end */
210+
198211 #ifdef X_H3050R
199212 if (getenv("COLORCAL") != 0) { /* for 3050RX */
200213 blue = "";
@@ -210,6 +223,14 @@ char *b[];
210223 }
211224
212225 xdate = _iocs_bindateget(); /* get date */
226+
227+ /* V1.92-A start */
228+ if (hdf) {
229+ --a; /* shift argc */
230+ shift = 1; /* shift pos */
231+ }
232+ /* V1.92-A start */
233+
213234 switch (a) {
214235 case 1:
215236 year = bcd2bin(dt[1])+1980; /* day:year:month:date */
@@ -217,11 +238,11 @@ char *b[];
217238 cur_flg = 1; /* today's year & month */
218239 break;
219240 case 2:
220- year = atoi(b[1]);
241+ year = atoi(b[1+shift]);
221242 break;
222243 case 3:
223- month = atoi(b[1]);
224- year = atoi(b[2]);
244+ month = atoi(b[1+shift]);
245+ year = atoi(b[2+shift]);
225246 break;
226247 }
227248 if (year < 1) {
@@ -238,6 +259,14 @@ char *b[];
238259 memset(holi, 0, sizeof(holi)); /* V1.90-A */
239260
240261 adjust_holiday(year); /* adjust holiday V1.90-A */
262+
263+ /* V1.92-A start */
264+ if (hdf) {
265+ dump_holiday(year); /* dump holiday */
266+ return 0;
267+ }
268+ /* V1.92-A end */
269+
241270 get_holiday(); /* read holiday file V1.90-M */
242271
243272 if (month == 0) {
@@ -247,8 +276,33 @@ char *b[];
247276 }
248277
249278 restore_color(); /* V1.91-C */
279+
280+ return 0; /* V1.92-A */
250281 }
251282
283+/* V1.92-A start */
284+/*
285+ * dump holiday table
286+ * note: call after adjust_holiday()
287+ *
288+ */
289+void dump_holiday(yy)
290+int yy;
291+{
292+ int i = 0;
293+
294+ printf("Year %d's holiday\n", yy);
295+
296+ /* search holiday */
297+ while (holi[i*3+2]) {
298+ printf("%4d/%2d/%2d\n", yy, holi[i*3+1], holi[i*3+2]);
299+ ++i;
300+ }
301+
302+}
303+/* V1.92-A end */
304+
305+
252306 /* V1.90-A start */
253307 /*
254308 * add to holiday table
@@ -441,7 +495,8 @@ int year;
441495 wk = d[l*7+j][i*6+k];
442496 you = j;
443497 if (chk_holiday(year,month,wk)>0 || furikae > 0) {
444- if (furikae > 0) {
498+ /* if (furikae > 0) V1.92-D */
499+ if (!chk_holiday(year,month,wk) && furikae > 0) { /* V1.92-C */
445500 furikae--;
446501 }
447502 you = 0; /* 休日 */
@@ -514,8 +569,10 @@ int year,month,cur_flg,day;
514569 wk = d[((month-1)%3)*7+j][((month-1)/3)*6+k];
515570 you = j;
516571 if (chk_holiday(year,month,wk) || furikae > 0) {
517- if (furikae > 0)
572+ /* if (furikae > 0) V1.92-D */
573+ if (!chk_holiday(year,month,wk) && furikae > 0) { /* V1.92-C */
518574 furikae--;
575+ }
519576 you = 0; /* 休日(黄色) */
520577 if (j == 0) {
521578 furikae = 1;
@@ -583,7 +640,7 @@ int year;
583640 (year % 100 != 0 || year % 400 == 0) ) {
584641 r = 365*(year-1) + m2[month-1] ; /* うるう年 */
585642 m0=m2[month]-m2[month-1]; /* 月の最後の日 */
586- holi[14] = 20; /* V1.8 春分の日:3/20 */
643+ /* holi[14] = 20; V1.92-D */ /* V1.8 春分の日:3/20 */
587644 } else {
588645 r = 365*(year-1) + m1[month-1];
589646 m0=m1[month]-m1[month-1]; /* 月の最後の日 */
--- /dev/null
+++ b/netpf_send.c
@@ -0,0 +1,481 @@
1+/*
2+ * netpf_send.c
3+ *
4+ * network性能測定 (send only.)
5+ *
6+ * 98/04/22 V1.00 by oga.
7+ * 99/08/20 V1.01 add verbose mode
8+ * 01/02/17 V1.011 GetSystemTime => GetLocalTime
9+ * 03/06/07 V1.02 diff 0 対策
10+ * -------------------------------
11+ * 16/01/14 V1.03 netpf.c => netpf_send.c
12+ * 16/01/19 V1.04 add shutdown for win 10054 error
13+ */
14+#include <stdio.h>
15+#include <stdlib.h>
16+#include <string.h>
17+#include <errno.h>
18+
19+#ifdef DOS
20+#include <windows.h>
21+#include <winsock.h>
22+#else /* DOS */
23+#include <sys/types.h>
24+#include <sys/socket.h>
25+#include <sys/time.h>
26+#include <unistd.h>
27+#include <netinet/in.h>
28+#include <arpa/inet.h>
29+#include <netdb.h>
30+#include <fcntl.h>
31+#include <signal.h>
32+#endif /* DOS */
33+
34+#define VER "1.04"
35+#define LOOP 3
36+#define dprintf
37+#define SEND_SIZE (1024*1024*10) /* default: 10MB */
38+
39+#ifndef SHUT_RDWR
40+#define SHUT_RDWR SD_BOTH
41+#endif
42+
43+#ifndef SD_BOTH
44+#define SD_BOTH 0x02
45+#endif
46+
47+void PUT_DATA(int, char *, int);
48+void GET_DATA(int, char *, int);
49+void reapchild();
50+void memdump(FILE *, unsigned char *, int);
51+
52+int send_size = SEND_SIZE; /* default: 10MB */
53+int vf = 0; /* verbose */
54+
55+#ifdef DOS
56+/*
57+struct timeval {
58+ u_int tv_sec;
59+ u_int tv_usec;
60+};
61+*/
62+
63+int gettimeofday(struct timeval *tv, void *tz);
64+#endif
65+
66+main(a,b)
67+int a;
68+char *b[];
69+{
70+ int sockfd, newsockfd, clilen, childpid;
71+ struct sockaddr_in cli_addr, serv_addr;
72+ struct hostent *hostp;
73+ int fd;
74+ int con = 0;
75+ int port = 22122;
76+ int sz, i;
77+ int svf = 0; /* for client process */
78+ char *buf;
79+ char hostn[256];
80+#ifdef DOS
81+ char msg[256];
82+ WSADATA WsaData;
83+#endif
84+
85+ for (i = 1; i<a; i++) {
86+ if (!strncmp(b[i],"-h",2)) {
87+ printf("netpf_send ver%s\n", VER);
88+ printf("usage : netpf_send { -s | <hostname> } [-p <port(%d)>] [-c <send_size(MB)>\n", port);
89+ printf(" -s : start as netpf server\n");
90+ printf(" hostnames : netpf server name.(start as netpf client)\n");
91+ printf(" -c size : test data size(MB) default:%dMB\n", SEND_SIZE/1024/1024);
92+ printf(" -p port : test port\n");
93+ exit(1);
94+ }
95+ if (!strncmp(b[i],"-s",2)) {
96+ svf = 1;
97+ continue;
98+ }
99+ if (!strncmp(b[i],"-p",2)) {
100+ port = atoi(b[++i]);
101+ printf("port = %d\n",port);
102+ continue;
103+ }
104+ if (!strncmp(b[i],"-c",2)) {
105+ send_size = atoi(b[++i])*1024*1024;
106+ continue;
107+ }
108+ if (!strncmp(b[i],"-v",2)) {
109+ vf = 1;
110+ continue;
111+ }
112+ strcpy(hostn,b[i]);
113+ }
114+
115+ if (!(buf = (char *)malloc(send_size))) {
116+ printf("malloc error. errno=%d\n",errno);
117+ exit(1);
118+ }
119+
120+ memset((char *)&serv_addr, 0, sizeof(serv_addr));
121+
122+#ifdef DOS
123+ if (WSAStartup(0x0101, &WsaData)) {
124+ sprintf(msg,"WSAStartup Error : %d",WSAGetLastError());
125+ printf(msg);
126+ return -1;
127+ }
128+#endif
129+
130+ if (svf) {
131+
132+ /*
133+ * netpf server
134+ */
135+ printf("wait for port %d\n",port);
136+
137+ if( (sockfd=socket(AF_INET, SOCK_STREAM, 0)) < 0 ){
138+ perror("socket");
139+#ifdef DOS
140+ WSACleanup();
141+#endif
142+ exit(-1);
143+ }
144+
145+ serv_addr.sin_family = AF_INET;
146+ serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
147+ serv_addr.sin_port = htons((short)port);
148+
149+ if(bind(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0){
150+ perror("bind");
151+#ifdef DOS
152+ WSACleanup();
153+#endif
154+ exit(-1);
155+ }
156+
157+#ifndef DOS
158+ signal(SIGCLD, reapchild);
159+#endif
160+
161+ printf("listen...\n");
162+ if(listen(sockfd, 5) < 0){
163+ perror("listen");
164+#ifdef DOS
165+ WSACleanup();
166+#endif
167+ exit(-1);
168+ }
169+
170+ while (1) {
171+ clilen = sizeof(cli_addr);
172+ newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr,
173+ &clilen);
174+ if(newsockfd < 0){
175+ if (errno == EINTR) {
176+ printf("accept interrupted\n");
177+ continue;
178+ }
179+ perror("accept");
180+#ifdef DOS
181+ WSACleanup();
182+#endif
183+ exit(-1);
184+ }
185+
186+#ifndef DOS
187+ if (fork() == 0) {
188+ /* child */
189+#endif
190+ close(sockfd);
191+ printf("accept %d pid=%d\n",con,getpid());
192+ /* サーバ処理 */
193+ for (i = 0; i<LOOP; i++) {
194+ printf("## recv %d MB start\n",send_size/1024/1024);
195+ GET_DATA(newsockfd, buf, send_size);
196+ //printf("## send %d KB start\n",send_size/1024);
197+ //PUT_DATA(newsockfd, buf, send_size);
198+ }
199+ printf("chile pid=%d exit!\n",getpid());
200+ if (shutdown(newsockfd, SHUT_RDWR) < 0) {
201+#ifdef DOS
202+ printf("send: errno=%d LastErr=%d\n", errno, WSAGetLastError());
203+#else
204+ printf("send: errno=%d\n", errno);
205+#endif
206+ }
207+ close(newsockfd);
208+#ifndef DOS
209+ exit(0);
210+ }
211+#endif
212+ close(newsockfd);
213+ con++;
214+ }
215+ } else {
216+
217+ /*
218+ * netpf client
219+ */
220+
221+ hostp = gethostbyname(hostn);
222+ if (!hostp) {
223+ printf("Error: gethostbyname(%s) error \n",hostn);
224+ return 1;
225+ }
226+
227+ serv_addr.sin_family = AF_INET;
228+#if 1
229+ serv_addr.sin_addr.s_addr = *(int *)hostp->h_addr;
230+#else
231+ memcpy((char *)&serv_addr.sin_addr.s_addr,
232+ (char *)hostp->h_addr,
233+ sizeof(serv_addr.sin_addr.s_addr));
234+#endif
235+ serv_addr.sin_port = htons((short)port);
236+
237+ if (vf) {
238+ printf("DEBUG: host(%s) IP(%s)\n", hostn,
239+ inet_ntoa(serv_addr.sin_addr));
240+ }
241+
242+ if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0){
243+ perror("socket");
244+#ifdef DOS
245+ WSACleanup();
246+#endif
247+ exit(-1);
248+ }
249+
250+ if (connect(sockfd, (struct sockaddr *)&serv_addr,
251+ sizeof(serv_addr)) < 0){
252+ perror("connect");
253+#ifdef DOS
254+ printf("connect: winerr=%d\n", WSAGetLastError());
255+ WSACleanup();
256+#endif
257+ exit(-1);
258+ }
259+ for (i = 0; i<LOOP; i++) {
260+ printf("## send %d MB start\n",send_size/1024/1024);
261+ PUT_DATA(sockfd, buf, send_size);
262+ //printf("## recv %d MB start\n",send_size/1024/1024);
263+ //GET_DATA(sockfd, buf, send_size);
264+ }
265+ if (shutdown(sockfd, SHUT_RDWR) < 0) {
266+#ifdef DOS
267+ printf("send: errno=%d LastErr=%d\n", errno, WSAGetLastError());
268+#else
269+ printf("send: errno=%d\n", errno);
270+#endif
271+ }
272+ close(sockfd);
273+
274+ }
275+#ifdef DOS
276+ WSACleanup();
277+#endif
278+ return 0;
279+}
280+
281+void PUT_DATA(int sockfd, char *buf, int sz)
282+{
283+ int size, all=0;
284+ struct timeval tv, tv2;
285+ unsigned int wk,wk2,diff;
286+ int cnt = 0;
287+
288+ gettimeofday(&tv,0);
289+ wk = tv.tv_sec*1000000 + tv.tv_usec;
290+ dprintf("Send start usec : %u\n",wk);
291+
292+ do {
293+ ++cnt;
294+ size = send(sockfd, buf, sz-all, 0);
295+ if (size < 0) {
296+#ifdef DOS
297+ printf("send: errno=%d LastErr=%d\n", errno, WSAGetLastError());
298+#else
299+ printf("send: errno=%d\n", errno);
300+#endif
301+ exit(1);
302+ }
303+ all += size;
304+ } while (all < sz);
305+
306+ if (vf) {
307+ printf("num of send = %d\n", cnt);
308+ }
309+
310+ gettimeofday(&tv,0);
311+ wk2 = tv.tv_sec*1000000 + tv.tv_usec;
312+ diff = wk2-wk;
313+ if (diff <0 ) diff = -diff;
314+ dprintf("Send end usec : %u\n",wk2);
315+ dprintf(" diff usec : %u\n",diff);
316+ printf("Send Size = %d time = %.3fsec perf = %.3fMB/sec\n",
317+ all,
318+ (float)diff/1000000,
319+ (diff/1000 == 0)?999999:(float)all/diff); /* V1.02-C */
320+}
321+
322+/*
323+ * get socket data and write to file
324+ *
325+ * IN : fd : 入力ファイル
326+ * sockfd : 入力ソケットディスクリプタ
327+ * sz : 確実に読みとるサイズ
328+ */
329+void GET_DATA(int sockfd, char *buf, int sz)
330+{
331+ int size, all=0;
332+ struct timeval tv, tv2;
333+ unsigned int wk,wk2,diff;
334+ int cnt = 0;
335+
336+ gettimeofday(&tv,0);
337+ wk = tv.tv_sec*1000000 + tv.tv_usec;
338+ dprintf("Recv start usec : %u\n",wk);
339+
340+ do {
341+ ++cnt;
342+ size = recv(sockfd, buf, sz-all, 0);
343+ if (size < 0) {
344+#ifdef DOS
345+ printf("recv: errno=%d LastErr=%d\n", errno, WSAGetLastError());
346+#else
347+ printf("recv: errno=%d\n", errno);
348+#endif
349+ exit(1);
350+ }
351+ all += size;
352+ } while (all < sz);
353+
354+ if (vf) {
355+ printf("num of recv = %d\n", cnt);
356+ }
357+
358+ gettimeofday(&tv,0);
359+ wk2 = tv.tv_sec*1000000 + tv.tv_usec;
360+ diff = wk2-wk;
361+ if (diff <0 ) diff = -diff;
362+ dprintf("Recv end usec : %u\n",wk2);
363+ dprintf(" diff usec : %u\n",diff);
364+ printf("Recv Size = %d time = %.3fsec perf = %.3fMB/sec\n",
365+ all,
366+ (float)diff/1000000,
367+ (float)all/diff);
368+}
369+
370+void reapchild()
371+{
372+#ifndef DOS
373+ wait(0);
374+ signal(SIGCLD,reapchild);
375+#endif
376+}
377+
378+/*
379+ * void memdump(fp, buf, size)
380+ *
381+ * bufから、size分を fp にヘキサ形式で出力する
382+ *
383+ * <出力例>
384+ * Location: +0 +4 +8 +C /0123456789ABCDEF
385+ * 00000000: 2f2a0a20 2a205265 76697369 6f6e312e //#. # Revision1.
386+ * 00000010: 31203936 2e30372e 30312074 616b6173 /1 96.07.01 takas
387+ * 00000020: 6869206b 61696e75 6d610a20 2a2f0a2f /hi kainuma. #/./
388+ *
389+ * IN fp : 出力ファイルポインタ (標準出力の場合はstdoutを指定)
390+ * buf : ダンプメモリ先頭アドレス
391+ * size : ダンプサイズ
392+ *
393+ */
394+void memdump(fp, buf, size)
395+FILE *fp;
396+unsigned char *buf;
397+int size;
398+{
399+ int c, xx, addr = 0, i;
400+ int f=0, f2=0;
401+ int kflag = 0; /* 漢字出力 */
402+ int pos = 0;
403+ char asc[17];
404+
405+ /* ヘッダ出力 */
406+ fprintf(fp,
407+ "Location: +0 +4 +8 +C /0123456789ABCDEF\n");
408+
409+ c = buf[pos++]; /* c = getc(infp); */
410+ while(pos <= size) {
411+ xx = 0;
412+ strcpy(asc," ");
413+ fprintf(fp,"%08x: ",addr);
414+ f = 0;
415+ while(pos <= size && xx < 16) {
416+ fprintf(fp,"%02x",c);
417+ if (c < 32) {
418+ if (f) {
419+ asc[xx] = c;
420+ if (c == 10 || c == 13) {
421+ asc[xx] = '.'; /* 暫定 */
422+ }
423+ } else {
424+ asc[xx] = '.';
425+ }
426+ f = 0;
427+ } else if (c > 127 ) {
428+ if (kflag) {
429+ if (f) {
430+ asc[xx] = c;
431+ f = 0;
432+ } else {
433+ asc[xx] = c;
434+ f = 1;
435+ }
436+ } else {
437+ asc[xx] = '.';
438+ }
439+ } else {
440+ asc[xx] = c;
441+ f = 0;
442+ }
443+ if (xx == 0 && f2) {
444+ asc[xx] = '.';
445+ f = 0;
446+ f2 = 0;
447+ }
448+ if ((xx % 4) == 3) fprintf(fp," ");
449+ ++xx;
450+ ++addr;
451+ c = buf[pos++]; /* c = getc(infp); */
452+ if (f == 1 && xx >= 16) {
453+ asc[xx++] = c;
454+ f = 0;
455+ f2 = 1;
456+ }
457+ }
458+ while (xx <16) {
459+ fprintf(fp," ");
460+ if ((xx % 4) == 3) fprintf(fp," ");
461+ ++xx;
462+ }
463+ asc[xx]='\0';
464+ fprintf(fp,"/%16s \n",asc);
465+ }
466+}
467+
468+#ifdef DOS
469+int gettimeofday(struct timeval *tv, void *tz)
470+{
471+ SYSTEMTIME syst;
472+
473+ //GetSystemTime(&syst); // UTC
474+ GetLocalTime(&syst);
475+ tv->tv_sec = syst.wHour * 3600 +
476+ syst.wMinute *60 +
477+ syst.wSecond;
478+ tv->tv_usec = syst.wMilliseconds * 1000;
479+ return 0;
480+}
481+#endif /* DOS */