source: git/Singular/silink.cc @ da8702

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