File: switch_req.c

package info (click to toggle)
lfc-postgres 1.7.4.7-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 13,676 kB
  • ctags: 10,779
  • sloc: ansic: 146,136; sh: 13,176; perl: 11,142; python: 5,529; cpp: 5,113; sql: 1,790; makefile: 861; fortran: 113
file content (199 lines) | stat: -rw-r--r-- 7,168 bytes parent folder | download | duplicates (8)
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/*
 * $Id: switch_req.c 3172 2010-02-15 08:51:54Z baud $
 */

/*
 * Copyright (C) 1990-2010 by CERN/IT/PDP/DM
 * All rights reserved
 *
 * This is a file of functions that merge some code common
 * to rfio_fcalls.c and xyopen.c, xyclose.c, xywrite.c and  xyread.c
 *
 */

#define DEBUG           0               /* Debugging flag               */
#define RFIO_KERNEL     1               /* KERNEL part of the programs  */

#ifndef lint
static char sccsid[] = "@(#)$RCSfile: switch_req.c,v $ $Revision: 3172 $ $Date: 2010-02-15 09:51:54 +0100 (Mon, 15 Feb 2010) $ CERN/IT/PDP/DM Felix Hassine";
#endif

#include "rfio.h"                       /* Remote file I/O              */
#include "osdep.h"
#include <log.h>                        /* Genralized error logger      */

int DLL_DECL switch_open(access, lun, filename, filen, lrecl,append,trunc,mod)
int     *access		;
LONG	*lun		;
char 	*filename	;
int	*filen		;
LONG 	*lrecl		;	
LONG  	*append		;
LONG	*trunc		;
int 	mod		;
{
	int status;
        switch ((int)*access) {
                        case FFFACC_S:
				if (mod == LLTM) 
                                	log(LOG_INFO, "rxyopen(%s) SEQUENTIAL\n",filename);
				else 
					TRACE(2, "rfio",  "rfio_xyopen(%s) SEQUENTIAL (local)",filename);

#if defined(sun) || defined(sgi) || defined(hpux) || defined(_AIX) || ( defined(__osf__) && defined(__alpha) ) || defined(linux) || defined(_WIN32) || defined(__Lynx__) || defined( __APPLE__)

                                status=usf_open(lun, filename, append,trunc);
#else
                                (void) fopn_us_(lun, filename, filen, append, &status);
#endif
                                break;
                        case FFFACC_D:
				if (mod == LLTM)
                                	log(LOG_INFO, "rxyopen(%s) DIRECT\n",filename);
				else {
					TRACE(2, "rfio",  "rfio_xyopen(%s) DIRECT (local)",filename);
				}

#if defined(sun) || defined(sgi) || defined(hpux) || defined(_AIX) || ( defined(__osf__) && defined(__alpha) ) || defined(linux) || defined(_WIN32) || defined(__Lynx__) || defined( __APPLE__)
                                status=udf_open(lun, filename, lrecl,trunc);
#else
                                (void) fopn_ud_(lun, filename, filen, lrecl, &status);
#endif
                                break;
                        default:
				if (mod == LLTM)
                                	log(LOG_ERR, "rxyopen(%s) invalid access type: %d\n",filename, *access);
				else {
					TRACE(2, "rfio",  "rfio_xyopen(%d) invalid access type: %d\n",lun, *access);
				}
                                status = SEBADFOPT;
        }
		return (status);

}

int DLL_DECL switch_write(access,lun,ptr,nwrit,nrec,mod)
int     access          ;
LONG    *lun            ;
char 	*ptr		;
int 	*nwrit		;
int	*nrec		;
int 	mod 		;
{ 
	int status;
	switch (access) {
                case FFFACC_S:
			 if (mod == LLTM)
                        	log(LOG_DEBUG, "rxywrit(%d) SEQUENTIAL\n",*lun);
			 else {
				TRACE(2, "rfio",  "rfio_xywrit(%d) SEQUENTIAL",*lun);
			 }

#if defined(sun) || defined(sgi) || defined(hpux) || defined(_AIX) || ( defined(__osf__) && defined(__alpha) ) || defined(linux) || defined(_WIN32) || defined(__Lynx__) || defined( __APPLE__)
                        status=usf_write(lun, ptr, nwrit);
#else
                        (void) fwr_us_(lun, ptr, nwrit, &status);
#endif
                        break;
                case FFFACC_D:
			if (mod == LLTM)
                        	log(LOG_DEBUG, "rxywrit(%d) DIRECT\n",*lun);
			else
				TRACE(2, "rfio",  "rfio_xywrit(%d) DIRECT",*lun);

#if defined(sun) || defined(sgi) || defined(hpux) || defined(_AIX) || ( defined(__osf__) && defined(__alpha) ) || defined(linux) || defined(_WIN32) || defined(__Lynx__) || defined( __APPLE__)
                        status=udf_write(lun, ptr, nrec, nwrit);
#else
                        (void) fwr_ud_(lun, ptr, nrec, nwrit, &status);
#endif
                        break;
                default:
			if (mod == LLTM)
                        	log(LOG_ERR, "rxyopen(%d) invalid access type: %d\n",*lun, access);
			else
				TRACE(2, "rfio",  "rfio_xywrite(%d) invalid access type:%d",*lun, access);

                        status = SEBADFOPT;
        }
	return (status);
}


int DLL_DECL switch_read(access,ptlun,buffer1,nwant,nrec,readopt,ngot,mod)
int  	access	;
int 	*ptlun  	;
char 	*buffer1;
int	*nwant	;
int 	*nrec	;
int	readopt	;
int	*ngot	;
int 	mod	;

{
	int status;
        if (readopt == FFREAD_C)        {
			if (mod == LLTM)
                                log(LOG_DEBUG, "rxyread(%d) SPECIAL\n",*ptlun);
			else {
				TRACE(2, "rfio", "rfio_xyread(%d) SPECIAL",*ptlun);
			}

#if defined(sun) || defined(sgi) || defined(hpux) || defined(_AIX) || ( defined(__osf__) && defined(__alpha) ) || defined(linux) || defined(_WIN32) || defined(__Lynx__) || defined( __APPLE__)
                                (void) uf_cread(ptlun, buffer1, nrec, nwant, ngot, &status);
#else
                                (void) frdc_(ptlun, buffer1, nwant, ngot, &status);
#endif

        }
        else    {
                switch (access) {
                        case FFFACC_S:
				if (mod == LLTM)
                                	log(LOG_DEBUG, "rxyread(%d) SEQUENTIAL\n",*ptlun);
				else
					TRACE(2, "rfio", "rfio_xyread(%d) SEQUENTIAL",*ptlun);
#if defined(sun) || defined(sgi) || defined(hpux) || defined(_AIX) || ( defined(__osf__) && defined(__alpha) ) || defined(linux) || defined(_WIN32) || defined(__Lynx__) || defined( __APPLE__)
                                status=usf_read(ptlun, buffer1, nwant);
#else
                                (void) frd_us_(ptlun, buffer1, nwant, &status);
#endif

                                *ngot = *nwant;
                                break;
                        case FFFACC_D:
				if (mod == LLTM)
                                	log(LOG_DEBUG, "rxyread(%d) DIRECT\n",*ptlun);
				else
					TRACE(2, "rfio", "rfio_xyread(%d) DIRECT",*ptlun);
#if defined(sun) || defined(sgi) || defined(hpux) || defined(_AIX) || ( defined(__osf__) && defined(__alpha) ) || defined(linux) || defined(_WIN32) || defined(__Lynx__) || defined( __APPLE__)
                                status =udf_read(ptlun, buffer1, nrec, nwant);
#else
                                (void) frd_ud_(ptlun, buffer1, nrec, nwant, &status);
#endif

                                *ngot = *nwant;
                                break;
                        default:
				if (mod == LLTM)
                                	log(LOG_ERR, "rxyread(%d) invalid access type: %d\n",*ptlun, access);
				else
					 TRACE(2, "rfio", "rfio_xyread(%d) invalid access type: %d",*ptlun, access);
                                *ngot = 0;
                                status = SEBADFOPT;
                }
	}
	return (status);

}

int DLL_DECL switch_close(lun)
int	*lun;
{
	int irc;
#if defined(sun) || defined(sgi) || defined(hpux) || defined(_AIX) || ( defined(__osf__) && defined(__alpha) ) || defined(linux) || defined(_WIN32) || defined(__Lynx__) || defined( __APPLE__)
        irc=uf_close(lun);
#else
        (void) fcls_f_ (lun , &irc) ;
#endif
	return(irc);
}