convert more code to use XFILE
authorAndrew Tridgell <tridge@samba.org>
Mon, 10 Sep 2001 12:46:42 +0000 (12:46 +0000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 10 Sep 2001 12:46:42 +0000 (12:46 +0000)
(This used to be commit fe6679dffba9a92bb35933ad52172c9be0e9ef90)

source3/lib/username.c
source3/lib/util_file.c
source3/libsmb/namequery.c
source3/nmbd/nmbd_lmhosts.c
source3/nmbd/nmbd_synclists.c
source3/nmbd/nmbd_winsserver.c
source3/nsswitch/winbindd_proto.h
source3/printing/pcap.c
source3/smbwrapper/smbsh.c

index 6abc4f9a77aae945811c27c2cf8dba9c9e2e2204..9164fd3936a4a40bc9f70687b14b49152aee9f5b 100644 (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 
index d80c09666b582f6aff24a0ec36705fc71ef16200..8eeb3475e38fbfb6df5a86ef426a42561abe202e 100644 (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':
index 39159be41bad821729cfe1890e23277fecd84c01..9dea4b7694763298b6a7fdb480448f76cf28922e 100644 (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;
index 158988813b7f918461cac5f54ac63888ffa80cb7..04ab280784c694d82934ea8e178dbf53076b136c 100644 (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",
index dea68d4c27805a09650dd71bf8576551a8dd6f85..51c9257f5a5640799974693dc548a30b8053c3a4 100644 (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);
 
index 0ba1aef0574d2c647ee39c530fd376fdb789f3a0..03d475133e1e0b79743b5a6c95ff416620564ee7 100644 (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;
 }
 
index e2de9cca6f4400d96676312df8291f23a99d95a8..8753d7becb32a365a61734ee4f6fcf6a8407f8aa 100644 (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_ */
index cbafe277280f050ae555d8293b973f3736120b1c..0ac7600dc567ac90a9000eaa7dd160188b9d207b 100644 (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);
 }
index 1a38b0dea882fb063123391e3e2085cbe81e13a7..f0cdc1f05360051d49eabfcc64ebd0d1cd7e4c40 100644 (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);
        }