File: phpdevel.xml

package info (click to toggle)
phpdoc 20020310-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 35,272 kB
  • ctags: 354
  • sloc: xml: 799,767; php: 1,395; cpp: 500; makefile: 200; sh: 140; awk: 51
file content (870 lines) | stat: -rw-r--r-- 35,160 bytes parent folder | download
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
858
859
860
861
862
863
864
865
866
867
868
869
870
<?xml version="1.0" encoding="utf-8"?>
<appendix id="phpdevel">
	<title>PHP 개발</title>
	<simpara/>
	<sect1 id="phpdevel-addfunc">
		<title>PHP 3에 함수 추가</title>
		<sect2 id="phpdevel-addfunc-prototype">
			<title>함수 표본</title>
			<para>
모든 함수는 다음과 같다:
    <programlisting>       
void php3_foo(INTERNAL_FUNCTION_PARAMETERS) {
     
}
    </programlisting>
비록 함수가 어떤 인수도 갖지 않더라도 함수라 칭한다.
</para>
		</sect2>
		<sect2 id="phpdevel-addfunc-args">
			<title>함수 인자</title>
			<para>
인자는 언제나 pval타입이다. 이 타입은 인자의 실제타입(actual type)의 결합을 포함한다.
그래서, 당신의 함수가 2개의 인자를 가진다면 당신은 당신의 함수 맨위에서 따르는것처럼 해야 할 것이다:
</para>
			<para>
				<example>
					<title>함수 인자 가져오기</title>
					<programlisting>
pval *arg1, *arg2;
if (ARG_COUNT(ht) != 2 || getParameters(ht,2,&amp;arg1,&amp;arg2)==FAILURE) {
   WRONG_PARAM_COUNT;
}
     </programlisting>
				</example>
노트 : 함수는 값이나 참조 둘중 하나로 인자를 넘길수 있다. 
양쪽 경우다 당신은 &amp;(pval *) 에서 getParameters로 통과하는게 필요할 것이다.
당신이 체크하겠다면 몇번째 인자가 당신에게 참조값이나 아닌것으로 보내지는지 
안다면 함수에서 사용할수 있다.
ParameterPassedByReference(ht,n). 그건 1이나 0 값을 반환한다.
</para>
			<simpara>
당신은 넘겨온 인자의 어떤것을 변경할때 그들은 참조나 값에 의해 보낼지 아닐지 
pval_destuctor 라 불리운 인자를 시작하거나, 만약 배열이라면 추가할때 함수 비숫하게 
배열같은 반환값을 다루는 internal_functions.h내에서 사용할수 있다
</simpara>
			<simpara>
이미 당신은 IS_STRING으로 인자를 바꾼다면 새로운 estrdup()였던 문자열, 문자열 길이, 
가장 나중에 바꾼 IS_STRING의 타입을 먼저 할당하는 것을 확실히 해야 한다.
이미 존재하는 IS_STRING이나 IS_ARRAY같은 인자의 문자열을 바꾼다면
pval_destructor를 먼저 실행해야 할 것이다.</simpara>
		</sect2>
		<sect2 id="phpdevel-addfunc-varargs">
			<title>변수형 함수 표본</title>
			<para>
이 함수는 표본의 변수형 숫자 가질 수 있다. 
당신의 함수가 2개나 3개의 인자를 가질수 있다면 다음과 같이 사용하라:
</para>
			<para>
				<example>
					<title>변수형 함수 인자</title>
					<programlisting>
pval *arg1, *arg2, *arg3;
int arg_count = ARG_COUNT(ht);

if (arg_count &lt; 2 || arg_count &gt; 3 ||
    getParameters(ht,arg_count,&amp;arg1,&amp;arg2,&amp;arg3)==FAILURE) {
    WRONG_PARAM_COUNT;
}
    </programlisting>
				</example>
			</para>
		</sect2>
		<sect2 id="phpdevel-addfunc-using-args">
			<title>함수 인자 사용하기</title>
			<para>
각 인자의 타입은 pval타입 필드로 저장된다. 이 타입은 다음중 어느것이든 사용할수 있다:		
    <table>
					<title>PHP 내부 타입들</title>
					<tgroup cols="2">
						<tbody>
							<row>
								<entry>IS_STRING</entry>
								<entry>String</entry>
							</row>
							<row>
								<entry>IS_DOUBLE</entry>
								<entry>Double-precision floating point</entry>
							</row>
							<row>
								<entry>IS_LONG</entry>
								<entry>Long integer</entry>
							</row>
							<row>
								<entry>IS_ARRAY</entry>
								<entry>Array</entry>
							</row>
							<row>
								<entry>IS_EMPTY</entry>
								<entry>None</entry>
							</row>
							<row>
								<entry>IS_USER_FUNCTION</entry>
								<entry>??</entry>
							</row>
							<row>
								<entry>IS_INTERNAL_FUNCTION</entry>
								<entry>?? (if some of these cannot be passed to a function - delete)</entry>
							</row>
							<row>
								<entry>IS_CLASS</entry>
								<entry>??</entry>
							</row>
							<row>
								<entry>IS_OBJECT</entry>
								<entry>??</entry>
							</row>
						</tbody>
					</tgroup>
				</table>
			</para>
			<para>
당신이 하나의 타입 인자 가지는 것과 다른 것처럼 사용하길 바라는 것 또는 
단지 확실한 타입의 인자를 시행하길 원한다면,
당신은 전환함수들 중 하나를 쓸수 있다:
    <programlisting>
convert_to_long(arg1);
convert_to_double(arg1);
convert_to_string(arg1); 
convert_to_boolean_long(arg1); /* If the string is "" or "0" it becomes 0, 1 otherwise */
convert_string_to_number(arg1);  /* Converts string to either LONG or DOUBLE depending on string */
     </programlisting>
			</para>
			<simpara>
이들 함수는 모두 하나로 변환를 한다. 아무런 반환을 하지 않는다.</simpara>
			<para>
실제적인 인자는 결합체로 저장된다; 그 구성원은: 
    <itemizedlist>
					<listitem>
						<simpara>IS_STRING: arg1-&gt;value.str.val</simpara>
					</listitem>
					<listitem>
						<simpara>IS_LONG: arg1-&gt;value.lval</simpara>
					</listitem>
					<listitem>
						<simpara>IS_DOUBLE: arg1-&gt;value.dval</simpara>
					</listitem>
				</itemizedlist>
			</para>
		</sect2>
		<sect2 id="phpdevel-addfunc-memmgmt">
			<title>함수내 메모리 관리</title>
			<simpara>
모든 메모리는 emalloc()이나 estrdup()로 할당되는 함수가 필요하다.
이것들은 malloc()와 strdup()함수과 같이 보이는 메모리처리가상함수이다.
메모리는 efree()로 해제될수 있다.
</simpara>
			<simpara>
이 프로그램내에서 두 종류의 메모리는:
변수형에서 파서를 반환하는 것과 당신이 내부 함수내 필요한 임시 기억장소.
당신이 문자열을 변수형으로 지정할때 
반환된 파서가 emalloc()나 estrdup()에 먼저 메모리에 할당되었는지 확인해야 한다. 
</simpara>
			<simpara>
어떤 임시/	영구 메모리를 위해 당신은 당신의 함수/라이브러리내에서 emalloc(), estrdup(), 그리고 efree() 함수 3개를 이용해야 한다.
당신은 사본 함수처럼 정확히 해야 할 것이다.

 Anything you emalloc() or estrdup() you have to efree()
    at some point or another, unless it's supposed to stick around
    until the end of the program; otherwise, there will be a memory
    leak. The meaning of "the functions behave exactly like their
    counterparts" is: if you efree() something which was not
    emalloc()'ed nor estrdup()'ed you might get a segmentation
    fault. So please take care and free all of your wasted memory.</simpara>
			<simpara>
만약 당신이 "-DDEBUG"로 컴파일한다면 PHP3는 지정된 emalloc()과 estrdup() 사용한 모든 메모리 리스트를 출력할 것이다. 명시된 스크립트가 실행되고 있을때는 efree()를 용한 해제를 해선 안된다.
</simpara>
		</sect2>
		<sect2 id="phpdevel-addfunc-symtab">
			<title>심볼 테이블에서 변수형 설정</title>
			<para>
			매크로들의 숫자는 심볼 테이블에서 더 쉽게 변수형으로 설정할 수 있다:
    <itemizedlist>
					<listitem>
						<simpara>SET_VAR_STRING(name,value) <footnoteref linkend="symtab-1"/>
						</simpara>
					</listitem>
					<listitem>
						<simpara>SET_VAR_DOUBLE(name,value)</simpara>
					</listitem>
					<listitem>
						<simpara>SET_VAR_LONG(name,value)</simpara>
					</listitem>
				</itemizedlist>
			</para>
			<para>
				<footnote id="symtab-1">
					<simpara>
이부분을 주의깊게 보라
이 값은 수동으로 malloc했어야 한다. 왜냐하면 메모리 관리 코드는 나중에 이 부분을
해제할 것이다. SET_VAR_STRING로부터 지정된 메모리를 정적으로 넘지 말아야 한다.</simpara>
				</footnote>
			</para>
			<simpara>
PHP 3.0의 심볼 테이블은 hash 테이블처럼 제공된다. 
주어진 어떤 시간에 &amp;symbol_table 은 'main' 심볼 테이블을 가르키고,
active_symbol_table은 현재 실행중인 심볼 테이블을 가르킨다.
(이것을은 아마 함수내에서 처음또는 다른때에도 동일할 것이다.)
</simpara>
			<para>

다음은 'active_symbol_table'을 이용한 예제들이다. 당신이 명확하게 'main' 심볼 테이블로 작업하길 원하면 &amp;symbol_table으로 그것을 대체해야 한다. 
마찬가지로 같은 함수들도 배열도 아래에 밝힌 것처럼 적용될 것이다. 
</para>
			<para>
				<example>
					<title>심볼테이블내 $foo가 존재하는지 체크</title>
					<programlisting>
if (hash_exists(active_symbol_table,"foo",sizeof("foo"))) { exists... }
else { doesn't exist }
     </programlisting>
				</example>
				<example>
					<title>심볼테이블내 변수형의 크기 찾기</title>
					<programlisting>
hash_find(active_symbol_table,"foo",sizeof("foo"),&amp;pvalue);
check(pvalue.type);
     </programlisting>
				</example>
PHP 3.0의 배열은 심볼 테이블처럼 같은 해시테이블로 사용하는 것을 제공된다.
두개 이상의 함수가 배열내에서 변수형을 체크하는 것을 할 수 있다는 뜻이다.    
</para>
			<simpara>
만약 당신 심볼테이블네에서 새로운 배열을 정의하길 원하면, 다음과 같이 해야 한다.
</simpara>
			<simpara>
			먼저 당신은 체크하길 원하는 것이 존재하는 지 승인이 취소되었는지 hash_exists()나 hash_find()로 확인해야 한다.
</simpara>
			<simpara>
다음, 배열을 초기화한다:</simpara>
			<para>
				<example>
					<title>새 배열 초기화</title>
					<programlisting>
pval arr;
  
if (array_init(&amp;arr) == FAILURE) { failed... };
hash_update(active_symbol_table,"foo",sizeof("foo"),&amp;arr,sizeof(pval),NULL);
     </programlisting>
				</example>
이 코드는 활성화된 심볼 테이블내에서 $foo란 이름으로 새 배열로 선언되었다.
이 배열은 비어 있다.</para>
			<simpara>
여기는 새 엔트리의 추가하는 법이다:
</simpara>
			<para>
				<example>
					<title>새 배열에 엔트리 추가</title>
					<programlisting>
pval entry;
  
entry.type = IS_LONG;
entry.value.lval = 5;
  
/* defines $foo["bar"] = 5 */
hash_update(arr.value.ht,"bar",sizeof("bar"),&amp;entry,sizeof(pval),NULL); 

/* defines $foo[7] = 5 */
hash_index_update(arr.value.ht,7,&amp;entry,sizeof(pval),NULL); 

/* defines the next free place in $foo[],
 * $foo[8], to be 5 (works like php2)
 */
hash_next_index_insert(arr.value.ht,&amp;entry,sizeof(pval),NULL); 
     </programlisting>
				</example>
만약 당신이 당신이 hash에 삽입한 값을 바꾸고 싶다면 당신은 먼저 hash에서 그것을 반환해와야 한다.

To prevent that overhead,
당신은 pval ** 에서 hash 추가 함수에 공급할수 있고, 그건 hash안에서 추가된 요소의pval * 주소로 수정될 수 있다.
만약 그 값이 &null; (모든 예제가 아닌 것처럼)이면, 그 인자는 무시된다.
</para>
			<simpara>
PHP 2.0에서 hash_next_index_insert() "$foo[] = bar;"같은 동일한 로직으로 사용되었다.</simpara>
			<simpara>
만약 함수로부터 반환을 위한 배열을 만든다면, 다음과 같이 배열을 초기화할수 있다:
</simpara>
			<programlisting>
if (array_init(return_value) == FAILURE) { failed...; }
   </programlisting>
			<simpara>
..그리고 helper함수와 함께 값을 추가한다
</simpara>
			<programlisting>
add_next_index_long(return_value,long_value);
add_next_index_double(return_value,double_value);
add_next_index_string(return_value,estrdup(string_value));
   </programlisting>
			<para>
물론, 배열초기화후 추가하지 않겠다면, 배열을 먼저 찾아야 한다:
<programlisting>
pval *arr;
  
if (hash_find(active_symbol_table,"foo",sizeof("foo"),(void **)&amp;arr)==FAILURE) { can't find... }
else { use arr-&gt;value.ht... }
    </programlisting>
			</para>
			<simpara>
hash_find는 포인터에서 pval포인터와 pval포인터 아니어도 받는다.
</simpara>
			<simpara>
거의 모든 hash 함수는 SUCCESS나 FAILURE만 반환한다. (불린 표준값을 반환하는 hast_exists()는 제외한다).
</simpara>
		</sect2>
		<sect2 id="phpdevel-addfunc-retsimple">
			<title>간단한 값 반환</title>
			<simpara>
매크로의 숫자은 함수로부터 간단하게 리턴받는게 가능하다.
</simpara>
			<para>
RETURN_* 매크로들 모두 반환값과 함수에서 반환되는 되는 것을 정한다.
    The RETURN_* macros all set the return value and return from the
    function:
    <itemizedlist>
					<listitem>
						<simpara>RETURN</simpara>
					</listitem>
					<listitem>
						<simpara>RETURN_FALSE</simpara>
					</listitem>
					<listitem>
						<simpara>RETURN_TRUE</simpara>
					</listitem>
					<listitem>
						<simpara>RETURN_LONG(l)</simpara>
					</listitem>
					<listitem>
						<simpara>RETURN_STRING(s,dup)   If dup is &true;, duplicates the string</simpara>
					</listitem>
					<listitem>
						<simpara>RETURN_STRINGL(s,l,dup)   Return string (s) specifying length (l).</simpara>
					</listitem>
					<listitem>
						<simpara>RETURN_DOUBLE(d)</simpara>
					</listitem>
				</itemizedlist>
			</para>
			<para>
RETVAL_*  매크로는 리턴값을 설정할 수 있으나, 반환은 되지 않는다. 
    <itemizedlist>
					<listitem>
						<simpara>RETVAL_FALSE</simpara>
					</listitem>
					<listitem>
						<simpara>RETVAL_TRUE</simpara>
					</listitem>
					<listitem>
						<simpara>RETVAL_LONG(l)</simpara>
					</listitem>
					<listitem>
						<simpara>RETVAL_STRING(s,dup)   If dup is &true;, duplicates the string</simpara>
					</listitem>
					<listitem>
						<simpara>RETVAL_STRINGL(s,l,dup)   Return string (s) specifying length (l).</simpara>
					</listitem>
					<listitem>
						<simpara>RETVAL_DOUBLE(d)</simpara>
					</listitem>
				</itemizedlist>
			</para>
			<simpara>
문자열 스트링은 's'인자가 통과된 모든 estrdup() 이상일 것이다.
그리고, 당신 안전하게 부른 매크로를 부른후 인자를 해제를 할 수 있거나, 부가적으로는
지정된 메모리를 정적으로 사용할 수 있다.
</simpara>
			<simpara>
만약 반환된 당신의 함수가 참/거짓 불린 값을 반환하면, 각각 RETURN_TRUE와 RETURN_FALSE 언제나 사용한다.
</simpara>
		</sect2>
		<sect2 id="phpdevel-addfunc-retcomplex">
			<title>완전한 값 반환</title>
			<simpara>
당신의 함수는 이미 객체나 배열의 완전한 데이타 타입을 리턴할 수 있다.
</simpara>
			<para>
객체 반환:

    <orderedlist numeration="arabic">
					<listitem>
						<simpara>object_init(return_value)를 부른다.</simpara>
					</listitem>
					<listitem>
						<para>값으로 채운다. 모든 함수는 아래로 출력되는 결과가 가능하다.</para>
					</listitem>
					<listitem>
						<para> 
가능하다면 이 객체를 위한 함수는 등록시킨다.
객체로부터 값을 차례대로 포함하고, 함수는 activ_symbol_table로부터 "this"를 가지고 와야 할 것이다.
이들 타입은 IS_OBJECT이 아니면 안되고, 기본적으로 정규 해시 테이블이어야 한다
(예, 당신은 .value.ht처럼 정규 해시 함수를 사용할 수 있다)
함수의 실제 등록은 다음과 같이 할수 있다:
       <programlisting>
add_method( return_value, function_name, function_ptr );
       </programlisting>
						</para>
					</listitem>
				</orderedlist>
			</para>
			<para>
    The functions used to populate an object are:
    <itemizedlist>
					<listitem>
						<simpara>add_property_long( return_value,
       property_name, l ) - long타입, I와 동일한 'property_name'이라는 프로퍼티 추가
</simpara>
					</listitem>
					<listitem>
						<simpara>add_property_double( return_value,
       property_name, d ) - 몇개의 double타입만 추가</simpara>
					</listitem>
					<listitem>
						<simpara>add_property_string( return_value,
       property_name, str ) - 몇개의 string타입만 추가</simpara>
					</listitem>
					<listitem>
						<simpara>add_property_stringl( return_value,
       property_name, str, l ) - 몇개의 'l'길이의 스트링만 추가'</simpara>
					</listitem>
				</itemizedlist>
			</para>
			<para>
배열 반환:
    
    <orderedlist numeration="arabic">
					<listitem>
						<simpara>array_init 부르기(return_value).</simpara>
					</listitem>
					<listitem>
						<simpara>값으로 채우기. 함수는 아래 목록의 사용을 가능하게 한다.</simpara>
					</listitem>
				</orderedlist>
			</para>
			<para>
	
    The functions used to populate an array are:
    <itemizedlist>
					<listitem>
						<simpara>add_assoc_long(return_value,key,l) - 
'ken'키와 'I'의 long으로 된 공동 엔트리
</simpara>
					</listitem>
					<listitem>
						<simpara>add_assoc_double(return_value,key,d)</simpara>
					</listitem>
					<listitem>
						<simpara>add_assoc_string(return_value,key,str,duplicate)</simpara>
					</listitem>
					<listitem>
						<simpara>add_assoc_stringl(return_value,key,str,length,duplicate)
스트링 길이 지정
</simpara>
					</listitem>
					<listitem>
						<simpara>add_index_long(return_value,index,l) - 
엔트리의 'index' 인덱스에 'i'으로 된 long을 추가
</simpara>
					</listitem>
					<listitem>
						<simpara>add_index_double(return_value,index,d)</simpara>
					</listitem>
					<listitem>
						<simpara>add_index_string(return_value,index,str)</simpara>
					</listitem>
					<listitem>
						<simpara>add_index_stringl(return_value,index,str,length)
     - 문자열 길이 지정</simpara>
					</listitem>
					<listitem>
						<simpara>add_next_index_long(return_value,l) - 
배열 엔트리의  'ㅣ'으로 된 long을 다음 free offset에 추가
</simpara>
					</listitem>
					<listitem>
						<simpara>add_next_index_double(return_value,d)</simpara>
					</listitem>
					<listitem>
						<simpara>add_next_index_string(return_value,str)</simpara>
					</listitem>
					<listitem>
						<simpara>add_next_index_stringl(return_value,str,length)
     - 문자열 길이 지정</simpara>
					</listitem>
				</itemizedlist>
			</para>
		</sect2>
		<sect2 id="phpdevel-addfunc-reslist">
			<title>자원 목록 사용하기</title>
			<simpara>
    PHP 3.0은 여러 자원의 가지 형태를 다루는 표준적인 방법을 가지고 있다. 이것은 PHP 2.0의 모든 지역적인 linked list를 대체한다</simpara>
			<para>
가능한 함수:

    <itemizedlist>
					<listitem>
						<simpara>php3_list_insert(ptr, type) - returns the 'id'
       of the newly inserted resource</simpara>
					</listitem>
					<listitem>
						<simpara>php3_list_delete(id) - delete the resource
       with the specified id</simpara>
					</listitem>
					<listitem>
						<simpara>php3_list_find(id,*type)
       - returns the pointer of the resource with the specified id,
       updates 'type' to the resource's type</simpara>
					</listitem>
				</itemizedlist>

    Typically, these functions are used for SQL drivers but they can
    be used for anything else; for instance, maintaining file
    descriptors.</para>
			<simpara>
    Typical list code would look like this:</simpara>
			<para>
				<example>
					<title>Adding a new resource</title>
					<programlisting>
RESOURCE *resource;

/* ...allocate memory for resource and acquire resource... */
/* add a new resource to the list */
return_value-&gt;value.lval = php3_list_insert((void *) resource, LE_RESOURCE_TYPE);
return_value-&gt;type = IS_LONG;
     </programlisting>
				</example>
				<example>
					<title>Using an existing resource</title>
					<programlisting>
pval *resource_id;
RESOURCE *resource;
int type;

convert_to_long(resource_id);
resource = php3_list_find(resource_id-&gt;value.lval, &amp;type);
if (type != LE_RESOURCE_TYPE) {
	php3_error(E_WARNING,"resource index %d has the wrong type",resource_id-&gt;value.lval);
	RETURN_FALSE;
}
/* ...use resource... */
     </programlisting>
				</example>
				<example>
					<title>Deleting an existing resource</title>
					<programlisting>
pval *resource_id;
RESOURCE *resource;
int type;

convert_to_long(resource_id);
php3_list_delete(resource_id-&gt;value.lval);
     </programlisting>
				</example>
   
    The resource types should be registered in php3_list.h, in enum
    list_entry_type.  In addition, one should add shutdown code for
    any new resource type defined, in list.c's list_entry_destructor()
    (even if you don't have anything to do on shutdown, you must add
    an empty case).</para>
		</sect2>
		<sect2 id="phpdevel-addfunc-prestable">
			<title>Using the persistent resource table</title>
			<para>
    PHP 3.0은 영구적인 자원(persistent resources; 예, 그동안의 히트수를 보관하는 자원)을 저장하는 표준적인 방법을 가지고 있다. 이 방법은 MySQL 모듈에서 처음사용되었고, mSQL도 이것을 따르고 있다. 따라서 persistent resource를 어떻게 사용하는가에 대해 알고 싶다면 우선 mysql.c를 읽어보도록하자. 주의해서 볼 함수들은 다은과 같다:

    <simplelist>
					<member>php3_mysql_do_connect</member>
					<member>php3_mysql_connect()</member>
					<member>php3_mysql_pconnect()</member>
				</simplelist>
			</para>
			<para>
persistence 모듈의 일반적인 idea는 다음과 같다:
    <orderedlist numeration="arabic">
					<listitem>
						<simpara>Code all of your module to work with the
       regular resource list mentioned in section (9).</simpara>
					</listitem>
					<listitem>
						<simpara>Code extra connect functions that check if the
       resource already exists in the persistent resource list.  If it
       does, register it as in the regular resource list as a pointer to
       the persistent resource list (because of 1., the rest of the code
       should work immediately).  If it doesn't, then create it, add it
       to the persistent resource list AND add a pointer to it from the
       regular resource list, so all of the code would work since it's
       in the regular resource list, but on the next connect, the
       resource would be found in the persistent resource list and be
       used without having to recreate it.  You should register these
       resources with a different type (e.g.  LE_MYSQL_LINK for
       non-persistent link and LE_MYSQL_PLINK for a persistent link).</simpara>
					</listitem>
				</orderedlist>
			</para>
			<simpara>
    If you read mysql.c, you'll notice that except for the more
    complex connect function, nothing in the rest of the module has to
    be changed.</simpara>
			<simpara>
    The very same interface exists for the regular resource list and
    the persistent resource list, only 'list' is replaced with
    'plist':</simpara>
			<itemizedlist>
				<listitem>
					<simpara>php3_plist_insert(ptr, type) - returns the 'id'
       of the newly inserted resource</simpara>
				</listitem>
				<listitem>
					<simpara>php3_plist_delete(id) - delete the resource
       with the specified id</simpara>
				</listitem>
				<listitem>
					<simpara>php3_plist_find(id,*type)
       - returns the pointer of the resource with the specified id,
       updates 'type' to the resource's type</simpara>
				</listitem>
			</itemizedlist>
			<simpara>
    However, it's more than likely that these functions would prove to
    be useless for you when trying to implement a persistent module.
    Typically, one would want to use the fact that the persistent
    resource list is really a hash table.  For instance, in the
    MySQL/mSQL modules, when there's a pconnect() call (persistent
    connect), the function builds a string out of the host/user/passwd
    that were passed to the function, and hashes the SQL link with
    this string as a key.  The next time someone calls a pconnect()
    with the same host/user/passwd, the same key would be generated,
    and the function would find the SQL link in the persistent list.</simpara>
			<simpara>
    Until further documented, you should look at mysql.c or msql.c to
    see how one should use the plist's hash table abilities.</simpara>
			<simpara>
    One important thing to note: resources going into the persistent
    resource list must *NOT* be allocated with PHP's memory manager,
    i.e., they should NOT be created with emalloc(), estrdup(), etc.
    Rather, one should use the regular malloc(), strdup(), etc.  The
    reason for this is simple - at the end of the request (end of the
    hit), every memory chunk that was allocated using PHP's memory
    manager is deleted.  Since the persistent list isn't supposed to
    be erased at the end of a request, one mustn't use PHP's memory
    manager for allocating resources that go to it.</simpara>
			<simpara>
    When you register a resource that's going to be in the persistent
    list, you should add destructors to it both in the non-persistent
    list and in the persistent list.  The destructor in the
    non-persistent list destructor shouldn't do anything.  The one in
    the persistent list destructor should properly free any resources
    obtained by that type (e.g. memory, SQL links, etc).  Just like
    with the non-persistent resources, you *MUST* add destructors for
    every resource, even it requires no destructotion and the
    destructor would be empty.  Remember, since emalloc() and friends
    aren't to be used in conjunction with the persistent list, you
    mustn't use efree() here either.</simpara>
		</sect2>
		<sect2 id="phpdevel-addfunc-addcfg">
			<title>런타임 설정 지시자(directives) 추가</title>
			<para>
    많은 PHP의 기능(feature)들이 실행중에 설정 가능하다. 이 설정 지시자(configuration directives)는 php3.ini에 설정되거나, Apache 모듈의 경우 .conf 파일에 설정가능하도록 되어 있다. Apache .conf 파일에 설정하는 것의 장점은 디렉토리별로 설정을 다르게 할 수 있다는 점이다. 이것은 예를들어 어떤 디렉토리가 다른 디렉토리를 가지고 있어도, 해당하는 한 디렉토리에만 safemodeexecdir 설정을 할 수 있다는 것이다. 이 개별 설정 기능은 서버가 multiple virtual hosts를 지원할 때 무척 유용하다</para>
			<para>
    The steps required to add a new directive:

    <orderedlist>
					<listitem>
						<simpara>Add directive to php3_ini_structure struct in mod_php3.h.</simpara>
					</listitem>
					<listitem>
						<simpara>In main.c, edit the php3_module_startup
       function and add the appropriate cfg_get_string() or
       cfg_get_long() call.</simpara>
					</listitem>
					<listitem>
						<simpara>Add the directive, restrictions and a comment
       to the php3_commands structure in mod_php3.c.  Note the
       restrictions part.  RSRC_CONF are directives that can only be
       present in the actual Apache .conf files.  Any OR_OPTIONS
       directives can be present anywhere, include normal .htaccess
       files.</simpara>
					</listitem>
					<listitem>
						<simpara>In either php3take1handler() or
       php3flaghandler() add the appropriate entry for your directive.</simpara>
					</listitem>
					<listitem>
						<simpara>In the configuration section of the
       _php3_info() function in functions/info.c you need to add your
       new directive.</simpara>
					</listitem>
					<listitem>
						<simpara>And last, you of course have to use your new
       directive somewhere.  It will be addressable as
       php3_ini.directive.</simpara>
					</listitem>
				</orderedlist>
			</para>
		</sect2>
	</sect1>
	<sect1 id="calling-user-functions">
		<title>사용자 함수를 부르기</title>
		<simpara>
내부 함수(internal function)에서 사용자 함수를 부르려면, <function>call_user_function</function>함수를 사용하여야 한다.
  </simpara>
		<simpara>
			<function>call_user_function</function> returns SUCCESS on success,
   and FAILURE in case the function cannot be found.  You should check
   that return value!  If it returns SUCCESS, you are responsible for
   destroying the retval pval yourself (or return it as the return value
   of your function). If it returns FAILURE, the value of retval is
   undefined, and you mustn't touch it.
  </simpara>
		<simpara>
   All internal functions that call user functions
   <emphasis>must</emphasis> be reentrant.  Among other things, this
   means they must not use globals or static variables.
  </simpara>
		<simpara>
			<function>call_user_function</function> takes six arguments:
  </simpara>
		<sect2 id="calling-user-functions.function-table">
			<title>HashTable *function_table</title>
			<simpara>
    This is the hash table in which the function is to be looked up.
   </simpara>
		</sect2>
		<sect2 id="calling-user-functions.object">
			<title>pval *object</title>
			<simpara>
    This is a pointer to an object on which the function is invoked.
    This should be &null; if a global function is called.  If it's not
    &null; (i.e.  it points to an object), the function_table argument is
    ignored, and instead taken from the object's hash.  The object *may*
    be modified by the function that is invoked on it (that function
    will have access to it via $this).  If for some reason you don't
    want that to happen, send a copy of the object instead.
   </simpara>
		</sect2>
		<sect2 id="calling-user-functions.function-name">
			<title>pval *function_name</title>
			<simpara>
    The name of the function to call.  Must be a pval of type
    IS_STRING with function_name.str.val and function_name.str.len
    set to the appropriate values.  The function_name is modified by
    call_user_function() - it's converted to lowercase.  If you need to
    preserve the case, send a copy of the function name instead.
   </simpara>
		</sect2>
		<sect2 id="calling-user-functions.retval">
			<title>pval *retval</title>
			<simpara>
    A pointer to a pval structure, into which the return value of
    the invoked function is saved.  The structure must be previously
    allocated - <function>call_user_function</function> does NOT allocate
    it by itself.
   </simpara>
		</sect2>
		<sect2 id="calling-user-functions.param-count">
			<title>int param_count</title>
			<simpara>
    The number of parameters being passed to the function.
   </simpara>
		</sect2>
		<sect2 id="calling-user-functions.params">
			<title>pval *params[]</title>
			<simpara>
    An array of pointers to values that will be passed as arguments to the
    function, the first argument being in offset 0, the second in offset
    1, etc.  The array is an array of pointers to pval's;  The pointers
    are sent as-is to the function, which means if the function modifies
    its arguments, the original values are changed (passing by reference).
    If you don't want that behavior, pass a copy instead.
   </simpara>
		</sect2>
	</sect1>
	<sect1 id="phpdevel-errors">
		<title>Reporting Errors</title>
		<simpara>
내부 함수에서 에러를 report할 때는 <function>php3_error</function>함수를 사용하는 것이 좋다. 이 함수는 최소 두개의 인수를 가지고 호출된다. 첫번째는 에러의 level이고, 다른 하나는 에러 메세지를 위한 format string( <function>printf</function>에서 사용되는 것과 같은 형태) 이다. 그리고 그 나머지는 주어진 format string의 parameter가 된다. 에러 level은 다음과 같다:  </simpara>
		<sect2 id="internal.e-notice">
			<title>E_NOTICE</title>
			<simpara>
Notice는 기본적으로는 출력되지 않는다. 이것은 스크립트가 뭔가 에러를 감지했지만, 그것이 정상적인 상황에서 발생하는 것이라는 의미이다. 예를들어 설정되지 않은 변수를 사용하려 했거나, 존재하지 않는 파일에 <function>stat</function>함수를 호출하는 것 등이다.
   </simpara>
		</sect2>
		<sect2 id="internal.e-warning">
			<title>E_WARNING</title>
			<simpara>
Warning은 기본적으로 출력된다. 그러나, 스크립트의 실행을 멈추지는 않는다. 이것은 호출이 완료되기 전에 스크립트에 의해 잡혀져야 하는 문제를 가리킨다. 예를들어 잘못된 regular expression으로 <function>ereg</function>를 호출하는 것 등이다. 
   </simpara>
		</sect2>
		<sect2 id="internal.e-error">
			<title>E_ERROR</title>
			<simpara>
Error도 기본적으로 출력된다. 그리고, 함수의 실행이 완료된 직후, 스크립트의 실행을 멈춘다. 이것은 memory allocation 문제같은 복구가 불가능한 에러를 의미한다   </simpara>
		</sect2>
		<sect2 id="internal.e-parse">
			<title>E_PARSE</title>
			<simpara>
Parse error는 오직 Parser만이 생성가능하다. code가 list된다.
   </simpara>
		</sect2>
		<sect2 id="internal.e-core-error">
			<title>E_CORE_ERROR</title>
			<simpara>
PHP의 core에의해 생성된다는 점을 제외하고는 E_ERROR와 동일하다. 일반 함수로는 이 형태의 에러를 만들지 못한다. </simpara>
		</sect2>
		<sect2 id="internal.e-core-warning">
			<title>E_CORE_WARNING</title>
			<simpara>
PHP의 core에의해 생성된다는 점을 제외하고는 E_WARNING와 동일하다. 일반 함수로는 이 형태의 에러를 만들지 못한다.</simpara>
		</sect2>
		<sect2 id="internal.e-compile-error">
			<title>E_COMPILE_ERROR</title>
			<simpara>
이것은 E-Error랑 비슷하다, 예외적으로 Zend스크립팅 엔진에 의해 발생한다.
함수는 이 에러의 	타입을 발생하지 않는다.
   </simpara>
		</sect2>
		<sect2 id="internal.e-compile-warning">
			<title>E_COMPILE_WARNING</title>
			<simpara>
이것은 E_WARNING이랑 비슷하다. 예외적으로 Zend 스크립팅 엔진에 의해 발생한다.
함수는 이 에러의 타입을 발생하지 않는다.			
</simpara>
		</sect2>
		<sect2 id="internal.e-user-error">
			<title>E_USER_ERROR</title>
			<simpara>
이것은 E_ERROR이랑 비슷하다. 예외적으로 PHP 함수<function>trigger_error</function>를 이요하는 PHP코드에 의해 발생한다.
함수는 이 에러의 타입을 발생하지 않는다.
   </simpara>
		</sect2>
		<sect2 id="internal.e-user-warning">
			<title>E_USER_WARNING</title>
			<simpara>
이것은 E_WARNING이랑 비슷하다. 예외적으로 PHP 함수<function>trigger_error</function>를 이요하는 PHP코드에 의해 발생한다.
함수는 이 에러의 타입을 발생하지 않는다.
   </simpara>
		</sect2>
		<sect2 id="internal.e-user-notice">
			<title>E_USER_NOTICE</title>
			<simpara>
이것은 E_NOTICE랑 비슷하다. 예외적으로 PHP 함수<function>trigger_error</function>를 이요하는 PHP코드에 의해 발생한다.
함수는 이 에러의 타입을 발생하지 않는다.</simpara>
		</sect2>
	</sect1>
</appendix>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->