summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-11-27 22:58:11 +0000
committerLuke Leighton <lkcl@samba.org>1999-11-27 22:58:11 +0000
commit70b218b3ea5a285f5016a42b483e78f01ac34eba (patch)
tree6b976980d199aaee1c85b13607f1c049bed49785 /source3
parentad1e5fdd96aa2c2d42b14a55c88d39ec0b927014 (diff)
downloadsamba-70b218b3ea5a285f5016a42b483e78f01ac34eba.tar.gz
samba-70b218b3ea5a285f5016a42b483e78f01ac34eba.tar.bz2
samba-70b218b3ea5a285f5016a42b483e78f01ac34eba.zip
moved at command over to new abstract connection system. matthew, you
initialised dest_wks _after_ using it in at_soon() :-) so i fixed this :) (This used to be commit 0aaf0c9c80b4a506955065e822a356b1c43a5ac5)
Diffstat (limited to 'source3')
-rw-r--r--source3/rpc_client/cli_atsvc.c64
-rw-r--r--source3/rpcclient/cmd_atsvc.c31
2 files changed, 58 insertions, 37 deletions
diff --git a/source3/rpc_client/cli_atsvc.c b/source3/rpc_client/cli_atsvc.c
index ba18a36313..9ba87e6e4a 100644
--- a/source3/rpc_client/cli_atsvc.c
+++ b/source3/rpc_client/cli_atsvc.c
@@ -28,8 +28,8 @@ extern int DEBUGLEVEL;
/****************************************************************************
add a job to the scheduler
****************************************************************************/
-BOOL at_add_job(struct cli_state *cli, uint16 fnum,
- char *server_name, AT_JOB_INFO *info, char *command,
+BOOL at_add_job(
+ char *srv_name, AT_JOB_INFO *info, char *command,
uint32 *jobid)
{
prs_struct rbuf;
@@ -37,6 +37,13 @@ BOOL at_add_job(struct cli_state *cli, uint16 fnum,
AT_Q_ADD_JOB q_a;
BOOL p = False;
+ struct cli_connection *con = NULL;
+
+ if (!cli_connection_init(srv_name, PIPE_ATSVC, &con))
+ {
+ return False;
+ }
+
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
@@ -45,13 +52,13 @@ BOOL at_add_job(struct cli_state *cli, uint16 fnum,
DEBUG(4,("Scheduler Add Job\n"));
/* store the parameters */
- make_at_q_add_job(&q_a, server_name, info, command);
+ make_at_q_add_job(&q_a, srv_name, info, command);
/* turn parameters into data stream */
at_io_q_add_job("", &q_a, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, AT_ADD_JOB, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, AT_ADD_JOB, &buf, &rbuf))
{
AT_R_ADD_JOB r_a;
@@ -74,20 +81,28 @@ BOOL at_add_job(struct cli_state *cli, uint16 fnum,
prs_mem_free(&rbuf);
prs_mem_free(&buf );
+ cli_connection_unlink(con);
+
return p;
}
/****************************************************************************
dequeue a job
****************************************************************************/
-BOOL at_del_job(struct cli_state *cli, uint16 fnum,
- char *server_name, uint32 min_jobid, uint32 max_jobid)
+BOOL at_del_job( char *srv_name, uint32 min_jobid, uint32 max_jobid)
{
prs_struct rbuf;
prs_struct buf;
AT_Q_DEL_JOB q_d;
BOOL p = False;
+ struct cli_connection *con = NULL;
+
+ if (!cli_connection_init(srv_name, PIPE_ATSVC, &con))
+ {
+ return False;
+ }
+
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
@@ -96,13 +111,13 @@ BOOL at_del_job(struct cli_state *cli, uint16 fnum,
DEBUG(4,("Scheduler Delete Job\n"));
/* store the parameters */
- make_at_q_del_job(&q_d, server_name, min_jobid, max_jobid);
+ make_at_q_del_job(&q_d, srv_name, min_jobid, max_jobid);
/* turn parameters into data stream */
at_io_q_del_job("", &q_d, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, AT_DEL_JOB, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, AT_DEL_JOB, &buf, &rbuf))
{
AT_R_DEL_JOB r_d;
@@ -120,14 +135,15 @@ BOOL at_del_job(struct cli_state *cli, uint16 fnum,
prs_mem_free(&rbuf);
prs_mem_free(&buf );
+ cli_connection_unlink(con);
+
return p;
}
/****************************************************************************
enumerate scheduled jobs
****************************************************************************/
-BOOL at_enum_jobs(struct cli_state *cli, uint16 fnum,
- char *server_name, uint32 *num_jobs,
+BOOL at_enum_jobs( char *srv_name, uint32 *num_jobs,
AT_ENUM_INFO *jobs, char ***commands)
{
prs_struct rbuf;
@@ -135,6 +151,13 @@ BOOL at_enum_jobs(struct cli_state *cli, uint16 fnum,
AT_Q_ENUM_JOBS q_e;
BOOL p = False;
+ struct cli_connection *con = NULL;
+
+ if (!cli_connection_init(srv_name, PIPE_ATSVC, &con))
+ {
+ return False;
+ }
+
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
@@ -143,13 +166,13 @@ BOOL at_enum_jobs(struct cli_state *cli, uint16 fnum,
DEBUG(4,("Scheduler Enumerate Jobs\n"));
/* store the parameters */
- make_at_q_enum_jobs(&q_e, server_name);
+ make_at_q_enum_jobs(&q_e, srv_name);
/* turn parameters into data stream */
at_io_q_enum_jobs("", &q_e, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, AT_ENUM_JOBS, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, AT_ENUM_JOBS, &buf, &rbuf))
{
AT_R_ENUM_JOBS r_e;
@@ -186,13 +209,15 @@ BOOL at_enum_jobs(struct cli_state *cli, uint16 fnum,
prs_mem_free(&rbuf);
prs_mem_free(&buf );
+ cli_connection_unlink(con);
+
return p;
}
/****************************************************************************
query job information
****************************************************************************/
-BOOL at_query_job(struct cli_state *cli, uint16 fnum, char *server_name,
+BOOL at_query_job(char *srv_name,
uint32 jobid, AT_JOB_INFO *job, fstring command)
{
prs_struct rbuf;
@@ -200,6 +225,13 @@ BOOL at_query_job(struct cli_state *cli, uint16 fnum, char *server_name,
AT_Q_QUERY_JOB q_q;
BOOL p = False;
+ struct cli_connection *con = NULL;
+
+ if (!cli_connection_init(srv_name, PIPE_ATSVC, &con))
+ {
+ return False;
+ }
+
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
@@ -208,13 +240,13 @@ BOOL at_query_job(struct cli_state *cli, uint16 fnum, char *server_name,
DEBUG(4,("Scheduler Query Job\n"));
/* store the parameters */
- make_at_q_query_job(&q_q, server_name, jobid);
+ make_at_q_query_job(&q_q, srv_name, jobid);
/* turn parameters into data stream */
at_io_q_query_job("", &q_q, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, AT_QUERY_JOB, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, AT_QUERY_JOB, &buf, &rbuf))
{
AT_R_QUERY_JOB r_q;
@@ -239,5 +271,7 @@ BOOL at_query_job(struct cli_state *cli, uint16 fnum, char *server_name,
prs_mem_free(&rbuf);
prs_mem_free(&buf );
+ cli_connection_unlink(con);
+
return p;
}
diff --git a/source3/rpcclient/cmd_atsvc.c b/source3/rpcclient/cmd_atsvc.c
index 39dc5213cf..547ca96053 100644
--- a/source3/rpcclient/cmd_atsvc.c
+++ b/source3/rpcclient/cmd_atsvc.c
@@ -33,7 +33,6 @@ extern int DEBUGLEVEL;
#define DEBUG_TESTING
-extern struct cli_state *smb_cli;
extern FILE* out_hnd;
@@ -160,7 +159,6 @@ scheduler add job
****************************************************************************/
void cmd_at(struct client_info *info, int argc, char *argv[])
{
- uint16 nt_pipe_fnum;
fstring dest_wks;
BOOL add = False;
BOOL del = False;
@@ -173,6 +171,10 @@ void cmd_at(struct client_info *info, int argc, char *argv[])
uint8 flags = JOB_NONINTERACTIVE;
pstring command;
+ safe_strcpy(dest_wks, "\\\\", sizeof(dest_wks));
+ safe_strcat(dest_wks, info->dest_host, sizeof(dest_wks));
+ strupper(dest_wks);
+
while (argc > 1)
{
argc--;
@@ -289,14 +291,6 @@ void cmd_at(struct client_info *info, int argc, char *argv[])
return;
}
- safe_strcpy(dest_wks, "\\\\", sizeof(dest_wks));
- safe_strcat(dest_wks, info->dest_host, sizeof(dest_wks));
- strupper(dest_wks);
-
- /* open scheduler session. */
- if (!cli_nt_session_open(smb_cli, PIPE_ATSVC, &nt_pipe_fnum))
- return;
-
if (add) /* add job */
{
AT_JOB_INFO job;
@@ -311,8 +305,7 @@ void cmd_at(struct client_info *info, int argc, char *argv[])
display_at_job_info(out_hnd, ACTION_ENUMERATE, &job, command);
display_at_job_info(out_hnd, ACTION_FOOTER , &job, command);
- if (at_add_job(smb_cli, nt_pipe_fnum, dest_wks, &job,
- command, &jobid))
+ if (at_add_job(dest_wks, &job, command, &jobid))
{
fprintf(out_hnd, "\tJob ID: %d\n\n", jobid);
}
@@ -322,14 +315,12 @@ void cmd_at(struct client_info *info, int argc, char *argv[])
if (jobid == -1)
{
fprintf(out_hnd, "\tDeleting all jobs.\n\n");
- at_del_job(smb_cli, nt_pipe_fnum, dest_wks,
- 0, 0xffffffff);
+ at_del_job(dest_wks, 0, 0xffffffff);
}
else
{
fprintf(out_hnd, "\tDeleting job %d.\n\n", jobid);
- at_del_job(smb_cli, nt_pipe_fnum, dest_wks,
- jobid, jobid);
+ at_del_job(dest_wks, jobid, jobid);
}
}
@@ -339,8 +330,7 @@ void cmd_at(struct client_info *info, int argc, char *argv[])
char **commands;
uint32 num_jobs;
- if (at_enum_jobs(smb_cli, nt_pipe_fnum, dest_wks, &num_jobs,
- jobs, &commands))
+ if (at_enum_jobs(dest_wks, &num_jobs, jobs, &commands))
{
display_at_enum_info(out_hnd, ACTION_HEADER , num_jobs, jobs, commands);
display_at_enum_info(out_hnd, ACTION_ENUMERATE, num_jobs, jobs, commands);
@@ -353,14 +343,11 @@ void cmd_at(struct client_info *info, int argc, char *argv[])
{
AT_JOB_INFO job;
- if (at_query_job(smb_cli, nt_pipe_fnum, dest_wks, jobid, &job, command))
+ if (at_query_job(dest_wks, jobid, &job, command))
{
display_at_job_info(out_hnd, ACTION_HEADER , &job, command);
display_at_job_info(out_hnd, ACTION_ENUMERATE, &job, command);
display_at_job_info(out_hnd, ACTION_FOOTER , &job, command);
}
}
-
- /* close the session */
- cli_nt_session_close(smb_cli, nt_pipe_fnum);
}