source: git/Singular/silink.h @ f82470

spielwiese
Last change on this file since f82470 was f82470, checked in by Olaf Bachmann <obachman@…>, 24 years ago
* string(LINK_CMD); git-svn-id: file:///usr/local/Singular/svn/trunk@2981 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.8 KB
Line 
1#ifndef SILINK_H
2#define SILINK_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id: silink.h,v 1.11 1999-04-15 09:57:05 obachman Exp $ */
7/*
8* ABSTRACT: general interface to links
9*/
10
11#include "structs.h"
12
13// extension links:
14typedef BOOLEAN    (*slOpenProc)(si_link l, short flag);
15typedef BOOLEAN    (*slWriteProc)(si_link l, leftv lv);
16typedef BOOLEAN    (*slCloseProc)(si_link l);
17typedef BOOLEAN    (*slKillProc)(si_link l);
18typedef leftv      (*slReadProc)(si_link l);
19typedef leftv      (*slRead2Proc)(si_link l, leftv a);
20typedef BOOLEAN    (*slDumpProc)(si_link l);
21typedef BOOLEAN    (*slGetDumpProc)(si_link l);
22typedef char*      (*slStatusProc)(si_link l, char *request);
23
24struct s_si_link_extension
25{
26  si_link_extension next;
27  slOpenProc       Open;
28  slCloseProc      Close;
29  slKillProc       Kill;
30  slReadProc       Read;
31  slRead2Proc      Read2;
32  slWriteProc      Write;
33  slDumpProc       Dump;
34  slGetDumpProc    GetDump;
35  slStatusProc     Status;
36  char             *type;
37};
38
39struct sip_link
40{
41  si_link_extension m; // methods
42  char *mode;
43  char *name;          // used for filename and/or further specs
44  void *data;          // the link itself
45  BITSET flags;        // 0=close open = 1: read = 2: write = 3
46  short ref;           // reference counter
47};
48
49BOOLEAN slExtend(si_link_extension s);
50
51// flags:
52#define SI_LINK_CLOSE   0
53#define SI_LINK_OPEN    1
54#define SI_LINK_READ    2
55#define SI_LINK_WRITE   4
56
57// tests:
58#define SI_LINK_CLOSE_P(l)  (!(l)->flags)
59#define SI_LINK_OPEN_P(l)   ((l)->flags & SI_LINK_OPEN)
60#define SI_LINK_W_OPEN_P(l) ((l)->flags &  SI_LINK_WRITE)
61#define SI_LINK_R_OPEN_P(l) ((l)->flags &  SI_LINK_READ)
62#define SI_LINK_RW_OPEN_P(l) (SI_LINK_W_OPEN_P(l) && SI_LINK_R_OPEN_P(l))
63
64#define SI_LINK_SET_CLOSE_P(l)  ((l)->flags = SI_LINK_CLOSE)
65#define SI_LINK_SET_OPEN_P(l, flag)   ((l)->flags = (l)->flags |SI_LINK_OPEN |flag)
66#define SI_LINK_SET_W_OPEN_P(l) ((l)->flags = (l)->flags | SI_LINK_OPEN | SI_LINK_WRITE)
67#define SI_LINK_SET_R_OPEN_P(l) ((l)->flags = (l)->flags | SI_LINK_OPEN | SI_LINK_READ)
68#define SI_LINK_SET_RW_OPEN_P(l) ((l)->flags = (l)->flags | SI_LINK_OPEN | SI_LINK_READ | SI_LINK_WRITE)
69
70BOOLEAN slOpen(si_link l, short flag);
71BOOLEAN slClose(si_link l);
72leftv   slRead(si_link l,leftv a=NULL);
73BOOLEAN slWrite(si_link l, leftv v);
74BOOLEAN slDump(si_link l);
75BOOLEAN slGetDump(si_link l);
76char* slStatus(si_link l, char *request);
77char* slStatusAscii(si_link l, char* request);
78BOOLEAN slInit(si_link l, char *str);
79void slKill(si_link l);
80void slCleanUp(si_link l);
81void slStandardInit();
82inline si_link slCopy(si_link l)
83{
84  l->ref++;
85  return l;
86}
87inline char* slString(si_link l)
88{
89  if (l->name != NULL)
90  {
91    return mstrdup(l->name);
92  }
93  else
94  {
95    return mstrdup("");
96  }
97}
98
99#endif // SILINK_H
Note: See TracBrowser for help on using the repository browser.