|
getnetgrent
getnetgrent
/* Copyright (C) 1995 Free Software Foundation, Inc.
* This file is part of the GNU C Library.
*
* The GNU C Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The GNU C Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the GNU C Library; see the file COPYING.LIB. If
* not, write to the Free Software Foundation, Inc., 675 Mass Ave,
* Cambridge, MA 02139, USA.
*
* Author: Swen Thuemmler
*
* Changes for the use with revnetgroup:
* Thorsten Kukuk
*/
#include
#include
#include
#include
#include
#include
#include "hash.h"
extern hash_t *input;
void rev_setnetgrent (const char *);
void rev_endnetgrent (void);
int rev_getnetgrent (char **, char **, char **);
struct netgrentry
{
char *host;
char *user;
char *domain;
};
struct netgrlist
{
int maxmembers;
int members;
struct netgrentry *list;
};
static void rev_expand_netgroupentry (const char *, struct netgrlist *);
static void rev_parse_entry (char *, char *, struct netgrlist *);
static void rev_netgr_free (struct netgrlist *);
static struct netgrlist list = {0, 0, NULL};
static int first = 1;
static char *netgroup = NULL;
static char *
search_netgroup (hash_t ** liste, const char *key)
{
hash_t *work;
work = *liste;
while ((work != NULL) && (0 != strcmp (work->key, key)))
work = work->next;
if (work != NULL)
return work->val;
else
return NULL;
}
void
rev_setnetgrent (const char *netgr)
{
if (NULL == netgroup || 0 != strcmp (netgroup, netgr))
{
rev_endnetgrent ();
netgroup = strdup (netgr);
rev_expand_netgroupentry (netgr, &list);
}
first = 1;
}
void
rev_endnetgrent (void)
{
if (NULL != netgroup)
{
free (netgroup);
netgroup = NULL;
}
if (NULL != list.list)
rev_netgr_free (&list);
first = 1;
}
int
rev_getnetgrent (char **machinep, char **userp, char **domainp)
{
static int current = 0;
struct netgrentry *entry;
if (1 == first)
current = first = 0;
else
current++;
if (current < list.members)
{
entry = &list.list[current];
*machinep = entry->host;
*userp = entry->user;
*domainp = entry->domain;
return 1;
}
return 0;
}
static void
rev_netgr_free (struct netgrlist *list)
{
int i;
for (i = 0; i < list->members; i++)
{
free (list->list[i].host);
free (list->list[i].user);
free (list->list[i].domain);
}
free (list->list);
list->maxmembers = 0;
list->members = 0;
list->list = NULL;
}
static void
rev_expand_netgroupentry (const char *netgr, struct netgrlist *list)
{
char *outval = NULL;
char *outptr = NULL;
char *start = NULL;
char *end = NULL;
char *realend = NULL;
if (*netgr == '\0')
return;
outptr = search_netgroup (&input, netgr);
if (outptr == NULL)
return;
/* make a copy to work with */
outval = strdup (outptr);
if (outval == NULL)
{
fprintf (stderr, "ERROR: could not allocate enough memory! [%s|%d]\n",
__FILE__, __LINE__);
exit (1);
}
/* outval enthaelt den Eintrag. Zuerst Leerzeichen ueberlesen */
start = outval;
realend = start + strlen (outval);
while (isspace (*start) && start < realend)
start++;
while (start < realend)
{
if ('(' == *start) /* Eintrag gefunden */
{
/* this a tuple... */
end = strchr (start, ')');
if (NULL == end)
{
free (outval);
return;
}
/* add the entry to the list? */
rev_parse_entry (start + 1, end, list);
}
else
{
/* okay, this should be a group (ie. not
a tuple... */
end = start + 1;
while ((*end != '\0') && (!isspace (*end)))
end++;
*end = '\0';
/* recursion */
rev_expand_netgroupentry (start, list);
}
/* skip to the next entry */
start = end + 1;
if (end == realend)
break;
assert (start <= realend);
while ((start < realend) && (isspace (*start)))
start++;
}
/* free the copy */
free (outval);
}
static void
rev_parse_entry (char *start, char *end, struct netgrlist *list)
{
char *host, *user, *domain;
struct netgrentry *entry;
/* First split entry into fields. Return, when finding malformed entry */
host = start;
start = strchr (host, ',');
if (NULL == start || start >= end)
return;
*start = '\0';
user = start + 1;
start = strchr (user, ',');
if (NULL == start || start >= end)
return;
*start = '\0';
domain = start + 1;
if (start > end)
return;
*end = '\0';
/* Entry is correctly formed, put it into the list */
if (0 == list->maxmembers)
{
list->list = malloc (10 * sizeof (struct netgrentry));
if (NULL != list->list)
list->maxmembers = 10;
}
if (list->members == list->maxmembers)
{
list->list = realloc (list->list,
(list->maxmembers + 10) * sizeof (struct netgrentry));
if (NULL == list->list)
{
list->maxmembers = 0;
list->members = 0;
return;
}
list->maxmembers += 10;
}
/*
* FIXME: this will not handle entries of the form ( asdf, sdfa , asdf )
* (note the spaces). This should be handled better!
*/
entry = &list->list[list->members];
entry->user = ('\0' == *user) ? NULL : strdup (user);
entry->host = ('\0' == *host) ? NULL : strdup (host);
entry->domain = ('\0' == *domain) ? NULL : strdup (domain);
list->members++;
return;
}
Java Web Hosting
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#ifndef _YP_H_RPCGEN
#define _YP_H_RPCGEN
#include
#ifdef __cplusplus
extern "C" {
#endif
#define YPMAXRECORD 1024
#define YPMAXDOMAIN 64
#define YPMAXMAP 64
#define YPMAXPEER 64
enum ypstat {
YP_TRUE = 1,
YP_NOMORE = 2,
YP_FALSE = 0,
YP_NOMAP = -1,
YP_NODOM = -2,
YP_NOKEY = -3,
YP_BADOP = -4,
YP_BADDB = -5,
YP_YPERR = -6,
YP_BADARGS = -7,
YP_VERS = -8
};
typedef enum ypstat ypstat;
enum ypxfrstat {
YPXFR_SUCC = 1,
YPXFR_AGE = 2,
YPXFR_NOMAP = -1,
YPXFR_NODOM = -2,
YPXFR_RSRC = -3,
YPXFR_RPC = -4,
YPXFR_MADDR = -5,
YPXFR_YPERR = -6,
YPXFR_BADARGS = -7,
YPXFR_DBM = -8,
YPXFR_FILE = -9,
YPXFR_SKEW = -10,
YPXFR_CLEAR = -11,
YPXFR_FORCE = -12,
YPXFR_XFRERR = -13,
YPXFR_REFUSED = -14
};
typedef enum ypxfrstat ypxfrstat;
typedef char *domainname;
typedef char *mapname;
typedef char *peername;
typedef struct {
u_int keydat_len;
char *keydat_val;
} keydat;
typedef struct {
u_int valdat_len;
char *valdat_val;
} valdat;
struct ypmap_parms {
domainname domain;
mapname map;
u_int ordernum;
peername peer;
};
typedef struct ypmap_parms ypmap_parms;
struct ypreq_key {
domainname domain;
mapname map;
keydat key;
};
typedef struct ypreq_key ypreq_key;
struct ypreq_nokey {
domainname domain;
mapname map;
};
typedef struct ypreq_nokey ypreq_nokey;
struct ypreq_xfr {
ypmap_parms map_parms;
u_int transid;
u_int prog;
u_int port;
};
typedef struct ypreq_xfr ypreq_xfr;
struct ypresp_val {
ypstat stat;
valdat val;
};
typedef struct ypresp_val ypresp_val;
struct ypresp_key_val {
ypstat stat;
valdat val;
keydat key;
};
typedef struct ypresp_key_val ypresp_key_val;
struct ypresp_master {
ypstat stat;
peername peer;
};
typedef struct ypresp_master ypresp_master;
struct ypresp_order {
ypstat stat;
u_int ordernum;
};
typedef struct ypresp_order ypresp_order;
typedef struct
{
struct
{
int (*encode)(ypresp_key_val *val, void *data);
int (*close)(void *data);
} u;
void *data;
} xdr_ypall_cb_t;
struct ypresp_all {
bool_t more;
union {
ypresp_key_val val;
} ypresp_all_u;
};
typedef struct ypresp_all ypresp_all;
struct ypresp_xfr {
u_int transid;
ypxfrstat xfrstat;
};
typedef struct ypresp_xfr ypresp_xfr;
struct ypmaplist {
mapname map;
struct ypmaplist *next;
};
typedef struct ypmaplist ypmaplist;
struct ypresp_maplist {
ypstat stat;
ypmaplist *maps;
};
typedef struct ypresp_maplist ypresp_maplist;
enum yppush_status {
YPPUSH_SUCC = 1,
YPPUSH_AGE = 2,
YPPUSH_NOMAP = -1,
YPPUSH_NODOM = -2,
YPPUSH_RSRC = -3,
YPPUSH_RPC = -4,
YPPUSH_MADDR = -5,
YPPUSH_YPERR = -6,
YPPUSH_BADARGS = -7,
YPPUSH_DBM = -8,
YPPUSH_FILE = -9,
YPPUSH_SKEW = -10,
YPPUSH_CLEAR = -11,
YPPUSH_FORCE = -12,
YPPUSH_XFRERR = -13,
YPPUSH_REFUSED = -14
};
typedef enum yppush_status yppush_status;
struct yppushresp_xfr {
u_int transid;
yppush_status status;
};
typedef struct yppushresp_xfr yppushresp_xfr;
enum ypbind_resptype {
YPBIND_SUCC_VAL = 1,
YPBIND_FAIL_VAL = 2
};
typedef enum ypbind_resptype ypbind_resptype;
struct ypbind_binding {
char ypbind_binding_addr[4];
char ypbind_binding_port[2];
};
typedef struct ypbind_binding ypbind_binding;
struct ypbind_resp {
ypbind_resptype ypbind_status;
union {
u_int ypbind_error;
ypbind_binding ypbind_bindinfo;
} ypbind_resp_u;
};
typedef struct ypbind_resp ypbind_resp;
#define YPBIND_ERR_ERR 1
#define YPBIND_ERR_NOSERV 2
#define YPBIND_ERR_RESC 3
struct ypbind_setdom {
domainname ypsetdom_domain;
ypbind_binding ypsetdom_binding;
u_int ypsetdom_vers;
};
typedef struct ypbind_setdom ypbind_setdom;
#define YPPROG 100004
#define YPVERS 2
#if defined(__STDC__) || defined(__cplusplus)
#define YPPROC_NULL 0
extern enum clnt_stat ypproc_null_2(void *, void *, CLIENT *);
extern bool_t ypproc_null_2_svc(void *, void *, struct svc_req *);
#define YPPROC_DOMAIN 1
extern enum clnt_stat ypproc_domain_2(domainname *, bool_t *, CLIENT *);
extern bool_t ypproc_domain_2_svc(domainname *, bool_t *, struct svc_req *);
#define YPPROC_DOMAIN_NONACK 2
extern enum clnt_stat ypproc_domain_nonack_2(domainname *, bool_t *, CLIENT *);
extern bool_t ypproc_domain_nonack_2_svc(domainname *, bool_t *, struct svc_req *);
#define YPPROC_MATCH 3
extern enum clnt_stat ypproc_match_2(ypreq_key *, ypresp_val *, CLIENT *);
extern bool_t ypproc_match_2_svc(ypreq_key *, ypresp_val *, struct svc_req *);
#define YPPROC_FIRST 4
extern enum clnt_stat ypproc_first_2(ypreq_key *, ypresp_key_val *, CLIENT *);
extern bool_t ypproc_first_2_svc(ypreq_nokey *, ypresp_key_val *, struct svc_req *);
#define YPPROC_NEXT 5
extern enum clnt_stat ypproc_next_2(ypreq_key *, ypresp_key_val *, CLIENT *);
extern bool_t ypproc_next_2_svc(ypreq_key *, ypresp_key_val *, struct svc_req *);
#define YPPROC_XFR 6
extern enum clnt_stat ypproc_xfr_2(ypreq_xfr *, ypresp_xfr *, CLIENT *);
extern bool_t ypproc_xfr_2_svc(ypreq_xfr *, ypresp_xfr *, struct svc_req *);
#define YPPROC_CLEAR 7
extern enum clnt_stat ypproc_clear_2(void *, void *, CLIENT *);
extern bool_t ypproc_clear_2_svc(void *, void *, struct svc_req *);
#define YPPROC_ALL 8
extern enum clnt_stat ypproc_all_2(ypreq_nokey *, ypresp_all *, CLIENT *);
extern bool_t ypproc_all_2_svc(ypreq_nokey *, ypresp_all *, struct svc_req *);
#define YPPROC_MASTER 9
extern enum clnt_stat ypproc_master_2(ypreq_nokey *, ypresp_master *, CLIENT *);
extern bool_t ypproc_master_2_svc(ypreq_nokey *, ypresp_master *, struct svc_req *);
#define YPPROC_ORDER 10
extern enum clnt_stat ypproc_order_2(ypreq_nokey *, ypresp_order *, CLIENT *);
extern bool_t ypproc_order_2_svc(ypreq_nokey *, ypresp_order *, struct svc_req *);
#define YPPROC_MAPLIST 11
extern enum clnt_stat ypproc_maplist_2(domainname *, ypresp_maplist *, CLIENT *);
extern bool_t ypproc_maplist_2_svc(domainname *, ypresp_maplist *, struct svc_req *);
extern int ypprog_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
#define YPPROC_NULL 0
extern enum clnt_stat ypproc_null_2();
extern bool_t ypproc_null_2_svc();
#define YPPROC_DOMAIN 1
extern enum clnt_stat ypproc_domain_2();
extern bool_t ypproc_domain_2_svc();
#define YPPROC_DOMAIN_NONACK 2
extern enum clnt_stat ypproc_domain_nonack_2();
extern bool_t ypproc_domain_nonack_2_svc();
#define YPPROC_MATCH 3
extern enum clnt_stat ypproc_match_2();
extern bool_t ypproc_match_2_svc();
#define YPPROC_FIRST 4
extern enum clnt_stat ypproc_first_2();
extern bool_t ypproc_first_2_svc();
#define YPPROC_NEXT 5
extern enum clnt_stat ypproc_next_2();
extern bool_t ypproc_next_2_svc();
#define YPPROC_XFR 6
extern enum clnt_stat ypproc_xfr_2();
extern bool_t ypproc_xfr_2_svc();
#define YPPROC_CLEAR 7
extern enum clnt_stat ypproc_clear_2();
extern bool_t ypproc_clear_2_svc();
#define YPPROC_ALL 8
extern enum clnt_stat ypproc_all_2();
extern bool_t ypproc_all_2_svc();
#define YPPROC_MASTER 9
extern enum clnt_stat ypproc_master_2();
extern bool_t ypproc_master_2_svc();
#define YPPROC_ORDER 10
extern enum clnt_stat ypproc_order_2();
extern bool_t ypproc_order_2_svc();
#define YPPROC_MAPLIST 11
extern enum clnt_stat ypproc_maplist_2();
extern bool_t ypproc_maplist_2_svc();
extern int ypprog_2_freeresult ();
#endif /* K&R C */
#define YPPUSH_XFRRESPPROG 0x40000000
#define YPPUSH_XFRRESPVERS 1
#if defined(__STDC__) || defined(__cplusplus)
#define YPPUSHPROC_NULL 0
extern enum clnt_stat yppushproc_null_1(void *, void *, CLIENT *);
extern bool_t yppushproc_null_1_svc(void *, void *, struct svc_req *);
#define YPPUSHPROC_XFRRESP 1
extern enum clnt_stat yppushproc_xfrresp_1(yppushresp_xfr *, void *, CLIENT *);
extern bool_t yppushproc_xfrresp_1_svc(yppushresp_xfr *, void *, struct svc_req *);
extern int yppush_xfrrespprog_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
#define YPPUSHPROC_NULL 0
extern enum clnt_stat yppushproc_null_1();
extern bool_t yppushproc_null_1_svc();
#define YPPUSHPROC_XFRRESP 1
extern enum clnt_stat yppushproc_xfrresp_1();
extern bool_t yppushproc_xfrresp_1_svc();
extern int yppush_xfrrespprog_1_freeresult ();
#endif /* K&R C */
#define YPBINDPROG 100007
#define YPBINDVERS 2
#if defined(__STDC__) || defined(__cplusplus)
#define YPBINDPROC_NULL 0
extern enum clnt_stat ypbindproc_null_2(void *, void *, CLIENT *);
extern bool_t ypbindproc_null_2_svc(void *, void *, struct svc_req *);
#define YPBINDPROC_DOMAIN 1
extern enum clnt_stat ypbindproc_domain_2(domainname *, ypbind_resp *, CLIENT *);
extern bool_t ypbindproc_domain_2_svc(domainname *, ypbind_resp *, struct svc_req *);
#define YPBINDPROC_SETDOM 2
extern enum clnt_stat ypbindproc_setdom_2(ypbind_setdom *, void *, CLIENT *);
extern bool_t ypbindproc_setdom_2_svc(ypbind_setdom *, void *, struct svc_req *);
extern int ypbindprog_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
#define YPBINDPROC_NULL 0
extern enum clnt_stat ypbindproc_null_2();
extern bool_t ypbindproc_null_2_svc();
#define YPBINDPROC_DOMAIN 1
extern enum clnt_stat ypbindproc_domain_2();
extern bool_t ypbindproc_domain_2_svc();
#define YPBINDPROC_SETDOM 2
extern enum clnt_stat ypbindproc_setdom_2();
extern bool_t ypbindproc_setdom_2_svc();
extern int ypbindprog_2_freeresult ();
#endif /* K&R C */
extern bool_t xdr_ypstat (XDR *, ypstat*);
extern bool_t xdr_ypxfrstat (XDR *, ypxfrstat*);
extern bool_t xdr_domainname (XDR *, domainname*);
extern bool_t xdr_mapname (XDR *, mapname*);
extern bool_t xdr_peername (XDR *, peername*);
extern bool_t xdr_keydat (XDR *, keydat*);
extern bool_t xdr_valdat (XDR *, valdat*);
extern bool_t xdr_ypmap_parms (XDR *, ypmap_parms*);
extern bool_t xdr_ypreq_key (XDR *, ypreq_key*);
extern bool_t xdr_ypreq_nokey (XDR *, ypreq_nokey*);
extern bool_t xdr_ypreq_xfr (XDR *, ypreq_xfr*);
extern bool_t xdr_ypresp_val (XDR *, ypresp_val*);
extern bool_t xdr_ypresp_key_val (XDR *, ypresp_key_val*);
extern bool_t xdr_ypresp_master (XDR *, ypresp_master*);
extern bool_t xdr_ypresp_order (XDR *, ypresp_order*);
extern bool_t xdr_ypresp_all (XDR *, ypresp_all*);
extern bool_t xdr_ypresp_xfr (XDR *, ypresp_xfr*);
extern bool_t xdr_ypmaplist (XDR *, ypmaplist*);
extern bool_t xdr_ypresp_maplist (XDR *, ypresp_maplist*);
extern bool_t xdr_yppush_status (XDR *, yppush_status*);
extern bool_t xdr_yppushresp_xfr (XDR *, yppushresp_xfr*);
extern bool_t xdr_ypbind_resptype (XDR *, ypbind_resptype*);
extern bool_t xdr_ypbind_binding (XDR *, ypbind_binding*);
extern bool_t xdr_ypbind_resp (XDR *, ypbind_resp*);
extern bool_t xdr_ypbind_setdom (XDR *, ypbind_setdom*);
extern bool_t ypxfr_xdr_ypresp_all (XDR *xdrs, ypresp_all *objp);
#ifdef __cplusplus
}
#endif
#endif /* !_YP_H_RPCGEN */
Page:
1
2
3
4
5
6
7
8
9
10
Java Web Hosting Cheap
Java Web Host
Java Web Hosting Cheap
Java Host
|