1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-29 02:50:28 +03:00

convert more code to use XFILE

(This used to be commit fe6679dffba9a92bb35933ad52172c9be0e9ef90)
This commit is contained in:
Andrew Tridgell 2001-09-10 12:46:42 +00:00
parent b12a4dd9b6
commit 79139fe8d8
9 changed files with 44 additions and 50 deletions

View File

@ -56,7 +56,7 @@ BOOL map_username(char *user)
{
static BOOL initialised=False;
static fstring last_from,last_to;
FILE *f;
XFILE *f;
char *mapfile = lp_username_map();
char *s;
pstring buf;
@ -82,7 +82,7 @@ BOOL map_username(char *user)
return True;
}
f = sys_fopen(mapfile,"r");
f = x_fopen(mapfile,O_RDONLY, 0);
if (!f) {
DEBUG(0,("can't open username map %s. Error %s\n",mapfile, strerror(errno) ));
return False;
@ -135,7 +135,7 @@ BOOL map_username(char *user)
fstrcpy(last_to,user);
if(return_if_mapped) {
lp_list_free (&dosuserlist);
fclose(f);
x_fclose(f);
return True;
}
}
@ -143,7 +143,7 @@ BOOL map_username(char *user)
lp_list_free (&dosuserlist);
}
fclose(f);
x_fclose(f);
/*
* Setup the last_from and last_to as an optimization so

View File

@ -272,14 +272,14 @@ read a line from a file with possible \ continuation chars.
Blanks at the start or end of a line are stripped.
The string will be allocated if s2 is NULL
****************************************************************************/
char *fgets_slash(char *s2,int maxlen,FILE *f)
char *fgets_slash(char *s2,int maxlen,XFILE *f)
{
char *s=s2;
int len = 0;
int c;
BOOL start_of_line = True;
if (feof(f))
if (x_feof(f))
return(NULL);
if (maxlen <2) return(NULL);
@ -296,7 +296,7 @@ char *fgets_slash(char *s2,int maxlen,FILE *f)
while (len < maxlen-1)
{
c = getc(f);
c = x_getc(f);
switch (c)
{
case '\r':

View File

@ -449,26 +449,26 @@ struct in_addr *name_query(int fd,const char *name,int name_type,
Start parsing the lmhosts file.
*********************************************************/
FILE *startlmhosts(char *fname)
XFILE *startlmhosts(char *fname)
{
FILE *fp = sys_fopen(fname,"r");
if (!fp) {
DEBUG(4,("startlmhosts: Can't open lmhosts file %s. Error was %s\n",
fname, strerror(errno)));
return NULL;
}
return fp;
XFILE *fp = x_fopen(fname,O_RDONLY, 0);
if (!fp) {
DEBUG(4,("startlmhosts: Can't open lmhosts file %s. Error was %s\n",
fname, strerror(errno)));
return NULL;
}
return fp;
}
/********************************************************
Parse the next line in the lmhosts file.
*********************************************************/
BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr)
BOOL getlmhostsent( XFILE *fp, pstring name, int *name_type, struct in_addr *ipaddr)
{
pstring line;
while(!feof(fp) && !ferror(fp)) {
while(!x_feof(fp) && !x_ferror(fp)) {
pstring ip,flags,extra;
char *ptr;
int count = 0;
@ -549,9 +549,9 @@ BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipad
Finish parsing the lmhosts file.
*********************************************************/
void endlmhosts(FILE *fp)
void endlmhosts(XFILE *fp)
{
fclose(fp);
x_fclose(fp);
}
BOOL name_register_wins(const char *name, int name_type)
@ -741,7 +741,7 @@ static BOOL resolve_lmhosts(const char *name, int name_type,
* "lmhosts" means parse the local lmhosts file.
*/
FILE *fp;
XFILE *fp;
pstring lmhost_name;
int name_type2;
struct in_addr return_ip;

View File

@ -36,7 +36,7 @@ void load_lmhosts_file(char *fname)
pstring name;
int name_type;
struct in_addr ipaddr;
FILE *fp = startlmhosts( fname );
XFILE *fp = startlmhosts( fname );
if (!fp) {
DEBUG(2,("load_lmhosts_file: Can't open lmhosts file %s. Error was %s\n",

View File

@ -241,7 +241,7 @@ read the completed sync info
**********************************************************************/
static void complete_sync(struct sync_record *s)
{
FILE *f;
XFILE *f;
fstring server, type_str;
unsigned type;
pstring comment;
@ -249,11 +249,11 @@ static void complete_sync(struct sync_record *s)
char *ptr;
int count=0;
f = sys_fopen(s->fname,"r");
f = x_fopen(s->fname,O_RDONLY, 0);
if (!f) return;
while (!feof(f)) {
while (!x_feof(f)) {
if (!fgets_slash(line,sizeof(pstring),f)) continue;
@ -272,7 +272,7 @@ static void complete_sync(struct sync_record *s)
count++;
}
fclose(f);
x_fclose(f);
unlink(s->fname);

View File

@ -173,7 +173,7 @@ Load or create the WINS database.
BOOL initialise_wins(void)
{
time_t time_now = time(NULL);
FILE *fp;
XFILE *fp;
pstring line;
if(!lp_we_are_a_wins_server())
@ -181,14 +181,14 @@ BOOL initialise_wins(void)
add_samba_names_to_subnet(wins_server_subnet);
if((fp = sys_fopen(lock_path(WINS_LIST),"r")) == NULL)
if((fp = x_fopen(lock_path(WINS_LIST),O_RDONLY, 0)) == NULL)
{
DEBUG(2,("initialise_wins: Can't open wins database file %s. Error was %s\n",
WINS_LIST, strerror(errno) ));
return True;
}
while (!feof(fp))
while (!x_feof(fp))
{
pstring name_str, ip_str, ttl_str, nb_flags_str;
unsigned int num_ips;
@ -219,7 +219,7 @@ BOOL initialise_wins(void)
version != WINS_VERSION ||
hash != wins_hash()) {
DEBUG(0,("Discarding invalid wins.dat file [%s]\n",line));
fclose(fp);
x_fclose(fp);
return True;
}
continue;
@ -342,7 +342,7 @@ BOOL initialise_wins(void)
free((char *)ip_list);
}
fclose(fp);
x_fclose(fp);
return True;
}

View File

@ -5,7 +5,6 @@
/* The following definitions come from nsswitch/winbindd.c */
void winbindd_dump_status(void);
int main(int argc, char **argv);
/* The following definitions come from nsswitch/winbindd_cache.c */
@ -74,9 +73,6 @@ BOOL winbindd_idmap_init(void);
void winbindd_idmap_dump_status(void);
/* The following definitions come from nsswitch/winbindd_misc.c */
BOOL _get_trust_account_password(char *domain, unsigned char *ret_pwd,
time_t *pass_last_set_time);
enum winbindd_result winbindd_check_machine_acct(
struct winbindd_cli_state *state);
enum winbindd_result winbindd_list_trusted_domains(struct winbindd_cli_state
@ -112,7 +108,6 @@ enum winbindd_result winbindd_list_users(struct winbindd_cli_state *state);
void debug_conn_state(void);
BOOL domain_handles_open(struct winbindd_domain *domain);
void winbindd_kill_connections(struct winbindd_domain *domain);
void winbindd_kill_all_connections(void);
void establish_connections(BOOL force_reestablish) ;
BOOL lookup_domain_sid(char *domain_name, struct winbindd_domain *domain);
@ -142,5 +137,4 @@ NTSTATUS winbindd_query_dispinfo(struct winbindd_domain *domain,
uint32 *start_ndx, uint16 info_level,
uint32 *num_entries, SAM_DISPINFO_CTR *ctr);
BOOL check_domain_env(char *domain_env, char *domain);
void parse_domain_user(char *domuser, fstring domain, fstring user);
#endif /* _PROTO_H_ */

View File

@ -99,14 +99,14 @@ static int strlocate(char *xpLine,char *xpS)
static void ScanQconfig_fn(char *psz,void (*fn)(char *, char *))
{
int iEtat;
FILE *pfile;
XFILE *pfile;
char *line,*p;
pstring name,comment;
line = NULL;
*name = 0;
*comment = 0;
if ((pfile = sys_fopen(psz, "r")) == NULL)
if ((pfile = x_fopen(psz, O_RDONLY, 0)) == NULL)
{
DEBUG(0,( "Unable to open qconfig file %s for read!\n", psz));
return;
@ -160,7 +160,7 @@ static void ScanQconfig_fn(char *psz,void (*fn)(char *, char *))
break;
}
}
fclose(pfile);
x_fclose(pfile);
}
/* Scan qconfig file and locate de printername */
@ -168,7 +168,7 @@ static void ScanQconfig_fn(char *psz,void (*fn)(char *, char *))
static BOOL ScanQconfig(char *psz,char *pszPrintername)
{
int iLg,iEtat;
FILE *pfile;
XFILE *pfile;
char *pName;
char *line;
@ -181,7 +181,7 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername)
DEBUG(0,(" Unable to allocate memory for printer %s\n",pszPrintername));
return(False);
}
if ((pfile = sys_fopen(psz, "r")) == NULL)
if ((pfile = x_fopen(psz, O_RDONLY, 0)) == NULL)
{
DEBUG(0,( "Unable to open qconfig file %s for read!\n", psz));
free(pName);
@ -234,7 +234,7 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername)
}
}
free (pName);
fclose(pfile);
x_fclose(pfile);
return(False);
}
#endif /* AIX */
@ -254,7 +254,7 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname)
char *line=NULL;
char *psz;
char *p,*q;
FILE *pfile;
XFILE *pfile;
if (pszPrintername == NULL || pszPrintername[0] == '\0')
{
@ -285,7 +285,7 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname)
return(ScanQconfig(psz,pszPrintername));
#endif
if ((pfile = sys_fopen(psz, "r")) == NULL)
if ((pfile = x_fopen(psz, O_RDONLY, 0)) == NULL)
{
DEBUG(0,( "Unable to open printcap file %s for read!\n", psz));
return(False);
@ -311,14 +311,14 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname)
/* normalise the case */
pstrcpy(pszPrintername,p);
free(line);
fclose(pfile);
x_fclose(pfile);
return(True);
}
p = q;
}
}
fclose(pfile);
x_fclose(pfile);
return(False);
}
@ -335,7 +335,7 @@ void pcap_printer_fn(void (*fn)(char *, char *))
char *line;
char *psz;
char *p,*q;
FILE *pfile;
XFILE *pfile;
/* only go looking if no printcap name supplied */
if (((psz = lp_printcapname()) == NULL) || (psz[0] == '\0'))
@ -366,7 +366,7 @@ void pcap_printer_fn(void (*fn)(char *, char *))
}
#endif
if ((pfile = sys_fopen(psz, "r")) == NULL)
if ((pfile = x_fopen(psz, O_RDONLY, 0)) == NULL)
{
DEBUG(0,( "Unable to open printcap file %s for read!\n", psz));
return;
@ -419,5 +419,5 @@ void pcap_printer_fn(void (*fn)(char *, char *))
if (*name)
fn(name,comment);
}
fclose(pfile);
x_fclose(pfile);
}

View File

@ -84,7 +84,7 @@ int main(int argc, char *argv[])
if (!smbw_getshared("USER")) {
printf("Username: ");
u = fgets_slash(line, sizeof(line)-1, stdin);
u = fgets_slash(line, sizeof(line)-1, x_stdin);
smbw_setshared("USER", u);
}