1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
/*
* SCCS: @(#)syncd_bs.c 1.7 (96/11/04)
*
* UniSoft Ltd., London, England
*
* (C) Copyright 1992 X/Open Company Limited
*
* All rights reserved. No part of this source code may be reproduced,
* stored in a retrieval system, or transmitted, in any form or by any
* means, electronic, mechanical, photocopying, recording or otherwise,
* except as stated in the end-user licence agreement, without the prior
* permission of the copyright owners.
*
* X/Open and the 'X' symbol are trademarks of X/Open Company Limited in
* the UK and other countries.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/************************************************************************
SCCS: @(#)syncd_bs.c 1.7 96/11/04 TETware release 3.3
NAME: syncd_bs.c
PRODUCT: TETware
AUTHOR: Andrew Dingwall, UniSoft Ltd.
DATE CREATED: April 1992
DESCRIPTION:
syncd-specific functions to convert DTET interprocess messages between
machine-independent and internal format
MODIFICATIONS:
Andrew Dingwall, UniSoft Ltd., October 1994
added support for tet_msync()
Aaron Plattner, April 2010
Fixed warnings when compiled with GCC's -Wall option.
************************************************************************/
#include <stdio.h>
#include <sys/types.h>
#include "dtmac.h"
#include "dtmsg.h"
#include "ptab.h"
#include "error.h"
#include "valmsg.h"
#include "dtetlib.h"
#include "server_bs.h"
#if TESTING
#include "avmsg.h"
#endif
static char reqerr[] = "unknown request code";
/*
** tet_ss_bs2md() - convert message data to internal format
**
** return length of internal-format message, or -ve error code on error
*/
int tet_ss_bs2md(from, pp)
char *from;
register struct ptab *pp;
{
register int request = pp->pt_savreq;
register int rc;
switch (request) {
case OP_USYNC:
case OP_ASYNC:
rc = tet_bs2synmsg(from, pp->ptm_len,
(struct valmsg **) &pp->ptm_data, &pp->pt_mdlen);
break;
case OP_SNSYS:
case OP_SNRM:
rc = tet_bs2valmsg(from, pp->ptm_len,
(struct valmsg **) &pp->ptm_data, &pp->pt_mdlen);
break;
#if TESTING
case OP_PRINT:
rc = tet_bs2avmsg(from, pp->ptm_len,
(struct avmsg **) &pp->ptm_data, &pp->pt_mdlen);
break;
#endif
default:
error(0, reqerr, tet_ptreqcode(request));
return(ER_REQ);
}
return(rc < 0 ? ER_ERR : rc);
}
/*
** tet_ss_md2bs() - convert message data to machine-independent format
**
** return length of machine-independent message
** or -ve error code on error
*/
int tet_ss_md2bs(pp, bp, lp, offs)
struct ptab *pp;
char **bp;
int *lp, offs;
{
register char *mp = pp->ptm_data;
register int request = pp->ptm_req;
register int len;
register int rc;
/* calculate outgoing data size */
switch (request) {
case OP_SNGET:
len = VM_VALMSGSZ(((struct valmsg *) mp)->vm_nvalue);
break;
case OP_ASYNC:
case OP_USYNC:
len = VM_SYNMSGSZ(((struct valmsg *) mp)->vm_nvalue,
VM_MSDLEN((struct valmsg *) mp));
break;
default:
error(0, reqerr, tet_ptreqcode(request));
return(ER_REQ);
}
/* make sure that the receiving area is big enough */
if (BUFCHK(bp, lp, len + offs) < 0)
return(ER_ERR);
/* copy the data to (*bp + offs) */
switch (request) {
case OP_SNGET:
rc = tet_valmsg2bs((struct valmsg *) mp, (*bp + offs));
break;
case OP_ASYNC:
case OP_USYNC:
rc = tet_synmsg2bs((struct valmsg *) mp, (*bp + offs));
break;
default:
error(0, reqerr, tet_ptreqcode(request));
return(ER_REQ);
}
return(rc < 0 ? ER_ERR : rc);
}
|