[GLUE] Rsync SAMBA_3_0 SVN r25598 in order to create the v3-0-test branch.
[Samba.git] / source / rpc_server / srv_echo_nt.c
blob89519602bce19cc5d0dd826f0c525582f0cdac71
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines for rpcecho
4 * Copyright (C) Tim Potter 2003.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 /* This is the interface to the rpcecho pipe. */
23 #include "includes.h"
24 #include "nterr.h"
26 #ifdef DEVELOPER
28 #undef DBGC_CLASS
29 #define DBGC_CLASS DBGC_RPC_SRV
31 /* Add one to the input and return it */
33 void _echo_add_one(pipes_struct *p, ECHO_Q_ADD_ONE *q_u, ECHO_R_ADD_ONE *r_u)
35 DEBUG(10, ("_echo_add_one\n"));
37 r_u->response = q_u->request + 1;
40 /* Echo back an array of data */
42 void _echo_data(pipes_struct *p, ECHO_Q_ECHO_DATA *q_u,
43 ECHO_R_ECHO_DATA *r_u)
45 DEBUG(10, ("_echo_data\n"));
47 if (q_u->size == 0) {
48 r_u->data = NULL;
49 r_u->size = 0;
50 return;
52 r_u->data = TALLOC(p->mem_ctx, q_u->size);
53 r_u->size = q_u->size;
54 memcpy(r_u->data, q_u->data, q_u->size);
57 /* Sink an array of data */
59 void _sink_data(pipes_struct *p, ECHO_Q_SINK_DATA *q_u,
60 ECHO_R_SINK_DATA *r_u)
62 DEBUG(10, ("_sink_data\n"));
64 /* My that was some yummy data! */
67 /* Source an array of data */
69 void _source_data(pipes_struct *p, ECHO_Q_SOURCE_DATA *q_u,
70 ECHO_R_SOURCE_DATA *r_u)
72 uint32 i;
74 DEBUG(10, ("_source_data\n"));
76 if (q_u->size == 0) {
77 r_u->data = NULL;
78 r_u->size = 0;
79 return;
81 r_u->data = TALLOC(p->mem_ctx, q_u->size);
82 r_u->size = q_u->size;
84 for (i = 0; i < r_u->size; i++)
85 r_u->data[i] = i & 0xff;
88 #endif /* DEVELOPER */