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;
114 START_PROFILE(SMBsends);
118 if (! (*lp_msg_command())) {
119 END_PROFILE(SMBsends);
120 return(ERROR(ERRSRV,ERRmsgoff));
123 outsize = set_message(outbuf,0,0,True);
125 orig = smb_buf(inbuf)+1;
126 dest = skip_string(orig,1)+1;
127 msg = skip_string(dest,1)+1;
129 fstrcpy(msgfrom,orig);
133 len = MIN(len,sizeof(msgbuf)-msgpos);
135 memset(msgbuf,'\0',sizeof(msgbuf));
137 memcpy(&msgbuf[msgpos],msg+2,len);
140 DEBUG( 3, ( "SMBsends (from %s to %s)\n", orig, dest ) );
144 END_PROFILE(SMBsends);
149 /****************************************************************************
151 ****************************************************************************/
152 int reply_sendstrt(connection_struct *conn,
153 char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
157 START_PROFILE(SMBsendstrt);
159 if (! (*lp_msg_command())) {
160 END_PROFILE(SMBsendstrt);
161 return(ERROR(ERRSRV,ERRmsgoff));
164 outsize = set_message(outbuf,1,0,True);
166 memset(msgbuf,'\0',sizeof(msgbuf));
169 orig = smb_buf(inbuf)+1;
170 dest = skip_string(orig,1)+1;
172 fstrcpy(msgfrom,orig);
175 DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) );
177 END_PROFILE(SMBsendstrt);
182 /****************************************************************************
184 ****************************************************************************/
185 int reply_sendtxt(connection_struct *conn,
186 char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
191 START_PROFILE(SMBsendtxt);
193 if (! (*lp_msg_command())) {
194 END_PROFILE(SMBsendtxt);
195 return(ERROR(ERRSRV,ERRmsgoff));
198 outsize = set_message(outbuf,0,0,True);
200 msg = smb_buf(inbuf) + 1;
203 len = MIN(len,sizeof(msgbuf)-msgpos);
205 memcpy(&msgbuf[msgpos],msg+2,len);
208 DEBUG( 3, ( "SMBsendtxt\n" ) );
210 END_PROFILE(SMBsendtxt);
215 /****************************************************************************
217 ****************************************************************************/
218 int reply_sendend(connection_struct *conn,
219 char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
222 START_PROFILE(SMBsendend);
224 if (! (*lp_msg_command())) {
225 END_PROFILE(SMBsendend);
226 return(ERROR(ERRSRV,ERRmsgoff));
229 outsize = set_message(outbuf,0,0,True);
231 DEBUG(3,("SMBsendend\n"));
235 END_PROFILE(SMBsendend);