r22542: Move over to using the _strict varients of the talloc
[sfrench/samba-autobuild/.git] / source3 / rpc_server / srv_echo_nt.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines for rpcecho
4  *  Copyright (C) Tim Potter                   2003.
5  *  Copyright (C) Jelmer Vernooij                          2006.
6  *  
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.
11  *  
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.
16  *  
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.
20  */
21
22 /* This is the interface to the rpcecho pipe. */
23
24 #include "includes.h"
25 #include "nterr.h"
26
27 #ifdef DEVELOPER
28
29 #undef DBGC_CLASS
30 #define DBGC_CLASS DBGC_RPC_SRV
31
32 /* Add one to the input and return it */
33
34 void _echo_AddOne(pipes_struct *p, struct echo_AddOne *r)
35 {
36         DEBUG(10, ("_echo_add_one\n"));
37
38         *r->out.out_data = r->in.in_data + 1;
39 }
40
41 /* Echo back an array of data */
42
43 void _echo_EchoData(pipes_struct *p, struct echo_EchoData *r)
44 {
45         DEBUG(10, ("_echo_data\n"));
46
47         memcpy(r->out.out_data, r->in.in_data, r->in.len);
48 }
49
50 /* Sink an array of data */
51
52 void _echo_SinkData(pipes_struct *p, struct echo_SinkData *r)
53 {
54         DEBUG(10, ("_sink_data\n"));
55
56         /* My that was some yummy data! */
57 }
58
59 /* Source an array of data */
60
61 void _echo_SourceData(pipes_struct *p, struct echo_SourceData *r)
62 {
63         uint32 i;
64
65         DEBUG(10, ("_source_data\n"));
66
67         for (i = 0; i < r->in.len; i++)
68                 r->out.data[i] = i & 0xff;
69 }
70
71 void _echo_TestCall(pipes_struct *p, struct echo_TestCall *r)
72 {
73         *r->out.s2 = talloc_strdup(p->mem_ctx, r->in.s1);
74 }
75
76 NTSTATUS _echo_TestCall2(pipes_struct *p, struct echo_TestCall2 *r)
77 {
78         switch (r->in.level) {
79         case 1:
80                 r->out.info->info1.v = 10;
81                 break;
82         case 2:
83                 r->out.info->info2.v = 20;
84                 break;
85         case 3:
86                 r->out.info->info3.v = 30;
87                 break;
88         case 4:
89                 r->out.info->info4.v = 40;
90                 break;
91         case 5:
92                 r->out.info->info5.v1 = 50;
93                 r->out.info->info5.v2 = 60;
94                 break;
95         case 6:
96                 r->out.info->info6.v1 = 70;
97                 r->out.info->info6.info1.v= 80;
98                 break;
99         case 7:
100                 r->out.info->info7.v1 = 80;
101                 r->out.info->info7.info4.v = 90;
102                 break;
103         default:
104                 return NT_STATUS_INVALID_LEVEL;
105         }
106
107         return NT_STATUS_OK;
108 }
109
110 uint32 _echo_TestSleep(pipes_struct *p, struct echo_TestSleep *r)
111 {
112         sleep(r->in.seconds);
113         return r->in.seconds;
114 }
115
116 void _echo_TestEnum(pipes_struct *p, struct echo_TestEnum *r)
117 {
118 }
119
120 void _echo_TestSurrounding(pipes_struct *p, struct echo_TestSurrounding *r)
121 {
122         r->out.data->x *= 2;
123         r->out.data->surrounding = TALLOC_ZERO_ARRAY(p->mem_ctx, uint16_t, r->in.data->x);
124 }
125
126 uint16 _echo_TestDoublePointer(pipes_struct *p, struct echo_TestDoublePointer *r)
127 {
128         if (!*r->in.data) 
129                 return 0;
130         if (!**r->in.data)
131                 return 0;
132         return ***r->in.data;
133 }
134
135 #endif /* DEVELOPER */