source: git/Singular/silink.cc @ a70441f

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