Skip to content

Commit 17b2bee

Browse files
author
root
committed
[Client]검출성능 향상
1 parent 553d4f8 commit 17b2bee

16 files changed

+80
-85
lines changed

src/glade/#main.glade#

100644100755
File mode changed.

src/glade/bxr_plover

-3.81 KB
Binary file not shown.

src/glade/main.c

Lines changed: 78 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#define ERASER_SIZE 512 //1k
1515
#define ERASER_ENC_SIZE 896 //1k
1616

17+
int x,y,z; //지울거
18+
int nomatch; // regex //
19+
const int n_matches = 200; // "N_matches" is the maximum number of matches allowed. //
20+
1721
static gchar *dpath; // default 경로 //
1822
static gchar *path; // 검사 파일경로 //
1923
static gchar *name; // 등록 유저이름 //
@@ -207,13 +211,13 @@ int compile_regex (regex_t *r, const char *regex_text)
207211

208212
if (status != 0)
209213
{
210-
char error_message[MAX_ERROR_MSG];
214+
char error_message[MAX_ERROR_MSG];
211215

212-
regerror(status, r, error_message, MAX_ERROR_MSG);
216+
regerror(status, r, error_message, MAX_ERROR_MSG);
213217

214-
printf("Regex error compiling '%s': %s\n", regex_text, error_message);
218+
printf("Regex error compiling '%s': %s\n", regex_text, error_message);
215219

216-
return 1;
220+
return 1;
217221
}
218222

219223
return 0;
@@ -226,19 +230,19 @@ char match_regex_jnfg (regex_t *r, const char *to_match, char *filepath, struct
226230
/* "P" is a pointer into the string which points to the end of the
227231
previous match. */
228232
const char *p = to_match;
229-
/* "N_matches" is the maximum number of matches allowed. */
230-
const int n_matches = 100;
233+
231234
/* "M" contains the matches found. */
232235
regmatch_t m[n_matches];
233236

234237
// 버퍼크기만큼 읽은 부분 전체를 해당 정규식과 비교 //
235238
while (1)
236239
{
237-
int nomatch = regexec(r, p, n_matches, m, 0);
240+
nomatch = regexec(r, p, n_matches, m, 0);
238241

239242
if (nomatch)
240243
{
241-
printf("No more matches.\n");
244+
//printf("No more matches.\n");
245+
printf("[%d] JF reading\n", z++);
242246
return 0;
243247
}
244248

@@ -277,23 +281,23 @@ char match_regex_jnfg (regex_t *r, const char *to_match, char *filepath, struct
277281

278282
if (jtmp >= 10)
279283
{
280-
jtmp -= 10;
284+
jtmp -= 10;
281285
}
282286

283287
if (fgtmp >= 10)
284288
{
285-
fgtmp -= 10;
289+
fgtmp -= 10;
286290
}
287291

288292
// 주민번호 유효성 통과 //
289293
if (jtmp == chk)
290294
{
291295
int res = strcmp(chk_fname, file->d_name); // 같은파일 = 0 //
292296

293-
if (res != 0)
294-
{
295-
chk_fcnt++;
296-
}
297+
if (res != 0)
298+
{
299+
chk_fcnt++;
300+
}
297301

298302
// 읽고있는중인 파일 이름 저장 //
299303
strcpy(chk_fname, file->d_name);
@@ -307,19 +311,17 @@ char match_regex_jnfg (regex_t *r, const char *to_match, char *filepath, struct
307311
fDs[chk_fcnt].fsize = buf.st_size;
308312
strcpy(fDs[chk_fcnt].stat, "일반");
309313

310-
printf("num: %d, jcnt: %d, dcnt: %d, fgcnt: %d, file_path: %s, file_name: %s, file_size: %dbyte\n",
311-
chk_fcnt+1, fDs[chk_fcnt].jcnt, fDs[chk_fcnt].dcnt, fDs[chk_fcnt].fgcnt, fDs[chk_fcnt].fpath, fDs[chk_fcnt].fname, fDs[chk_fcnt].fsize);
312314
}
313315

314316
// 외국인등록번호 유효성 통과 //
315317
if (fgtmp == chk)
316318
{
317-
int res = strcmp(chk_fname, file->d_name); // 같은파일 = 0 //
319+
int res = strcmp(chk_fname, file->d_name); // 같은파일 = 0 //
318320

319-
if (res != 0)
320-
{
321-
chk_fcnt++;
322-
}
321+
if (res != 0)
322+
{
323+
chk_fcnt++;
324+
}
323325

324326
// 읽고있는중인 파일 이름 저장 //
325327
strcpy(chk_fname, file->d_name);
@@ -333,8 +335,6 @@ char match_regex_jnfg (regex_t *r, const char *to_match, char *filepath, struct
333335
fDs[chk_fcnt].fsize = buf.st_size;
334336
strcpy(fDs[chk_fcnt].stat, "일반");
335337

336-
printf("num: %d, jcnt: %d, dcnt: %d, fgcnt: %d, pcnt: %d, file_path: %s, file_name: %s, file_size: %dbyte\n",
337-
chk_fcnt+1, fDs[chk_fcnt].jcnt, fDs[chk_fcnt].dcnt, fDs[chk_fcnt].fgcnt, fDs[chk_fcnt].pcnt, fDs[chk_fcnt].fpath, fDs[chk_fcnt].fname, fDs[chk_fcnt].fsize);
338338
}
339339
}
340340
}
@@ -350,18 +350,17 @@ char match_regex_d (regex_t *r, const char *to_match, char *filepath, struct dir
350350
{
351351
const char *p = to_match;
352352

353-
const int n_matches = 100;
354-
355353
regmatch_t m[n_matches];
356354

357355
//버퍼크기만큼 읽은 부분 전체를 해당 정규식과 비교//
358356
while (1)
359357
{
360-
int nomatch = regexec(r, p, n_matches, m, 0);
358+
nomatch = regexec(r, p, n_matches, m, 0);
361359

362360
if (nomatch)
363361
{
364-
printf("No more matches.\n");
362+
//printf("No more matches.\n");
363+
printf("[%d] D reading\n", x++);
365364
return 0;
366365
}
367366

@@ -396,8 +395,6 @@ char match_regex_d (regex_t *r, const char *to_match, char *filepath, struct dir
396395
fDs[chk_fcnt].fsize = buf.st_size;
397396
strcpy(fDs[chk_fcnt].stat, "일반");
398397

399-
printf("num: %d, jcnt: %d, dcnt: %d, fgcnt: %d, pcnt: %d, file_path: %s, file_name: %s, file_size: %dbyte\n",
400-
chk_fcnt+1, fDs[chk_fcnt].jcnt, fDs[chk_fcnt].dcnt, fDs[chk_fcnt].fgcnt, fDs[chk_fcnt].pcnt, fDs[chk_fcnt].fpath, fDs[chk_fcnt].fname, fDs[chk_fcnt].fsize);
401398
}
402399
}
403400
}
@@ -412,18 +409,17 @@ char match_regex_p (regex_t *r, const char *to_match, char *filepath, struct dir
412409
{
413410
const char *p = to_match;
414411

415-
const int n_matches = 100;
416-
417412
regmatch_t m[n_matches];
418413

419414
// 버퍼크기만큼 읽은 부분 전체를 해당 정규식과 비교 //
420415
while (1)
421416
{
422-
int nomatch = regexec(r, p, n_matches, m, 0);
417+
nomatch = regexec(r, p, n_matches, m, 0);
423418

424419
if (nomatch)
425420
{
426-
printf("No more matches.\n");
421+
//printf("No more matches.\n");
422+
printf("[%d] P reading\n", y++);
427423
return 0;
428424
}
429425

@@ -458,8 +454,6 @@ char match_regex_p (regex_t *r, const char *to_match, char *filepath, struct dir
458454
fDs[chk_fcnt].fsize = buf.st_size;
459455
strcpy(fDs[chk_fcnt].stat, "일반");
460456

461-
printf("num: %d, jcnt: %d, dcnt: %d, fgcnt: %d, pcnt: %d, file_path: %s, file_name: %s, file_size: %dbyte\n",
462-
chk_fcnt+1, fDs[chk_fcnt].jcnt, fDs[chk_fcnt].dcnt, fDs[chk_fcnt].fgcnt, fDs[chk_fcnt].pcnt, fDs[chk_fcnt].fpath, fDs[chk_fcnt].fname, fDs[chk_fcnt].fsize);
463457
}
464458
}
465459
}
@@ -519,63 +513,64 @@ int func_Detect (gchar *path)
519513
struct dirent *file = NULL;
520514
struct stat buf;
521515
char filepath[300];
522-
char buffer[5000];
523-
const char *find_text;
516+
uint sum = 0, cur = 0;
524517

525-
if ((dp = opendir(path)) == NULL)
518+
if ((dp = opendir(path)) != NULL)
526519
{
527-
printf("폴더를 열수 없습니다.\n");
520+
while ((file = readdir(dp)) != NULL)
521+
{
522+
// filepath에 현재 path넣기 //
523+
sprintf(filepath, "%s/%s", path, file->d_name);
524+
lstat(filepath, &buf);
528525

529-
return -1;
530-
}
526+
// 폴더 //
527+
if (S_ISDIR(buf.st_mode))
528+
{
529+
// .이거하고 ..이거 제외 //
530+
if ((!strcmp(file->d_name, ".")) || (!strcmp(file->d_name, "..")))
531+
{
532+
continue;
533+
}
531534

532-
while ((file = readdir(dp)) != NULL)
533-
{
534-
// filepath에 현재 path넣기 //
535-
sprintf(filepath, "%s/%s", path, file->d_name);
536-
lstat(filepath, &buf);
535+
// 안에 폴더로 재귀함수 //
536+
func_Detect(filepath);
537+
}
537538

538-
// 폴더 //
539-
if (S_ISDIR(buf.st_mode))
540-
{
541-
// .이거하고 ..이거 제외 //
542-
if ((!strcmp(file->d_name, ".")) || (!strcmp(file->d_name, "..")))
539+
// 파일 //
540+
else if (S_ISREG(buf.st_mode))
543541
{
544-
continue;
545-
}
542+
fp = fopen(filepath, "r");
543+
fseek( fp, 0, SEEK_END);
544+
long lSize = ftell(fp);
545+
fseek( fp, 0, SEEK_SET);
546546

547-
// 안에 폴더로 재귀함수 //
548-
func_Detect(filepath);
549-
}
547+
char *buff = (char *)malloc( sizeof (char)*lSize);
550548

551-
// 파일 //
552-
else if (S_ISREG(buf.st_mode))
553-
{
554-
fp = fopen(filepath, "r");
549+
while ((cur = fread(&buff[sum], sizeof(char), lSize - cur, fp)) > 0 )
550+
{
551+
sum += cur;
552+
}
553+
554+
if (sum != lSize)
555+
{
556+
printf("파일을 읽을수 없습니다.\n");
557+
}
555558

556-
if (NULL == fp)
557-
{
558-
printf("파일을 열수 없습니다.\n");
559-
return 1;
560-
}
559+
printf("버퍼에 다 넣었다~~~~~~~~~\n");
560+
check_kind_of_data( buff, filepath, file, buf);
561561

562-
// 버퍼 크기만큼 읽고 find_text에 넣어서 정규식검사로 이동 //
563-
while (feof(fp) == 0)
564-
{
565-
fread(buffer, sizeof(char), sizeof(buffer), fp);
566-
find_text = buffer;
567-
check_kind_of_data(find_text, filepath, file, buf);
568-
find_text = NULL;
562+
fclose(fp);
563+
printf("Close FILE\n");
564+
chk_fname[0] = 0; // 초기화 //
569565
}
570-
571-
// 메모리관리(초기화), 파일닫기 //
572-
memset(buffer, 0, sizeof(buffer));
573-
fclose(fp);
574-
printf("Close FILE\n");
575-
chk_fname[0] = 0; // 초기화 //
576566
}
577567
}
578-
568+
else
569+
{
570+
printf("폴더를 열수 없습니다.\n");
571+
return -1;
572+
}
573+
579574
closedir(dp);
580575

581576
printf("Close DIR\n");
@@ -722,7 +717,7 @@ int func_Send()
722717
enc = b64_encode((unsigned char *)&fDs[i], in_len, enc);
723718

724719
printf("[enc_data: %s]\n", enc);
725-
printf("[UUID: %s, cnt: %d, jumin: %d, driver: %d, forign: %d, pass: %d, fsize: %d, fstat: %s, fpath: %s]\n\n",
720+
printf("[UUID: %s, cnt: %d, jumin: %d, driver: %d, forign: %d, pass: %d, fsize: %ld, fstat: %s, fpath: %s]\n\n",
726721
fDs[i].uuid, i, fDs[i].jcnt, fDs[i].dcnt, fDs[i].fgcnt, fDs[i].pcnt, fDs[i].fsize, fDs[i].stat, fDs[i].fpath);
727722

728723
sprintf( message, "%.0f%% Complete", percent);
@@ -913,7 +908,7 @@ int func_file_eraser(int type)
913908
FILE *fp;
914909
int mode = R_OK | W_OK;
915910
char MsgTmp[5];
916-
guint size = 0;
911+
gulong size = 0;
917912
char *msize;
918913

919914
if( access( sfDs.fpath, mode ) != 0 )
@@ -1077,7 +1072,7 @@ d_view_selection_func (GtkTreeSelection *selection,
10771072
{
10781073
GtkTreeIter iter;
10791074
gchar *stat, *fpath;
1080-
uint fsize;
1075+
ulong fsize;
10811076

10821077
if (gtk_tree_model_get_iter(model, &iter, path))
10831078
{
@@ -1304,7 +1299,7 @@ void d_delete_btn_clicked (GtkButton *d_delete_btn, gpointer *data)
13041299
gtk_container_remove (GTK_CONTAINER(d_scrolledwindow), d_view); // 다 지우기
13051300
//gtk_tree_store_remove(dtreestore, &diter); // 선택한거만 지우기
13061301

1307-
printf("[UUID: %s], [파일이름: %s], [파일크기: %d], [파일상태: %s], [파일경로: %s]\n", sfDs.uuid, sfDs.fname, sfDs.fsize, sfDs.stat, sfDs.fpath);
1302+
printf("[UUID: %s], [파일이름: %s], [파일크기: %ld], [파일상태: %s], [파일경로: %s]\n", sfDs.uuid, sfDs.fname, sfDs.fsize, sfDs.stat, sfDs.fpath);
13081303

13091304
d_view = d_create_view_and_model();
13101305
gtk_container_add (GTK_CONTAINER(d_scrolledwindow), d_view);

src/glade/main.glade~

100644100755
File mode changed.

src/glade/main.o

100644100755
File mode changed.

src/glade/plover.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ typedef struct _Fdata_Storage
4444
uint dcnt; // 운전면허 개수 //
4545
uint fgcnt; // 외국인등록번호 개수 //
4646
uint pcnt; // 여권번호 개수 //
47-
uint fsize; // 파일 크기 //
47+
ulong fsize; // 파일 크기 //
4848
char stat[20]; // 파일 상태 //
4949
char fpath[300]; // 파일 경로 //
5050

@@ -55,7 +55,7 @@ typedef struct _SFdata_Storage
5555
{
5656
char uuid[37]; // UUID //
5757
char fname[100]; // 파일 이름 //
58-
uint fsize; // 파일 크기 //
58+
ulong fsize; // 파일 크기 //
5959
char stat[20]; // 파일 상태 //
6060
char fpath[300]; // 파일 경로 //
6161

src/glade/plover.ini

100644100755
File mode changed.

src/glade/resource/bg-main.svg

100644100755
File mode changed.

src/glade/resource/bg-select-div.svg

100644100755
File mode changed.

src/glade/resource/bg_settings.svg

100644100755
File mode changed.

0 commit comments

Comments
 (0)