1 /******************************************************************************
2     (c) 2001-2003 Christine Caulfield                 christine.caulfield@googlemail.com
3 
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     any later version.
8 
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13 ******************************************************************************/
14 
15 #include <sys/types.h>
16 #include <sys/time.h>
17 #include <unistd.h>
18 #include <string.h>
19 
20 #include <sstream>
21 #include <list>
22 #include <string>
23 #include <map>
24 #include <queue>
25 #include <iterator>
26 
27 #include "lat.h"
28 #include "latcp.h"
29 #include "utils.h"
30 #include "services.h"
31 #include "session.h"
32 #include "localport.h"
33 #include "connection.h"
34 #include "circuit.h"
35 #include "latcpcircuit.h"
36 #include "server.h"
37 
38 
send_reply(int cmd,const char * buf,int len)39 bool Circuit::send_reply(int cmd, const char *buf, int len)
40 {
41     char outhead[3];
42 
43     if (len == -1) len=strlen(buf)+1;
44 
45     outhead[0] = cmd;
46     outhead[1] = len/256;
47     outhead[2] = len%256;
48     if (write(fd, outhead, 3) != 3) return false;
49     if (write(fd, buf, len) != len) return false;
50     return true;
51 }
52 
53