summaryrefslogtreecommitdiff
path: root/source3/client
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-09-10 11:08:57 +0000
committerAndrew Tridgell <tridge@samba.org>2001-09-10 11:08:57 +0000
commitb30e75692d68233448b3ad3d7ddd4b4ac423d3ab (patch)
treeed752b80838a33953632c7f3ffcaf0a71c47a7f5 /source3/client
parentba8e3e03432ee7649a3f59ba8b37edbb32c34190 (diff)
downloadsamba-b30e75692d68233448b3ad3d7ddd4b4ac423d3ab.tar.gz
samba-b30e75692d68233448b3ad3d7ddd4b4ac423d3ab.tar.bz2
samba-b30e75692d68233448b3ad3d7ddd4b4ac423d3ab.zip
replaced stdio in many parts of samba with a XFILE. XFILE is a cut-down
replacemnt of stdio that doesn't suffer from the 8-bit filedescriptor limit that we hit with nasty consequences on some systems I would eventually prefer us to have a configure test to see if we need to replace stdio, but for now this code needs to be tested widely so I'm enabling it by default. (This used to be commit 1af8bf34f1caa3e7ec312d8109c07d32a945a448)
Diffstat (limited to 'source3/client')
-rw-r--r--source3/client/client.c38
-rw-r--r--source3/client/clitar.c12
-rw-r--r--source3/client/smbmount.c2
3 files changed, 26 insertions, 26 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index 5612fc64b8..c9842335a9 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -135,17 +135,17 @@ static int writefile(int f, char *b, int n)
read from a file with LF->CR/LF translation if appropriate. return the
number read. read approx n bytes.
****************************************************************************/
-static int readfile(char *b, int n, FILE *f)
+static int readfile(char *b, int n, XFILE *f)
{
int i;
int c;
if (!translation)
- return fread(b,1,n,f);
+ return x_fread(b,1,n,f);
i = 0;
while (i < (n - 1) && (i < BUFFER_SIZE)) {
- if ((c = getc(f)) == EOF) {
+ if ((c = x_getc(f)) == EOF) {
break;
}
@@ -981,7 +981,7 @@ static void cmd_mkdir(void)
static void do_put(char *rname,char *lname)
{
int fnum;
- FILE *f;
+ XFILE *f;
int nread=0;
char *buf=NULL;
int maxwrite=io_bufsize;
@@ -999,10 +999,10 @@ static void do_put(char *rname,char *lname)
/* allow files to be piped into smbclient
jdblair 24.jun.98 */
if (!strcmp(lname, "-")) {
- f = stdin;
+ f = x_stdin;
/* size of file is not known */
} else {
- f = sys_fopen(lname,"r");
+ f = x_fopen(lname,O_RDONLY, 0);
}
if (!f) {
@@ -1019,12 +1019,12 @@ static void do_put(char *rname,char *lname)
d_printf("ERROR: Not enough memory!\n");
return;
}
- while (!feof(f)) {
+ while (!x_feof(f)) {
int n = maxwrite;
int ret;
if ((n = readfile(buf,n,f)) < 1) {
- if((n == 0) && feof(f))
+ if((n == 0) && x_feof(f))
break; /* Empty local file. */
d_printf("Error reading local file: %s\n", strerror(errno));
@@ -1043,13 +1043,13 @@ static void do_put(char *rname,char *lname)
if (!cli_close(cli, fnum)) {
d_printf("%s closing remote file %s\n",cli_errstr(cli),rname);
- fclose(f);
+ x_fclose(f);
if (buf) free(buf);
return;
}
- fclose(f);
+ x_fclose(f);
if (buf) free(buf);
{
@@ -1068,7 +1068,7 @@ static void do_put(char *rname,char *lname)
put_total_size / (1.024*put_total_time_ms)));
}
- if (f == stdin) {
+ if (f == x_stdin) {
cli_shutdown(cli);
exit(0);
}
@@ -2280,7 +2280,7 @@ static int do_message_op(void)
fstring base_directory;
char *pname = argv[0];
int opt;
- extern FILE *dbf;
+ extern XFILE *dbf;
extern char *optarg;
extern int optind;
int old_debug;
@@ -2315,7 +2315,7 @@ static int do_message_op(void)
for (opt = 1; opt < argc; opt++) {
if (strcmp(argv[opt], "-E") == 0)
- dbf = stderr;
+ dbf = x_stderr;
else if(strncmp(argv[opt], "-s", 2) == 0) {
if(argv[opt][2] != '\0')
pstrcpy(servicesf, &argv[opt][2]);
@@ -2473,7 +2473,7 @@ static int do_message_op(void)
break;
case 'E':
display_set_stderr();
- dbf = stderr;
+ dbf = x_stderr;
break;
case 'U':
{
@@ -2490,22 +2490,22 @@ static int do_message_op(void)
case 'A':
{
- FILE *auth;
+ XFILE *auth;
fstring buf;
uint16 len = 0;
char *ptr, *val, *param;
- if ((auth=sys_fopen(optarg, "r")) == NULL)
+ if ((auth=x_fopen(optarg, O_RDONLY, 0)) == NULL)
{
/* fail if we can't open the credentials file */
d_printf("ERROR: Unable to open credentials file!\n");
exit (-1);
}
- while (!feof(auth))
+ while (!x_feof(auth))
{
/* get a line from the file */
- if (!fgets (buf, sizeof(buf), auth))
+ if (!x_fgets(buf, sizeof(buf), auth))
continue;
len = strlen(buf);
@@ -2539,7 +2539,7 @@ static int do_message_op(void)
memset(buf, 0, sizeof(buf));
}
- fclose(auth);
+ x_fclose(auth);
}
break;
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index 8ce73f6645..6169c9af46 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -71,7 +71,7 @@ stack dir_stack = {NULL, 0}; /* Want an empty stack */
#define SEPARATORS " \t\n\r"
extern int DEBUGLEVEL;
extern struct cli_state *cli;
-extern FILE *dbf;
+extern XFILE *dbf;
/* These defines are for the do_setrattr routine, to indicate
* setting and reseting of file attributes in the function call */
@@ -1533,7 +1533,7 @@ accordingly.
***************************************************************************/
static int read_inclusion_file(char *filename)
{
- FILE *inclusion = NULL;
+ XFILE *inclusion = NULL;
char buf[MAXPATHLEN + 1];
char *inclusion_buffer = NULL;
int inclusion_buffer_size = 0;
@@ -1545,7 +1545,7 @@ static int read_inclusion_file(char *filename)
clipn = 0;
buf[MAXPATHLEN] = '\0'; /* guarantee null-termination */
- if ((inclusion = sys_fopen(filename, "r")) == NULL) {
+ if ((inclusion = x_fopen(filename, O_RDONLY, 0)) == NULL) {
/* XXX It would be better to include a reason for failure, but without
* autoconf, it's hard to use strerror, sys_errlist, etc.
*/
@@ -1553,7 +1553,7 @@ static int read_inclusion_file(char *filename)
return 0;
}
- while ((! error) && (fgets(buf, sizeof(buf)-1, inclusion))) {
+ while ((! error) && (x_fgets(buf, sizeof(buf)-1, inclusion))) {
if (inclusion_buffer == NULL) {
inclusion_buffer_size = 1024;
if ((inclusion_buffer = malloc(inclusion_buffer_size)) == NULL) {
@@ -1584,7 +1584,7 @@ static int read_inclusion_file(char *filename)
inclusion_buffer_sofar += strlen(buf) + 1;
clipn++;
}
- fclose(inclusion);
+ x_fclose(inclusion);
if (! error) {
/* Allocate an array of clipn + 1 char*'s for cliplist */
@@ -1827,7 +1827,7 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind)
* tar output
*/
if (tarhandle == 1)
- dbf = stderr;
+ dbf = x_stderr;
} else {
if (tar_type=='c' && (dry_run || strcmp(argv[Optind], "/dev/null")==0))
{
diff --git a/source3/client/smbmount.c b/source3/client/smbmount.c
index 71c7e29810..a87eb789ef 100644
--- a/source3/client/smbmount.c
+++ b/source3/client/smbmount.c
@@ -148,7 +148,7 @@ static struct cli_state *do_connection(char *service)
if (have_ip) ip = dest_ip;
/* have to open a new connection */
- if (!(c=cli_initialise(NULL)) || (cli_set_port(c, smb_port) != port) ||
+ if (!(c=cli_initialise(NULL)) || (cli_set_port(c, smb_port) != smb_port) ||
!cli_connect(c, server_n, &ip)) {
DEBUG(0,("%d: Connection to %s failed\n", getpid(), server_n));
if (c) {