epcmd2.c

filter: Statementstmt 0.0% 0 / 233 Branchbran 0.0% 0 / 182 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 415 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« epcgiinit.c ↑ Summary epcomp.c »
1 /*###################################################################################
2 #
3 # Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de
4 # Embperl - Copyright (c) 2008-2015 Gerald Richter
5 # Embperl - Copyright (c) 2015-2023 actevy.io
6 #
7 # You may distribute under the terms of either the GNU General Public
8 # License or the Artistic License, as specified in the Perl README file.
9 #
10 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
11 # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
12 # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 #
14 ###################################################################################*/
15  
16  
17 #include "ep.h"
18 #include "epmacro.h"
19  
20 /* ---------------------------------------------------------------------------- */
21 /* */
22 /* Split values in from %fdat */
23 /* */
24 /* ---------------------------------------------------------------------------- */
25  
26  
27 0 SV * SplitFdat (/*i/o*/ register req * r,
28 /*in*/ SV ** ppSVfdat,
29 /*out*/ SV ** ppSVerg,
30 /*in*/ char * pName,
31 /*in*/ STRLEN nlen)
32  
33 {
34 epTHX_
35 STRLEN dlen ;
36 char * pData ;
37 char * s ;
38 char * p ;
39
40 0 ▶ if (ppSVerg && *ppSVerg && SvTYPE (*ppSVerg))
Branch: 3 branches
BranchTrueFalseTotal
if (ppSVerg && *ppSVerg && SvTYPE (*ppSVerg)) 0 0 0
if (ppSVerg && *ppSVerg && SvTYPE (*ppSVerg)) 0 0 0
if (ppSVerg && *ppSVerg && SvTYPE (*ppSVerg)) 0 0 0
41 {
42 0 return *ppSVerg ;
43 }
44  
45 0 pData = SvPV (*ppSVfdat, dlen) ;
46 0 s = pData ;
47  
48 0 ▶ if ((p = strchr (s, r -> Config.cMultFieldSep)))
Branch: 1 branch
BranchTrueFalseTotal
if ((p = strchr (s, r -> Config.cMultFieldSep))) 0 0 0
49 { /* Multiple values -> put them into a hash */
50 0 HV * pHV = newHV () ;
51 int l ;
52  
53 0 ▶ while (p)
Branch: 1 branch
BranchTrueFalseTotal
while (p) 0 0 0
54 {
55 0 hv_store (pHV, s, p - s, &sv_undef, 0) ;
56 0 s = p + 1 ;
57 0 p = strchr (s, r -> Config.cMultFieldSep) ;
58 }
59  
60 0 l = dlen - (s - pData) ;
61 0 ▶ if (l > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (l > 0) 0 0 0
62 0 hv_store (pHV, s, l, &sv_undef, 0) ;
63 0 hv_store (r -> pThread -> pFormSplitHash, (char *)pName, nlen, (SV *)pHV, 0) ;
64 0 ▶ if (r -> Component.Config.bDebug & dbgInput)
Branch: 1 branch
BranchTrueFalseTotal
if (r -> Component.Config.bDebug & dbgInput) 0 0 0
65 0 lprintf (r -> pApp, "[%d]INPU: <mult values>\n", r -> pThread -> nPid) ;
66 0 return (SV *)pHV;
67 }
68 else
69 {
70 0 SvREFCNT_inc (*ppSVfdat) ;
71 0 hv_store (r -> pThread -> pFormSplitHash, (char *)pName, nlen, *ppSVfdat, 0) ;
72 0 ▶ if (r -> Component.Config.bDebug & dbgInput)
Branch: 1 branch
BranchTrueFalseTotal
if (r -> Component.Config.bDebug & dbgInput) 0 0 0
73 0 lprintf (r -> pApp, "[%d]INPU: value = %s\n", r -> pThread -> nPid, SvPV(*ppSVfdat, na)) ;
74 0 return *ppSVfdat ;
75 }
76 }
77  
78 /* ---------------------------------------------------------------------------- */
79 /* */
80 /* SetRemove Attribute on html tag ... */
81 /* */
82 /* ---------------------------------------------------------------------------- */
83  
84  
85  
86 0 static void embperlCmd_SetRemove (/*i/o*/ register req * r,
87 /*in*/ tDomTree * pDomTree,
88 /*in*/ tNode xNode,
89 /*in*/ tRepeatLevel nRepeatLevel,
90 /*in*/ const char * pName,
91 /*in*/ int nNameLen,
92 /*in*/ const char * pVal,
93 /*in*/ int nValLen,
94 /*in*/ const char * sAttrName,
95 /*in*/ int nAttrLen,
96 /*in*/ int bSetInSource)
97  
98 {
99 epTHX_
100 0 int bEqual = 0 ;
101 0 SV ** ppSV = hv_fetch(r -> pThread -> pFormHash, (char *)pName, nNameLen, 0) ;
102 0 ▶ tNodeData * pNode = Node_selfLevel (r -> pApp, pDomTree, xNode, nRepeatLevel) ;
Branch: 2 branches
BranchTrueFalseTotal
tNodeData * pNode = Node_selfLevel (r -> pApp, pDomTree, xNode, nRepeatLevel) ; 0 0 0
tNodeData * pNode = Node_selfLevel (r -> pApp, pDomTree, xNode, nRepeatLevel) ; 0 0 0
103 0 SV * pInputHashValue = NULL ;
104 0 char * tmp = NULL ;
105  
106 0 ▶ if (ppSV)
Branch: 1 branch
BranchTrueFalseTotal
if (ppSV) 0 0 0
107 {
108 0 SV ** ppSVerg = hv_fetch(r -> pThread -> pFormSplitHash, (char *)pName, nNameLen, 0) ;
109 0 SV * pSV = SplitFdat (r, ppSV, ppSVerg, (char *)pName, nNameLen) ;
110 0 tmp = malloc (nValLen) ;
111 0 memcpy (tmp, pVal, nValLen) ;
112 0 pVal = tmp ;
113
114 0 ▶ if (SvTYPE (pSV) == SVt_PVHV)
Branch: 1 branch
BranchTrueFalseTotal
if (SvTYPE (pSV) == SVt_PVHV) 0 0 0
115 { /* -> Hash -> check if key exists */
116 0 nValLen = TransHtml (r, (char *)pVal, nValLen) ;
117 0 ▶ if (hv_exists ((HV *)pSV, (char *)pVal, nValLen))
Branch: 1 branch
BranchTrueFalseTotal
if (hv_exists ((HV *)pSV, (char *)pVal, nValLen)) 0 0 0
118 {
119 0 bEqual = 1 ;
120 0 ▶ pInputHashValue = newSVpv ((nValLen?((char *)pVal):""), nValLen) ;
Branch: 1 branch
BranchTrueFalseTotal
pInputHashValue = newSVpv ((nValLen?((char *)pVal):""), nValLen) ; 0 0 0
121 }
122 }
123 else
124 {
125 STRLEN dlen ;
126 0 char * pData = SvPV (pSV, dlen) ;
127 0 nValLen = TransHtml (r, (char *)pVal, nValLen) ;
128 0 ▶ if ((int)dlen == nValLen && strncmp (pVal, pData, dlen) == 0)
Branch: 2 branches
BranchTrueFalseTotal
if ((int)dlen == nValLen && strncmp (pVal, pData, dlen) == 0) 0 0 0
if ((int)dlen == nValLen && strncmp (pVal, pData, dlen) == 0) 0 0 0
129 {
130 0 bEqual = 1 ;
131 0 pInputHashValue = newSVsv(pSV) ;
132 }
133 }
134  
135 0 ▶ if (bEqual)
Branch: 1 branch
BranchTrueFalseTotal
if (bEqual) 0 0 0
136 {
137 0 ▶ if (r -> Config.nOutputMode)
Branch: 1 branch
BranchTrueFalseTotal
if (r -> Config.nOutputMode) 0 0 0
138 0 Element_selfSetAttribut (r -> pApp, pDomTree, pNode, nRepeatLevel, sAttrName, nAttrLen, sAttrName, nAttrLen) ;
139 else
140 0 Element_selfSetAttribut (r -> pApp, pDomTree, pNode, nRepeatLevel, sAttrName, nAttrLen, NULL, 0) ;
141 0 ▶ if (r -> Component.Config.bDebug & dbgInput)
Branch: 1 branch
BranchTrueFalseTotal
if (r -> Component.Config.bDebug & dbgInput) 0 0 0
142 0 lprintf (r -> pApp, "[%d]INPU: Set Attribut: Name: '%*.*s' Value: '%*.*s' Attribute: '%*.*s' nRepeatLevel=%d\n", r -> pThread -> nPid, nNameLen, nNameLen, pName, nValLen, nValLen, pVal, nAttrLen, nAttrLen, sAttrName, nRepeatLevel) ;
143 }
144 else
145 {
146 0 Element_selfRemoveAttribut (r -> pApp, pDomTree, pNode, nRepeatLevel, sAttrName, nAttrLen) ;
147 0 ▶ if (r -> Component.Config.bDebug & dbgInput)
Branch: 1 branch
BranchTrueFalseTotal
if (r -> Component.Config.bDebug & dbgInput) 0 0 0
148 0 lprintf (r -> pApp, "[%d]INPU: Remove Attribut: Name: '%*.*s' Value: '%*.*s' Attribute: '%*.*s' nRepeatLevel=%d\n", r -> pThread -> nPid, nNameLen, nNameLen, pName, nValLen, nValLen, pVal, nAttrLen, nAttrLen, sAttrName, nRepeatLevel ) ;
149 }
150 }
151 else
152 {
153 0 ▶ if (Element_selfGetAttribut (r -> pApp, pDomTree, pNode, sAttrName, nAttrLen))
Branch: 1 branch
BranchTrueFalseTotal
if (Element_selfGetAttribut (r -> pApp, pDomTree, pNode, sAttrName, nAttrLen)) 0 0 0
154 {
155 0 ▶ hv_store (r -> pThread -> pInputHash, (char *)pName, nNameLen, newSVpv ((nValLen?((char *)pVal):""), nValLen), 0) ;
Branch: 1 branch
BranchTrueFalseTotal
hv_store (r -> pThread -> pInputHash, (char *)pName, nNameLen, newSVpv ((nValLen?((char *)pVal):""), nValLen), 0) ; 0 0 0
156 0 ▶ if (r -> Component.Config.bDebug & dbgInput)
Branch: 1 branch
BranchTrueFalseTotal
if (r -> Component.Config.bDebug & dbgInput) 0 0 0
157 0 lprintf (r -> pApp, "[%d]INPU: Has already Attribut: Name: '%*.*s' Value: '%*.*s' Attribute: '%*.*s' nRepeatLevel=%d\n", r -> pThread -> nPid, nNameLen, nNameLen, pName, nValLen, nValLen, pVal, nAttrLen, nAttrLen, sAttrName, nRepeatLevel ) ;
158 }
159 else
160 {
161 0 ▶ if (r -> Component.Config.bDebug & dbgInput)
Branch: 1 branch
BranchTrueFalseTotal
if (r -> Component.Config.bDebug & dbgInput) 0 0 0
162 0 ▶ lprintf (r -> pApp, "[%d]INPU: No value in %%fdat for Attribut: Name: '%*.*s' Value: '%*.*s' Attribute: '%*.*s' nRepeatLevel=%d\n", r -> pThread -> nPid, nNameLen, nNameLen, pName?pName:"", nValLen, nValLen, pVal?pVal:"", nAttrLen, nAttrLen, sAttrName, nRepeatLevel ) ;
Branch: 2 branches
BranchTrueFalseTotal
lprintf (r -> pApp, "[%d]INPU: No value in %%fdat for Attribut: Name: '%*.*s' Value: '%*.*s' Attribute: '%*.*s' nRepeatLevel=%d\n", r -> pThread -> nPid, nNameLen, nNameLen, pName?pName:"", nValLen, nValLen, pVal?pVal:"", nAttrLen, nAttrLen, sAttrName, nRepeatLevel ) ; 0 0 0
lprintf (r -> pApp, "[%d]INPU: No value in %%fdat for Attribut: Name: '%*.*s' Value: '%*.*s' Attribute: '%*.*s' nRepeatLevel=%d\n", r -> pThread -> nPid, nNameLen, nNameLen, pName?pName:"", nValLen, nValLen, pVal?pVal:"", nAttrLen, nAttrLen, sAttrName, nRepeatLevel ) ; 0 0 0
163 }
164  
165 }
166  
167 0 ▶ if (pInputHashValue)
Branch: 1 branch
BranchTrueFalseTotal
if (pInputHashValue) 0 0 0
168 0 hv_store (r -> pThread -> pInputHash, (char *)pName, nNameLen, pInputHashValue, 0) ;
169 else
170 {
171 0 ▶ if (!hv_exists (r -> pThread -> pInputHash, (char *)pName, nNameLen))
Branch: 1 branch
BranchTrueFalseTotal
if (!hv_exists (r -> pThread -> pInputHash, (char *)pName, nNameLen)) 0 0 0
172 0 hv_store (r -> pThread -> pInputHash, (char *)pName, nNameLen, newSVpv ("", 0), 0) ;
173 }
174  
175 0 ▶ if (tmp)
Branch: 1 branch
BranchTrueFalseTotal
if (tmp) 0 0 0
176 0 free (tmp) ;
177
178 0 }
179  
180 /* ---------------------------------------------------------------------------- */
181 /* */
182 /* input checkbox/radio html tag ... */
183 /* */
184 /* ---------------------------------------------------------------------------- */
185  
186  
187  
188 0 void embperlCmd_InputCheck (/*i/o*/ register req * r,
189 /*in*/ tDomTree * pDomTree,
190 /*in*/ tNode xNode,
191 /*in*/ tRepeatLevel nRepeatLevel,
192 /*in*/ const char * pName,
193 /*in*/ int nNameLen,
194 /*in*/ const char * pVal,
195 /*in*/ int nValLen,
196 /*in*/ int bSetInSource)
197  
198 {
199 0 embperlCmd_SetRemove (r, pDomTree, xNode, nRepeatLevel, pName, nNameLen, pVal, nValLen, "checked", 7, bSetInSource) ;
200 0 }
201  
202  
203 /* ---------------------------------------------------------------------------- */
204 /* */
205 /* option html tag ... */
206 /* */
207 /* ---------------------------------------------------------------------------- */
208  
209  
210 0 void embperlCmd_Option (/*i/o*/ register req * r,
211 /*in*/ tDomTree * pDomTree,
212 /*in*/ tNode xNode,
213 /*in*/ tRepeatLevel nRepeatLevel,
214 /*in*/ const char * pName,
215 /*in*/ int nNameLen,
216 /*in*/ const char * pVal,
217 /*in*/ int nValLen,
218 /*in*/ int bSetInSource)
219
220  
221 {
222 0 embperlCmd_SetRemove (r, pDomTree, xNode, nRepeatLevel, pName, nNameLen, pVal, nValLen, "selected", 8, bSetInSource) ;
223 0 }
224  
225  
226  
227  
228  
229 /* ---------------------------------------------------------------------------- */
230 /* */
231 /* hidden command ... */
232 /* */
233 /* ---------------------------------------------------------------------------- */
234  
235  
236 0 int embperlCmd_Hidden (/*i/o*/ register req * r,
237 /*in*/ tDomTree * pDomTree,
238 /*in*/ tNode xNode,
239 /*in*/ tRepeatLevel nRepeatLevel,
240 /*in*/ const char * sArg)
241  
242 {
243 epTHX_
244 char * pKey ;
245 SV * psv ;
246 SV * * ppsv ;
247 0 HV * pAddHash = r -> pThread -> pFormHash ;
248 0 HV * pSubHash = r -> pThread -> pInputHash ;
249 0 AV * pSort = NULL ;
250 HE * pEntry ;
251 I32 l ;
252 char * sArgs ;
253 char * sVarName ;
254 char sVar[512] ;
255 int nMax ;
256 STRLEN nKey ;
257 tNodeData * pNode ;
258 tNodeData * pNewNode ;
259  
260  
261 EPENTRY (CmdHidden) ;
262  
263 0 ▶ pNode = Node_selfCondCloneNode (r -> pApp, pDomTree, Node_selfLevel (r -> pApp, pDomTree, xNode, nRepeatLevel), nRepeatLevel) ;
Branch: 2 branches
BranchTrueFalseTotal
pNode = Node_selfCondCloneNode (r -> pApp, pDomTree, Node_selfLevel (r -> pApp, pDomTree, xNode, nRepeatLevel), nRepeatLevel) ; 0 0 0
pNode = Node_selfCondCloneNode (r -> pApp, pDomTree, Node_selfLevel (r -> pApp, pDomTree, xNode, nRepeatLevel), nRepeatLevel) ; 0 0 0
264  
265 0 pNewNode = pNode ;
266  
267 0 sArgs = _ep_strdup (r, sArg) ;
268 0 ▶ if (sArgs && *sArgs != '\0')
Branch: 2 branches
BranchTrueFalseTotal
if (sArgs && *sArgs != '\0') 0 0 0
if (sArgs && *sArgs != '\0') 0 0 0
269 {
270 0 strncpy (sVar, r -> Component.sEvalPackage, sizeof (sVar) - 5) ;
271 0 sVar[r -> Component.nEvalPackage] = ':' ;
272 0 sVar[r -> Component.nEvalPackage+1] = ':' ;
273 0 sVar[sizeof(sVar) - 1] = '\0' ;
274 0 nMax = sizeof(sVar) - r -> Component.nEvalPackage - 3 ;
275
276 0 ▶ if ((sVarName = strtok (sArgs, ", \t\n")))
Branch: 1 branch
BranchTrueFalseTotal
if ((sVarName = strtok (sArgs, ", \t\n"))) 0 0 0
277 {
278 0 ▶ if (*sVarName == '%')
Branch: 1 branch
BranchTrueFalseTotal
if (*sVarName == '%') 0 0 0
279 0 sVarName++ ;
280
281 0 strncpy (sVar + r -> Component.nEvalPackage + 2, sVarName, nMax) ;
282
283 0 ▶ if ((pAddHash = perl_get_hv ((char *)sVar, FALSE)) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if ((pAddHash = perl_get_hv ((char *)sVar, FALSE)) == NULL) 0 0 0
284 {
285 0 strncpy (r -> errdat1, sVar, sizeof (r -> errdat1) - 1) ;
286 0 _free (r, sArgs) ;
287 0 return rcHashError ;
288 }
289  
290 0 ▶ if ((sVarName = strtok (NULL, ", \t\n")))
Branch: 1 branch
BranchTrueFalseTotal
if ((sVarName = strtok (NULL, ", \t\n"))) 0 0 0
291 {
292 0 ▶ if (*sVarName == '%')
Branch: 1 branch
BranchTrueFalseTotal
if (*sVarName == '%') 0 0 0
293 0 sVarName++ ;
294
295 0 strncpy (sVar + r -> Component.nEvalPackage + 2, sVarName, nMax) ;
296
297 0 ▶ if ((pSubHash = perl_get_hv ((char *)sVar, FALSE)) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if ((pSubHash = perl_get_hv ((char *)sVar, FALSE)) == NULL) 0 0 0
298 {
299 0 strncpy (r -> errdat1, sVar, sizeof (r -> errdat1) - 1) ;
300 0 _free (r, sArgs) ;
301 0 return rcHashError ;
302 }
303  
304 0 ▶ if ((sVarName = strtok (NULL, ", \t\n")))
Branch: 1 branch
BranchTrueFalseTotal
if ((sVarName = strtok (NULL, ", \t\n"))) 0 0 0
305 {
306 0 ▶ if (*sVarName == '@')
Branch: 1 branch
BranchTrueFalseTotal
if (*sVarName == '@') 0 0 0
307 0 sVarName++ ;
308
309 0 strncpy (sVar + r -> Component.nEvalPackage + 2, sVarName, nMax) ;
310
311 0 ▶ if ((pSort = perl_get_av ((char *)sVar, FALSE)) == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if ((pSort = perl_get_av ((char *)sVar, FALSE)) == NULL) 0 0 0
312 {
313 0 strncpy (r -> errdat1, sVar, sizeof (r -> errdat1) - 1) ;
314 0 _free (r, sArgs) ;
315 0 return rcArrayError ;
316 }
317 }
318 }
319 }
320 }
321 else
322 0 pSort = r -> pThread -> pFormArray ;
323  
324  
325 /* oputc (r, '\n') ; */
326 0 ▶ if (pSort)
Branch: 1 branch
BranchTrueFalseTotal
if (pSort) 0 0 0
327 {
328 0 int n = AvFILL (pSort) + 1 ;
329 int i ;
330  
331 0 ▶ for (i = 0; i < n; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) 0 0 0
332 {
333 0 ppsv = av_fetch (pSort, i, 0) ;
334 0 ▶ if (ppsv && (pKey = SvPV(*ppsv, nKey)) && !hv_exists (pSubHash, pKey, nKey))
Branch: 3 branches
BranchTrueFalseTotal
if (ppsv && (pKey = SvPV(*ppsv, nKey)) && !hv_exists (pSubHash, pKey, nKey)) 0 0 0
if (ppsv && (pKey = SvPV(*ppsv, nKey)) && !hv_exists (pSubHash, pKey, nKey)) 0 0 0
if (ppsv && (pKey = SvPV(*ppsv, nKey)) && !hv_exists (pSubHash, pKey, nKey)) 0 0 0
335 {
336 STRLEN lppsv ;
337 0 ppsv = hv_fetch (pAddHash, pKey, nKey, 0) ;
338
339 0 ▶ if (ppsv && (!(r -> Component.Config.bOptions & optNoHiddenEmptyValue) || *SvPV (*ppsv, lppsv)))
Branch: 3 branches
BranchTrueFalseTotal
if (ppsv && (!(r -> Component.Config.bOptions & optNoHiddenEmptyValue) || *SvPV (*ppsv, lppsv))) 0 0 0
if (ppsv && (!(r -> Component.Config.bOptions & optNoHiddenEmptyValue) || *SvPV (*ppsv, lppsv))) 0 0 0
if (ppsv && (!(r -> Component.Config.bOptions & optNoHiddenEmptyValue) || *SvPV (*ppsv, lppsv))) 0 0 0
340 {
341 char * s ;
342 STRLEN l ;
343 SV * sEscapedText ;
344 0 tNode xInputNode = Node_appendChild (r -> pApp, pDomTree, pNewNode -> xNdx, nRepeatLevel, ntypTag, 0, "input", 5, 0, 0, NULL) ;
345 0 tNode xAttr = Node_appendChild (r -> pApp, pDomTree, xInputNode, nRepeatLevel, ntypAttr, 0, "type", 4, 0, 0, NULL) ;
346 0 Node_appendChild (r -> pApp, pDomTree, xAttr, nRepeatLevel, ntypAttrValue, 0, "hidden", 6, 0, 0, NULL) ;
347
348 0 xAttr = Node_appendChild (r -> pApp, pDomTree, xInputNode, nRepeatLevel, ntypAttr, 0, "name", 4, 0, 0, NULL) ;
349  
350 0 sEscapedText = Escape (r, pKey, nKey, r -> Component.nCurrEscMode, NULL, '\0') ;
351 0 ▶ s = SV2String (sEscapedText, l) ;
Branch: 1 branch
BranchTrueFalseTotal
s = SV2String (sEscapedText, l) ; 0 0 0
352 0 Node_appendChild (r -> pApp, pDomTree, xAttr, nRepeatLevel, ntypAttrValue, 0, s, l, 0, 0, NULL) ;
353 0 xAttr = Node_appendChild (r -> pApp, pDomTree, xInputNode, nRepeatLevel, ntypAttr, 0, "value", 5, 0, 0, NULL) ;
354  
355 0 s = SvPV (*ppsv, l) ;
356 0 sEscapedText = Escape (r, s, l, r -> Component.nCurrEscMode, NULL, '\0') ;
357 0 ▶ s = SV2String (sEscapedText, l) ;
Branch: 1 branch
BranchTrueFalseTotal
s = SV2String (sEscapedText, l) ; 0 0 0
358
359 0 Node_appendChild (r -> pApp, pDomTree, xAttr, nRepeatLevel, ntypAttrValue, 0, s, l, 0, 0, NULL) ;
360 0 SvREFCNT_dec (sEscapedText) ;
361 }
362 }
363 }
364 }
365 else
366 {
367 0 hv_iterinit (pAddHash) ;
368 0 ▶ while ((pEntry = hv_iternext (pAddHash)))
Branch: 1 branch
BranchTrueFalseTotal
while ((pEntry = hv_iternext (pAddHash))) 0 0 0
369 {
370 STRLEN nKey ;
371 0 pKey = hv_iterkey (pEntry, &l) ;
372 0 nKey = strlen (pKey) ;
373 0 ▶ if (!hv_exists (pSubHash, pKey, nKey))
Branch: 1 branch
BranchTrueFalseTotal
if (!hv_exists (pSubHash, pKey, nKey)) 0 0 0
374 {
375 STRLEN lpsv ;
376 0 psv = hv_iterval (pAddHash, pEntry) ;
377  
378 0 ▶ if (!(r -> Component.Config.bOptions & optNoHiddenEmptyValue) || *SvPV (psv, lpsv))
Branch: 2 branches
BranchTrueFalseTotal
if (!(r -> Component.Config.bOptions & optNoHiddenEmptyValue) || *SvPV (psv, lpsv)) 0 0 0
if (!(r -> Component.Config.bOptions & optNoHiddenEmptyValue) || *SvPV (psv, lpsv)) 0 0 0
379 {
380 char * s ;
381 STRLEN l ;
382 SV * sEscapedText ;
383 0 tNode xInputNode = Node_appendChild (r -> pApp, pDomTree, pNewNode -> xNdx, nRepeatLevel, ntypTag, 0, "input", 5, 0, 0, NULL) ;
384 0 tNode xAttr = Node_appendChild (r -> pApp, pDomTree, xInputNode, nRepeatLevel, ntypAttr, 0, "type", 4, 0, 0, NULL) ;
385 0 Node_appendChild (r -> pApp, pDomTree, xAttr, nRepeatLevel, ntypAttrValue, 0, "hidden", 6, 0, 0, NULL) ;
386
387 0 xAttr = Node_appendChild (r -> pApp, pDomTree, xInputNode, nRepeatLevel, ntypAttr, 0, "name", 4, 0, 0, NULL) ;
388
389 0 sEscapedText = Escape (r, pKey, nKey, r -> Component.nCurrEscMode, NULL, '\0') ;
390 0 ▶ s = SV2String (sEscapedText, l) ;
Branch: 1 branch
BranchTrueFalseTotal
s = SV2String (sEscapedText, l) ; 0 0 0
391 0 Node_appendChild (r -> pApp, pDomTree, xAttr, nRepeatLevel, ntypAttrValue, 0, s, l, 0, 0, NULL) ;
392 0 xAttr = Node_appendChild (r -> pApp, pDomTree, xInputNode, nRepeatLevel, ntypAttr, 0, "value", 5, 0, 0, NULL) ;
393  
394 0 s = SvPV (psv, l) ;
395 0 sEscapedText = Escape (r, s, l, r -> Component.nCurrEscMode, NULL, '\0') ;
396 0 ▶ s = SV2String (sEscapedText, l) ;
Branch: 1 branch
BranchTrueFalseTotal
s = SV2String (sEscapedText, l) ; 0 0 0
397
398 0 Node_appendChild (r -> pApp, pDomTree, xAttr, nRepeatLevel, ntypAttrValue, 0, s, l, 0, 0, NULL) ;
399 0 SvREFCNT_dec (sEscapedText) ;
400 }
401 }
402 }
403 }
404  
405 0 ▶ if (sArgs)
Branch: 1 branch
BranchTrueFalseTotal
if (sArgs) 0 0 0
406 0 _free (r, sArgs) ;
407  
408 0 return ok ;
409 }
410  
411  
412  
413  
414 /* ---------------------------------------------------------------------------- */
415 /* */
416 /* ouput data inside a url */
417 /* */
418 /* ---------------------------------------------------------------------------- */
419  
420  
421 0 SV * Node_replaceChildWithUrlDATA (/*in*/ tReq * r,
422 /*in*/ tIndex xDomTree,
423 tIndex xOldChild,
424 /*in*/ tRepeatLevel nRepeatLevel,
425 SV * sText)
426
427 {
428 epTHX_
429 STRLEN l ;
430 char * s ;
431 AV * pAV ;
432 HV * pHV ;
433 0 tDomTree * pDomTree = DomTree_self(xDomTree) ;
434  
435 0 ▶ if (SvROK(sText) && SvTYPE((pAV = (AV *)SvRV(sText))) == SVt_PVAV)
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(sText) && SvTYPE((pAV = (AV *)SvRV(sText))) == SVt_PVAV) 0 0 0
if (SvROK(sText) && SvTYPE((pAV = (AV *)SvRV(sText))) == SVt_PVAV) 0 0 0
436 0 { /* Array reference inside URL */
437 SV ** ppSV ;
438 int i ;
439 0 int f = AvFILL(pAV) ;
440 tNode xNode ;
441  
442 0 xOldChild = Node_replaceChildWithCDATA (r -> pApp, DomTree_self(xDomTree), xOldChild, nRepeatLevel, "", 0, 4, 0) ;
443  
444 0 ▶ for (i = 0; i <= f; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i <= f; i++) 0 0 0
445 {
446 0 ppSV = av_fetch (pAV, i, 0) ;
447 0 ▶ if (ppSV && *ppSV)
Branch: 2 branches
BranchTrueFalseTotal
if (ppSV && *ppSV) 0 0 0
if (ppSV && *ppSV) 0 0 0
448 {
449 0 ▶ s = SV2String (*ppSV, l) ;
Branch: 1 branch
BranchTrueFalseTotal
s = SV2String (*ppSV, l) ; 0 0 0
450 0 ▶ xNode = Node_appendChild (r -> pApp, pDomTree, xOldChild, nRepeatLevel, (tNodeType)((r -> Component.nCurrEscMode & 3)?ntypTextHTML:ntypCDATA), 0, s, l, 0, 0, NULL) ;
Branch: 1 branch
BranchTrueFalseTotal
xNode = Node_appendChild (r -> pApp, pDomTree, xOldChild, nRepeatLevel, (tNodeType)((r -> Component.nCurrEscMode & 3)?ntypTextHTML:ntypCDATA), 0, s, l, 0, 0, NULL) ; 0 0 0
451 0 ▶ if (r -> Component.nCurrEscMode & 2)
Branch: 1 branch
BranchTrueFalseTotal
if (r -> Component.nCurrEscMode & 2) 0 0 0
452 0 ▶ Node_selfLevel (r -> pApp, pDomTree, xNode, nRepeatLevel) -> bFlags |= nflgEscUrl ;
Branch: 2 branches
BranchTrueFalseTotal
Node_selfLevel (r -> pApp, pDomTree, xNode, nRepeatLevel) -> bFlags |= nflgEscUrl ; 0 0 0
Node_selfLevel (r -> pApp, pDomTree, xNode, nRepeatLevel) -> bFlags |= nflgEscUrl ; 0 0 0
453 }
454 0 ▶ if ((i & 1) == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ((i & 1) == 0) 0 0 0
455 0 Node_appendChild (r -> pApp, pDomTree, xOldChild, nRepeatLevel, ntypCDATA, 0, "=", 1, 0, 0, NULL) ;
456 0 ▶ else if (i < f)
Branch: 1 branch
BranchTrueFalseTotal
else if (i < f) 0 0 0
457 0 Node_appendChild (r -> pApp, pDomTree, xOldChild, nRepeatLevel, ntypCDATA, 0, "&amp;", 5, 0, 0, NULL) ;
458 }
459
460 }
461  
462 0 ▶ else if (SvROK(sText) && SvTYPE((pHV = (HV *)SvRV(sText))) == SVt_PVHV)
Branch: 2 branches
BranchTrueFalseTotal
else if (SvROK(sText) && SvTYPE((pHV = (HV *)SvRV(sText))) == SVt_PVHV) 0 0 0
else if (SvROK(sText) && SvTYPE((pHV = (HV *)SvRV(sText))) == SVt_PVHV) 0 0 0
463 0 { /* Hash reference inside URL */
464 HE * pEntry ;
465 char * pKey ;
466 SV * pSVValue ;
467 tNode xNode ;
468 0 int i = 0 ;
469 I32 l32 ;
470  
471 0 lprintf (r -> pApp, "xOldChild=%d, rl=%d\n", xOldChild, nRepeatLevel) ;
472 0 xOldChild = Node_replaceChildWithCDATA (r -> pApp, DomTree_self(xDomTree), xOldChild, nRepeatLevel, "", 0, 4, 0) ;
473 0 lprintf (r -> pApp, "a xOldChild=%d, rl=%d\n", xOldChild, nRepeatLevel) ;
474  
475 0 hv_iterinit (pHV) ;
476 0 ▶ while ((pEntry = hv_iternext (pHV)))
Branch: 1 branch
BranchTrueFalseTotal
while ((pEntry = hv_iternext (pHV))) 0 0 0
477 {
478 0 ▶ if (i++ > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (i++ > 0) 0 0 0
479 0 Node_appendChild (r -> pApp, pDomTree, xOldChild, nRepeatLevel, ntypCDATA, 0, "&amp;", 5, 0, 0, NULL) ;
480 0 pKey = hv_iterkey (pEntry, &l32) ;
481 0 ▶ xNode = Node_appendChild (r -> pApp, pDomTree, xOldChild, nRepeatLevel, (tNodeType)((r -> Component.nCurrEscMode & 3)?ntypTextHTML:ntypCDATA), 0, pKey, l32, 0, 0, NULL) ;
Branch: 1 branch
BranchTrueFalseTotal
xNode = Node_appendChild (r -> pApp, pDomTree, xOldChild, nRepeatLevel, (tNodeType)((r -> Component.nCurrEscMode & 3)?ntypTextHTML:ntypCDATA), 0, pKey, l32, 0, 0, NULL) ; 0 0 0
482 0 ▶ if (r -> Component.nCurrEscMode & 2)
Branch: 1 branch
BranchTrueFalseTotal
if (r -> Component.nCurrEscMode & 2) 0 0 0
483 0 Node_self (pDomTree, xNode) -> bFlags |= nflgEscUrl ;
484  
485 0 Node_appendChild (r -> pApp, pDomTree, xOldChild, nRepeatLevel, ntypCDATA, 0, "=", 1, 0, 0, NULL) ;
486  
487 0 pSVValue = hv_iterval (pHV , pEntry) ;
488 0 ▶ if (pSVValue)
Branch: 1 branch
BranchTrueFalseTotal
if (pSVValue) 0 0 0
489 {
490 0 ▶ s = SV2String (pSVValue, l) ;
Branch: 1 branch
BranchTrueFalseTotal
s = SV2String (pSVValue, l) ; 0 0 0
491 0 ▶ xNode = Node_appendChild (r -> pApp, pDomTree, xOldChild, nRepeatLevel, (tNodeType)((r -> Component.nCurrEscMode & 3)?ntypTextHTML:ntypCDATA), 0, s, l, 0, 0, NULL) ;
Branch: 1 branch
BranchTrueFalseTotal
xNode = Node_appendChild (r -> pApp, pDomTree, xOldChild, nRepeatLevel, (tNodeType)((r -> Component.nCurrEscMode & 3)?ntypTextHTML:ntypCDATA), 0, s, l, 0, 0, NULL) ; 0 0 0
492 0 ▶ if (r -> Component.nCurrEscMode & 2)
Branch: 1 branch
BranchTrueFalseTotal
if (r -> Component.nCurrEscMode & 2) 0 0 0
493 0 ▶ Node_selfLevel (r -> pApp, pDomTree, xNode, nRepeatLevel) -> bFlags |= nflgEscUrl ;
Branch: 2 branches
BranchTrueFalseTotal
Node_selfLevel (r -> pApp, pDomTree, xNode, nRepeatLevel) -> bFlags |= nflgEscUrl ; 0 0 0
Node_selfLevel (r -> pApp, pDomTree, xNode, nRepeatLevel) -> bFlags |= nflgEscUrl ; 0 0 0
494 }
495 }
496 }
497 else
498 {
499 0 ▶ char * s = SV2String (sText, l) ;
Branch: 1 branch
BranchTrueFalseTotal
char * s = SV2String (sText, l) ; 0 0 0
500 0 ▶ Node_replaceChildWithCDATA (r -> pApp, DomTree_self(xDomTree), xOldChild, nRepeatLevel, s, l, (r -> Component.nCurrEscMode & 3) == 3?2 + (r -> Component.nCurrEscMode & 4):r -> Component.nCurrEscMode, 0) ;
Branch: 1 branch
BranchTrueFalseTotal
Node_replaceChildWithCDATA (r -> pApp, DomTree_self(xDomTree), xOldChild, nRepeatLevel, s, l, (r -> Component.nCurrEscMode & 3) == 3?2 + (r -> Component.nCurrEscMode & 4):r -> Component.nCurrEscMode, 0) ; 0 0 0
501 }
502  
503 0 r -> Component.nCurrEscMode = r -> Component.Config.nEscMode ;
504 0 r -> Component.bEscModeSet = -1 ;
505 /* SvREFCNT_inc (sText) ; */
506 /* ST(0) = sText ;*/
507 /* XSRETURN(1) ; */
508 0 return sText ;
509 }
510  
511  
512  
513  
514 /* ---------------------------------------------------------------------------- */
515 /* */
516 /* AddSessionIdToLink */
517 /* */
518 /* ---------------------------------------------------------------------------- */
519  
520  
521 0 int embperlCmd_AddSessionIdToLink (/*i/o*/ register req * r,
522 /*in*/ tDomTree * pDomTree,
523 /*in*/ tNode xNode,
524 /*in*/ tRepeatLevel nRepeatLevel,
525 /*in*/ char * sAttrName)
526  
527 {
528 tNodeData * pNode ;
529 tAttrData * pAttr ;
530 int nAttrLen ;
531 0 char * pAttrString = NULL ;
532 char * pAttrValue ;
533 int l ;
534 int sl ;
535  
536 0 ▶ if (!r -> sSessionID)
Branch: 1 branch
BranchTrueFalseTotal
if (!r -> sSessionID) 0 0 0
537 0 return ok ;
538  
539 0 pNode = Node_self(pDomTree,xNode) ;
540 0 nAttrLen = strlen (sAttrName) ;
541 0 pAttr = Element_selfGetAttribut (r -> pApp, pDomTree, pNode, sAttrName, nAttrLen) ;
542 0 ▶ if (!pAttr)
Branch: 1 branch
BranchTrueFalseTotal
if (!pAttr) 0 0 0
543 0 return ok ;
544  
545 0 pAttrValue = Attr_selfValue (r -> pApp, pDomTree, pAttr, nRepeatLevel, &pAttrString) ;
546  
547 0 sl = strlen (r -> sSessionID) ;
548 0 ▶ if (!pAttrString)
Branch: 1 branch
BranchTrueFalseTotal
if (!pAttrString) 0 0 0
549 {
550 0 l = strlen (pAttrValue) ;
551 0 StringNew (r -> pApp, &pAttrString, l + 10 + sl) ;
552 0 StringAdd (r -> pApp, &pAttrString, pAttrValue, l) ;
553
554 }
555
556 0 ▶ if (strchr(pAttrValue, '?'))
Branch: 1 branch
BranchTrueFalseTotal
if (strchr(pAttrValue, '?')) 0 0 0
557 {
558 0 StringAdd (r -> pApp, &pAttrString, "&", 1) ;
559 }
560 else
561 {
562 0 StringAdd (r -> pApp, &pAttrString, "?", 1) ;
563 }
564 0 StringAdd (r -> pApp, &pAttrString, r -> sSessionID, sl) ;
565  
566 0 Element_selfSetAttribut (r -> pApp, pDomTree, pNode, nRepeatLevel, sAttrName, nAttrLen, pAttrString, ArrayGetSize (r -> pApp, pAttrString)) ;
567  
568 0 StringFree (r -> pApp, &pAttrString) ;
569  
570 0 return ok ;
571 }
572  
573  
574 /* ---------------------------------------------------------------------------- */
575 /* */
576 /* AddSessionIdToHidden */
577 /* */
578 /* ---------------------------------------------------------------------------- */
579  
580  
581 0 int embperlCmd_AddSessionIdToHidden(/*i/o*/ register req * r,
582 /*in*/ tDomTree * pDomTree,
583 /*in*/ tNode xNode,
584 /*in*/ tRepeatLevel nRepeatLevel)
585  
586 {
587 0 char * sid = r -> sSessionID ;
588 tNodeData * pNode ;
589  
590 0 pNode = Node_self(pDomTree,xNode) ;
591 0 ▶ if (sid)
Branch: 1 branch
BranchTrueFalseTotal
if (sid) 0 0 0
592 {
593 0 char * val = strchr (sid, '=') ;
594 0 ▶ if (val)
Branch: 1 branch
BranchTrueFalseTotal
if (val) 0 0 0
595 {
596 0 tNode xInputNode = Node_appendChild (r -> pApp, pDomTree, pNode -> xNdx, nRepeatLevel, ntypTag, 0, "input", 5, 0, 0, NULL) ;
597 0 tNode xAttr = Node_appendChild (r -> pApp, pDomTree, xInputNode, nRepeatLevel, ntypAttr, 0, "type", 4, 0, 0, NULL) ;
598 0 Node_appendChild (r -> pApp, pDomTree, xAttr, nRepeatLevel, ntypAttrValue, 0, "hidden", 6, 0, 0, NULL) ;
599
600 0 xAttr = Node_appendChild (r -> pApp, pDomTree, xInputNode, nRepeatLevel, ntypAttr, 0, "name", 4, 0, 0, NULL) ;
601 0 Node_appendChild (r -> pApp, pDomTree, xAttr, nRepeatLevel, ntypAttrValue, 0, sid, val - sid, 0, 0, NULL) ;
602 0 xAttr = Node_appendChild (r -> pApp, pDomTree, xInputNode, nRepeatLevel, ntypAttr, 0, "value", 5, 0, 0, NULL) ;
603 0 Node_appendChild (r -> pApp, pDomTree, xAttr, nRepeatLevel, ntypAttrValue, 0, val+1, strlen(val+1), 0, 0, NULL) ;
604 }
605 }
606
607 0 return ok ;
608 }
« epcgiinit.c ↑ Summary epcomp.c »