summaryrefslogtreecommitdiff
path: root/source3/client
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-11-10 19:49:41 +0100
committerVolker Lendecke <vl@samba.org>2009-11-10 23:48:22 +0100
commit2b759339601ad853588cb74e986a7a88301aea17 (patch)
tree522b21bfc8ad4024ecfec1987ac4a8378e05e770 /source3/client
parentfd4061daddc33085855f24dd7f36f0038daaeabb (diff)
downloadsamba-2b759339601ad853588cb74e986a7a88301aea17.tar.gz
samba-2b759339601ad853588cb74e986a7a88301aea17.tar.bz2
samba-2b759339601ad853588cb74e986a7a88301aea17.zip
s3: Convert libsmb/cli_message to the async API
Diffstat (limited to 'source3/client')
-rw-r--r--source3/client/client.c54
1 files changed, 16 insertions, 38 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index 6b273b47b0..435ede904e 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -243,51 +243,29 @@ static size_t push_source(uint8_t *buf, size_t n, void *priv)
static void send_message(const char *username)
{
- int total_len = 0;
- int grp_id;
-
- if (!cli_message_start(cli, desthost, username, &grp_id)) {
- d_printf("message start: %s\n", cli_errstr(cli));
- return;
- }
-
-
- d_printf("Connected. Type your message, ending it with a Control-D\n");
-
- while (!feof(stdin) && total_len < 1600) {
- int maxlen = MIN(1600 - total_len,127);
- char msg[1024];
- int l=0;
- int c;
-
- ZERO_ARRAY(msg);
+ char buf[1600];
+ NTSTATUS status;
+ int i;
- for (l=0;l<maxlen && (c=fgetc(stdin))!=EOF;l++) {
- if (c == '\n')
- msg[l++] = '\r';
- msg[l] = c;
- }
+ d_printf("Type your message, ending it with a Control-D\n");
- if ((total_len > 0) && (strlen(msg) == 0)) {
+ i = 0;
+ while (i<sizeof(buf)-2) {
+ int c = fgetc(stdin);
+ if (c == EOF) {
break;
}
-
- if (!cli_message_text(cli, msg, l, grp_id)) {
- d_printf("SMBsendtxt failed (%s)\n",cli_errstr(cli));
- return;
+ if (c == '\n') {
+ buf[i++] = '\r';
}
-
- total_len += l;
+ buf[i++] = c;
}
+ buf[i] = '\0';
- if (total_len >= 1600)
- d_printf("the message was truncated to 1600 bytes\n");
- else
- d_printf("sent %d bytes\n",total_len);
-
- if (!cli_message_end(cli, grp_id)) {
- d_printf("SMBsendend failed (%s)\n",cli_errstr(cli));
- return;
+ status = cli_message(cli, desthost, username, buf);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "cli_message returned %s\n",
+ nt_errstr(status));
}
}