2 Unix SMB/Netbios implementation.
5 Copyright (C) Andrew Tridgell 1992-1995
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 This file handles the messaging system calls for winpopup style
30 /* look in server.c for some explanation of these variables */
31 extern int DEBUGLEVEL;
34 static char msgbuf[1600];
36 static fstring msgfrom="";
37 static fstring msgto="";
39 /****************************************************************************
41 ****************************************************************************/
42 static void msg_deliver(void)
49 if (! (*lp_msg_command()))
51 DEBUG(1,("no messaging command specified\n"));
56 /* put it in a temporary file */
57 sprintf(s,"/tmp/msg.XXXXXX");
58 strcpy(name,(char *)mktemp(s));
63 DEBUG(1,("can't open message file %s\n",name));
69 if (msgbuf[i]=='\r' && i<(msgpos-1) && msgbuf[i+1]=='\n')
78 if (*lp_msg_command())
80 strcpy(s,lp_msg_command());
81 string_sub(s,"%s",name);
82 string_sub(s,"%f",msgfrom);
83 string_sub(s,"%t",msgto);
93 /****************************************************************************
95 ****************************************************************************/
96 int reply_sends(char *inbuf,char *outbuf)
99 char *orig,*dest,*msg;
105 if (! (*lp_msg_command()))
106 return(ERROR(ERRSRV,ERRmsgoff));
108 outsize = set_message(outbuf,0,0,True);
110 orig = smb_buf(inbuf)+1;
111 dest = skip_string(orig,1)+1;
112 msg = skip_string(dest,1)+1;
114 strcpy(msgfrom,orig);
118 len = MIN(len,1600-msgpos);
120 memcpy(&msgbuf[msgpos],msg+2,len);
123 DEBUG(3,("%s SMBsends (from %s to %s)\n",timestring(),orig,dest));
131 /****************************************************************************
133 ****************************************************************************/
134 int reply_sendstrt(char *inbuf,char *outbuf)
139 if (! (*lp_msg_command()))
140 return(ERROR(ERRSRV,ERRmsgoff));
142 outsize = set_message(outbuf,1,0,True);
146 orig = smb_buf(inbuf)+1;
147 dest = skip_string(orig,1)+1;
149 strcpy(msgfrom,orig);
152 DEBUG(3,("%s SMBsendstrt (from %s to %s)\n",timestring(),orig,dest));
158 /****************************************************************************
160 ****************************************************************************/
161 int reply_sendtxt(char *inbuf,char *outbuf)
167 if (! (*lp_msg_command()))
168 return(ERROR(ERRSRV,ERRmsgoff));
170 outsize = set_message(outbuf,0,0,True);
172 msg = smb_buf(inbuf) + 1;
175 len = MIN(len,1600-msgpos);
177 memcpy(&msgbuf[msgpos],msg+2,len);
180 DEBUG(3,("%s SMBsendtxt\n",timestring()));
186 /****************************************************************************
188 ****************************************************************************/
189 int reply_sendend(char *inbuf,char *outbuf)
193 if (! (*lp_msg_command()))
194 return(ERROR(ERRSRV,ERRmsgoff));
196 outsize = set_message(outbuf,0,0,True);
198 DEBUG(3,("%s SMBsendend\n",timestring()));