root/tags/5.4.pre05/ciupdmarx.c

Revision 1, 55.7 kB (checked in by heitor.barbieri, 4 years ago)

Criação do svn para Cisis.

Line 
1
2
3/* Begin PROCXSOCKREC
4
5         Gload[/<tag>][/nolf][/xml][/socket][/head][={<url>|<file>}]
6
7         Gmarx [/<tag>] [/<elem>[,<elem>..]] [=<tag>[,<tag>..]]
8
9Gmarx/1       /documents               =2      |  1.1 2.1
10Gmarx/2       /fulltext                =21     |  1.1 2.1 21.1
11Gmarx/2       /receipt                 =22     |  1.1 2.1 22.1
12
13*/
14#if PROCXSOCKREC
15
16#define MAXXPATH 99
17
18#define bpmovemax(bp,max,len,xleft)   {                                   \
19                                    if (max >= 20 && len > max) {         \
20                                        int m2=max/3*2,m3=max-m2-3;         \
21                                        char *q=bp+m2,*p=bp+len-m3;       \
22                                        char *z=bp+max-1;                 \
23                                        int left=max;                     \
24                                        int lmin=(xleft)?m2:0;            \
25                                        while (left-- > lmin)             \
26                                          if (*z--==' ')                  \
27                                            if (*z=='.' || *z==';')       \
28                                              break;                      \
29                                        if (left >= lmin) {               \
30                                          len=left+3;                     \
31                                          memcpy(bp+left," ..",3);        \
32                                        } else {                          \
33                                          len=m2+3+m3;                    \
34                                          memcpy(q,"...",3); q+=3;        \
35                                          while (m3--) *q++= *p++;        \
36                                        }                                 \
37                                    }                                     \
38                                  }
39//end bpmovemax(bp,max,len,xleft)
40
41#define hpmovemax(hp,max,a,len)   {                                       \
42                                    if (max >= 20 && len > max) {         \
43                                        int m2=max/3*2,m3=max-m2-3;       \
44                                        memcpy(hp,a,m2);        hp+=m2;   \
45                                        memcpy(hp,"+++",3);     hp+=3;    \
46                                        memcpy(hp,a+len-m3,m3); hp+=m3;   \
47                                    }                                     \
48                                    else {                                \
49                                        memcpy(hp,a,len); hp+=len;        \
50                                    }                                     \
51                                  }
52//end hpmovemax(hp,max,a,len)
53
54
55             if (  strncmp(p,"load=",5) == 0 || strncmp(p,"load/",5) == 0 || strcmp(p,"load") == 0 ||
56
57                   strncmp(p,"marx=",5) == 0 || strncmp(p,"marx/",5) == 0 || strncmp(p,"marx ",5) == 0
58
59                                         /* &&  (strstr(p,"/socket=") || strstr(p,"/socket/")  */      ) {
60
61
62                int isload = ( strncmp(p,"load=",5) == 0 || strncmp(p,"load/",5) == 0 || strcmp(p,"load") == 0 ) ? 1 : 0;
63                int ismarx = ( strncmp(p,"marx=",5) == 0 || strncmp(p,"marx/",5) == 0 || strncmp(p,"marx ",5) == 0 ) ? 1 : 0;
64
65            LONGX xtag=1;
66            int xtagzero=0;
67            int parmsocket=0;
68            int parmcmd=0;
69            int parmhead=0;
70            char *filnamp=NULL;
71
72            int parm0=0; //1; // strip 0D
73            int parm1=0;      // strip 0A
74            //int parmprint=0;
75            //FILE *parmfp=stdout;
76
77            int parmparse=0;
78            char *vxpath[MAXXPATH+1];
79            int vxtag[MAXXPATH+1];
80            int xmlspec=1;
81            int colonspec=0;
82            char *colonspecp="";
83            char *colonspecq;
84            int parmxml=0;
85            int xmlopened=0;
86
87            int  parmfile=0;
88            char *filepath="";
89            char *filechar="";
90            char *filename="";
91            char *filedot="";
92            char *fileext="";
93
94            int parmindex=0;
95            char *iphbuff=NULL;
96            char *ihtbuff=NULL;
97            char *ihtptr[21];
98            int   ihtlen[21];
99            int   ihtocc[21];
100            char *ihtpta[21];
101            int   ihtpla[21];
102            char *ihtptc[21];
103            char *ihtptd[21];
104
105            char *xbuffer=NULL;
106
107            int parmtag=0; //allow 0
108            int parmmin=0;
109            int parmmax=0;
110            int parm1cc=0;
111            int parm1c2=0;
112            int parmocc=0;
113            int parmoc2=0;
114            int clean=0;
115            int parmxlen=0;
116            int parmx=0;
117            int chunch1=0;
118            int chunch2=0;
119            int chunch3=0;
120            int parmvin=0;
121
122            char selattr[BUFSIZ+BUFSIZ];
123            int selsize;
124            int selparm;
125            char selcode[BUFSIZ];
126            char selcodearea[BUFSIZ];
127
128
129            char *xarea=NULL;
130            LONGX nbytes;
131            char *urlp=NULL;
132            char *q;
133
134            char *haddp=NULL;
135            char *hlenp=NULL;
136            char *hdatap=NULL;
137            LONGX hlen=0;
138
139            char *protocol;
140            char *serverhost;
141            uint16_t port;
142            char *pathp;
143
144            int maxrds=INT_MAX;
145            int xport=0;
146
147            char *msgp;
148            int rc;
149
150            //char *dbname;
151            //LONGX mfn;
152            //char *key;
153
154#if VDBBNAM_SERVER_PORT
155            //int dbx;
156            //int ndbx=3;
157            char *vdbname[] = {
158                "lilacs",
159                "artigo",
160                "citacoes",
161            };
162            char *vdbserver[] = {
163                "bases.bireme.br",
164                "www.scielo.br",
165                "serverofi.bireme.br",
166            };
167            int vdbport[] = {
168                1417,
169                1417,
170                1417
171            };
172#endif
173            vxpath[0]=NULL; vxtag[0]=0; //eol
174
175            /* scan parms
176            */
177            if (ismarx) {  // Gmarx
178              char *q;
179              int ipath=0;
180              p+=4;  /* skip marx */
181              while (isspace(*p)) p++;
182              if (*p != '/') fatal("fldupdat/procx/Gmarx [/<tag>] /<elem> =<tag>");
183              p++;
184              while (isspace(*p)) p++;
185              parmtag=1; //default
186              if (isdigit(*p)) for (parmtag=0; isdigit(*p); p++ ) parmtag=parmtag*10+((int)(*p)-(int)'0');
187              if (parmtag < 1) fatal("fldupdat/procx/Gmarx/tag");
188              while (isspace(*p)) p++;
189              if (*p=='/') p++; else fatal("fldupdat/procx/Gmarx/elem dlm");
190              vxpath[ipath]=p; // /element
191              selattr[0]='\0'; selsize=0; selparm=0; selcode[0]='\0';
192              q=strstr(p,"@@");
193              if (q) {
194                  int n=0; *q='\0'; p=q+2; while (isdigit(*p) || *p=='.') { n++; p++; }
195                  if (n>sizeof(selcode)-1) n=sizeof(selcode)-1; memcpy(selcode,q+2,n); selcode[n]='\0'; selparm=n;
196              }
197              else {
198                q=strchr(p,'@');
199                if (q) {
200                  q=strstr(q+1,"=\""); if (q) q=strchr(q+2,'"');
201                  if (q) {
202                    char *qb;
203                    int n;
204                    p=strchr(p,'@'); *p++='\0'; q=p; for (; *p; p++) if (*p==' ') if (*(p+1)=='=') { qb=p-1; *p='\0'; p++; break; }
205                    n=strlen(q); for (; *qb != '"'; qb--) n--;
206                    if (n>sizeof(selattr)-1) n=sizeof(selattr)-1; memcpy(selattr,q,n); selattr[n]='\0'; selsize=n;
207                  }
208                }
209              }//end selection
210              if (!q) for (; *p; p++) if (*p==' ' || *p=='=') { *p='\0'; p++; break; } //no selattr selparm
211              while (isspace(*p) || *p=='=') p++;
212              if (!isdigit(*p)) fatal("fldupdat/procx/Gmarx/=tag non numeric");
213              for (xtag=0; isdigit(*p); p++ ) xtag=xtag*10+((int)(*p)-(int)'0');
214              if (xtag < 1) fatal("fldupdat/procx/Gmarx/=tag lt 1");
215              vxtag[ipath]=xtag; ipath++;
216              while (isspace(*p)) p++;
217              while (*p=='/') {
218                  if (*(p+1)=='/') { *p='\0'; break; }  //comment
219                  if (strncmp(p,"/file="  ,6)==0)                               { p+=6; filepath=p; while (*p) if (isspace(*p)) break; else p++; if (*p) *p++='\0';
220                                                                                  for (q=p-2; q!=filepath; q--) { if (*q=='/' || *q=='\\') break;
221                                                                                                                  if (*q=='.') { *q++='\0'; fileext=q; filedot="."; break; }
222                                                                                                                }
223                                                                                  filename=filepath;
224                                                                                  if (strchr(filename,'\\')) while ((q=strchr(filename,'\\')) != NULL) filename=q+1;
225                                                                                  if (strchr(filename,'/' )) while ((q=strchr(filename,'/' )) != NULL) filename=q+1;
226                                                                                  if (filename==filepath) filepath="";
227                                                                                  else { q=filename-1; filechar=(*q=='/')?"/":"\\"; *q='\0'; }
228                                                                                  parmfile=1;
229                                                                                }
230                  if (strncmp(p,"/1cc="   ,5)==0)                               { p+=5; for (n=0; isdigit(*p); p++ ) n=n*10+((int)(*p)-(int)'0'); parm1cc=n; }
231                  if (strncmp(p,"/1c2="   ,5)==0)                               { p+=5; for (n=0; isdigit(*p); p++ ) n=n*10+((int)(*p)-(int)'0'); parm1c2=n; }
232                  if (strncmp(p,"/occ="   ,5)==0)                               { p+=5; for (n=0; isdigit(*p); p++ ) n=n*10+((int)(*p)-(int)'0'); parmocc=n; }
233                  if (strncmp(p,"/oc2="   ,5)==0)                               { p+=5; for (n=0; isdigit(*p); p++ ) n=n*10+((int)(*p)-(int)'0'); parmoc2=n; }
234                  if (strncmp(p,"/tag="   ,5)==0)                               { p+=5; for (n=0; isdigit(*p); p++ ) n=n*10+((int)(*p)-(int)'0'); parmvin=n; }
235                  if (strncmp(p,"/clean " ,7)==0 || strncmp(p,"/clean/" ,7)==0) { p+=7; clean=1; }
236                  if (strcmp (p,"/clean"    )==0)                               { p+=6; clean=1; }
237                  if (strncmp(p,"/index " ,7)==0 || strncmp(p,"/index/" ,7)==0) { p+=7; parmindex=1; xmlspec=0; colonspec=1; }  // /.@level:header,text
238                  if (strcmp (p,"/index"    )==0)                               { p+=6; parmindex=1; xmlspec=0; colonspec=1; }
239                  if (strncmp(p,"/i "     ,3)==0 || strncmp(p,"/i/"     ,3)==0) { p+=3; parmindex=1; xmlspec=0; colonspec=1; }  // /.@level:header,text
240                  if (strcmp (p,"/i"        )==0)                               { p+=2; parmindex=1; xmlspec=0; colonspec=1; }
241                  if (strncmp(p,"/len "   ,5)==0 || strncmp(p,"/len/"   ,5)==0) { p+=5; parmxlen=1; }
242                  if (strcmp (p,"/len"      )==0)                               { p+=4; parmxlen=1; }
243                  if (strncmp(p,"/xml "   ,5)==0 || strncmp(p,"/xml/"   ,5)==0) { p+=5; parmxml=1; }
244                  if (strcmp (p,"/xml"      )==0)                               { p+=4; parmxml=1; }
245                  if (strncmp(p,"/chunch ",8)==0 || strncmp(p,"/chunch/",8)==0) { p+=8; parmx=1; chunch1=224; }
246                  if (strcmp (p,"/chunch"   )==0)                               { p+=7; parmx=1; chunch1=224; }
247                  if (strncmp(p,"/c "     ,3)==0 || strncmp(p,"/c/"     ,3)==0) { p+=3; parmx=1; chunch1=224; }
248                  if (strcmp (p,"/c"        )==0)                               { p+=2; parmx=1; chunch1=224; }
249                  if (strncmp(p,"/chunch=",8)==0 ||
250                      strncmp(p,"/c="     ,3)==0)                               { if (strncmp(p,"/c="     ,3)==0) p+=3; else p+=8;
251                                                                                  for (n=0; isdigit(*p); p++ ) n=n*10+((int)(*p)-(int)'0'); chunch1=n;
252                                                                                  if (chunch1 < 20) chunch1=20;
253                                                                                  chunch2=chunch3=0;
254                                                                                  while (isspace(*p)) p++;
255                                                                                  if (*p==',') {
256                                                                                    int n;
257                                                                                    p++; for (n=0; isdigit(*p); p++ ) n=n*10+((int)(*p)-(int)'0'); chunch2=n;
258                                                                                  }
259                                                                                  while (isspace(*p)) p++;
260                                                                                  if (*p==',') {
261                                                                                    int n;
262                                                                                    p++; for (n=0; isdigit(*p); p++ ) n=n*10+((int)(*p)-(int)'0'); chunch3=n;
263                                                                                  }
264                                                                                }
265                  while (isspace(*p)) p++;
266              }
267              if (*p==':') {
268                p++; while (isspace(*p)) p++;
269                if (*p=='/') if (*(p+1)=='/') *p='\0';   //comment
270                colonspecp=p;
271                colonspecq=p;
272                if (strlen(p)) {
273                  p=p+strlen(p)-1; while (isspace(*p)) p--; colonspecq=p;
274                }
275                xmlspec=0; colonspec=1;
276              }
277              vxpath[ipath]=NULL; vxtag[ipath]=0; //eol
278              parmparse=1; // !load
279            }
280
281            /* scan parms
282            */
283            if (isload) {  // Gload
284              p+=4;  /* skip load or marx */
285              if (*p) { /* proc='Gload' */
286               while (*p == '/') {      /* /<tag>/socket */
287                p++;
288                if (isdigit(*p)) {                                                   /* /<tag> */
289                  if (*p=='0') xtagzero=1;  // allow tag /0n
290                  for (xtag=0; isdigit(*p); p++ ) xtag=xtag*10+((int)(*p)-(int)'0');
291                  if (xtag < 1) fatal("fldupdat/procx/Gload/tag");
292                  if (*p=='/' || *p=='='); else fatal("fldupdat/procx/Gload/tag dlm");
293                } else
294                if (strncmp(p,"no0D=",5) == 0 || strncmp(p,"no0D/",5) == 0 ||        /* /no0D */
295                    strncmp(p,"noCR=",5) == 0 || strncmp(p,"noCR/",5) == 0) {        /* /noCR */
296                  p+=4;
297                  parm0=1;
298                } else
299                if (strncmp(p,"no0A=",5) == 0 || strncmp(p,"no0A/",5) == 0 ||        /* /no0A */
300                    strncmp(p,"noLF=",5) == 0 || strncmp(p,"noLF/",5) == 0) {        /* /noLF */
301                  p+=4;
302                  parm1=1;
303                } else
304                if (strncmp(p,"line=",5) == 0 || strncmp(p,"line/",5) == 0 ||        /* /line */
305                    strncmp(p,"nonl=",5) == 0 || strncmp(p,"nonl/",5) == 0) {        /* /nonl */
306                  p+=4;
307                  parm0=parm1=1;
308                } else
309                if (strncmp(p,"socket=",7) == 0 || strncmp(p,"socket/",7) == 0) {    /* /socket */
310                  p+=6;
311                  parmsocket=1;
312                } else
313                if (strncmp(p,"head=",5) == 0 || strncmp(p,"head/",5) == 0) {        /* /head */
314                  p+=4;
315                  parmhead=1;
316                } else
317                if (strncmp(p,"xml=",4) == 0 || strncmp(p,"xml/",4) == 0) {          /* /xml */
318                  p+=3;
319                  parmcmd=1;
320                } else
321                if (strncmp(p,"tell=",5) == 0 || strncmp(p,"tell/",5) == 0) {        /* /tell */
322                  p+=4;
323                  parmcmd=2;
324                } else
325                if (strncmp(p,"trace=",6) == 0 || strncmp(p,"trace/",6) == 0) {      /* /trace */
326                  p+=5;
327                  parmcmd=3;
328                } else
329                fatal("fldupdat/procx/Gload[/<tag>][/nolf][/xml][/socket][/head][={<url>|<file>}]");
330               } /* while /x */
331              } /* proc='Gload' */
332              if (*p == '=') {
333                p++; if (parmsocket) urlp=p; else filnamp=p; p+=strlen(p);    /* <file> | <url> */
334             
335              }
336            }
337
338
339            /* alloc working area
340            */
341            nbytes=(rec_maxmfrl>MAXMFRL)?rec_maxmfrl:MAXMFRL;
342            if (nbytes < MFRmfrl) nbytes=MFRmfrl;
343            nbytes+=BUFSIZ;     /* buffup */ /* nbytes=MFRmfrl+MFRmfrl+BUFSIZ; */
344#if CICPP
345            try { xarea = (char *) new char [nbytes]; }
346            catch (BAD_ALLOC) { xarea = (char *)ALLONULL; }
347#else /* CICPP */
348            xarea=(char *)ALLOC((ALLOPARM)nbytes);
349#endif /* CICPP */
350            if (xarea == (char *)ALLONULL) fatal("fldupdat/procx/Gload/socket/ALLOC");
351            *xarea='\0';
352
353            q=xarea; /* batchp */
354
355            /* del/add command
356            */
357            if (isload) {
358                if (!xtagzero) sprintf(q,"D%ld",xtag);
359                else      sprintf(q,"D*");                       q+=strlen(q);   // exec tag /0n
360
361                sprintf(haddp=q,"H%09ld ",(xtag)?(LONGX)xtag:1L); q+=strlen(q);
362                sprintf(hlenp=q,"123456789 ");                   q+=strlen(q);
363            }
364
365            hdatap=q;
366
367             if (parmparse) {            /* ./mx null "proc='Gsplit/marx /215 /Para =2151'" */
368
369            /* scan, xdata and parse
370            */
371            int min;//=parmmin;
372            int max;//=parmmax;
373            int occ=parm1cc;
374            int oc2=parm1c2;
375            int tag=parmtag;
376            char *bufp=NULL;
377            int xdir,loop;
378            int iocc=0,lastag=0;
379
380            haddp=hdatap; // fldupdat() ptr
381
382            //if (tag<0) tag=1;
383            //if (!tag)  tag=1; // Gload/1  Gmarx/1
384
385            if (occ<0) occ=0;
386            if (oc2<0) oc2=0;
387            if (oc2<occ) oc2=occ;
388
389            for (xdir=0, loop=MFRnvf; loop--; xdir++) {
390                int itag=DIRtag(xdir);
391                int ilen=DIRlen(xdir);
392                if (tag) if (itag != tag) continue;   // otherwise all tags
393                if (!tag) if (itag == 2000) continue; // exclude cicgi tag
394                if (itag == lastag) iocc++; else { lastag=itag; iocc=1; }
395                if (occ) if (iocc < occ) continue;
396                if (oc2) if (iocc > oc2) continue;
397                min=parmmin;
398                max=parmmax;
399                if (min<1) min=1;
400                if (max<1) max=nbytes-BUFSIZ;
401                if (ilen < min) continue;
402
403                if (!xbuffer) {
404#if CICPP
405                    try { xbuffer = (char *) new char [nbytes]; }
406                    catch (BAD_ALLOC) { xbuffer = (char *)ALLONULL; }
407#else /* CICPP */
408                    xbuffer=(char *)ALLOC((ALLOPARM)nbytes);
409#endif /* CICPP */
410                    if (xbuffer == (char *)ALLONULL) fatal("fldupdat/procx/Gsplit/marx/ALLOC");
411                }
412                *(bufp=xbuffer)='\0';
413
414                if (ilen) {
415                    char *fldp=FIELDP(xdir);
416                    bpmovemax(fldp,max,ilen,0);
417                }
418                if (ilen) {
419                    char *fldp=FIELDP(xdir);
420                    int left=(ilen<100)?ilen-1:100-1;
421                    int s=0;
422                    char *p,*q;
423                    char k=fldp[left];
424                    fldp[left]='\0'; q=strstr(fldp,"<x a=\""); fldp[left]=k;
425                    if (q) {
426                      for (p=fldp;       ; p++) { s++; if (*p=='>') break;          } // ancest
427                      for (p=q+6; *p!='"'; p++) { if (*p==',') break; *bufp++ = *p; } // ancest,*offset.lenght
428                      *bufp++='|'; *bufp++='|';
429                      memcpy(bufp,fldp+s,ilen-s);           bufp+=(ilen-s);
430                    }
431                    else {
432                      fldp[left]='\0'; q=strstr(fldp,"||"); fldp[left]=k;
433                      if (q) {
434                        for (p=fldp;  p!=; p++) { s++; } s+=2;                        // ancest
435                        for (p=fldp; *p!='|'; p++) { if (*p==',') break; *bufp++ = *p; } // ancest,*offset.lenght
436                        *bufp++='|'; *bufp++='|';
437                        memcpy(bufp,fldp+s,ilen-s);          bufp+=(ilen-s);
438                      }
439                      else {
440                        sprintf(bufp,"%d.%d||",itag,iocc);   bufp+=strlen(bufp);
441                        memcpy(bufp,fldp,ilen);              bufp+=ilen;
442                      }
443                    }
444                }
445                *bufp++='\n';
446                *bufp='\0';
447
448                if (*xbuffer) {
449
450                    // rc = mainparse ( parmcmd, xbuffer, vxpath, vxtag, hdatap, nbytes-strlen(xbuffer) );
451
452                    char *hp=haddp;
453                    //char *hpback=hp;
454                    char *x=xbuffer; // input data
455                    //int xbufaoff=strlen(xbuffer);
456                    int lft;
457                    char carea[BUFSIZ];
458                    char *name=carea+2;
459                    char *p;
460                    char *np;
461                    char *path;
462                    int ipath;
463                    int i;
464                    char *a;  //opening ptr
465
466                    int itag,iocc=0,lastag=0;
467
468                    carea[0]='<'; carea[1]='/';
469
470                    while ((a=strchr(x,'<')) != NULL) // while <element..>
471
472                      if (strchr(a,'>')) { // opening element // if
473
474                        char *b;  //opening end
475                        char *c=NULL;  //closing ptr
476                        char *d=NULL;  //closing end
477                        int xb;   //opening len
478                        int xn;   //element name len
479                        char *ba;
480                        int xx=0;
481                        int xen=0;
482                        int len=0;
483                        int hasattr=0;
484                        int closed=0;
485                        //
486                        char *ihtba=NULL;
487                        int ihtxen=0;
488                        int level=0;
489                        char *indattr=" level=\"";
490                        int   indsize=8,xlev;
491                        //
492
493                        for (xb=1, b=a; *b != '>'; b++) xb++;                 // <x ...>....</x>
494                        if (*(b-1) == '/') closed=1;                          // <x ../>
495
496                        for (np=name, xn=0, p=a+1, lft=xb; lft--; p++) {
497                            if (*p == ' ') hasattr=1;
498                            if (*p == ' ' || *p == '/' || *p == '>') break;
499                            xn++; *np++= *p;
500                        }
501                        *np='\0';
502
503                        for (ipath=EOF, i=0; ; i++) {
504                            path=vxpath[i]; if (!path) break;
505                            if (strcmp(path,name) == 0) { ipath=i; itag=vxtag[ipath]; break; }
506                        }
507
508                        x=b+1;                                                // contents
509                        if (ipath == EOF) continue;        // skip element
510
511
512                        if (itag == lastag) iocc++; else { lastag=itag; iocc=1; hlen=0; }
513#if 01
514                        if (parmocc) if (iocc < parmocc) continue;
515                        if (parmoc2) if (iocc > parmoc2) continue;
516#endif
517                        if (*colonspecp == '-') continue;  // skip element - void output
518
519                        if (selsize) if (hasattr) {
520                            int skip=1;
521                            char *p;
522                            for (p=a; p!=b; p++) {
523                                if (*p == ' ') {
524                                    p++; // space
525                                    if (strncmp(p,selattr,selsize)==0) {
526                                        char c=p[selsize];
527                                        if (c == ' ' || c == '/' || c == '>') { skip=0; break; }
528                                    }
529                                }
530                            }
531                            if (skip) continue;            // skip element
532                        }
533
534                        if (closed) {                                         // <x ../>
535                            for (p=a; ; p++) { len++; if (p==b) break; }
536                        }
537                        else {                                                // <x ..>....</x>
538                        //
539                            char *q,oarea[BUFSIZ];
540                            int oxn;
541                        //
542                            int empty=0; //(c==x)?1:0;
543                            //
544                            level=0;
545                            //
546                            strcat(carea,">"); c=strstr(x,carea);
547                            if (c) d=strchr(c,'>');
548                            //
549                            //
550                            if (parmindex) if (c) { //it's well formed
551                                char *op=NULL;
552                                char *q=b;       //hierarchal index stops at b instead of c
553                                oxn=1+xn; oarea[0]='<'; memcpy(oarea+1,name,xn); oarea[oxn]='\0';
554                                *c='\0'; q=strstr(q+1,oarea); *c='<';                                                  // <name
555                                if (q) if (q[oxn]==' ' || q[oxn]=='>') { op=q; for (; q!=c; q++) if (*q=='>') break; } // <name ..>
556                                if (op) {
557                                  c=op;   //dlm as if </index>
558                                  d=op-1; //set forward x=d+1
559                                }
560                            }
561
562                        //
563                        // <index level=1> <index level=2> </index><index level=2><index level=3></index></index><index level=2></index></index>
564                        //                 op
565                        // a             b                 c      d                                                                      c     d
566
567                        // <index level=1> <index level=2> 2A </index> <index level=2> 2B</index> <index level=2> 2C </index> </index>
568                        //                 op
569                        // a             b                    c      d                   c      d                    c      d C      D
570                        //
571                                                                              // a     b    c  d
572                                if (parmindex) {
573                                    if (!iphbuff) {
574#if CICPP
575                                        try { iphbuff = (char *) new char [nbytes]; }
576                                        catch (BAD_ALLOC) { iphbuff = (char *)ALLONULL; }
577#else /* CICPP */
578                                        iphbuff=(char *)ALLOC((ALLOPARM)nbytes);
579#endif /* CICPP */
580                                        if (iphbuff == (char *)ALLONULL) fatal("fldupdat/procx/Gsplit/marx/ALLOC");
581                                    }
582                                    if (!ihtbuff) {
583#if CICPP
584                                        try { ihtbuff = (char *) new char [nbytes]; }
585                                        catch (BAD_ALLOC) { ihtbuff = (char *)ALLONULL; }
586#else /* CICPP */
587                                        ihtbuff=(char *)ALLOC((ALLOPARM)nbytes);
588#endif /* CICPP */
589                                        if (ihtbuff == (char *)ALLONULL) fatal("fldupdat/procx/Gsplit/marx/ALLOC");
590                                        *ihtbuff='\0'; for (xlev=0; xlev<21; xlev++) { ihtptr[xlev]=ihtbuff; ihtlen[xlev]=0; ihtocc[xlev]=0; ihtpta[xlev]=NULL; ihtpla[xlev]=0; ihtptc[xlev]=NULL; ihtptd[xlev]=NULL; }
591                                    }
592                                    level=0; ihtxen=0; xen=0;
593                                    if (hasattr) for (p=a+1; p!=b; p++) if (*p == ' ') if (strncmp(p,indattr,indsize)==0) {                   //.level="
594                                      for (p+=indsize; isdigit(*p); p++ ) level=level*10+((int)(*p)-(int)'0'); break;
595                                    }
596                                    if (level>=1 && level<21) {
597                                      //header
598                                      char *a1,*b1=NULL,*c1=NULL;
599                                      char *a2,*b2=NULL,*c2=NULL;
600                                      char *oarea1="<header",*carea1="</header>";
601                                      char *oarea2="<text",*carea2="</text>";
602                                      int oxn1=7,oxn2=5;
603                                      //
604                                      //header
605                                      *c='\0'; a1=strstr(b+1,oarea1);  if (a1) if (a1[oxn1]==' ' || a1[oxn1]=='>') b1=strchr(a1,'>'); *c='<'; // <header..>
606                                      if (b1) { c1=strstr(b1+1,carea1); }                                                                     // </header>
607                                      if (c1) {
608                                        int n;
609                                        char *ihtp=ihtptr[level]+ihtlen[level]+1;
610                                        //copy header
611                                        if (level>1) *ihtp++=' ';
612                                        *c1='\0'; n=strlen(b1+1); *c1='<'; memcpy(ihtp,b1+1,n); ihtptr[level]=ihtp; ihtp+=n; ihtlen[level]=n; *ihtp='\0';
613                                        ihtocc[level]=iocc;
614                                        ihtpta[level]=a; ihtpla[level]=b-a+1; if (closed) ihtpla[level]--;
615                                        ihtptc[level]=c; ihtptd[level]=d;
616                                   /**/ for (xlev=level+1; xlev<21; xlev++) { ihtptr[xlev]=ihtp; ihtlen[xlev]=0; ihtocc[xlev]=0; ihtpta[xlev]=NULL; ihtpla[xlev]=0; ihtptc[xlev]=NULL; ihtptd[xlev]=NULL; }
617                                        //
618                                        //text
619                                        *c='\0'; a2=strstr(b+1,oarea2);  if (a2) if (a2[oxn2]==' ' || a2[oxn2]=='>') b2=strchr(a2,'>'); *c='<'; // <text..>
620                                        if (b2) { c2=strstr(b2+1,carea2); }                                                                     // </text>
621                                        if (c2) { *c2='\0';  ihtxen=strlen(b2+1); *c2='<'; ihtba=b2+1; }
622                                      }//c1
623                                    }//level
624                                    //ihtmove(p,max,len,xleft)
625                                }//end parmindex
626                            else // nested
627                            if (d) {
628                              q=b;       //nested elements in b+1..c-1
629                              oxn=1+xn; oarea[0]='<'; memcpy(oarea+1,name,xn); oarea[oxn]='\0';
630                              while (d) {  //while following closing and nested opening
631                                char *op=NULL;
632                                *c='\0'; q=strstr(q+1,oarea); *c='<';                                                  // <name
633                                if (q) if (q[oxn]==' ' || q[oxn]=='>') { op=q; for (; q!=c; q++) if (*q=='>') break; } // <name ..>
634                                if (op) {                       //nested opening
635                                  c=strstr(d+1,carea); d=NULL;  //following c                                          // </name>
636                                  if (c) d=strchr(c,'>');       //following d
637                                }
638                                else break;
639                              }//end while following closing and nested opening
640                            }//d
641
642                            if (selparm) {
643                              int skip=1;
644                              char *p;
645                              if (!parmindex) {
646                                level=0; ihtxen=0; xen=0;
647                                if (hasattr) for (p=a+1; p!=b; p++) if (*p == ' ') if (strncmp(p,indattr,indsize)==0) {                   //.level="
648                                  for (p+=indsize; isdigit(*p); p++ ) level=level*10+((int)(*p)-(int)'0'); break;
649                                }
650                                if (level>=1 && level<21) ihtocc[level]=iocc;
651                              }
652                              if (level>=1 && level<21) {
653                                for (p=selcodearea, xlev=1; xlev<=level; xlev++) { sprintf(p,"%d.",ihtocc[xlev]); p+=strlen(p); } *p++='\0';
654                                if (strcmp(selcodearea,selcode) == 0) skip=0;  // get this element - code
655                              }
656                              if (skip) continue;                              // skip element - code
657                            }//end selparm
658
659                            if (d) if (!parmindex) {
660                              char *bc=c;
661                              //remove CDATA marks
662                              int parmy=clean;
663                              if (parmy) {
664                                    char *p,*q;
665                                    char k= *c; *c='\0';
666                                    p=b+1; while ((q=strstr(p,"<![CDATA[")) !=NULL) { memset(q,(int)' ',9); p=q+9; }
667                                    p=b+1; while ((q=strstr(p,"]]>"      )) != NULL) { memset(q,(int)' ',3); p=q+3; }
668                                    p=b+1; while ((q=strchr(p,'<')) != NULL) if ((p=strchr(q,'>')) == NULL) { *q=' '; p=q+1; } else for (*p=' '; p!=q; ) *--p=' ';
669                                    *c=k;
670                              } // parmy
671                              for (p=a;  ; p++) { len++; if (p==d)  break; }
672                              for (ba=b+1; ba!=&& isspace(*ba); ) { ba++; xx++; }
673                              if (ba==c)  empty=1; else for (bc=c-1; bc!=ba && isspace(*bc); ) { bc--; xx++; }
674                              if (ba==bc) empty=1;
675                              if (!empty) {
676                                for (p=ba; ; p++) { xen++; if (p==bc) break; }
677                                if (clean) {
678                                    int left=xen,n=0;
679                                    char *p=ba,*q=ba,x='\0';
680                                    while (left--)
681                                      if (x==' ' && *p==' ') { p++; n++; }
682                                      else
683                                      if (x=='.' && *p=='.') { p++; n++; }
684                                      else
685                                      { x= *p; if (p == q) { p++; q++; } else *q++ = *p++; }
686                                    xen-=n;
687                                }//clean
688                                //
689                              }//!empty
690                            }//d
691                        }//!closed
692
693                        while (xmlspec || hasattr || xen || ihtxen) {
694#if 01
695                            if (xmlspec || hasattr || xen >= min || ihtxen >= min) {
696#endif
697                                char *hdatp;
698                                LONGX litag=(parmvin)?parmvin:itag;
699                                if (ihtxen) {
700                                    //int xlev;
701                                    int xe;
702                                    char *iphp,*c2,k;
703                                    char *pp;   //par1 a
704                                    int qpcase; //case
705//
706                                    //execute /index@level:header,text
707                                    ba=iphbuff;
708                                    //copy headers
709                                    for (iphp=iphbuff, xlev=1; xlev<=level; xlev++) {
710                                      if (ihtlen[xlev]) { memcpy(iphp,ihtptr[xlev],ihtlen[xlev]); iphp+=ihtlen[xlev]; } else *iphp++='-';
711                                    //*iphp++='.'; *iphp++=' ';
712                                      *iphp++='|';
713                                    }
714                                    *iphp++='|';
715                                    *iphp='\0'; xen=strlen(iphbuff);
716                                    //copy text
717                                    c2=ihtba+ihtxen; k= *c2; *c2='\0'; //skip headers, search for .space
718
719                                    p=strstr(pp=ihtba,". ");           // Par1.   Par2.
720                                    while (isspace(*pp)) pp++;         // Par1.   Par2.
721                                    qpcase=0;                          // Par1.   Par2.
722                                    while (p) {                        // pp  p   qq  pq
723                                                                       // Aetc.   Aetc.
724                                                                       // Aetc.   12. Aetc
725                                      char *q;
726                                      char *qq; //par2 a
727                                      char *pq; //par2 b
728                                      int n=0;  //par1 lenght excluding .
729                                      int s=0;  //spaces before par2
730                                      int m=0;  //par2 lenght excluding .
731                                      int v=0;  //par2 starts with digits
732                                      int w=0;  //par2 is all digits, period and upper case letter
733//
734                                      for (q=pp;  q!=p;        q++) n++;
735                                      for (q=p+1; isspace(*q); q++) s++;
736                                      pq=strstr(qq=q,". ");
737                                      qpcase=0;
738                                      if (pq) qpcase=2; else for (; *q; q++) if (*q=='.' && !*(q+1)) { pq=q; qpcase=1; }
739                                      if (pq) for (q=p+1+s; q!=pq;       q++) m++;
740                                      if (pq) for (q=p+1+s; isdigit(*q); q++) v++;
741                                      if (v) if (*q=='.' && *(q+1)==' ') { q+=2; while (isspace(*q)) q++; if (isupper(*q)) w=v; }
742//
743                                      if (n<=3) {                      //par1 is too short - 1.
744                                         pp=qq; p=pq;
745                                         continue;
746                                      }
747                                      if (w && w<=2) {                 //par2 is 12. Aetc
748                                         break;
749                                      }
750                                      if (m) if (!isupper(*qq)) {      //par2 not Aetc     - E. coli
751                                         pp=qq; p=pq;
752                                         continue;
753                                      }
754                                      if (m<=3) {                      //par2 is too short - Tard A. O.
755                                         pp=qq; p=pq;
756                                         continue;
757                                      }
758                                      break;           //otherwise
759                                    }
760                                    *c2=k;
761#if 1
762                                    if (p) { *(p+1)='\0'; xe=strlen(ihtba); *(p+1)=' '; memcpy(iphp,ihtba,xe);    ihtba+=(xe+1);  ihtxen-=(xe+1); }
763                                    else   {              xe=ihtxen;                    memcpy(iphp,ihtba,xe);    ihtba=NULL;     ihtxen=0;       }
764#else
765                                    if (p) {
766                                      if (qpcase == 2)
767                                           { *(p+1)='\0'; xe=strlen(ihtba); *(p+1)=' '; memcpy(iphp,ihtba,xe);    ihtba+=(xe+1);  ihtxen-=(xe+1); }
768                                      else
769                                      if (qpcase == 1)
770                                           {              xe=strlen(ihtba);             memcpy(iphp,ihtba,xe);    ihtba+=(xe  );  ihtxen-=(xe  ); }
771                                      else
772                                           {              xe=ihtxen;                    memcpy(iphp,ihtba,xe);    ihtba=NULL;     ihtxen=0;       }
773                                    }
774                                    else   {              xe=ihtxen;                    memcpy(iphp,ihtba,xe);    ihtba=NULL;     ihtxen=0;       }
775#endif
776                                    if (xe) { //
777                                      char *pa=iphp,*pc=iphp+xe;
778                                      for (; pa!=pc && isspace(*pa); ) { pa++; xe--; }
779                                      if (pa==pc) xe=0; else for (; pc!=pa && isspace(*pc); ) { pc--; xe--; }
780                                      if (pa==pc) xe=0;
781                                      if (xe) {
782                                            int left=xe,n=0;
783                                            char *p=pa,*q=iphbuff+xen,x='\0';
784                                            while (left--)
785                                              if (x==' ' && *p==' ') { p++; n++; }
786                                              else
787                                              if (x=='.' && *p=='.') { p++; n++; }
788                                              else
789                                              { x= *p; if (p == q) { p++; q++; } else *q++ = *p++; }
790                                            xe-=n;
791                                      }//!empty
792                                    }//xe
793                                    xen+=xe;
794                                    if (!xe) xen=0; // no text to display
795                                }//end if ihtxen
796                                if (parmindex) if (!xen) break;
797
798                                if (colonspec) {
799                                    if (parmx) {
800                                      if (chunch2 < 6 || chunch2>=chunch1) chunch2=chunch1/2;
801                                      if (chunch3 < 6 || chunch3>=chunch1) chunch3=chunch1/3;
802                                      max=chunch1+chunch2;
803                                      if (hlen) {
804                                        if (closed) { if (hasattr)              hlen=0; }
805                                        else {        int xe=0;
806                                                      char *xep=ba;
807                                                      while (isdigit(*xep) || *xep=='.') { xep++; xe++; }
808                                                      if (xe>1) if (*xep==' ')  hlen=0;   //    - / n.n.
809                                                      if (xen      >  max    )  hlen=0;   //336 - / 224...112
810                                                      if (xen      >  chunch1)  hlen=0;   //224 - / xen
811                                        }
812                                        if (hlen) {
813                                          *hp++=' '; *hp++=' ';
814                                        }
815                                      }
816                                      if (hlen==0) {
817                                        hlenp=hp+11; sprintf(hp,"H%09ld 123456789 ",litag); hp+=strlen(hp); hdatp=hp;
818                                        if (parmfile) { sprintf(hp,"%s ",filename);                         hp+=strlen(hp); }
819                                        sprintf(hp,"%d %d: ",itag,iocc);                                    hp+=strlen(hp);
820                                        if (level) { //headers ptrs/code
821                                            sprintf(hp,"%d",ihtocc[1]); hp+=strlen(hp); for (xlev=2; xlev<=level; xlev++) { sprintf(hp,".%d",ihtocc[xlev]); hp+=strlen(hp); }
822                                            sprintf(hp,"||");                                               hp+=strlen(hp);
823                                        }
824                                        bpmovemax(ba,max,xen,1);  //336  //224
825                                      }
826                                      max+=3;
827                                    }
828                                    else {  //parse/index !parmx
829                                      hlenp=hp+11; sprintf(hp,"H%09ld 123456789 ",litag); hp+=strlen(hp); hdatp=hp;
830                                      //if (parmfile) { sprintf(hp,"%s%s%s%s%s ",filepath,filechar,filename,filedot,fileext);  hp+=strlen(hp); }
831                                      if (parmfile) { sprintf(hp,"%s ",filename);                         hp+=strlen(hp); }
832                                      for (p=xbuffer; ; p++) { if (*p=='|') break; *hp++ = *p; }  // ancestor
833                                      if (parmxlen) { sprintf(hp," %d.%d, %d,%d,%d,%d||",itag,iocc,xn,xb,xen,len);          hp+=strlen(hp); }
834                                      else          { sprintf(hp," %d.%d||"             ,itag,iocc              );          hp+=strlen(hp); }
835                                      if (level) { //headers ptrs/code
836                                            sprintf(hp,"%d",ihtocc[1]); hp+=strlen(hp); for (xlev=2; xlev<=level; xlev++) { sprintf(hp,".%d",ihtocc[xlev]); hp+=strlen(hp); }
837                                            sprintf(hp,"||");                                               hp+=strlen(hp);
838                                      }
839                                    } //end parmx
840                                } else { //xmlspec/!colonspec
841                                    hlenp=hp+11; sprintf(hp,"H%09ld 123456789 ",litag); hp+=strlen(hp); hdatp=hp;
842                                    if (parmxml) if (!xmlopened) {
843                                      sprintf(hp,"<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n");     hp+=strlen(hp);
844                                      sprintf(hp,"<marx file=\"%s\" type=\"%s%s\" path=\"%s%s\">\n",filename,filedot,fileext,filepath,filechar);  hp+=strlen(hp);
845                                      xmlopened=1;
846                                    }
847                                    sprintf(hp,"<x a=\"");                                                  hp+=strlen(hp);
848                                    for (p=xbuffer; ; p++) { if (*p=='|') break; *hp++ = *p; } // ancestor
849                                    sprintf(hp," %d.%d\"",itag,iocc);                                      hp+=strlen(hp);
850                                    if (parmxlen) { sprintf(hp," b=\"%d,%d,%d,%d\"",xn,xb,xen,len);         hp+=strlen(hp); }
851                                    if (level) { //headers ptrs/code
852                                          sprintf(hp," c=\"");                                              hp+=strlen(hp);
853                                          sprintf(hp,"%d",ihtocc[1]); hp+=strlen(hp); for (xlev=2; xlev<=level; xlev++) { sprintf(hp,".%d",ihtocc[xlev]); hp+=strlen(hp); }
854                                          sprintf(hp,"\"");                                                 hp+=strlen(hp);
855                                    }
856                                    sprintf(hp,"/>"); hp+=strlen(hp);
857                                }
858
859                                if (colonspec) {
860                                  if (*colonspecp) {
861                                    for (q=colonspecp; *q; q++) {
862                                      if (*q == '&') {
863                                        char *p=q+1;
864                                        char *m;
865                                        if (isalpha(*p) || isdigit(*p)) {   //&name - attr char1
866                                          char bb[BUFSIZ];
867                                          char *aap=NULL;
868                                          char *aaq=NULL;
869                                          char k;
870                                          for (m=bb, *m=' '; isalpha(*p) || isdigit(*p); p++) { *m++= *p; q++; } *m++='='; *m++='"'; *m='\0';  //.attrname="
871                                          k= *b; *b='\0'; aap=strstr(a+1,bb); if (aap) aaq=strchr(aap+=strlen(bb),'"'); *b=k;
872                                          if (aaq) while (aap != aaq) *hp++ = *aap++;           //output attr contents
873                                        }
874                                        else {                              //& - element name, attrs, contents
875                                          for (  p=a+1,      m=p+xn;          p != m; p++) *hp++= *p;             //output element name
876                                          if (hasattr) { *hp++=' ';                                               //output
877                                            if (closed) for (p=a+1+xn+1, m=b-1/*closed*/; p != m; p++) *hp++= *p; //output all attrs
878                                            else        for (p=a+1+xn+1, m=b-0/*      */; p != m; p++) *hp++= *p; //output all attrs
879                                          }
880                                          if (xen) {
881                                            *hp++=' ';                                                            //output
882                                            //for (p=ba; xen--; p++) *hp++= *p;                                   //output all contents //
883                                            hpmovemax(hp,max,ba,xen);                                             //output all contents //
884                                          }
885                                        }// end if char1
886                                      } else {                              //. - spec char
887                                        *hp++ = *q;                                                               //output spec char
888                                      }//& or .
889                                      if (q==colonspecq) break;
890                                    }//end for
891                                  } //colonspecp
892                                  else { //colonspecp                       //: - contents
893                                      if (closed) { xen=len-3; ba=a+1; }
894                                      hpmovemax(hp,max,ba,xen);                                                   //: - output contents
895                                  } //colonspec
896                                } else { //colonspec
897                                    hpmovemax(hp,max,a,len);                                                      //: - output xml
898                                } //colonspec
899
900                                if (xmlopened) {
901                                  sprintf(hp,"</marx>\n");  hp+=strlen(hp);
902                                }
903                                //null hp string
904                                *hp='\0'; haddp=hp;
905
906                                //actual len
907                                hlen=strlen(hdatp); sprintf(hlenp,"%9ld",(LONGX)hlen); hlenp[9]=' ';
908
909                                if (parmx) {
910                                        if (  hlen      >= chunch1         )    hlen=0;   //224 - /
911                                        if (!closed) if ( xen > chunch3 ) {               //75  - 75./
912                                                          if ( ba[xen-1]=='.' ) hlen=0;
913                                                          if ( ba[xen-1]==';' ) hlen=0;
914                                        }
915                                } // parmx
916
917                                //move forward ok
918                                if (d) x=d+1;
919
920                            } // end if xmlspec || hasattr || xen >= min || ihtxen >= min
921                            // else continues from x=b+1
922
923                            if (!ihtxen) break;
924
925                        } // end while xmlspec || hasattr ||xen || ihtxen
926
927
928                      } else { // else while <element..>
929
930                        x++;
931
932                      } // fi while <element..>
933
934                } // *xbuffer
935            } // xdir
936             } // parmparse
937
938         else  /* else parmparse */
939
940             if (parmsocket) {            /* ./mx null "proc='Gload/socket=http://www.bireme.br:80/'" */
941
942            /* scan <url>
943            */
944            protocol="HTTP";
945            q=strstr(p=urlp,"://"); /* http:// */
946            if (q) {
947                char *x;
948                int len;
949                *q='\0'; len=strlen(p);
950                if (len < 8) {
951                  protocol=p;                                                    /* http | x1417*/
952                  for (x=p; *x; x++) *x=toupper(*x);
953                  p=q+3;
954                }
955                else *q=':';
956            }
957
958            serverhost=p;                                                       /* www.bireme.br | serverofi.bireme.br */
959
960            pathp=strchr(p+1,'/');                                           /* /path | /dbname/parms */
961            if (pathp) *pathp='\0';
962            else pathp="/";
963
964            port=80;                          /* :80 */
965            q=strchr(p,':');
966            if (q) {
967                *q='\0';
968                if (sscanf(q+1,"%d",&xport) == 1) port=xport;                   /* :80 | :1417 */
969                else xport=0; /*fatal("fldupdat/procx/Gload/socket/port");*/
970            }
971
972            /* X1417://serverofi.bireme.br:1417/msg
973                                               /dbname/control/maxmfn
974                                               /dbname/text/mfn/mfn2/count/step
975                                               /dbname/dict/key/key2/contains/count
976                                               /dbname/bool/expression
977                                               /dbname/rank/text
978            */
979            if (strcmp(protocol,"X1417") == 0) {
980                maxrds=1;                                                        /* single read */
981                if (!xport) port=1417;     /* :1417 */
982            }
983
984            msgp=hdatap;
985            *msgp='\0';
986            if (strcmp(protocol,"X1417") == 0) {
987                sprintf(msgp,"%s\n",pathp+1);
988            }
989            else
990            if (strcmp(protocol,"HTTP") == 0) {
991                sprintf(msgp,"%s /%s HTTP/1.0\n\n",(parmhead)?"HEAD":"GET",pathp+1);
992            }
993
994            if (*msgp) rc = mainclient ( parmcmd, protocol, serverhost, port, msgp, hdatap, nbytes-strlen(xarea), maxrds);
995
996             }
997
998         else { /* else parmsocket: <file> */
999
1000             rc = mainfile ( parmcmd, filnamp, parm0, parm1, hdatap, nbytes-strlen(xarea) );
1001
1002             } /* end parmsocket */
1003
1004
1005
1006        if (isload) {
1007            if (rc < 0) {
1008                sprintf(hdatap,"Gload%s error %d",parmsocket?"/socket":"",(-rc));
1009                hlen=strlen(hdatap);
1010            }
1011            else hlen=rc;
1012
1013            if (hlen) {
1014                /* actual add lenght */
1015                sprintf(hlenp,"%9ld",(LONGX)hlen); hlenp[9]=' ';
1016                /* print */
1017                //if (parmprint) fprintf(parmfp,"%s",hdatap);
1018            }
1019            else if (haddp) *haddp='\0';
1020        }
1021
1022        //else printf("%s\n",xarea);
1023
1024#if CICPP
1025        if (recp->xfldupdat(xarea)) fatal(errp);
1026        delete xarea;
1027        delete xbuffer;
1028#else /* CICPP */
1029//printf("antes do fldupdat\n");
1030        if (fldupdat(irec,xarea)) fatal(errp);
1031//printf("depois do fldupdat\n");
1032        if (xarea) FREE(xarea);
1033        if (xbuffer) FREE(xbuffer);
1034#endif /* CICPP */
1035
1036        return NULL; //isgdump=1;
1037
1038        }  /* end Gload/socket */
1039        else
1040
1041#endif /* PROCXSOCKREC */
1042/* End PROCXSOCKREC
1043*/
1044
1045#if INDEXAT
1046                                            for (xlev=1; xlev<=level; xlev++) {
1047                                              char *p=ihtpta[xlev]+1;
1048                                              int n=ihtpla[xlev]-1;
1049                                              *hp++='/';
1050                                              while (n) if (*p==' ' || *p=='/' || *p=='>') break; else { *hp++ = *p++; n--; }
1051                                              if (*p==' ') { p++; n--; }
1052                                              *hp++='@';
1053                                              n--; if (closed) n--;
1054                                              memcpy(hp,p,n); hp+=n;
1055                                              *hp++='|';
1056                                            }
1057#endif
Note: See TracBrowser for help on using the browser.