source: git/Singular/silink.cc @ 31a392

spielwiese
Last change on this file since 31a392 was 4082e8, checked in by Hans Schoenemann <hannes@…>, 14 years ago
pipelInk stuff git-svn-id: file:///usr/local/Singular/svn/trunk@13171 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 18.6 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id$ */
5
6/*
7* ABSTRACT: general interface to links
8*/
9
10#include <stdio.h>
11#include <string.h>
12#include <sys/types.h>
13#include <sys/stat.h>
14#include <unistd.h>
15
16#include <Singular/mod2.h>
17#include <Singular/tok.h>
18#include <kernel/options.h>
19#include <omalloc.h>
20#include <kernel/febase.h>
21#include <Singular/subexpr.h>
22#include <Singular/ipid.h>
23#include <Singular/silink.h>
24#include <Singular/ipshell.h>
25#include <kernel/matpol.h>
26#include <kernel/ring.h>
27#include <Singular/lists.h>
28#include <kernel/ideals.h>
29#include <kernel/numbers.h>
30#include <kernel/intvec.h>
31#include <Singular/ssiLink.h>
32#include <Singular/pipeLink.h>
33
34// #ifdef HAVE_DBM
35// #ifdef ix86_Win
36// #define USE_GDBM
37// #endif
38// #endif
39
40omBin s_si_link_extension_bin = omGetSpecBin(sizeof(s_si_link_extension));
41omBin sip_link_bin = omGetSpecBin(sizeof(sip_link));
42omBin ip_link_bin = omGetSpecBin(sizeof(ip_link));
43
44/* declarations */
45static BOOLEAN DumpAscii(FILE *fd, idhdl h);
46static BOOLEAN DumpAsciiIdhdl(FILE *fd, idhdl h);
47static const char* GetIdString(idhdl h);
48static int DumpRhs(FILE *fd, idhdl h);
49static BOOLEAN DumpQring(FILE *fd, idhdl h, const char *type_str);
50static BOOLEAN DumpAsciiMaps(FILE *fd, idhdl h, idhdl rhdl);
51static si_link_extension slTypeInit(si_link_extension s, const char* type);
52
53/* ====================================================================== */
54si_link_extension si_link_root=NULL;
55
56BOOLEAN slInit(si_link l, char *istr)
57{
58  char *type = NULL, *mode = NULL, *name = NULL;
59  int i = 0, j;
60
61  // set mode and type
62  if (istr != NULL)
63  {
64    // find the first colon char in istr
65    i = 0;
66    while (istr[i] != ':' && istr[i] != '\0') i++;
67    if (istr[i] == ':')
68    {
69      // if found, set type
70      if (i > 0)
71      {
72        istr[i] = '\0';
73        type = omStrDup(istr);
74        istr[i] = ':';
75      }
76      // and check for mode
77      j = ++i;
78      while (istr[j] != ' ' && istr[j] != '\0') j++;
79      if (j > i)
80      {
81        mode = omStrDup(&(istr[i]));
82        mode[j - i] = '\0';
83      }
84      // and for the name
85      while (istr[j] == ' '&& istr[j] != '\0') j++;
86      if (istr[j] != '\0') name = omStrDup(&(istr[j]));
87    }
88    else // no colon find -- string is entire name
89    {
90      j=0;
91      while (istr[j] == ' '&& istr[j] != '\0') j++;
92      if (istr[j] != '\0') name = omStrDup(&(istr[j]));
93    }
94  }
95
96  // set the link extension
97  if (type != NULL)
98  {
99    si_link_extension s = si_link_root;
100    si_link_extension prev = s;
101
102    while (strcmp(s->type, type) != 0)
103    {
104      if (s->next == NULL)
105      {
106        prev = s;
107        s = NULL;
108        break;
109      }
110      else
111      {
112        s = s->next;
113      }
114    }
115
116    if (s != NULL)
117      l->m = s;
118    else
119    {
120      l->m = slTypeInit(prev, type);
121    }
122    omFree(type);
123  }
124  else
125    l->m = si_link_root;
126
127  if (l->m == NULL) return TRUE;
128
129  l->name = (name != NULL ? name : omStrDup(""));
130  l->mode = (mode != NULL ? mode : omStrDup(""));
131  l->ref = 1;
132  return FALSE;
133}
134
135void slCleanUp(si_link l)
136{
137  (l->ref)--;
138  if (l->ref == 0)
139  {
140    if (SI_LINK_OPEN_P(l))
141    {
142      if (l->m->Kill != NULL) l->m->Kill(l);
143      else if (l->m->Close != NULL) l->m->Close(l);
144    }
145    omFree((ADDRESS)l->name);
146    omFree((ADDRESS)l->mode);
147    memset((void *) l, 0, sizeof(ip_link));
148  }
149}
150
151void slKill(si_link l)
152{
153  slCleanUp(l);
154  if (l->ref == 0)
155    omFreeBin((ADDRESS)l,  ip_link_bin);
156}
157
158const char* slStatus(si_link l, const char *request)
159{
160  if (l == NULL) return "empty link";
161  else if (l->m == NULL) return "unknown link type";
162  else if (strcmp(request, "type") == 0) return l->m->type;
163  else if (strcmp(request, "mode") == 0) return l->mode;
164  else if (strcmp(request, "name") == 0) return l->name;
165  else if (strcmp(request, "exists") ==0)
166  {
167    struct stat buf;
168    if (lstat(l->name,&buf)==0) return "yes";
169    else return "no";
170  }
171  else if (strcmp(request, "open") == 0)
172  {
173    if (SI_LINK_OPEN_P(l)) return "yes";
174    else return "no";
175  }
176  else if (strcmp(request, "openread") == 0)
177  {
178    if (SI_LINK_R_OPEN_P(l)) return "yes";
179    else return "no";
180  }
181  else if (strcmp(request, "openwrite") == 0)
182  {
183    if (SI_LINK_W_OPEN_P(l)) return "yes";
184    else return "no";
185  }
186  else if (l->m->Status == NULL) return "unknown status request";
187  else return l->m->Status(l, request);
188}
189
190//--------------------------------------------------------------------------
191BOOLEAN slOpen(si_link l, short flag)
192{
193  BOOLEAN res;
194
195  if (l->m == NULL) slInit(l, ((char*)""));
196
197  if (SI_LINK_OPEN_P(l))
198  {
199    Warn("open: link of type: %s, mode: %s, name: %s is already open",
200         l->m->type, l->mode, l->name);
201    return FALSE;
202  }
203  else if (l->m->Open != NULL)
204    res = l->m->Open(l, flag);
205  else
206    res = TRUE;
207
208  if (res)
209    Werror("open: Error for link of type: %s, mode: %s, name: %s",
210           l->m->type, l->mode, l->name);
211  return res;
212}
213
214BOOLEAN slClose(si_link l)
215{
216  BOOLEAN res;
217
218  if(! SI_LINK_OPEN_P(l))
219    return FALSE;
220  else if (l->m->Close != NULL)
221    res = l->m->Close(l);
222  else
223    res = TRUE;
224
225  if (res)
226    Werror("close: Error for link of type: %s, mode: %s, name: %s",
227           l->m->type, l->mode, l->name);
228  return res;
229}
230
231leftv slRead(si_link l, leftv a)
232{
233  char *mode;
234  leftv v = NULL;
235  if( ! SI_LINK_R_OPEN_P(l)) // open r ?
236  {
237#ifdef HAVE_DBM
238#ifdef USE_GDBM
239    if (! SI_LINK_CLOSE_P(l))
240      {
241        if (slClose(l)) return NULL;
242      }
243#endif
244#endif
245    if (slOpen(l, SI_LINK_READ)) return NULL;
246  }
247
248  if (SI_LINK_R_OPEN_P(l))
249  { // open r
250    if (a==NULL)
251    {
252      if (l->m->Read != NULL) v = l->m->Read(l);
253    }
254    else
255    {
256      if (l->m->Read2 != NULL) v = l->m->Read2(l,a);
257    }
258  }
259  else
260  {
261    Werror("read: Error to open link of type %s, mode: %s, name: %s for reading",
262           l->m->type, l->mode, l->name);
263    return NULL;
264  }
265
266  // here comes the eval:
267  if (v != NULL)
268  {
269    if (v->Eval() && !errorreported)
270      WerrorS("eval: failed");
271  }
272  else
273    Werror("read: Error for link of type %s, mode: %s, name: %s",
274           l->m->type, l->mode, l->name);
275  return v;
276}
277
278BOOLEAN slWrite(si_link l, leftv v)
279{
280  BOOLEAN res;
281
282  if(! SI_LINK_W_OPEN_P(l)) // open w ?
283  {
284#ifdef HAVE_DBM
285#ifdef USE_GDBM
286    if (! SI_LINK_CLOSE_P(l))
287      {
288        if (slClose(l)) return TRUE;
289      }
290#endif
291#endif
292    if (slOpen(l, SI_LINK_WRITE)) return TRUE;
293  }
294
295  if (SI_LINK_W_OPEN_P(l))
296  { // now open w
297    if (l->m->Write != NULL)
298      res = l->m->Write(l,v);
299    else
300      res = TRUE;
301
302    if (res)
303      Werror("write: Error for link of type %s, mode: %s, name: %s",
304             l->m->type, l->mode, l->name);
305    return res;
306  }
307  else
308  {
309    Werror("write: Error to open link of type %s, mode: %s, name: %s for writing",
310           l->m->type, l->mode, l->name);
311    return TRUE;
312  }
313}
314
315BOOLEAN slDump(si_link l)
316{
317  BOOLEAN res;
318
319  if(! SI_LINK_W_OPEN_P(l)) // open w ?
320  {
321    if (slOpen(l, SI_LINK_WRITE)) return TRUE;
322  }
323
324  if(SI_LINK_W_OPEN_P(l))
325  { // now open w
326    if (l->m->Dump != NULL)
327      res = l->m->Dump(l);
328    else
329      res = TRUE;
330
331    if (res)
332      Werror("dump: Error for link of type %s, mode: %s, name: %s",
333             l->m->type, l->mode, l->name);
334    return res;
335  }
336  else
337  {
338    Werror("dump: Error to open link of type %s, mode: %s, name: %s for writing",
339           l->m->type, l->mode, l->name);
340    return TRUE;
341  }
342}
343
344BOOLEAN slGetDump(si_link l)
345{
346  BOOLEAN res;
347
348  if(! SI_LINK_R_OPEN_P(l)) // open r ?
349  {
350    if (slOpen(l, SI_LINK_READ)) return TRUE;
351  }
352
353  if(SI_LINK_R_OPEN_P(l))
354  { // now open r
355    if (l->m->GetDump != NULL)
356      res = l->m->GetDump(l);
357    else
358      res = TRUE;
359
360    if (res)
361      Werror("getdump: Error for link of type %s, mode: %s, name: %s",
362             l->m->type, l->mode, l->name);
363    //res|=slClose(l);
364    return res;
365  }
366  else
367  {
368    Werror("dump: Error open link of type %s, mode: %s, name: %s for reading",
369           l->m->type, l->mode, l->name);
370    return TRUE;
371  }
372}
373
374
375/* =============== ASCII ============================================= */
376BOOLEAN slOpenAscii(si_link l, short flag)
377{
378  const char *mode;
379  if (flag & SI_LINK_OPEN)
380  {
381    if (l->mode[0] != '\0' && (strcmp(l->mode, "r") == 0))
382      flag = SI_LINK_READ;
383    else flag = SI_LINK_WRITE;
384  }
385
386  if (flag == SI_LINK_READ) mode = "r";
387  else if (strcmp(l->mode, "w") == 0) mode = "w";
388  else mode = "a";
389
390
391  if (l->name[0] == '\0')
392  {
393    // stdin or stdout
394    if (flag == SI_LINK_READ)
395    {
396      l->data = (void *) stdin;
397      mode = "r";
398    }
399    else
400    {
401      l->data = (void *) stdout;
402      mode = "a";
403    }
404  }
405  else
406  {
407    // normal ascii link to a file
408    FILE *outfile;
409    char *filename=l->name;
410
411    if(filename[0]=='>')
412    {
413      if (filename[1]=='>')
414      {
415        filename+=2;
416        mode = "a";
417      }
418      else
419      {
420        filename++;
421        mode="w";
422      }
423    }
424    outfile=myfopen(filename,mode);
425    if (outfile!=NULL)
426      l->data = (void *) outfile;
427    else
428      return TRUE;
429  }
430
431  omFree(l->mode);
432  l->mode = omStrDup(mode);
433  SI_LINK_SET_OPEN_P(l, flag);
434  return FALSE;
435}
436
437BOOLEAN slCloseAscii(si_link l)
438{
439  SI_LINK_SET_CLOSE_P(l);
440  if (l->name[0] != '\0')
441  {
442    return (fclose((FILE *)l->data)!=0);
443  }
444  return FALSE;
445}
446
447leftv slReadAscii2(si_link l, leftv pr)
448{
449  FILE * fp=(FILE *)l->data;
450  char * buf=NULL;
451  if (fp!=NULL && l->name[0] != '\0')
452  {
453    fseek(fp,0L,SEEK_END);
454    long len=ftell(fp);
455    fseek(fp,0L,SEEK_SET);
456    buf=(char *)omAlloc((int)len+1);
457    if (BVERBOSE(V_READING))
458      Print("//Reading %ld chars\n",len);
459    myfread( buf, len, 1, fp);
460    buf[len]='\0';
461  }
462  else
463  {
464    if (pr->Typ()==STRING_CMD)
465    {
466      buf=(char *)omAlloc(80);
467      fe_fgets_stdin((char *)pr->Data(),buf,80);
468    }
469    else
470    {
471      WerrorS("read(<link>,<string>) expected");
472      buf=omStrDup("");
473    }
474  }
475  leftv v=(leftv)omAlloc0Bin(sleftv_bin);
476  v->rtyp=STRING_CMD;
477  v->data=buf;
478  return v;
479}
480
481leftv slReadAscii(si_link l)
482{
483  sleftv tmp;
484  memset(&tmp,0,sizeof(sleftv));
485  tmp.rtyp=STRING_CMD;
486  tmp.data=(void*) "? ";
487  return slReadAscii2(l,&tmp);
488}
489
490BOOLEAN slWriteAscii(si_link l, leftv v)
491{
492  FILE *outfile=(FILE *)l->data;
493  BOOLEAN err=FALSE;
494  char *s;
495  while (v!=NULL)
496  {
497    s = v->String();
498    // free v ??
499    if (s!=NULL)
500    {
501      fprintf(outfile,"%s\n",s);
502      omFree((ADDRESS)s);
503    }
504    else
505    {
506      Werror("cannot convert to string");
507      err=TRUE;
508    }
509    v = v->next;
510  }
511  fflush(outfile);
512  return err;
513}
514
515const char* slStatusAscii(si_link l, const char* request)
516{
517  if (strcmp(request, "read") == 0)
518  {
519    if (SI_LINK_R_OPEN_P(l)) return "ready";
520    else return "not ready";
521  }
522  else if (strcmp(request, "write") == 0)
523  {
524    if (SI_LINK_W_OPEN_P(l)) return "ready";
525    else return "not ready";
526  }
527  else return "unknown status request";
528}
529
530/*------------------ Dumping in Ascii format -----------------------*/
531
532BOOLEAN slDumpAscii(si_link l)
533{
534  FILE *fd = (FILE *) l->data;
535  idhdl h = IDROOT, rh = currRingHdl;
536  BOOLEAN status = DumpAscii(fd, h);
537
538  if (! status ) status = DumpAsciiMaps(fd, h, NULL);
539
540  if (currRingHdl != rh) rSetHdl(rh);
541  fprintf(fd, "option(set, intvec(%d, %d));\n", test, verbose);
542  fprintf(fd, "RETURN();\n");
543  fflush(fd);
544
545  return status;
546}
547
548// we do that recursively, to dump ids in the the order in which they
549// were actually defined
550static BOOLEAN DumpAscii(FILE *fd, idhdl h)
551{
552  if (h == NULL) return FALSE;
553
554  if (DumpAscii(fd, IDNEXT(h))) return TRUE;
555
556  // need to set the ring before writing it, otherwise we get in
557  // trouble with minpoly
558  if (IDTYP(h) == RING_CMD || IDTYP(h) == QRING_CMD)
559    rSetHdl(h);
560
561  if (DumpAsciiIdhdl(fd, h)) return TRUE;
562
563  if (IDTYP(h) == RING_CMD || IDTYP(h) == QRING_CMD)
564    return DumpAscii(fd, IDRING(h)->idroot);
565  else
566    return FALSE;
567}
568
569static BOOLEAN DumpAsciiMaps(FILE *fd, idhdl h, idhdl rhdl)
570{
571  if (h == NULL) return FALSE;
572  if (DumpAsciiMaps(fd, IDNEXT(h), rhdl)) return TRUE;
573
574  if (IDTYP(h) == RING_CMD || IDTYP(h) == QRING_CMD)
575    return DumpAsciiMaps(fd, IDRING(h)->idroot, h);
576  else if (IDTYP(h) == MAP_CMD)
577  {
578    char *rhs;
579    rSetHdl(rhdl);
580    rhs = h->String();
581
582    if (fprintf(fd, "setring %s;\n", IDID(rhdl)) == EOF) return TRUE;
583    if (fprintf(fd, "%s %s = %s, %s;\n", Tok2Cmdname(MAP_CMD), IDID(h),
584                IDMAP(h)->preimage, rhs) == EOF)
585    {
586      omFree(rhs);
587      return TRUE;
588    }
589    else
590    {
591      omFree(rhs);
592      return FALSE;
593    }
594  }
595  else return FALSE;
596}
597
598static BOOLEAN DumpAsciiIdhdl(FILE *fd, idhdl h)
599{
600  const char *type_str = GetIdString(h);
601  int type_id = IDTYP(h);
602
603  if ((type_id == PACKAGE_CMD) &&(strcmp(IDID(h), "Top") == 0))
604    return FALSE;
605
606  // we do not throw an error if a wrong type was attempted to be dumped
607  if (type_str == NULL)
608    return FALSE;
609
610  // handle qrings separately
611  if (type_id == QRING_CMD)
612    return DumpQring(fd, h, type_str);
613
614  // put type and name
615  if (fprintf(fd, "%s %s", type_str, IDID(h)) == EOF)
616    return TRUE;
617  // for matricies, append the dimension
618  if (type_id == MATRIX_CMD)
619  {
620    ideal id = IDIDEAL(h);
621    if (fprintf(fd, "[%d][%d]", id->nrows, id->ncols)== EOF) return TRUE;
622  }
623  else if (type_id == INTMAT_CMD)
624  {
625    if (fprintf(fd, "[%d][%d]", IDINTVEC(h)->rows(), IDINTVEC(h)->cols())
626        == EOF) return TRUE;
627  }
628
629  if (type_id == PACKAGE_CMD)
630  {
631    return (fprintf(fd, ";\n") == EOF);
632  }
633
634  // write the equal sign
635  if (fprintf(fd, " = ") == EOF) return TRUE;
636
637  // and the right hand side
638  if (DumpRhs(fd, h) == EOF) return TRUE;
639
640  // semicolon und tschuess
641  if (fprintf(fd, ";\n") == EOF) return TRUE;
642
643  return FALSE;
644}
645
646static const char* GetIdString(idhdl h)
647{
648  int type = IDTYP(h);
649
650  switch(type)
651  {
652      case LIST_CMD:
653      {
654        lists l = IDLIST(h);
655        int i, nl = l->nr + 1;
656        char *name;
657
658        for (i=0; i<nl; i++)
659          if (GetIdString((idhdl) &(l->m[i])) == NULL) return NULL;
660      }
661      case PACKAGE_CMD:
662      case INT_CMD:
663      case INTVEC_CMD:
664      case INTMAT_CMD:
665      case STRING_CMD:
666      case RING_CMD:
667      case QRING_CMD:
668      case PROC_CMD:
669      case NUMBER_CMD:
670      case POLY_CMD:
671      case IDEAL_CMD:
672      case VECTOR_CMD:
673      case MODUL_CMD:
674      case MATRIX_CMD:
675        return Tok2Cmdname(type);
676
677      case MAP_CMD:
678      case LINK_CMD:
679        return NULL;
680
681      default:
682       Warn("Error dump data of type %s", Tok2Cmdname(IDTYP(h)));
683       return NULL;
684  }
685}
686
687static BOOLEAN DumpQring(FILE *fd, idhdl h, const char *type_str)
688{
689  char *ring_str = h->String();
690  if (fprintf(fd, "%s temp_ring = %s;\n", Tok2Cmdname(RING_CMD), ring_str)
691              == EOF) return TRUE;
692  if (fprintf(fd, "%s temp_ideal = %s;\n", Tok2Cmdname(IDEAL_CMD),
693              iiStringMatrix((matrix) IDRING(h)->qideal, 1))
694      == EOF) return TRUE;
695  if (fprintf(fd, "attrib(temp_ideal, \"isSB\", 1);\n") == EOF) return TRUE;
696  if (fprintf(fd, "%s %s = temp_ideal;\n", type_str, IDID(h)) == EOF)
697    return TRUE;
698  if (fprintf(fd, "kill temp_ring;\n") == EOF) return TRUE;
699  else
700  {
701    omFree(ring_str);
702    return FALSE;
703  }
704}
705
706
707static int DumpRhs(FILE *fd, idhdl h)
708{
709  int type_id = IDTYP(h);
710
711  if (type_id == LIST_CMD)
712  {
713    lists l = IDLIST(h);
714    int i, nl = l->nr;
715
716    fprintf(fd, "list(");
717
718    for (i=0; i<nl; i++)
719    {
720      if (DumpRhs(fd, (idhdl) &(l->m[i])) == EOF) return EOF;
721      fprintf(fd, ",");
722    }
723    if (nl > 0)
724    {
725      if (DumpRhs(fd, (idhdl) &(l->m[nl])) == EOF) return EOF;
726    }
727    fprintf(fd, ")");
728  }
729  else  if (type_id == STRING_CMD)
730  {
731    char *pstr = IDSTRING(h), c;
732    fputc('"', fd);
733    while (*pstr != '\0')
734    {
735      if (*pstr == '"' || *pstr == '\\')  fputc('\\', fd);
736      fputc(*pstr, fd);
737      pstr++;
738    }
739    fputc('"', fd);
740  }
741  else  if (type_id == PROC_CMD)
742  {
743    procinfov pi = IDPROC(h);
744    if (pi->language == LANG_SINGULAR) {
745      if( pi->data.s.body==NULL) iiGetLibProcBuffer(pi);
746      char *pstr = pi->data.s.body, c;
747      fputc('"', fd);
748      while (*pstr != '\0') {
749        if (*pstr == '"' || *pstr == '\\') fputc('\\', fd);
750        fputc(*pstr, fd);
751        pstr++;
752      }
753      fputc('"', fd);
754    } else fputs("(null)", fd);
755  }
756  else
757  {
758    char *rhs = h->String();
759
760    if (rhs == NULL) return EOF;
761
762    if (type_id == INTVEC_CMD) fprintf(fd, "intvec(");
763
764    if (fprintf(fd, "%s", rhs) == EOF) return EOF;
765    omFree(rhs);
766
767    if ((type_id == RING_CMD || type_id == QRING_CMD) &&
768        IDRING(h)->minpoly != NULL)
769    {
770      StringSetS("");
771      nWrite(IDRING(h)->minpoly);
772      rhs = StringAppendS("");
773      if (fprintf(fd, "; minpoly = %s", rhs) == EOF) return EOF;
774    }
775    else if (type_id == INTVEC_CMD) fprintf(fd, ")");
776  }
777  return 1;
778}
779
780BOOLEAN slGetDumpAscii(si_link l)
781{
782  if (l->name[0] == '\0')
783  {
784    Werror("getdump: Can not get dump from stdin");
785    return TRUE;
786  }
787  else
788  {
789    BOOLEAN status = newFile(l->name);
790    if (status)
791      return TRUE;
792
793    int old_echo=si_echo;
794    si_echo=0;
795
796    status=yyparse();
797
798    si_echo=old_echo;
799
800    if (status)
801      return TRUE;
802    else
803    {
804      // lets reset the file pointer to the end to reflect that
805      // we are finished with reading
806      FILE *f = (FILE *) l->data;
807      fseek(f, 0L, SEEK_END);
808      return FALSE;
809    }
810  }
811}
812
813
814/*------------Initialization at Start-up time------------------------*/
815
816#include <Singular/slInit.h>
817
818static si_link_extension slTypeInit(si_link_extension s, const char* type)
819{
820  assume(s != NULL);
821  s->next = NULL;
822  si_link_extension ns = (si_link_extension)omAlloc0Bin(s_si_link_extension_bin);
823
824  if (0) 0;
825#ifdef HAVE_MPSR
826  else if (strcmp(type, "MPfile") == 0)
827    s->next = slInitMPFileExtension(ns);
828  else if (strcmp(type, "MPtcp") == 0)
829    s->next = slInitMPTcpExtension(ns);
830#endif
831#ifdef HAVE_DBM
832  else if (strcmp(type, "DBM") == 0)
833    s->next = slInitDBMExtension(ns);
834#endif
835#if 1
836  else if (strcmp(type, "ssi") == 0)
837    s->next = slInitSsiExtension(ns);
838#endif
839#if 1
840  else if (strcmp(type, "|") == 0)
841    s->next = slInitPipeExtension(ns);
842#endif
843  else
844  {
845    Warn("Found unknown link type: %s", type);
846    Warn("Use default link type: %s", si_link_root->type);
847    omFreeBin(ns, s_si_link_extension_bin);
848    return si_link_root;
849  }
850
851  if (s->next == NULL)
852  {
853    Werror("Can not initialize link type %s", type);
854    omFreeBin(ns, s_si_link_extension_bin);
855    return NULL;
856  }
857  return s->next;
858}
859
860void slStandardInit()
861{
862  si_link_extension s;
863  si_link_root=(si_link_extension)omAlloc0Bin(s_si_link_extension_bin);
864  si_link_root->Open=slOpenAscii;
865  si_link_root->Close=slCloseAscii;
866  si_link_root->Kill=slCloseAscii;
867  si_link_root->Read=slReadAscii;
868  si_link_root->Read2=slReadAscii2;
869  si_link_root->Write=slWriteAscii;
870  si_link_root->Dump=slDumpAscii;
871  si_link_root->GetDump=slGetDumpAscii;
872  si_link_root->Status=slStatusAscii;
873  si_link_root->type="ASCII";
874  s = si_link_root;
875  s->next = NULL;
876}
Note: See TracBrowser for help on using the repository browser.