Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libcs/css.h
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1990-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#pragma prototyped
21
22
/*
23
* Glenn Fowler
24
* AT&T Research
25
*
26
* connect stream server interface definitions
27
*/
28
29
#ifndef _CSS_H
30
#define _CSS_H
31
32
#define CSS_VERSION 19970717L
33
34
#ifndef CS_INTERFACE
35
#define CS_INTERFACE 2
36
#endif
37
38
#define CSS_AUTHENTICATE (1<<10) /* authenticate connections */
39
#define CSS_DAEMON (1<<0) /* become daemon proc */
40
#define CSS_LOG (1<<1) /* stderr to daemon log file */
41
#define CSS_PRESERVE (1<<2) /* preserve daemon fd's */
42
#define CSS_RECURSIVE (1<<3) /* allow recursive csspoll() */
43
44
#define CSS_CLOSE (1<<4) /* server close exception */
45
#define CSS_DORMANT (1<<5) /* dormant timeout exception */
46
#define CSS_ERROR (1<<6) /* error exception */
47
#define CSS_INTERRUPT (1<<7) /* interrupt exception */
48
#define CSS_TIMEOUT (1<<8) /* timeout exception */
49
#define CSS_WAKEUP (1<<9) /* wakeup exception */
50
51
#define CS_POLL_DUP 1
52
#define CS_POLL_MOVE 2
53
#define CS_POLL_PRI 3
54
55
#define CS_POLL_ARG 0x80000000
56
#define CS_POLL_SHIFT 16
57
#define CS_POLL_MASK 0x00007fff
58
59
#define CS_POLL_CMD(f,c)(CS_POLL_ARG|(c)|(((long)(f)&CS_POLL_MASK)<<CS_POLL_SHIFT))
60
61
#include <cs.h>
62
63
struct Css_s;
64
struct Cssdisc_s;
65
struct Cssfd_s;
66
67
typedef struct Css_s Css_t;
68
typedef struct Cssdisc_s Cssdisc_t;
69
typedef struct Cssfd_s Cssfd_t;
70
71
struct Cssdisc_s /* user discipline */
72
{
73
unsigned long version; /* CSS_VERSION */
74
unsigned long flags; /* CSS_* flags */
75
unsigned long timeout; /* timeout in ms, 0 if none */
76
unsigned long wakeup; /* wakeup in ms, 0 if none */
77
Error_f errorf; /* error message handler */
78
int (*acceptf)(Css_t*, Cssfd_t*, Csid_t*, char**, Cssdisc_t*);
79
/* accept new connection/fd */
80
int (*actionf)(Css_t*, Cssfd_t*, Cssdisc_t*);
81
/* fd state change action */
82
int (*exceptf)(Css_t*, unsigned long, unsigned long, Cssdisc_t*);
83
/* poll exception action */
84
};
85
86
struct Cssfd_s /* fd info */
87
{
88
int fd; /* fd */
89
int status; /* action status */
90
int (*actionf)(Css_t*, Cssfd_t*, Cssdisc_t*);
91
/* css.actionf by default */
92
void* data; /* user data, 0 by default */
93
94
#ifdef _CSS_FD_PRIVATE_
95
_CSS_FD_PRIVATE_
96
#endif
97
98
};
99
100
struct Css_s /* connect stream server state */
101
{
102
char* id; /* library identifier */
103
char* service; /* service name */
104
char* path; /* service path */
105
int fd; /* service fd */
106
int fdmax; /* max # serviceable fd's */
107
int perm; /* service permissions */
108
char mount[PATH_MAX];/* service mount path */
109
char* control; /* CS_MNT_* in css.mount */
110
Cs_t* state; /* from csalloc() */
111
112
#ifdef _CSS_PRIVATE_
113
_CSS_PRIVATE_
114
#endif
115
116
};
117
118
#if _BLD_cs && defined(__EXPORT__)
119
#define extern __EXPORT__
120
#endif
121
122
extern Css_t* cssopen(const char*, Cssdisc_t*);
123
extern Cssfd_t* cssfd(Css_t*, int, unsigned long);
124
extern Cssfd_t* csspoll(unsigned long, unsigned long);
125
extern int cssclose(Css_t*);
126
127
#undef extern
128
129
#endif
130
131