본문 바로가기

DuruEdit

두루에디트 HTML 구문분석 파싱소스..


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
/* 
  $Id: DEParserHtml.cpp 25 2000-11-28 00:34:01Z krkim $ $Revision: 125 $
  $HeadURL: http://krkim-laptop/svn/DuruEdit/Src/DEEditDLL/DEParserHtml.cpp $
  HomePage: http://krkim.net
  Copyright(c) 1990-2010 krkim Allrights reserved.
 */

//HTML 파일안에는 script 영역(vb,java),html일반,asp 스크립트,php 스크립트 영역이 있다.
//클라이언트 스크립트:
//클라이언트 스크립트내 주석처리 태그 <!-- 와 --> 는 실제로 
//이사이를 주석처리 컬러링하면 안되고 <!--와 -->만 컬러링처리
//JAVASCRIPT,VBSCRIPT

//서버 스크립트:
//HTML 본문이나 CLIENTSCRIPT 본문에 올수 있음
//ASP,JSP,PHP등의 서버스크립트 구간

/*
<script language="javascript">  or <script type="text/javascript>
<!--  => 는 주석이 아니고 스크립트 지원안하는 브라우저를 위한 태그주석임,따라서 스크립트 영역내 <!--는 무시한다
// code here 
//--> 
</script> 
//자바스크립트내에서 PHP호출 한 경우
<script type="text/javascript"> 
var TabURL = '<?=$value?>'; 
</script> 

*/
#include "stdafx.h"
#include "html.h"

enum ENUM_HTMLCOOKIE{
	HTMLCOOKIE_NORMAL,				//HTML 본문(html 태그밖)
	HTMLCOOKIE_BRACKET,				//태그
	HTMLCOOKIE_COMMENT,				//<!-- -->
	HTMLCOOKIE_VALUE1,				//태그 속성이름
	HTMLCOOKIE_VALUE2,				//태그 속성값

	HTMLCOOKIE_CSS,					// <style

	/*
	  <script ~> 와 </script> 의 Java 클라이언트 스크립트 본문
	 */
	HTMLCOOKIE_JAVASCRIPT,			
	HTMLCOOKIE_VBSCRIPT,			
	HTMLCOOKIE_CLIENTSCRIPT_BRACKET,
	HTMLCOOKIE_CSS_BRACKET,
	/*
	  <% %> ,<? ?> 등 서버스크립트 본문
	  ASP with JavaScript and VBScript
     */
	HTMLCOOKIE_ASP,
	HTMLCOOKIE_ASPSTRING,			// "
	HTMLCOOKIE_ASPLINECOM,			// ' or rem
	HTMLCOOKIE_PHP,
	HTMLCOOKIE_PHPSTRING,			// ' or " :작은 따옴표single quotation marks 《 '》와 큰 따옴표double quotation marks《" "》 
	HTMLCOOKIE_PHPSINGLESTRING,		// ' or " :작은 따옴표single quotation marks 《 '》와 큰 따옴표double quotation marks《" "》 
	HTMLCOOKIE_PHPLINECOM,			// // or #
	HTMLCOOKIE_PHPBLOCKCOM,			// /* */

	HTMLCOOKIE_JSP,
	HTMLCOOKIE_JSPBLOCKCOM,			// <%-- --%>
	HTMLCOOKIE_URL,
};

enum ENUM_HTMLSTYLEINDEX{
	HTML_STYLE_NORMAL = STYLEINDEX_NORMAL,
	HTML_STYLE_URL    = STYLEINDEX_URL,
	HTML_STYLE_TAG    = STYLEINDEX_USER,
	HTML_STYLE_ATTR,
	HTML_STYLE_VALUE,
	HTML_STYLE_COMMENT,
	HTML_STYLE_OPERATOR,
	HTML_STYLE_FUNCNAME,
	HTML_STYLE_CS,		//Client Script
	HTML_STYLE_CSKEY,
	HTML_STYLE_CSSTRING,
	HTML_STYLE_CSCOMMENT,
	HTML_STYLE_CSOPERATOR,
	HTML_STYLE_CSFUNCNAME,
	HTML_STYLE_SS,		//Server Script
	HTML_STYLE_SSKEY,
	HTML_STYLE_SSSTRING,
	HTML_STYLE_SSCOMMENT,
	HTML_STYLE_SSFUNCTION,
	HTML_STYLE_SSOPERATOR,
	HTML_STYLE_SSFUNCNAME,
};

DEParserHtml::DEParserHtml()
{
	m_aTextStyle[STYLEINDEX_SEARCH]	= DETEXTSTYLE("검색결과",RGB(255,255,0),RGB(128,0,0));
	m_aTextStyle[HTML_STYLE_NORMAL]	= DETEXTSTYLE("보통",COLOR_DEFAULT,COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_URL]	= DETEXTSTYLE("링크",RGB(0,0,255)		,COLOR_DEFAULT		,0,1,1);
	m_aTextStyle[HTML_STYLE_TAG]	= DETEXTSTYLE("HTML 일반"	,RGB(0,0,255),COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_ATTR]	= DETEXTSTYLE("HTML 속성"	,RGB(255,0,0),COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_VALUE]	= DETEXTSTYLE("HTML 속성값"	,RGB(0,128,0)		,COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_COMMENT]	= DETEXTSTYLE("HTML 주석"	,RGB(128,128,128)	,COLOR_DEFAULT,0,0,1);
	m_aTextStyle[HTML_STYLE_OPERATOR]	= DETEXTSTYLE("연산자"			,RGB(256,64,96)		,COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_FUNCNAME]	= DETEXTSTYLE("일반 함수이름"	,RGB(196,96,96)		,COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_CS]		= DETEXTSTYLE("Client Script 코드"		,RGB(128,0,0)		,COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_CSKEY]	= DETEXTSTYLE("Client Script 키워드"		,RGB(128,0,255)		,COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_CSSTRING]	= DETEXTSTYLE("Client Script 문자열"		,RGB(225,0,225)		,COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_CSCOMMENT]	= DETEXTSTYLE("Client Script 주석"		,RGB(0,128,0)		,COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_CSOPERATOR]	= DETEXTSTYLE("Client Script 연산자"		,RGB(128,72,0)		,COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_CSFUNCNAME]	= DETEXTSTYLE("Client Script 함수이름"	,RGB(142,0,128)		,COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_SS]		= DETEXTSTYLE("Server Script 코드"		,RGB(0,64,128)		,COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_SSKEY]	= DETEXTSTYLE("Server Script 키워드"		,RGB(0,0,255)		,COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_SSSTRING]	= DETEXTSTYLE("Server Script 문자열"		,RGB(225,0,225)		,COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_SSCOMMENT]	= DETEXTSTYLE("Server Script 주석"		,RGB(128,0,128)		,COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_SSFUNCTION]	= DETEXTSTYLE("Server Script 함수"		,RGB(255,0,0)		,COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_SSOPERATOR]	= DETEXTSTYLE("Server Script 연산자"		,RGB(24,64,96)		,COLOR_DEFAULT);
	m_aTextStyle[HTML_STYLE_SSFUNCNAME]	= DETEXTSTYLE("Server Script 함수이름"	,RGB(96,96,128)		,COLOR_DEFAULT);
}

[+]BOOL DEParserHtml::IsHTMLTag(LPCTSTR lpBuffer,int nLen)
[+]BOOL DEParserHtml::IsHTMLAttr(LPCTSTR lpBuffer,int nLen)
[+]BOOL DEParserHtml::IsJSPFunction(LPCTSTR lpBuffer,int nLen)
[+]BOOL DEParserHtml::IsJSPKeyword(LPCTSTR lpBuffer,int nLen)


[+]
BOOL
DEParserHtml::IsPhpKeyword(LPCTSTR lpBuffer,int nLen) [+]BOOL DEParserHtml::IsPhpFunction(LPCTSTR lpBuffer,int nLen) [+]BOOL DEParserHtml::IsAspKeyword(LPCTSTR lpBuffer,int nLen) [+]BOOL DEParserHtml::IsOperator(TCHAR ch) [-]DWORD DEParserHtml::ParseLine(DWORD dwCookie,DEPARAINFO *ParaInfo,LPCALLBACKPUSHTEXTBLOCK
lpfnCallbackPushTextBlock)
{
	int i;
	int iEnd;
	int QuitFlag = 0;

	BOOL bFirstChar = TRUE;
	BOOL bRedefineBlock = TRUE;
	BOOL bDecIndex = FALSE;
	int  iBegin = -1;
	BOOL bScriptTag = FALSE;
	int nCookie = LOBYTE(LOWORD(dwCookie));
	int nPrevID = HIBYTE(LOWORD(dwCookie));
	int nRootID = HIBYTE(HIWORD(dwCookie));
	int nCurrID = LOBYTE(HIWORD(dwCookie));

	//다음라인에 영향을 주는(이전라인에서 영향을 받아 계승하는) 블럭쿠키들
	//공백줄
	if(ParaInfo->nLen <= 0){//블럭주석 처리시는 체크
		if(nCookie == HTMLCOOKIE_PHPBLOCKCOM || nCookie == HTMLCOOKIE_JSPBLOCKCOM) // /* or <%-- --%>
			DEFINE_BLOCK(0,(nCurrID <= HTMLCOOKIE_VBSCRIPT) ? HTML_STYLE_CSCOMMENT : HTML_STYLE_SSCOMMENT);
		else if(nCookie == HTMLCOOKIE_COMMENT) // <!-- 블럭가능
			DEFINE_BLOCK(0,HTML_STYLE_COMMENT);
		else if(nCookie == HTMLCOOKIE_ASP || nCookie == HTMLCOOKIE_PHP)
			DEFINE_BLOCK(0,HTML_STYLE_SS);
		else if(nCookie == HTMLCOOKIE_JAVASCRIPT || nCookie == HTMLCOOKIE_VBSCRIPT)
			DEFINE_BLOCK(0,HTML_STYLE_CS);
		else if(nCookie == HTMLCOOKIE_PHPLINECOM || nCookie == HTMLCOOKIE_ASPLINECOM){	// // or #
			DEFINE_BLOCK(0,(nCurrID <= HTMLCOOKIE_VBSCRIPT) ? HTML_STYLE_CS : HTML_STYLE_SS);
			//nCookie = nCurrID;
		}
		else{ //asp는 ' 나 rem 한줄 주석밖에 없음
			DEFINE_BLOCK(0,HTML_STYLE_NORMAL);
			nCookie = HTMLCOOKIE_NORMAL;
		}
		return MAKELONG(MAKEWORD(nCookie,nPrevID),MAKEWORD(nCurrID,nRootID));
	}
	for (i = 0; i < ParaInfo->nLen ; i++){
		if(bRedefineBlock)//새 블록 시작시
		{
			int nPos = i;
			if(bDecIndex)
				nPos--;

			bRedefineBlock = FALSE;
			bDecIndex = FALSE;
			iBegin = i;
			switch(nCookie){
			case HTMLCOOKIE_VALUE1:
			case HTMLCOOKIE_VALUE2:
				DEFINE_BLOCK(nPos,HTML_STYLE_VALUE);
				break;
			case HTMLCOOKIE_VBSCRIPT:
			case HTMLCOOKIE_JAVASCRIPT:
				DEFINE_BLOCK(nPos,HTML_STYLE_CS);
				break;
			case HTMLCOOKIE_ASP:
			case HTMLCOOKIE_PHP:
				DEFINE_BLOCK(nPos,HTML_STYLE_SS);
				break;
			case HTMLCOOKIE_ASPSTRING:
			case HTMLCOOKIE_PHPSTRING:
			case HTMLCOOKIE_PHPSINGLESTRING:
				DEFINE_BLOCK(nPos,(nCurrID <= HTMLCOOKIE_VBSCRIPT) ? HTML_STYLE_CSSTRING : HTML_STYLE_SSSTRING);
				break;
			case HTMLCOOKIE_COMMENT:
				DEFINE_BLOCK(nPos,HTML_STYLE_COMMENT);
				break;
			case HTMLCOOKIE_PHPBLOCKCOM:
			case HTMLCOOKIE_JSPBLOCKCOM:
				DEFINE_BLOCK(nPos,(nCurrID <= HTMLCOOKIE_VBSCRIPT) ? HTML_STYLE_CSCOMMENT : HTML_STYLE_SSCOMMENT);
				break;
			case HTMLCOOKIE_PHPLINECOM:
			case HTMLCOOKIE_ASPLINECOM:
				DEFINE_BLOCK(nPos,(nCurrID <= HTMLCOOKIE_VBSCRIPT) ? HTML_STYLE_CS : HTML_STYLE_SS);
				nCookie = nCurrID;//CRLF로 분리된 파라단위로 들어오기 때문에 노멀처리한다.
				break;
			case HTMLCOOKIE_URL:
				if(nPrevID == HTMLCOOKIE_PHPBLOCKCOM)
					DEFINE_BLOCK_EX(nPos,HTML_STYLE_URL,textmask_nocolor);
				else
					DEFINE_BLOCK(nPos,HTML_STYLE_URL);
				break;
			case HTMLCOOKIE_BRACKET:
			case HTMLCOOKIE_CLIENTSCRIPT_BRACKET:
			case HTMLCOOKIE_CSS_BRACKET:
				DEFINE_BLOCK(nPos,HTML_STYLE_TAG);
				break;
			default:
				DEFINE_BLOCK(nPos,HTML_STYLE_NORMAL);
				break;
			}
		}

		if(i >= ParaInfo->nLen)
			break;
		//[2]해제루틴
		switch(nCookie){
		//str = "<a href=""/"">home</a>"
		case HTMLCOOKIE_ASPSTRING:
			if(ParaInfo->pBuff[i]=='\"'){// && (ParaInfo->pBuff[i+1] != '\"')) {
				bRedefineBlock = TRUE;
				nCookie = nCurrID;
			}
			continue;
		case HTMLCOOKIE_PHPSTRING:
		case HTMLCOOKIE_PHPSINGLESTRING:
			{
				TCHAR ch = '\"';
				if(nCookie == HTMLCOOKIE_PHPSINGLESTRING)
					ch = '\'';
				if(ParaInfo->pBuff[i]== ch && (i == 0 || i > 0 && ParaInfo->pBuff[i-1] != '\\')) {
					bRedefineBlock = TRUE;
					nCookie = nCurrID;
					continue;
				}
				if(CheckURL(ParaInfo->pBuff + i,6))
				{
					DEFINE_BLOCK_EX(i,HTML_STYLE_URL,textmask_nocolor);
					nPrevID = nCookie;
					nCookie = HTMLCOOKIE_URL;
					i += 6;
					continue;
				}
			}
			continue;
		case HTMLCOOKIE_URL:
			if(IsSpaceChar(ParaInfo->pBuff[i]) || ParaInfo->pBuff[i] == '\t' ||
				ParaInfo->pBuff[i] == '\"' || ParaInfo->pBuff[i] == ';' || ParaInfo->pBuff[i] == ')' || ParaInfo->pBuff[i] == '<'){
				bRedefineBlock = TRUE;
				nCookie = nPrevID;
				i--;
				continue;
			}
			if(ParaInfo->pBuff[i] == '/' && (ParaInfo->pBuff[i+1] == '/' || ParaInfo->pBuff[i+1] == '*')){
				bRedefineBlock = TRUE;
				nCookie = nCurrID;
				i--;
				continue;
			}
			continue;
		case HTMLCOOKIE_COMMENT:
			if (ParaInfo->pBuff[i]=='-' && ParaInfo->pBuff[i+1]=='-' && ParaInfo->pBuff[i+2]=='>') {
				i+=2;
				bRedefineBlock = TRUE;
				nCookie = nCurrID;
			}
			continue;
		case HTMLCOOKIE_PHPBLOCKCOM:
			if (ParaInfo->pBuff[i]=='*' && ParaInfo->pBuff[i+1]=='/') {
				i++;
				bRedefineBlock = TRUE;
				nCookie = nCurrID;
			}
			if(CheckURL(ParaInfo->pBuff + i,6))
			{
				DEFINE_BLOCK_EX(i,HTML_STYLE_URL,textmask_nocolor);
				nPrevID = nCookie;
				nCookie = HTMLCOOKIE_URL;
				i += 6;
				continue;
			}
			continue;
		case HTMLCOOKIE_JSPBLOCKCOM:
			if (ParaInfo->pBuff[i]=='-' && ParaInfo->pBuff[i+1]=='-' && ParaInfo->pBuff[i+2]=='%'
				 && ParaInfo->pBuff[i+3]=='>') {
				i+=3;
				bRedefineBlock = TRUE;
				nCookie = nCurrID;
			}
			continue;
		case HTMLCOOKIE_VALUE1:
			if (ParaInfo->pBuff[i]=='\\') {
				i++;
				continue;
			}
			if (ParaInfo->pBuff[i]=='\"') {
				bRedefineBlock = TRUE;
				nCookie = HTMLCOOKIE_BRACKET;
			}
			continue;
		case HTMLCOOKIE_VALUE2:
			if (ParaInfo->pBuff[i]=='\\') {
				i++;
				continue;
			}
			if (ParaInfo->pBuff[i]=='\'') {
				bRedefineBlock = TRUE;
				nCookie = HTMLCOOKIE_BRACKET;
			}
			continue;
		case HTMLCOOKIE_ASP:
			if (ParaInfo->pBuff[i]=='%' && ParaInfo->pBuff[i+1]=='>') {
				i++;
				bRedefineBlock = TRUE;
				//자바스크립트영역내에서도 호출될 수 있음
				nCookie = nRootID;//Normal or Script
				continue;
			}
			break;
		case HTMLCOOKIE_PHP:
			if (ParaInfo->pBuff[i]=='?' && ParaInfo->pBuff[i+1]=='>') {
				i++;
				bRedefineBlock = TRUE;
				nCookie = nRootID;//Normal or Script
				continue;
			}
			break;
		case HTMLCOOKIE_BRACKET:
		case HTMLCOOKIE_CLIENTSCRIPT_BRACKET:
		case HTMLCOOKIE_CSS_BRACKET:
			if(ParaInfo->pBuff[i]=='>') {
				DEFINE_BLOCK(i,HTML_STYLE_TAG);
				bRedefineBlock = TRUE;
				//내가속한 본문속성으로,자바스크립트 시작태그이면 HTMLCOOKIE_JAVASCRIPT 이고
				//일반 태그나 스크립트 끝 태그이면 HTMLCOOKIE_NORMAL 
				nCookie = nCurrID;
				continue;
			}
			break;
		case HTMLCOOKIE_CSS:
			if(ParaInfo->pBuff[i]=='<') {
				if(ParaInfo->pBuff[i+1]=='/' && !strnicmp(ParaInfo->pBuff+i+2,"style",5)){
					DEFINE_BLOCK(i,HTML_STYLE_TAG);
					bRedefineBlock = TRUE;
					nCookie = HTMLCOOKIE_BRACKET;
					nCurrID = HTMLCOOKIE_NORMAL;//각문서의 기본쿠키로 설정할것
					continue;
				}
			}
			break;
		case HTMLCOOKIE_JAVASCRIPT: //자바,vb스크립트 본문
		case HTMLCOOKIE_VBSCRIPT:
			if (ParaInfo->pBuff[i]=='-' && ParaInfo->pBuff[i+1]=='-' && ParaInfo->pBuff[i+2]=='>') {
				DEFINE_BLOCK(i,HTML_STYLE_COMMENT);
				i+=2;
				bRedefineBlock = TRUE;
				nCookie = nCurrID;
				continue;
			}
			if(ParaInfo->pBuff[i]=='<') {
				if(ParaInfo->pBuff[i+1]=='/' && !strnicmp(ParaInfo->pBuff+i+2,"script",6)){
					DEFINE_BLOCK(i,HTML_STYLE_TAG);
					bRedefineBlock = TRUE;
					nCookie = HTMLCOOKIE_BRACKET;
					nCurrID = HTMLCOOKIE_NORMAL;//각문서의 기본쿠키로 설정할것
					continue;
				}
			}
			break;
		}

		//[1]설정루틴
		switch(nCookie){
			case HTMLCOOKIE_NORMAL://among HTML Tag (HTML 일반)
				if (ParaInfo->pBuff[i]=='<' && ParaInfo->pBuff[i+1]=='!' && ParaInfo->pBuff[i+2]=='-' && ParaInfo->pBuff[i+3]=='-') {
					DEFINE_BLOCK(i,HTML_STYLE_COMMENT);
					i += 3;
					nCookie = HTMLCOOKIE_COMMENT;
					continue;
				}
				//ASP or JSP
				if (ParaInfo->pBuff[i]=='<' && ParaInfo->pBuff[i+1]=='%') {
					DEFINE_BLOCK(i,HTML_STYLE_SS);
					i += 1;
					nRootID = nCookie;
					nCurrID = nCookie = HTMLCOOKIE_ASP;
					//TODO:: ';'유무로 JSP 구분지어야 함.
					//이유는 ASP는 '가 한라인 주석으로 처리되고 JSP는 C,PHP와 같이
					//문자열로 취급하기 때문이다.
					continue;
				}
				if (ParaInfo->pBuff[i]=='<' && ParaInfo->pBuff[i+1]=='?') {
					DEFINE_BLOCK(i,HTML_STYLE_SS);
					i += 1;
					nRootID = nCookie;
					nCurrID = nCookie = HTMLCOOKIE_PHP;
					continue;
				}
				if (!strnicmp(ParaInfo->pBuff+i,"<style",6)) {
					DEFINE_BLOCK(i,HTML_STYLE_TAG);
					i +=5;
					bScriptTag = 1;
					nRootID = nCookie;
					nCurrID = HTMLCOOKIE_CSS;
					nCookie = HTMLCOOKIE_BRACKET;
					continue;
				}
				if (!strnicmp(ParaInfo->pBuff+i,"<script",7)) {
					DEFINE_BLOCK(i,HTML_STYLE_TAG);
					i +=6;
					bScriptTag = 1;
					nRootID = nCookie;
					nCurrID = HTMLCOOKIE_JAVASCRIPT;
					if(FindBuffer(ParaInfo->pBuff+i+7,TEXT("vbscript"),128) != -1){
						nCurrID = HTMLCOOKIE_VBSCRIPT;
					}
					nCookie = HTMLCOOKIE_CLIENTSCRIPT_BRACKET;
					continue;
				}
				if (ParaInfo->pBuff[i]=='<') {
					bScriptTag = 0;
					DEFINE_BLOCK(i,HTML_STYLE_TAG);
					nRootID = nCookie;
					nCurrID = nCookie;
					nCookie = HTMLCOOKIE_BRACKET;
					continue;
				}
				if(CheckURL(ParaInfo->pBuff + i,6))
				{
					DEFINE_BLOCK(i,HTML_STYLE_URL);
					nRootID = nCookie;
					nPrevID = nCurrID = nCookie;
					nCookie = HTMLCOOKIE_URL;
					i += 6;
					continue;
				}
				break;
			case HTMLCOOKIE_JAVASCRIPT:
			case HTMLCOOKIE_VBSCRIPT:
				if (ParaInfo->pBuff[i]=='<' && ParaInfo->pBuff[i+1]=='!' && ParaInfo->pBuff[i+2]=='-' && ParaInfo->pBuff[i+3]=='-') {
					DEFINE_BLOCK(i,HTML_STYLE_COMMENT);
					i += 3;
					bRedefineBlock = TRUE;
					continue;
				}
				//ASP or JSP
				if (ParaInfo->pBuff[i]=='<' && ParaInfo->pBuff[i+1]=='%') {
					DEFINE_BLOCK(i,HTML_STYLE_SS);
					i += 1;
					nRootID = nCookie;
					nCurrID = nCookie = HTMLCOOKIE_ASP;
					continue;
				}
				if (ParaInfo->pBuff[i]=='<' && ParaInfo->pBuff[i+1]=='?') {
					DEFINE_BLOCK(i,HTML_STYLE_SS);
					i += 1;
					nRootID = nCookie;
					nCurrID = nCookie = HTMLCOOKIE_PHP;
					continue;
				}
				if (ParaInfo->pBuff[i]=='\"') {
					DEFINE_BLOCK(i,HTML_STYLE_CSSTRING);
					nCurrID = nCookie;
					nCookie = HTMLCOOKIE_PHPSTRING;
					if(nCookie == HTMLCOOKIE_VBSCRIPT)
						nCookie = HTMLCOOKIE_ASPSTRING;
					
					continue;
				}
				if(CheckURL(ParaInfo->pBuff + i,6))
				{
					DEFINE_BLOCK(i,HTML_STYLE_URL);
					nRootID = nCookie;
					nPrevID = nCurrID = nCookie;
					nCookie = HTMLCOOKIE_URL;
					i += 6;
					continue;
				}
				if(nCookie == HTMLCOOKIE_VBSCRIPT){
					if (ParaInfo->pBuff[i]=='\'' ||
						(!strnicmp(ParaInfo->pBuff+i,"rem",3) && IsSpaceChar(ParaInfo->pBuff[i+3]))) {
						DEFINE_BLOCK(i,HTML_STYLE_CSCOMMENT);
						nCurrID = nCookie;
						nCookie = HTMLCOOKIE_ASPLINECOM;//CRLF로 분리된 파라단위로 들어오기 때문에 노멀처리한다.
						goto QuitParse;
					}
					break;
				}
				if (ParaInfo->pBuff[i]=='/' && ParaInfo->pBuff[i+1]=='*') {
					DEFINE_BLOCK(i,HTML_STYLE_CSCOMMENT);
					nCurrID = nCookie;
					nCookie = HTMLCOOKIE_PHPBLOCKCOM;
					i++;
					continue;
				}
				if ((ParaInfo->pBuff[i]=='/' && ParaInfo->pBuff[i+1]=='/')) {
					DEFINE_BLOCK(i,HTML_STYLE_CSCOMMENT);
					nCurrID = nCookie;
					nCookie = HTMLCOOKIE_PHPLINECOM;//CRLF로 분리된 파라단위로 들어오기 때문에 노멀처리한다.
					goto QuitParse;
				}
				break;
			case HTMLCOOKIE_ASP:
				if (ParaInfo->pBuff[i]=='<' && ParaInfo->pBuff[i+1]=='%' && ParaInfo->pBuff[i+2]=='-' 
					&& ParaInfo->pBuff[i+3]=='-') {
						DEFINE_BLOCK(i,HTML_STYLE_SSCOMMENT);
						nCurrID = nCookie;
						nCookie = HTMLCOOKIE_JSPBLOCKCOM;
						i += 3;
						continue;
				}
				if (ParaInfo->pBuff[i]=='\"') {
					DEFINE_BLOCK(i,HTML_STYLE_SSSTRING);
					nCurrID = nCookie;
					nCookie = HTMLCOOKIE_ASPSTRING;
					continue;
				}
				if (ParaInfo->pBuff[i]=='\'' || 
					(!strnicmp(ParaInfo->pBuff+i,"rem",3) && IsSpaceChar(ParaInfo->pBuff[i+3]))) {
					DEFINE_BLOCK(i,HTML_STYLE_SSCOMMENT);
					nCookie = HTMLCOOKIE_ASPLINECOM;//CRLF로 분리된 파라단위로 들어오기 때문에 노멀처리한다.
					goto QuitParse;
				}
				else if(CheckURL(ParaInfo->pBuff + i,6))
				{
					DEFINE_BLOCK(i,HTML_STYLE_URL);
					nPrevID = nCurrID = nCookie;
					nCookie = HTMLCOOKIE_URL;
					i += 6;
					continue;
				}
				if(IsOperator(ParaInfo->pBuff[i])){
					DEFINE_BLOCK(i,HTML_STYLE_SSOPERATOR);
					bRedefineBlock = TRUE;
					continue;
				}
				break;
			case HTMLCOOKIE_PHP:
				if (ParaInfo->pBuff[i]=='\"' || ParaInfo->pBuff[i]=='\'' ) {
					DEFINE_BLOCK(i,HTML_STYLE_SSSTRING);
					nCookie = HTMLCOOKIE_PHPSTRING;
					if(ParaInfo->pBuff[i]=='\'')
						nCookie = HTMLCOOKIE_PHPSINGLESTRING;
					continue;
				}
				if (ParaInfo->pBuff[i]=='/' && ParaInfo->pBuff[i+1]=='*') {
					DEFINE_BLOCK(i,HTML_STYLE_SSCOMMENT);
					nCookie = HTMLCOOKIE_PHPBLOCKCOM;
					i++;
					continue;
				}
				if ((ParaInfo->pBuff[i]=='/' && ParaInfo->pBuff[i+1]=='/') || (ParaInfo->pBuff[i]=='#')) {
					DEFINE_BLOCK(i,HTML_STYLE_SSCOMMENT);
					nCookie = HTMLCOOKIE_PHPLINECOM;//CRLF로 분리된 파라단위로 들어오기 때문에 노멀처리한다.
					goto QuitParse;
				}
				else if(CheckURL(ParaInfo->pBuff + i,6))
				{
					DEFINE_BLOCK(i,HTML_STYLE_URL);
					nPrevID = nCurrID = nCookie;
					nCookie = HTMLCOOKIE_URL;
					i += 6;
					continue;
				}
				if(IsOperator(ParaInfo->pBuff[i])){
					DEFINE_BLOCK(i,HTML_STYLE_SSOPERATOR);
					bRedefineBlock = TRUE;
					continue;
				}
				break;
			case HTMLCOOKIE_BRACKET:
			case HTMLCOOKIE_CLIENTSCRIPT_BRACKET:
			
				if (ParaInfo->pBuff[i]=='\"') {
					DEFINE_BLOCK(i,HTML_STYLE_VALUE);
					nCookie = HTMLCOOKIE_VALUE1;
					continue;
				}
				if (ParaInfo->pBuff[i]=='\'') {
					DEFINE_BLOCK(i,HTML_STYLE_VALUE);
					nCookie = HTMLCOOKIE_VALUE2;
					continue;
				}
				break;
		}
		if(bFirstChar)
		{
			if(!IsSpaceChar(ParaInfo->pBuff[i]))
				bFirstChar = FALSE;
		}

		if(!strchr(GetInfo(1),ParaInfo->pBuff[i])){//기호가 아닌 영문알파벳등이면
			if(iBegin == -1)
				iBegin = i;
		}
		else{//공백 및 기호들
ProcParse:
			if(iBegin >= 0){
				bDecIndex = TRUE;
				iEnd = (i == ParaInfo->nLen -1) ? i + 1 : i;
				if(iEnd == iBegin){
					switch(nCookie){
					case HTMLCOOKIE_CSS:
						if(IsOperator(ParaInfo->pBuff[iBegin])){
							DEFINE_BLOCK(iBegin,HTML_STYLE_OPERATOR);
							bDecIndex = FALSE;
						}
						break;
					case HTMLCOOKIE_JAVASCRIPT:
					case HTMLCOOKIE_VBSCRIPT:
						if(IsOperator(ParaInfo->pBuff[iBegin])){
							DEFINE_BLOCK(iBegin,HTML_STYLE_CSOPERATOR);
							bDecIndex = FALSE;
						}
						break;
					case HTMLCOOKIE_ASP:
					case HTMLCOOKIE_JSP:
					case HTMLCOOKIE_PHP:
						if(IsOperator(ParaInfo->pBuff[iBegin])){
							DEFINE_BLOCK(iBegin,HTML_STYLE_SSOPERATOR);
							bDecIndex = FALSE;
						}
						break;
					}
				}
				if(iEnd - iBegin >= 1){
					switch(nCookie){
						case HTMLCOOKIE_CSS:
							if (IsAttr(ParaInfo->pBuff + iBegin,iEnd - iBegin))
								DEFINE_BLOCK(iBegin,HTML_STYLE_ATTR);
							break;
						case HTMLCOOKIE_JAVASCRIPT:
						case HTMLCOOKIE_VBSCRIPT:
							if (IsAspKeyword(ParaInfo->pBuff+iBegin,iEnd-iBegin))
								DEFINE_BLOCK(iBegin,HTML_STYLE_CSKEY);
							else if (IsPhpKeyword(ParaInfo->pBuff + iBegin,iEnd - iBegin))
								DEFINE_BLOCK(iBegin,HTML_STYLE_CSKEY);
							else{//현재 i위치부터 공백,탭이나 _ 문자가 아닐때까지 탐색,함수명 뒤에 괄호사이에 func  () 낀 공백스킵
								int n = i;
								while(n < ParaInfo->nLen && ParaInfo->pBuff[n] && ( IsSpaceChar(ParaInfo->pBuff[n]) || ParaInfo->pBuff[n] == '_')) n++;
								if(ParaInfo->pBuff[n]  == '(')
									DEFINE_BLOCK(iBegin,HTML_STYLE_CSFUNCNAME);
							}
							break;
						case HTMLCOOKIE_ASP:
							if (IsAspKeyword(ParaInfo->pBuff+iBegin,iEnd-iBegin))
								DEFINE_BLOCK(iBegin,HTML_STYLE_SSKEY);
							else{//현재 i위치부터 공백,탭이나 _ 문자가 아닐때까지 탐색,함수명 뒤에 괄호사이에 func  () 낀 공백스킵
								int n = i;
								while(n < ParaInfo->nLen && ParaInfo->pBuff[n] && ( IsSpaceChar(ParaInfo->pBuff[n]) || ParaInfo->pBuff[n] == '_')) n++;
								if(ParaInfo->pBuff[n]  == '(')
									DEFINE_BLOCK(iBegin,HTML_STYLE_SSFUNCNAME);
							}
							break;
						case HTMLCOOKIE_PHP:
							if (IsPhpKeyword(ParaInfo->pBuff + iBegin,iEnd - iBegin))
								DEFINE_BLOCK(iBegin,HTML_STYLE_SSKEY);
							else if (IsPhpFunction(ParaInfo->pBuff+iBegin,iEnd - iBegin))
								DEFINE_BLOCK(iBegin,HTML_STYLE_SSFUNCTION);
							else{//현재 i위치부터 공백,탭이나 _ 문자가 아닐때까지 탐색,함수명 뒤에 괄호사이에 func  () 낀 공백스킵
								int n = i;
								while(n < ParaInfo->nLen && ParaInfo->pBuff[n] && ( IsSpaceChar(ParaInfo->pBuff[n]) || ParaInfo->pBuff[n] == '_')) n++;
								if(ParaInfo->pBuff[n]  == '(')
									DEFINE_BLOCK(iBegin,HTML_STYLE_SSFUNCNAME);
							}
							break;
						case HTMLCOOKIE_BRACKET:
							if((iBegin > 0 && ParaInfo->pBuff[iBegin-1] == '<') || (iBegin > 1 && ParaInfo->pBuff[iBegin-2]=='<' && ParaInfo->pBuff[iBegin-1]=='/')) {
								if (IsHTMLTag(ParaInfo->pBuff + iBegin,iEnd - iBegin)) {
									if (iBegin > 0 && ParaInfo->pBuff[iBegin-1] == '/' )
										iBegin--;
									DEFINE_BLOCK(iBegin,HTML_STYLE_TAG);
								}
							}
							else if (IsHTMLAttr(ParaInfo->pBuff + iBegin,iEnd - iBegin))
								DEFINE_BLOCK(iBegin,HTML_STYLE_ATTR);
							else{//태그내 스크립트 함수명: 현재 i위치부터 공백,탭이나 _ 문자가 아닐때까지 탐색,함수명 뒤에 괄호사이에 func  () 낀 공백스킵
								int n = i;
								while(n < ParaInfo->nLen && ParaInfo->pBuff[n] && ( IsSpaceChar(ParaInfo->pBuff[n]) || ParaInfo->pBuff[n] == '_')) n++;
								if(ParaInfo->pBuff[n]  == '(')
									DEFINE_BLOCK(iBegin,HTML_STYLE_FUNCNAME);
							}
					}
				}
				iBegin = i;
				switch(nCookie){
					case HTMLCOOKIE_CSS:
						if(IsOperator(ParaInfo->pBuff[iBegin])){
							DEFINE_BLOCK(iBegin,HTML_STYLE_OPERATOR);
							bDecIndex = FALSE;
						}
						break;
					case HTMLCOOKIE_JAVASCRIPT:
					case HTMLCOOKIE_VBSCRIPT:
						if(IsOperator(ParaInfo->pBuff[iBegin])){
							DEFINE_BLOCK(iBegin,HTML_STYLE_CSOPERATOR);
							bDecIndex = FALSE;
						}
						break;
					case HTMLCOOKIE_ASP:
					case HTMLCOOKIE_JSP:
					case HTMLCOOKIE_PHP:
						if(IsOperator(ParaInfo->pBuff[iBegin])){
							DEFINE_BLOCK(iBegin,HTML_STYLE_SSOPERATOR);
							bDecIndex = FALSE;
						}
						break;
				}
				bRedefineBlock = TRUE;
				iBegin = -1;
			}

			if(QuitFlag)
				goto QuitParse;
		}
	}
QuitParse:
	if(iBegin >= 0){
		QuitFlag = 1;
		goto ProcParse;
	}
	return MAKELONG(MAKEWORD(nCookie,nPrevID),MAKEWORD(nCurrID,nRootID));
}
소스 데이타 파일

<HTML>
<HEAD>
<TITLE>Baro Upload Test Form </TITLE>
<style type="text/css">
div,td { font-family: tahoma; font-size: 9pt }
input { border:1px solid; border-color:#CCCCCC }
textarea { border:1px solid; border-color:#CCCCCC }
</style>

<!--
// form의 file 필드의 버튼을 숨기는 스크립트..
// joyfileform.js 처럼 file 필드의 버튼을 숨겨줘야 제대로 동작하게 된다.
// joyfileform.js 를 로드 한뒤 body 태그에서 페이지의 로딩이 끝나면 
// file 필드의 버튼을 숨기는 함수를 호출 한다. 
// onload=activexFileForm(사용할 폼);  
-->
<script language="javascript" src="barotest.js"></script>
<script language="vbscript">
	dim aaa
	dim str = "<a href=""/"">home</a>"
function AttachFiles
	document.JoyUpLoad.AttachFiles
end function
</script>
<script language = "javascript">
http://zzangdol.lgnas.com:20000
<!--HIDE
var bUploadControl = true;
var bSubmit = false;

function AttachFiles()
{
<?
	/* PHP
	http://zzangdol.lgnas.com:20000
	*/
	//PHP 주석http://zzangdol.lgnas.com:20000
aaa = "http://zzangdol.lgnas.com:20000;"

set_time_limit(0);
$g_save_dir="../upload/";
?>

<%
	' ASP 주석
	<%--   JSP 주석  --%>
	dim aaa="aaa";
%>
	document.JoyUpLoad.AttachFiles(<? aaa(0);?>);
}

function AttachFilesForm(filefield)
{ 	
	if(document.JoyUpLoad.AttachFilesForm(filefield) == false){
		//alert("선택 실패");
	}
}
-->
function DeleteFiles()
{
	document.JoyUpLoad.DeleteFiles();
}

결과 화면