~ubuntu-branches/ubuntu/trusty/maloc/trusty-proposed

« back to all changes in this revision

Viewing changes to src/vsys/maloc/vio.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2006-06-29 15:21:06 UTC
  • Revision ID: james.westby@ubuntu.com-20060629152106-kyqdw6qlc3vmqum3
Tags: upstream-0.2
ImportĀ upstreamĀ versionĀ 0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ***************************************************************************
 
3
 * MALOC = < Minimal Abstraction Layer for Object-oriented C >
 
4
 * Copyright (C) 1994--2000  Michael Holst
 
5
 * 
 
6
 * This program is free software; you can redistribute it and/or modify it
 
7
 * under the terms of the GNU General Public License as published by the
 
8
 * Free Software Foundation; either version 2 of the License, or (at your
 
9
 * option) any later version.
 
10
 * 
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
14
 * See the GNU General Public License for more details.
 
15
 * 
 
16
 * You should have received a copy of the GNU General Public License along
 
17
 * with this program; if not, write to the Free Software Foundation, Inc.,
 
18
 * 675 Mass Ave, Cambridge, MA 02139, USA.
 
19
 * 
 
20
 * rcsid="$Id: vio.h,v 1.18 2004/02/18 01:10:56 mholst Exp $"
 
21
 * ***************************************************************************
 
22
 */
 
23
 
 
24
/*
 
25
 * ***************************************************************************
 
26
 * File:     vio.h    < vio.c >
 
27
 *
 
28
 * Purpose:  Class Vio: virtual <SDIO/FILE/BUFF/UNIX/INET> I/O layer.
 
29
 *
 
30
 * Author:   Michael Holst
 
31
 * ***************************************************************************
 
32
 */
 
33
 
 
34
#ifndef _VIO_H_
 
35
#define _VIO_H_
 
36
 
 
37
#include <maloc/maloc_base.h>
 
38
 
 
39
#include <maloc/vnm.h>
 
40
 
 
41
/*
 
42
 * ***************************************************************************
 
43
 * Class Vio: Parameters and datatypes
 
44
 * ***************************************************************************
 
45
 */
 
46
 
 
47
#define VPORTNUMBER 14916   /* our portbase;  5000 < VPORTNUMBER < 49152 */
 
48
#define VIO_MAXBUF 10       /* number of internal buffers (BUFF datatype) */
 
49
 
 
50
typedef enum VIOtype {
 
51
    VIO_NO_TYPE,
 
52
    VIO_SDIO,
 
53
    VIO_BUFF,
 
54
    VIO_FILE,
 
55
    VIO_UNIX,
 
56
    VIO_INET
 
57
} VIOtype;
 
58
 
 
59
typedef enum VIOfrmt {
 
60
    VIO_NO_FRMT,
 
61
    VIO_XDR,
 
62
    VIO_ASC
 
63
} VIOfrmt;
 
64
 
 
65
typedef enum VIOrwkey {
 
66
    VIO_NO_RW,
 
67
    VIO_R,
 
68
    VIO_W
 
69
} VIOrwkey;
 
70
 
 
71
/*
 
72
 * ***************************************************************************
 
73
 * Class Vio: Definition
 
74
 * ***************************************************************************
 
75
 */
 
76
 
 
77
typedef struct Vio {
 
78
 
 
79
    VIOtype type;       /* file (or device) type                            */
 
80
                        /*   VIO_NO_TYPE = not initialized                  */
 
81
                        /*   VIO_SDIO    = standard I/O                     */
 
82
                        /*   VIO_FILE    = file I/O                         */
 
83
                        /*   VIO_BUFF    = buffer I/O                       */
 
84
                        /*   VIO_UNIX    = UNIX (domain) socket I/O         */
 
85
                        /*   VIO_INET    = INET (network) socket I/O        */
 
86
 
 
87
    VIOfrmt frmt;       /* data format                                      */
 
88
                        /*   VIO_NO_FRMT = not initialized                  */
 
89
                        /*   VIO_ASC     = ASCII (FILE,BUFF,UNIX,INET)      */
 
90
                        /*   VIO_XDR     = BINARY (FILE,BUFF,UNIX,INET)     */
 
91
 
 
92
    VIOrwkey rwkey;     /* r/w key                                          */
 
93
                        /*   VIO_NO_R = not initialized                     */
 
94
                        /*   VIO_R    = read (FILE,BUFF,UNIX,INET)          */
 
95
                        /*   VIO_W    = write (FILE,BUFF,UNIX,INET)         */
 
96
 
 
97
    char file[80];      /* file or device name (FILE,BUFF,UNIX,INET)        */
 
98
    char lhost[80];     /* local hostname (me) (UNIX,INET)                  */
 
99
    char rhost[80];     /* remote hostname (the other guy) (UNIX,INET)      */
 
100
 
 
101
    int error;          /* note if any error has occurred on this vio device*/
 
102
    int dirty;          /* dirty read bit -- have we read file yet (FILE)   */
 
103
 
 
104
    FILE *fp;           /* file pointer (SDIO,FILE)                         */
 
105
    int so;             /* primary unix domain or inet socket (UNIX,INET)   */
 
106
    int soc;            /* subsocket created for socket reading (UNIX,INET) */
 
107
    void *name;         /* &sockaddr_un or &sockaddr_in (UNIX,INET)         */
 
108
    void *axdr;         /* ASC/XDR structure pointer (ASC,XDR)              */
 
109
 
 
110
    char whiteChars[VMAX_ARGNUM]; /* white space character set (ASC)        */
 
111
    char commChars[VMAX_ARGNUM];  /* comment character set (ASC,XDR)        */
 
112
 
 
113
    char ioBuffer[VMAX_BUFSIZE];  /* I/O buffer (ASC,XDR)                   */
 
114
    int ioBufferLen;              /* I/O buffer length (ASC,XDR)            */
 
115
 
 
116
    char putBuffer[VMAX_BUFSIZE]; /* final write buffer (ASC,XDR)           */
 
117
    int putBufferLen;             /* final write buffer length (ASC,XDR)    */
 
118
 
 
119
    char *VIObuffer;    /* (BUFF) */
 
120
    int VIObufferLen;   /* (BUFF) */
 
121
    int VIObufferPtr;   /* (BUFF) */
 
122
 
 
123
} Vio;
 
124
 
 
125
/*
 
126
 * ***************************************************************************
 
127
 * Class Vio: Inlineable methods (vio.c)
 
128
 * ***************************************************************************
 
129
 */
 
130
 
 
131
#if !defined(VINLINE_MALOC)
 
132
#else /* if defined(VINLINE_MALOC) */
 
133
#endif /* if !defined(VINLINE_MALOC) */
 
134
 
 
135
/*
 
136
 * ***************************************************************************
 
137
 * Class Vio: Non-Inlineable methods (vio.c)
 
138
 * ***************************************************************************
 
139
 */
 
140
 
 
141
VEXTERNC void Vio_start(void);
 
142
VEXTERNC void Vio_stop(void);
 
143
 
 
144
VEXTERNC Vio* Vio_ctor(const char *socktype, const char *datafrmt, 
 
145
    const char *hostname, const char *filename, const char *rwkey);
 
146
VEXTERNC int Vio_ctor2(Vio *thee, const char *socktype, const char *datafrmt, 
 
147
    const char *hostname, const char *filename, const char *rwkey);
 
148
 
 
149
VEXTERNC void Vio_dtor(Vio **thee);
 
150
VEXTERNC void Vio_dtor2(Vio *thee);
 
151
 
 
152
VEXTERNC Vio *Vio_socketOpen(char *key,
 
153
    const char *iodev, const char *iofmt,
 
154
    const char *iohost, const char *iofile);
 
155
VEXTERNC void Vio_socketClose(Vio **sock);
 
156
 
 
157
VEXTERNC void Vio_setWhiteChars(Vio *thee, char *whiteChars);
 
158
VEXTERNC void Vio_setCommChars(Vio *thee, char *commChars);
 
159
 
 
160
VEXTERNC int Vio_accept(Vio *thee, int nonblock);
 
161
VEXTERNC void Vio_acceptFree(Vio *thee);
 
162
 
 
163
VEXTERNC int Vio_connect(Vio *thee, int nonblock);
 
164
VEXTERNC void Vio_connectFree(Vio *thee);
 
165
 
 
166
VEXTERNC int Vio_scanf(Vio *thee, char *parms, ...);
 
167
VEXTERNC int Vio_printf(Vio *thee, char *parms, ...);
 
168
 
 
169
VEXTERNC int Vio_read(Vio *thee, char *buf, int bufsize);
 
170
VEXTERNC int Vio_write(Vio *thee, char *buf, int bufsize);
 
171
 
 
172
VEXTERNC int Vio_bufSize(Vio *thee);
 
173
VEXTERNC char* Vio_bufGive(Vio *thee);
 
174
VEXTERNC void Vio_bufTake(Vio *thee, char *buf, int bufsize);
 
175
 
 
176
#endif /* _VIO_H_ */
 
177