2020#include "decode.c"
2121
2222#define MAX_ERROR_MSG 0x1000
23- #define MAX_FCNT 50
23+ #define MAX_CNTF 50
2424
2525typedef struct Data_storage
2626{
2727 char fpath [300 ]; //파일 경로
2828 char fname [20 ]; //파일 이름
2929 uint jcnt ; //주민번호 개수
3030 uint dcnt ; //운전면허 개수
31+ uint fgcnt ; //외국인등록번호 개수
3132 uint fsize ; //파일 크기
3233 char stat ; //파일 상태
3334
3435
3536}data_storage ;
3637
37- data_storage ds [MAX_FCNT ]; //파일기준의 data구조체
38+ data_storage ds [MAX_CNTF ]; //파일기준의 data구조체
3839
3940static gchar * path ;
40- static int fcnt = 0 ;
41+ static int cntf = 0 ;
4142static char chkfname [20 ];
4243int chk_tf ; //chk_true false
4344//uint data_flag = 1; //어떤종류의 민감정보인지 확인하기위한 flag
@@ -90,7 +91,7 @@ int compile_regex (regex_t *r, const char *regex_text)
9091}
9192
9293//Match the string in "to_match" against the compiled regular expression in "r"//
93- char match_regex_j (regex_t * r , const char * to_match , char * filepath , struct dirent * file , struct stat buf )
94+ char match_regex_jnfg (regex_t * r , const char * to_match , char * filepath , struct dirent * file , struct stat buf )
9495{
9596 /* "P" is a pointer into the string which points to the end of the
9697 previous match. */
@@ -124,51 +125,83 @@ char match_regex_j (regex_t *r, const char *to_match, char *filepath, struct dir
124125
125126 start = m [i ].rm_so + (p - to_match );
126127
127- //주민번호 정규식 검사 통과//
128+ //주민번호, 외국인등록번호 정규식 검사 통과//
128129 if (i == 0 )
129130 {
130- int chk = 0 , tmp = 0 , sum = 0 ;
131- char buf_jumin [15 ] = {0 ,};
132- //주민번호 유효성 검사//
131+ int chk = 0 , jtmp = 0 , fgtmp = 0 , sum = 0 ;
132+ char buf_tmp [15 ] = {0 ,};
133+ //주민번호, 외국인등록번호 유효성 검사//
133134 for (int j = 0 ; j < 14 ; j ++ )
134135 {
135- buf_jumin [j ] = * (to_match + start + j );
136- buf_jumin [j ] -= 48 ;
136+ buf_tmp [j ] = * (to_match + start + j );
137+ buf_tmp [j ] -= 48 ;
137138 }
138139
139- sum = buf_jumin [0 ]* 2 + buf_jumin [1 ]* 3 + buf_jumin [2 ]* 4 + buf_jumin [3 ]* 5 + buf_jumin [4 ]* 6 + buf_jumin [5 ]* 7
140- + buf_jumin [7 ]* 8 + buf_jumin [8 ]* 9 + buf_jumin [9 ]* 2 + buf_jumin [10 ]* 3 + buf_jumin [11 ]* 4 + buf_jumin [12 ]* 5 ;
140+ sum = buf_tmp [0 ]* 2 + buf_tmp [1 ]* 3 + buf_tmp [2 ]* 4 + buf_tmp [3 ]* 5 + buf_tmp [4 ]* 6 + buf_tmp [5 ]* 7
141+ + buf_tmp [7 ]* 8 + buf_tmp [8 ]* 9 + buf_tmp [9 ]* 2 + buf_tmp [10 ]* 3 + buf_tmp [11 ]* 4 + buf_tmp [12 ]* 5 ;
141142
142- chk = buf_jumin [13 ];
143- tmp = 11 - (sum % 11 );
143+ chk = buf_tmp [13 ];
144+ jtmp = 11 - (sum % 11 ); //주민번호
145+ fgtmp = 13 - (sum % 11 ); //외국인번호
144146
145- if (tmp >= 10 )
147+ if (jtmp >= 10 )
146148 {
147- tmp -= 10 ;
149+ jtmp -= 10 ;
150+ }
151+
152+ if (fgtmp >= 10 )
153+ {
154+ fgtmp -= 10 ;
148155 }
149156
150157 //주민번호 유효성 통과//
151- if (tmp == chk )
158+ if (jtmp == chk )
152159 {
153160 int res = strcmp (chkfname , file -> d_name ); //같은파일 = 0
154161
155162 if (res != 0 )
156163 {
157- fcnt ++ ;
164+ cntf ++ ;
158165 }
159166
160167 //읽고있는중인 파일 이름 저장
161168 strcpy (chkfname , file -> d_name );
162169
163170 //검출된 주민등록번호의 수//
164- ds [fcnt ].jcnt ++ ;
171+ ds [cntf ].jcnt ++ ;
165172
166173 //data 구조체에 저장//
167- strcpy (ds [fcnt ].fpath , filepath );
168- strcpy (ds [fcnt ].fname , file -> d_name );
169- ds [fcnt ].fsize = buf .st_size ;
174+ strcpy (ds [cntf ].fpath , filepath );
175+ strcpy (ds [cntf ].fname , file -> d_name );
176+ ds [cntf ].fsize = buf .st_size ;
170177
171- printf ("num: %d, jcnt: %d, dcnt: %d, file_path: %s, file_name: %s, file_size: %dbyte\n" , fcnt , ds [fcnt ].jcnt , ds [fcnt ].dcnt , ds [fcnt ].fpath , ds [fcnt ].fname , ds [fcnt ].fsize );
178+ printf ("num: %d, jcnt: %d, dcnt: %d, fgcnt: %d, file_path: %s, file_name: %s, file_size: %dbyte\n" ,
179+ cntf , ds [cntf ].jcnt , ds [cntf ].dcnt , ds [cntf ].fgcnt , ds [cntf ].fpath , ds [cntf ].fname , ds [cntf ].fsize );
180+ }
181+
182+ //외국인등록번호 유효성 통과//
183+ if (fgtmp == chk )
184+ {
185+ int res = strcmp (chkfname , file -> d_name ); //같은파일 = 0
186+
187+ if (res != 0 )
188+ {
189+ cntf ++ ;
190+ }
191+
192+ //읽고있는중인 파일 이름 저장
193+ strcpy (chkfname , file -> d_name );
194+
195+ //검출된 외국인등록번호의 수//
196+ ds [cntf ].fgcnt ++ ;
197+
198+ //data 구조체에 저장//
199+ strcpy (ds [cntf ].fpath , filepath );
200+ strcpy (ds [cntf ].fname , file -> d_name );
201+ ds [cntf ].fsize = buf .st_size ;
202+
203+ printf ("num: %d, jcnt: %d, dcnt: %d, fgcnt: %d, file_path: %s, file_name: %s, file_size: %dbyte\n" ,
204+ cntf , ds [cntf ].jcnt , ds [cntf ].dcnt , ds [cntf ].fgcnt , ds [cntf ].fpath , ds [cntf ].fname , ds [cntf ].fsize );
172205 }
173206 }
174207 }
@@ -216,21 +249,22 @@ char match_regex_d (regex_t *r, const char *to_match, char *filepath, struct dir
216249
217250 if (res != 0 )
218251 {
219- fcnt ++ ;
252+ cntf ++ ;
220253 }
221254
222255 //읽고있는중인 파일 이름 저장
223256 strcpy (chkfname , file -> d_name );
224257
225258 //검출된 운전면허의 수//
226- ds [fcnt ].dcnt ++ ;
259+ ds [cntf ].dcnt ++ ;
227260
228261 //data 구조체에 저장//
229- strcpy (ds [fcnt ].fpath , filepath );
230- strcpy (ds [fcnt ].fname , file -> d_name );
231- ds [fcnt ].fsize = buf .st_size ;
262+ strcpy (ds [cntf ].fpath , filepath );
263+ strcpy (ds [cntf ].fname , file -> d_name );
264+ ds [cntf ].fsize = buf .st_size ;
232265
233- printf ("num: %d, jcnt: %d, dcnt: %d, file_path: %s, file_name: %s, file_size: %dbyte\n" , fcnt , ds [fcnt ].jcnt , ds [fcnt ].dcnt , ds [fcnt ].fpath , ds [fcnt ].fname , ds [fcnt ].fsize );
266+ printf ("num: %d, jcnt: %d, dcnt: %d, fgcnt: %d, file_path: %s, file_name: %s, file_size: %dbyte\n" ,
267+ cntf , ds [cntf ].jcnt , ds [cntf ].dcnt , ds [cntf ].fgcnt , ds [cntf ].fpath , ds [cntf ].fname , ds [cntf ].fsize );
234268 }
235269 }
236270 }
@@ -256,15 +290,15 @@ void check_kind_of_data (const char *to_match, char *filepath, struct dirent *fi
256290 break;
257291
258292 case 2:
259- regex_text = "[0-9]{2}[-~.[:space:]][ 0-9]{6}[-~.[:space:]] [0-9]{2}"; //운전면허 정규식//
293+ regex_text = "[0-9]{2}-[ 0-9]{6}- [0-9]{2}"; //운전면허 정규식//
260294 compile_regex(&r, regex_text); //정규식 컴파일//
261295 //match_regex_d(&r, to_match, filepath, file, buf);
262296 }
263297*/
264298
265- regex_text = "([0-9]{2}(0[1-9]|1[0-2])(0[1-9]|[1,2][0-9]|3[0,1])-[1-4][0-9]{6})" ; //주민번호 정규식//
299+ regex_text = "([0-9]{2}(0[1-9]|1[0-2])(0[1-9]|[1,2][0-9]|3[0,1])-[1-4][0-9]{6})" ; //주민번호, 외국인등록번호 정규식//
266300 compile_regex (& r , regex_text ); //정규식 컴파일//
267- match_regex_j (& r , to_match , filepath , file , buf );
301+ match_regex_jnfg (& r , to_match , filepath , file , buf );
268302
269303 regex_text = "[0-9]{2}-[0-9]{6}-[0-9]{2}" ; //운전면허 정규식//
270304 compile_regex (& r , regex_text ); //정규식 컴파일//
@@ -437,7 +471,7 @@ int detect_func(gchar *path)
437471 /*
438472 publish
439473 */
440- for (int i = 1 ; i <= fcnt ; i ++ )
474+ for (int i = 1 ; i <= cntf ; i ++ )
441475 {
442476 size_t in_len = sizeof (ds [i ]);
443477 //printf("ds[%d]: %ld\n", i ,in_len); //구조체 크기확인
654688 d_treeview_filename ,
655689 d_treeview_jcnt ,
656690 d_treeview_dcnt ,
691+ d_treeview_fgcnt ,
657692 d_treeview_stat ,
658693 d_treeview_size ,
659694 d_treeview_filelocation ,
@@ -666,17 +701,18 @@ create_and_fill_model (void)
666701 GtkTreeStore * treestore ;
667702 GtkTreeIter iter ;
668703
669- treestore = gtk_tree_store_new (NUM_COLS , G_TYPE_UINT , G_TYPE_STRING , G_TYPE_UINT , G_TYPE_UINT , G_TYPE_STRING , G_TYPE_UINT , G_TYPE_STRING );
704+ treestore = gtk_tree_store_new (NUM_COLS , G_TYPE_UINT , G_TYPE_STRING , G_TYPE_UINT , G_TYPE_UINT , G_TYPE_UINT , G_TYPE_STRING , G_TYPE_UINT , G_TYPE_STRING );
670705
671- for (int i = 1 ; i <= fcnt ; i ++ )
706+ for (int i = 1 ; i <= cntf ; i ++ )
672707 {
673708 gtk_tree_store_append (treestore , & iter , NULL );
674709 gtk_tree_store_set (treestore , & iter ,
675710 d_treeview_num , i ,
676711 d_treeview_filename , ds [i ].fname ,
677712 d_treeview_jcnt , ds [i ].jcnt ,
678713 d_treeview_dcnt , ds [i ].dcnt ,
679- d_treeview_stat , "have to define" ,
714+ d_treeview_fgcnt , ds [i ].fgcnt ,
715+ d_treeview_stat , "soon" ,
680716 d_treeview_size , ds [i ].fsize ,
681717 d_treeview_filelocation , ds [i ].fpath ,
682718 -1 );
@@ -733,6 +769,14 @@ create_view_and_model (void)
733769 renderer = gtk_cell_renderer_text_new ();
734770 gtk_tree_view_column_pack_start (col , renderer , TRUE);
735771 gtk_tree_view_column_add_attribute (col , renderer , "text" , d_treeview_dcnt );
772+
773+ /* --- Column #외국인등록번호 개수 --- */
774+ col = gtk_tree_view_column_new ();
775+ gtk_tree_view_column_set_title (col , "외국인등록" );
776+ gtk_tree_view_append_column (GTK_TREE_VIEW (view ), col );
777+ renderer = gtk_cell_renderer_text_new ();
778+ gtk_tree_view_column_pack_start (col , renderer , TRUE);
779+ gtk_tree_view_column_add_attribute (col , renderer , "text" , d_treeview_fgcnt );
736780
737781 /* --- Column #상태 --- */
738782 col = gtk_tree_view_column_new ();
0 commit comments