~ubuntu-branches/ubuntu/natty/orbit2/natty

« back to all changes in this revision

Viewing changes to test/everything/sequenceServer.c

  • Committer: Bazaar Package Importer
  • Author(s): Chris Waters
  • Date: 2002-03-25 17:24:03 UTC
  • Revision ID: james.westby@ubuntu.com-20020325172403-8lexv63608acfqgt
Tags: upstream-2.3.107
ImportĀ upstreamĀ versionĀ 2.3.107

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * CORBA C language mapping tests
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License as published by the
 
6
 * Free Software Foundation; either version 2, or (at your option) any
 
7
 * 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
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software Foundation,
 
16
 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
 *
 
18
 * Author: Phil Dawes <philipd@users.sourceforge.net>
 
19
 */
 
20
 
 
21
 
 
22
#include "everything.h"
 
23
#include "constants.h"
 
24
#include <stdio.h>
 
25
 
 
26
static  
 
27
test_StrSeq *
 
28
SequenceServer_opStrSeq(PortableServer_Servant _servant,
 
29
                                                const test_StrSeq * inArg,
 
30
                                                test_StrSeq * inoutArg,
 
31
                                                test_StrSeq ** outArg,
 
32
                                                CORBA_Environment * ev) {
 
33
  test_StrSeq *retn;
 
34
  guint i;
 
35
  for (i=0;i<inArg->_length;i++){
 
36
        g_assert(strcmp(inArg->_buffer[i],constants_SEQ_STRING_IN[i]) == 0);
 
37
  }
 
38
  
 
39
  for (i=0;i<inoutArg->_length;i++){
 
40
        g_assert(strcmp(inoutArg->_buffer[i],constants_SEQ_STRING_INOUT_IN[i]) == 0);
 
41
  }
 
42
 
 
43
  if (CORBA_sequence_get_release (inoutArg))
 
44
    CORBA_free(inoutArg->_buffer);
 
45
  inoutArg->_buffer = CORBA_sequence_CORBA_string_allocbuf(2);
 
46
  inoutArg->_length = 2;
 
47
  CORBA_sequence_set_release(inoutArg, CORBA_TRUE);
 
48
  
 
49
  for (i=0;i<inoutArg->_length;i++)
 
50
        inoutArg->_buffer[i] = CORBA_string_dup(constants_SEQ_STRING_INOUT_OUT[i]);
 
51
  
 
52
  *outArg = CORBA_sequence_CORBA_string__alloc();
 
53
  (*outArg)->_buffer = CORBA_sequence_CORBA_string_allocbuf(2);
 
54
  (*outArg)->_length = 2;
 
55
  CORBA_sequence_set_release(*outArg, CORBA_TRUE);
 
56
 
 
57
  for (i=0;i<(*outArg)->_length;i++)
 
58
        (*outArg)->_buffer[i] = CORBA_string_dup(constants_SEQ_STRING_OUT[i]);
 
59
  
 
60
  
 
61
  retn = CORBA_sequence_CORBA_string__alloc();
 
62
  retn->_buffer = CORBA_sequence_CORBA_string_allocbuf(2);
 
63
  retn->_length = 2;
 
64
  CORBA_sequence_set_release(retn, CORBA_TRUE);
 
65
 
 
66
  for (i=0;i<retn->_length;i++)
 
67
        retn->_buffer[i] = CORBA_string_dup(constants_SEQ_STRING_RETN[i]);
 
68
 
 
69
  return retn;
 
70
}
 
71
 
 
72
static
 
73
test_BoundedStructSeq *
 
74
SequenceServer_opBoundedStructSeq(PortableServer_Servant _servant,
 
75
                                                                  const test_BoundedStructSeq * inArg,
 
76
                                                                  test_BoundedStructSeq * inoutArg,
 
77
                                                                  test_BoundedStructSeq ** outArg,
 
78
                                                                  CORBA_Environment * ev){
 
79
  test_BoundedStructSeq *retn;
 
80
  CORBA_long i;
 
81
  for (i=0;i<inArg->_length;i++){
 
82
        g_assert(strcmp(inArg->_buffer[i].a.a,constants_SEQ_STRING_IN[i]) == 0);
 
83
  }
 
84
  
 
85
  for (i=0;i<inoutArg->_length;i++){
 
86
        g_assert(strcmp(inoutArg->_buffer[i].a.a,constants_SEQ_STRING_INOUT_IN[i]) == 0);
 
87
  }
 
88
 
 
89
  if (CORBA_sequence_get_release (inoutArg))
 
90
    CORBA_free(inoutArg->_buffer);
 
91
  inoutArg->_buffer = CORBA_sequence_test_CompoundStruct_allocbuf(2);
 
92
  inoutArg->_length = 2;
 
93
  CORBA_sequence_set_release(inoutArg, CORBA_TRUE);
 
94
  
 
95
  for (i=0;i<inoutArg->_length;i++)
 
96
        inoutArg->_buffer[i].a.a = CORBA_string_dup(constants_SEQ_STRING_INOUT_OUT[i]);
 
97
  
 
98
  *outArg = CORBA_sequence_test_CompoundStruct__alloc();
 
99
  (*outArg)->_buffer = CORBA_sequence_test_CompoundStruct_allocbuf(2);
 
100
  (*outArg)->_length = 2;
 
101
  CORBA_sequence_set_release(*outArg, CORBA_TRUE);
 
102
 
 
103
  for (i=0;i<(*outArg)->_length;i++)
 
104
        (*outArg)->_buffer[i].a.a = CORBA_string_dup(constants_SEQ_STRING_OUT[i]);
 
105
  
 
106
  
 
107
  retn = CORBA_sequence_test_CompoundStruct__alloc();
 
108
  retn->_buffer = CORBA_sequence_test_CompoundStruct_allocbuf(2);
 
109
  retn->_length = 2;
 
110
  CORBA_sequence_set_release(retn, CORBA_TRUE);
 
111
 
 
112
  for (i=0;i<retn->_length;i++)
 
113
        retn->_buffer[i].a.a = CORBA_string_dup(constants_SEQ_STRING_RETN[i]);
 
114
 
 
115
  return retn;
 
116
}
 
117
 
 
118
 
 
119
 
 
120
PortableServer_ServantBase__epv SequenceServer_base_epv = {NULL,NULL,NULL};
 
121
 
 
122
POA_test_SequenceServer__epv SequenceServer_epv = {
 
123
  NULL,
 
124
  SequenceServer_opStrSeq,
 
125
  SequenceServer_opBoundedStructSeq,
 
126
};
 
127
 
 
128
POA_test_SequenceServer__vepv SequenceServer_vepv = {&SequenceServer_base_epv,&SequenceServer_epv};
 
129
 
 
130
POA_test_SequenceServer SequenceServer_servant = {NULL,&SequenceServer_vepv};  /* Singleton */