4 Unix SMB/Netbios implementation.
7 Copyright (C) Andrew Tridgell 1992-1998
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 This file handles the messaging system calls for winpopup style
31 /* look in server.c for some explanation of these variables */
32 extern int DEBUGLEVEL;
35 static char msgbuf[1600];
37 static fstring msgfrom="";
38 static fstring msgto="";
40 /****************************************************************************
42 ****************************************************************************/
43 static void msg_deliver(void)
50 if (! (*lp_msg_command()))
52 DEBUG(1,("no messaging command specified\n"));
57 /* put it in a temporary file */
58 slprintf(s,sizeof(s)-1, "%s/msg.XXXXXX",tmpdir());
59 fstrcpy(name,(char *)smbd_mktemp(s));
61 fd = sys_open(name,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL,0600);
63 DEBUG(1,("can't open message file %s\n",name));
68 * Incoming message is in DOS codepage format. Convert to UNIX in
73 msgbuf[msgpos] = '\0'; /* Ensure null terminated. */
74 dos_to_unix(msgbuf,True);
78 if (msgbuf[i]=='\r' && i<(msgpos-1) && msgbuf[i+1]=='\n') {
81 write(fd,&msgbuf[i++],1);
87 if (*lp_msg_command())
89 fstring alpha_msgfrom;
92 pstrcpy(s,lp_msg_command());
93 pstring_sub(s,"%s",name);
94 pstring_sub(s,"%f",alpha_strcpy(alpha_msgfrom,msgfrom,sizeof(alpha_msgfrom)));
95 pstring_sub(s,"%t",alpha_strcpy(alpha_msgto,msgto,sizeof(alpha_msgto)));
96 standard_sub_basic(s);
105 /****************************************************************************
107 ****************************************************************************/
108 int reply_sends(connection_struct *conn,
109 char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
112 char *orig,*dest,*msg;
117 if (! (*lp_msg_command()))
118 return(ERROR(ERRSRV,ERRmsgoff));
120 outsize = set_message(outbuf,0,0,True);
122 orig = smb_buf(inbuf)+1;
123 dest = skip_string(orig,1)+1;
124 msg = skip_string(dest,1)+1;
126 fstrcpy(msgfrom,orig);
130 len = MIN(len,sizeof(msgbuf)-msgpos);
132 memset(msgbuf,'\0',sizeof(msgbuf));
134 memcpy(&msgbuf[msgpos],msg+2,len);
137 DEBUG( 3, ( "SMBsends (from %s to %s)\n", orig, dest ) );
145 /****************************************************************************
147 ****************************************************************************/
148 int reply_sendstrt(connection_struct *conn,
149 char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
154 if (! (*lp_msg_command()))
155 return(ERROR(ERRSRV,ERRmsgoff));
157 outsize = set_message(outbuf,1,0,True);
159 memset(msgbuf,'\0',sizeof(msgbuf));
162 orig = smb_buf(inbuf)+1;
163 dest = skip_string(orig,1)+1;
165 fstrcpy(msgfrom,orig);
168 DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) );
174 /****************************************************************************
176 ****************************************************************************/
177 int reply_sendtxt(connection_struct *conn,
178 char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
184 if (! (*lp_msg_command()))
185 return(ERROR(ERRSRV,ERRmsgoff));
187 outsize = set_message(outbuf,0,0,True);
189 msg = smb_buf(inbuf) + 1;
192 len = MIN(len,sizeof(msgbuf)-msgpos);
194 memcpy(&msgbuf[msgpos],msg+2,len);
197 DEBUG( 3, ( "SMBsendtxt\n" ) );
203 /****************************************************************************
205 ****************************************************************************/
206 int reply_sendend(connection_struct *conn,
207 char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
211 if (! (*lp_msg_command()))
212 return(ERROR(ERRSRV,ERRmsgoff));
214 outsize = set_message(outbuf,0,0,True);
216 DEBUG(3,("SMBsendend\n"));