struct cli_state *cli;
extern BOOL in_client;
+static int port = SMB_PORT;
pstring cur_dir = "\\";
pstring cd_path = "";
static pstring service;
static pstring workgroup;
static char *cmdstr;
static BOOL got_pass;
-static BOOL no_pass;
extern struct in_addr ipzero;
extern pstring scope;
int l=0;
int c;
- ZERO_STRUCT(msg);
+ ZERO_ARRAY(msg);
for (l=0;l<maxlen && (c=fgetc(stdin))!=EOF;l++) {
if (c == '\n')
if (do_list_fn == display_finfo) {
DEBUG(0,("\n%s\n",CNV_LANG(mask2)));
}
- pstrcat(mask2,"\\*.*");
+ pstrcat(mask2,"\\*");
do_list(mask2, do_list_attr, do_list_fn, True, True);
}
return;
/****************************************************************************
a wrapper around cli_list that adds recursion
****************************************************************************/
-void do_list(const char *mask,int attribute,void (*fn)(file_info *),BOOL rec, BOOL dirs)
+void do_list(const char *mask,uint16 attribute,void (*fn)(file_info *),BOOL rec, BOOL dirs)
{
do_list_recurse = rec;
do_list_dirs = dirs;
****************************************************************************/
static void cmd_dir(void)
{
- int attribute = aDIR | aSYSTEM | aHIDDEN;
+ uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
pstring mask;
fstring buf;
char *p=buf;
pstrcat(mask,p);
}
else {
- pstrcat(mask,"*.*");
+ pstrcat(mask,"*");
}
do_list(mask, attribute, display_finfo, recurse, True);
****************************************************************************/
static void cmd_du(void)
{
- int attribute = aDIR | aSYSTEM | aHIDDEN;
+ uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
pstring mask;
fstring buf;
char *p=buf;
else
pstrcat(mask,p);
} else {
- pstrcat(mask,"*.*");
+ pstrcat(mask,"*");
}
do_list(mask, attribute, do_du, recurse, True);
char *data;
struct timeval tp_start;
int read_size = 65520;
- uint32 attr;
+ uint16 attr;
size_t size;
off_t nread = 0;
if(!strcmp(lname,"-")) {
handle = fileno(stdout);
} else {
- handle = open(lname,O_WRONLY|O_CREAT|O_TRUNC,0644);
+ handle = sys_open(lname,O_WRONLY|O_CREAT|O_TRUNC,0644);
newhandle = True;
}
if (handle < 0) {
}
- if (!cli_getattrE(cli, fnum, &attr, &size, NULL, NULL, NULL)) {
- DEBUG(0,("getattrE: %s\n",cli_errstr(cli)));
+ if (!cli_qfileinfo(cli, fnum,
+ &attr, &size, NULL, NULL, NULL, NULL, NULL) &&
+ !cli_getattrE(cli, fnum,
+ &attr, &size, NULL, NULL, NULL)) {
+ DEBUG(0,("getattrib: %s\n",cli_errstr(cli)));
return;
}
-
DEBUG(2,("getting file %s of size %.0f as %s ",
lname, (double)size, lname));
}
if (archive_level >= 2 && (attr & aARCH)) {
- cli_setatr(cli, rname, attr & ~aARCH, 0);
+ cli_setatr(cli, rname, attr & ~(uint16)aARCH, 0);
}
{
if (lowercase)
strlower(finfo->name);
- if (!directory_exist(finfo->name,NULL) &&
+ if (!dos_directory_exist(finfo->name,NULL) &&
dos_mkdir(finfo->name,0777) != 0) {
DEBUG(0,("failed to create directory %s\n",CNV_LANG(finfo->name)));
pstrcpy(cur_dir,saved_curdir);
}
pstrcpy(mget_mask,cur_dir);
- pstrcat(mget_mask,"*.*");
+ pstrcat(mget_mask,"*");
do_list(mget_mask, aSYSTEM | aHIDDEN | aDIR,do_mget,False, True);
chdir("..");
****************************************************************************/
static void cmd_mget(void)
{
- int attribute = aSYSTEM | aHIDDEN;
+ uint16 attribute = aSYSTEM | aHIDDEN;
pstring mget_mask;
fstring buf;
char *p=buf;
pstrcpy(mget_mask,cur_dir);
if(mget_mask[strlen(mget_mask)-1]!='\\')
pstrcat(mget_mask,"\\");
- pstrcat(mget_mask,"*.*");
+ pstrcat(mget_mask,"*");
do_list(mget_mask, attribute,do_mget,False,True);
}
}
f = stdin;
/* size of file is not known */
} else {
- f = fopen(lname,"r");
+ f = sys_fopen(lname,"r");
}
if (!f) {
pstring rname;
fstring buf;
char *p=buf;
- file_info finfo;
- finfo = def_finfo;
pstrcpy(rname,cur_dir);
pstrcat(rname,"\\");
DEBUG(0,("%s does not exist\n",lname));
return;
}
- finfo.mtime = st.st_mtime;
}
do_put(rname,lname);
{
pstring lname;
pstring rname;
- file_info finfo;
fstring buf;
char *p=buf;
- finfo = def_finfo;
-
while (next_token(NULL,p,NULL,sizeof(buf))) {
SMB_STRUCT_STAT st;
pstring cmd;
"/bin/ls %s > %s",p,tmpname);
system(cmd);
- f = fopen(tmpname,"r");
+ f = sys_fopen(tmpname,"r");
if (!f) continue;
while (!feof(f)) {
dos_format(rname);
- /* null size so do_put knows to ignore it */
- finfo.size = -1;
-
- /* set the date on the file */
- finfo.mtime = st.st_mtime;
-
do_put(rname,lname);
}
fclose(f);
{
pstring mask;
fstring buf;
- int attribute = aSYSTEM | aHIDDEN;
+ uint16 attribute = aSYSTEM | aHIDDEN;
if (recurse)
attribute |= aDIR;
pstring d;
if (next_token(NULL,buf,NULL,sizeof(buf)))
- dos_chdir(buf);
- DEBUG(2,("the local directory is now %s\n",GetWd(d)));
+ chdir(buf);
+ DEBUG(2,("the local directory is now %s\n",sys_getwd(d)));
}
/****************************************************************************
ip = ipzero;
- strupper(server);
-
make_nmb_name(&calling, global_myname, 0x0, "");
make_nmb_name(&called , server, name_type, "");
+ if (port == 0)
+ port = 139; /* If not set, set to 139, FIXME, NUMBERS BAD */
+
again:
ip = ipzero;
if (have_ip) ip = dest_ip;
/* have to open a new connection */
- if (!(c=cli_initialise(NULL)) || !cli_connect(c, server_n, &ip)) {
+ if (!(c=cli_initialise(NULL)) || (cli_set_port(c, port) == 0) ||
+ !cli_connect(c, server_n, &ip)) {
DEBUG(0,("Connection to %s failed\n", server_n));
return NULL;
}
return NULL;
}
+ /*
+ * These next two lines are needed to emulate
+ * old client behaviour for people who have
+ * scripts based on client output.
+ * QUESTION ? Do we want to have a 'client compatibility
+ * mode to turn these on/off ? JRA.
+ */
+
+ if (*c->server_domain || *c->server_os || *c->server_type)
+ DEBUG(1,("Domain=[%s] OS=[%s] Server=[%s]\n",
+ c->server_domain,c->server_os,c->server_type));
+
DEBUG(4,(" session setup ok\n"));
if (!cli_send_tconX(c, share, "?????",
static BOOL process(char *base_directory)
{
cli = do_connect(desthost, service);
-
if (!cli) {
return(False);
}
-
+
if (*base_directory) do_cd(base_directory);
if (cmdstr) {
sscanf(p, "%d", &fd);
close_it = False;
} else if ((p = getenv("PASSWD_FILE")) != NULL) {
- fd = open(p, O_RDONLY);
+ fd = sys_open(p, O_RDONLY, 0);
pstrcpy(spec, p);
if (fd < 0) {
fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n",
static int do_host_query(char *query_host, int port)
{
cli = do_connect(query_host, "IPC$");
- if (!cli) return 1;
+ if (!cli)
+ return 1;
browse_host(True);
list_servers(workgroup);
{
int ret;
cli = do_connect(desthost, service);
+ if (!cli)
+ return 1;
recurse=True;
ip = ipzero;
- strupper(desthost);
-
make_nmb_name(&calling, global_myname, 0x0, "");
make_nmb_name(&called , desthost, name_type, "");
{
fstring base_directory;
char *pname = argv[0];
- int port = SMB_PORT;
int opt;
extern FILE *dbf;
extern char *optarg;
case 'M':
name_type = 0x03; /* messages are sent to NetBIOS name type 0x3 */
pstrcpy(desthost,optarg);
- strupper(desthost);
message = True;
break;
case 'i':
break;
case 'N':
got_pass = True;
- no_pass = True;
break;
case 'n':
pstrcpy(global_myname,optarg);
}
break;
case 'L':
- got_pass = True;
pstrcpy(query_host,optarg);
if(!explicit_user)
*username = '\0';
}
get_myname((*global_myname)?NULL:global_myname,NULL);
- strupper(global_myname);
if(*new_name_resolve_order)
lp_set_name_resolve_order(new_name_resolve_order);