source: git/Singular/silink.cc @ cf42ab1

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