Mercurial > mercurial > hgweb_xdwtools.cgi
comparison xdwgrep2.cpp @ 8:61ce4754737e
bug fix.
author | pyon@macmini |
---|---|
date | Tue, 03 Apr 2018 00:11:01 +0900 |
parents | 8de5b1bd9506 |
children |
comparison
equal
deleted
inserted
replaced
7:8de5b1bd9506 | 8:61ce4754737e |
---|---|
1 /* Makefile | 1 /* Makefile |
2 debug: xdwgrep2.c | 2 debug: xdwgrep2.cpp |
3 gcc -g -O0 -I. xdwgrep2.c xdwapi.lib | 3 gcc -g -O0 -I. xdwgrep2.cpp xdwapi.lib |
4 #date | 4 #date |
5 #./a.exe target.xdw | 5 #./a.exe target.xdw |
6 #date | 6 #date |
7 | 7 |
8 release: xdwgrep2.c | 8 release: xdwgrep2.cpp |
9 gcc -I. xdwgrep2.c xdwapi.lib -static -o xdwgrep2.exe | 9 gcc -I. xdwgrep2.cpp xdwapi.lib -static -o xdwgrep2.exe |
10 strip xdwgrep2.exe | 10 strip xdwgrep2.exe |
11 | 11 |
12 */ | 12 */ |
13 | 13 |
14 #include <stdbool.h> | 14 #include <stdbool.h> |
19 #include <io.h> | 19 #include <io.h> |
20 #include <windows.h> | 20 #include <windows.h> |
21 #include <xdw_api.h> | 21 #include <xdw_api.h> |
22 | 22 |
23 #define MAXKWORD 256 | 23 #define MAXKWORD 256 |
24 #define MAXLINE 256 | 24 #define MAXLINE 4096 |
25 | 25 |
26 void print_error( int code ) { | 26 void print_error( int code ) { |
27 fprintf( stderr, "Error code : %d\n", code ); | 27 fprintf( stderr, "Error code : %d\n", code ); |
28 switch ( code ) { | 28 switch ( code ) { |
29 case XDW_E_NOT_INSTALLED: | 29 case XDW_E_NOT_INSTALLED: |
50 fprintf( stderr, "エラーが発生しました。" ); | 50 fprintf( stderr, "エラーが発生しました。" ); |
51 break; | 51 break; |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 void print_now( char *msg ) { | 55 void print_now( const char *msg ) { |
56 time_t now = time( NULL ); | 56 time_t now = time( NULL ); |
57 struct tm *ts = localtime( &now ); | 57 struct tm *ts = localtime( &now ); |
58 | 58 |
59 char buf[80]; | 59 char buf[80]; |
60 strftime( buf, sizeof( buf ), "%H:%M:%S %Z", ts ); | 60 strftime( buf, sizeof( buf ), "%H:%M:%S %Z", ts ); |
61 printf( "%s\t%s\n", buf, msg ); | 61 printf( "%s\t%s\n", buf, msg ); |
62 } | 62 } |
63 | 63 |
64 /* 指定された単語で検索 */ | 64 /* 指定された単語で検索 */ |
65 int xdw_grep( char infile[ _MAX_PATH ], char outfile[ _MAX_PATH ], char keyword[ MAXKWORD ], int inv ) { | 65 int xdw_grep( const char infile[ _MAX_PATH ], const char outfile[ _MAX_PATH ], const char keyword[ MAXKWORD ], int inv ) { |
66 | 66 |
67 char in_path[ _MAX_PATH ], out_path[ _MAX_PATH ], tmp_path[ _MAX_PATH ]; | 67 char in_path[ _MAX_PATH ], out_path[ _MAX_PATH ], tmp_path[ _MAX_PATH ]; |
68 _fullpath( in_path, infile, _MAX_PATH ); | 68 _fullpath( in_path, infile, _MAX_PATH ); |
69 _fullpath( out_path, outfile, _MAX_PATH ); | 69 _fullpath( out_path, outfile, _MAX_PATH ); |
70 _fullpath( tmp_path, "tempXXXX.xdw", _MAX_PATH ); | 70 _fullpath( tmp_path, "tempXXXX.xdw", _MAX_PATH ); |
116 | 116 |
117 return 0; | 117 return 0; |
118 } | 118 } |
119 | 119 |
120 /* 検索する単語のリストをファイルから読み込む */ | 120 /* 検索する単語のリストをファイルから読み込む */ |
121 int xdw_grep_list( char infile[ _MAX_PATH ], char outfile[ _MAX_PATH ], bool inv ) { | 121 int xdw_grep_list( const char infile[ _MAX_PATH ], const char outfile[ _MAX_PATH ], bool inv ) { |
122 | 122 |
123 char in_path[ _MAX_PATH ], out_path[ _MAX_PATH ], tmp_path[ _MAX_PATH ]; | 123 char in_path[ _MAX_PATH ], out_path[ _MAX_PATH ], tmp_path[ _MAX_PATH ]; |
124 _fullpath( in_path, infile, _MAX_PATH ); | 124 _fullpath( in_path, infile, _MAX_PATH ); |
125 _fullpath( out_path, outfile, _MAX_PATH ); | 125 _fullpath( out_path, outfile, _MAX_PATH ); |
126 _fullpath( tmp_path, "tempXXXX.xdw", _MAX_PATH ); | 126 _fullpath( tmp_path, "tempXXXX.xdw", _MAX_PATH ); |