ReactOS 0.4.15-dev-6644-g539123c
getrpcent.c File Reference
#include <wintirpc.h>
#include <sys/types.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rpc/rpc.h>
#include <libc_private.h>
Include dependency graph for getrpcent.c:

Go to the source code of this file.

Classes

struct  rpcdata
 

Macros

#define MAXALIASES   35
 
#define RPCDB   "/etc/rpc"
 

Functions

static struct rpcentinterpret (char *val, size_t len)
 
static struct rpcdata_rpcdata (void)
 
void setrpcent (int f)
 
void endrpcent ()
 
struct rpcentgetrpcent ()
 

Variables

static struct rpcdatarpcdata
 

Macro Definition Documentation

◆ MAXALIASES

#define MAXALIASES   35

Definition at line 58 of file getrpcent.c.

◆ RPCDB

#define RPCDB   "/etc/rpc"

Definition at line 75 of file getrpcent.c.

Function Documentation

◆ _rpcdata()

static struct rpcdata * _rpcdata ( void  )
static

Definition at line 80 of file getrpcent.c.

81{
82 struct rpcdata *d = rpcdata;
83
84 if (d == 0) {
85 d = (struct rpcdata *)calloc(1, sizeof (struct rpcdata));
86 rpcdata = d;
87 }
88 return (d);
89}
#define d
Definition: ke_i.h:81
#define calloc
Definition: rosglue.h:14

Referenced by endrpcent(), getrpcent(), interpret(), and setrpcent().

◆ endrpcent()

void endrpcent ( void  )

Definition at line 188 of file getrpcent.c.

189{
190 struct rpcdata *d = _rpcdata();
191
192 if (d == 0)
193 return;
194#ifdef YP
195 if (!__yp_nomap && _yp_check(NULL)) {
196 if (d->current && !d->stayopen)
197 free(d->current);
198 d->current = NULL;
199 d->currentlen = 0;
200 return;
201 }
202 __yp_nomap = 0;
203#endif /* YP */
204 if (d->rpcf && !d->stayopen) {
205 fclose(d->rpcf);
206 d->rpcf = NULL;
207 }
208}
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
static struct rpcdata * _rpcdata(void)
Definition: getrpcent.c:80
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)

◆ getrpcent()

struct rpcent * getrpcent ( )

Definition at line 211 of file getrpcent.c.

212{
213 struct rpcdata *d = _rpcdata();
214#ifdef YP
215 struct rpcent *hp;
216 int reason;
217 char *val = NULL;
218 int vallen;
219#endif
220
221 if (d == 0)
222 return(NULL);
223#ifdef YP
224 if (!__yp_nomap && _yp_check(&d->domain)) {
225 if (d->current == NULL && d->currentlen == 0) {
226 reason = yp_first(d->domain, "rpc.bynumber",
227 &d->current, &d->currentlen,
228 &val, &vallen);
229 } else {
230 reason = yp_next(d->domain, "rpc.bynumber",
231 d->current, d->currentlen,
232 &d->current, &d->currentlen,
233 &val, &vallen);
234 }
235 switch(reason) {
236 case 0:
237 break;
238 case YPERR_MAP:
239 __yp_nomap = 1;
240 goto no_yp;
241 break;
242 default:
243 return(0);
244 break;
245 }
246 val[vallen] = '\0';
247 hp = interpret(val, vallen);
248 (void) free(val);
249 return hp;
250 }
251no_yp:
252#endif /* YP */
253 if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "r")) == NULL)
254 return (NULL);
255 /* -1 so there is room to append a \n below */
256 if (fgets(d->line, BUFSIZ - 1, d->rpcf) == NULL)
257 return (NULL);
258 return (interpret(d->line, strlen(d->line)));
259}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904
static struct rpcent * interpret(char *val, size_t len)
Definition: getrpcent.c:262
#define RPCDB
Definition: getrpcent.c:75
GLuint GLfloat * val
Definition: glext.h:7180
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
#define BUFSIZ
Definition: nsplookup.c:25
Definition: rpcent.h:48

Referenced by interpret().

◆ interpret()

static struct rpcent * interpret ( char val,
size_t  len 
)
static

Definition at line 262 of file getrpcent.c.

265{
266 struct rpcdata *d = _rpcdata();
267 char *p;
268 char *cp, **q;
269
270 assert(val != NULL);
271
272 if (d == 0)
273 return (0);
274 (void) strncpy(d->line, val, BUFSIZ);
275 d->line[BUFSIZ] = '\0';
276 p = d->line;
277 p[len] = '\n';
278 if (*p == '#')
279 return (getrpcent());
280 cp = strpbrk(p, "#\n");
281 if (cp == NULL)
282 return (getrpcent());
283 *cp = '\0';
284 cp = strpbrk(p, " \t");
285 if (cp == NULL)
286 return (getrpcent());
287 *cp++ = '\0';
288 /* THIS STUFF IS INTERNET SPECIFIC */
289 d->rpc.r_name = d->line;
290 while (*cp == ' ' || *cp == '\t')
291 cp++;
292 d->rpc.r_number = atoi(cp);
293 q = d->rpc.r_aliases = d->rpc_aliases;
294 cp = strpbrk(cp, " \t");
295 if (cp != NULL)
296 *cp++ = '\0';
297 while (cp && *cp) {
298 if (*cp == ' ' || *cp == '\t') {
299 cp++;
300 continue;
301 }
302 if (q < &(d->rpc_aliases[MAXALIASES - 1]))
303 *q++ = cp;
304 cp = strpbrk(cp, " \t");
305 if (cp != NULL)
306 *cp++ = '\0';
307 }
308 *q = NULL;
309 return (&d->rpc);
310}
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
char * strpbrk(const char *String, const char *Delimiters)
Definition: utclib.c:302
#define assert(x)
Definition: debug.h:53
struct rpcent * getrpcent()
Definition: getrpcent.c:211
#define MAXALIASES
Definition: getrpcent.c:58
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
POINT cp
Definition: magnifier.c:59

Referenced by getrpcent().

◆ setrpcent()

void setrpcent ( int  f)

Definition at line 163 of file getrpcent.c.

165{
166 struct rpcdata *d = _rpcdata();
167
168 if (d == 0)
169 return;
170#ifdef YP
171 if (!__yp_nomap && _yp_check(NULL)) {
172 if (d->current)
173 free(d->current);
174 d->current = NULL;
175 d->currentlen = 0;
176 return;
177 }
178 __yp_nomap = 0;
179#endif /* YP */
180 if (d->rpcf == NULL)
181 d->rpcf = fopen(RPCDB, "r");
182 else
183 rewind(d->rpcf);
184 d->stayopen |= f;
185}
_CRTIMP void __cdecl rewind(_Inout_ FILE *_File)
#define f
Definition: ke_i.h:83

Variable Documentation

◆ rpcdata