mirror of
https://github.com/samba-team/samba.git
synced 2024-12-30 13:18:05 +03:00
Patch from Samuel Thibault to convert messages from unix to dos charset. Works
on 2000. sending messages to 9x needs to be fixed, but that didn't work anyway
This commit is contained in:
parent
05b1681b03
commit
ca066502a2
@ -186,7 +186,7 @@ size_t convert_string(charset_t from, charset_t to,
|
||||
* @returns Size in bytes of the converted string; or -1 in case of error.
|
||||
**/
|
||||
|
||||
static size_t convert_string_allocate(charset_t from, charset_t to,
|
||||
size_t convert_string_allocate(charset_t from, charset_t to,
|
||||
void const *src, size_t srclen, void **dest)
|
||||
{
|
||||
size_t i_len, o_len, destlen;
|
||||
|
@ -65,6 +65,8 @@ send a message
|
||||
****************************************************************************/
|
||||
BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp)
|
||||
{
|
||||
char *msgdos;
|
||||
int lendos;
|
||||
char *p;
|
||||
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
@ -77,9 +79,18 @@ BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp)
|
||||
|
||||
p = smb_buf(cli->outbuf);
|
||||
*p++ = 1;
|
||||
SSVAL(p,0,len); p += 2;
|
||||
memcpy(p,msg,len);
|
||||
p += len;
|
||||
|
||||
if ((lendos = convert_string_allocate(CH_UNIX, CH_DOS, msg,len, (void **) &msgdos)) < 0 || !msgdos) {
|
||||
DEBUG(3,("Conversion failed, sending message in UNIX charset\n"));
|
||||
SSVAL(p, 0, len); p += 2;
|
||||
memcpy(p, msg, len);
|
||||
p += len;
|
||||
} else {
|
||||
SSVAL(p, 0, lendos); p += 2;
|
||||
memcpy(p, msgdos, lendos);
|
||||
p += lendos;
|
||||
SAFE_FREE(msgdos);
|
||||
}
|
||||
|
||||
cli_setup_bcc(cli, p);
|
||||
cli_send_smb(cli);
|
||||
|
@ -41,6 +41,8 @@ static void msg_deliver(void)
|
||||
pstring name;
|
||||
int i;
|
||||
int fd;
|
||||
char *msg;
|
||||
int len;
|
||||
|
||||
if (! (*lp_msg_command()))
|
||||
{
|
||||
@ -61,16 +63,23 @@ static void msg_deliver(void)
|
||||
/*
|
||||
* Incoming message is in DOS codepage format. Convert to UNIX.
|
||||
*/
|
||||
|
||||
if(msgpos > 0) {
|
||||
msgbuf[msgpos] = '\0'; /* Ensure null terminated. */
|
||||
}
|
||||
|
||||
for (i=0;i<msgpos;) {
|
||||
if (msgbuf[i]=='\r' && i<(msgpos-1) && msgbuf[i+1]=='\n') {
|
||||
i++; continue;
|
||||
|
||||
if ((len = convert_string_allocate(CH_DOS, CH_UNIX, msgbuf, msgpos, (void **) &msg)) < 0 || !msg) {
|
||||
DEBUG(3,("Conversion failed, delivering message in DOS codepage format\n"));
|
||||
for (i = 0; i < msgpos;) {
|
||||
if (msgbuf[i] == '\r' && i < (msgpos-1) && msgbuf[i+1] == '\n') {
|
||||
i++; continue;
|
||||
}
|
||||
write(fd, &msgbuf[i++], 1);
|
||||
}
|
||||
write(fd,&msgbuf[i++],1);
|
||||
} else {
|
||||
for (i = 0; i < len;) {
|
||||
if (msg[i] == '\r' && i < (len-1) && msg[i+1] == '\n') {
|
||||
i++; continue;
|
||||
}
|
||||
write(fd, &msg[i++],1);
|
||||
}
|
||||
SAFE_FREE(msg);
|
||||
}
|
||||
close(fd);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user