aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ic/doc/src/ic_clib.xml
blob: 2fbe766c9f797ebff1079f4b9143a9926b446511 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE cref SYSTEM "cref.dtd">

<cref>
  <header>
    <copyright>
      <year>2003</year><year>2013</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
 
          http://www.apache.org/licenses/LICENSE-2.0

      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
    
    </legalnotice>

    <title>IC C Library Functions</title>
    <prepared></prepared>
    <docno></docno>
    <date>2003-12-16</date>
    <rev>PB1</rev>
  </header>
  <lib>ic_clib</lib>
  <libsummary>IC C Library Functions</libsummary>
  <description>
    <p>This manual page lists some of the functions in the IC C runtime
      library. </p>
  </description>

  <section>
    <title>Allocation and Deallocation Functions</title>
    <p>The following functions are used for allocating and
      deallocating a <em>CORBA_Environment</em> structure.</p>
  </section>
  <funcs>
    <func>
      <name><ret>CORBA_Environment *</ret><nametext>CORBA_Environment_alloc(int inbufsz, int outbufsz)</nametext></name>
      <fsummary>Allocate environment data.</fsummary>
      <desc>
        <p>This function is used to allocate and initiate the
          <c>CORBA_Environment</c> structure. In particular, it is used
          to dynamically allocate a CORBA_Environment structure and set
          the default values for the structure's fields.</p>
        <p><em>inbufsize</em> is the initial size of the input
          buffer.</p>
        <p><em>outbufsize</em> is the initial size of the output
          buffer.</p>
        <p><em>CORBA_Environment</em> is the CORBA 2.0 state structure
          used by the generated stub.</p>
        <p>This function will set all needed default values and
          allocate buffers the lengths of which are equal to the
          values passed, but will not allocate space for the _to_pid
          and _from_pid fields.</p>
        <p>To free the space allocated by CORBA_Environment_alloc() do
          as follows.</p>
        <list type="bulleted">
          <item>
            <p>First call CORBA_free for the input and output buffers.</p>
          </item>
          <item>
            <p>After freeing the buffer space, call CORBA_free for the
              CORBA_Environment space.</p>
          </item>
        </list>
      </desc>
    </func>
    <func>
      <name><ret>void</ret><nametext>CORBA_free(void *p)</nametext></name>
      <fsummary>Free any allocated data.</fsummary>
      <desc>
        <p>Frees allocated space pointed to by <c>p</c>.</p>
      </desc>
    </func>
    <func>
      <name><ret>CORBA_char *</ret><nametext>CORBA_string_alloc(CORBA_unsigned_long len)</nametext></name>
      <fsummary>Allocate a string.</fsummary>
      <desc>
        <p>Allocates a (simple) CORBA character string of length <c>len + 1</c>.</p>
      </desc>
    </func>
    <func>
      <name><ret>CORBA_wchar *</ret><nametext>CORBA_wstring_alloc(CORBA_unsigned_long len)</nametext></name>
      <fsummary>Allocate a wide string.</fsummary>
      <desc>
        <p>Allocates a CORBA wide string of length <c>len + 1</c>.</p>
      </desc>
    </func>
  </funcs>

  <section>
    <title>Exception Functions</title>
    <p>Functions for retrieving exception ids and values, and for setting
      exceptions. </p>
  </section>
  <funcs>
    <func>
      <name><ret>CORBA_char *</ret><nametext>CORBA_exception_id(CORBA_Environment *env)</nametext></name>
      <fsummary>Get exception identity.</fsummary>
      <desc>
        <p>Returns the exception identity if an exception is set, otherwise
          it returns <c>NULL</c>.</p>
      </desc>
    </func>
    <func>
      <name><ret>void *</ret><nametext>CORBA_exception_value(CORBA_Environment *env)</nametext></name>
      <fsummary>Get exception value.</fsummary>
      <desc>
        <p>Returns the exception value, if an exception is set, otherwise
          it returns <c>NULL</c>.</p>
      </desc>
    </func>
    <func>
      <name><ret>void</ret><nametext>CORBA_exc_set(CORBA_Environment *env, CORBA_exception_type Major, CORBA_char *Id, CORBA_char *Value)</nametext></name>
      <fsummary>Set exception.</fsummary>
      <desc>
        <p>Sets the exception type, exception identity, and exception value
          in the environment pointed to by <c>env</c>.</p>
      </desc>
    </func>
  </funcs>

  <section>
    <title>Server Reception</title>
    <p>The following function is provided for convenience. </p>
  </section>
  <funcs>
    <func>
      <name><ret>int</ret><nametext>oe_server_receive(CORBA_Environment *env, oe_map_t *map)</nametext></name>
      <name><ret>int</ret><nametext>oe_server_receive_tmo(CORBA_Environment *env, oe_map_t *map,  unsigned int send_ms, unsigned int recv_ms)</nametext></name>
      <fsummary>Server receive of notification or request, and sending of reply (in case of request).</fsummary>
      <desc>
        <p>Provides a loop that receives one message, executes the
          operation in question, and in case of a two-way operation
          sends a reply.</p>
        <p><c>send_ms</c> and <c>recv_ms</c> specify timeout values
          in milliseconds for send and receive, respectively.</p>
      </desc>
    </func>
  </funcs>

  <section>
    <title>Generic Execution Switch and Map Merging</title>
    <p>Function for searching for server operation function, and for
      calling it if found. Function for merging maps (see the include
      file <c>ic.h</c> for definitions). </p>
  </section>
  <funcs>
    <func>
      <name><ret>int</ret><nametext>oe_exec_switch(CORBA_Object obj, CORBA_Environment *env, oe_map_t *map)</nametext></name>
      <fsummary>Search for server operation and execute it.</fsummary>
      <desc>
        <p>Search for server operation and execute it.</p>
      </desc>
    </func>
    <func>
      <name><ret>oe_map_t *</ret><nametext>oe_merge_maps(oe_map_t *maps, int size)</nametext></name>
      <fsummary>Merge an array of server maps to one single map.</fsummary>
      <desc>
        <p>Merge an array of server maps to one single map.</p>
      </desc>
    </func>
  </funcs>

  <section>
    <title>The CORBA_Environment structure</title>
    <p>Here is the complete definition of the CORBA_Environment structure,
      defined in file <em>ic.h</em>: </p>
    <code type="none">
      /* Environment definition */
      typedef struct {

      /*----- CORBA compatibility part ------------------------*/
      /* Exception tag, initially set to CORBA_NO_EXCEPTION ---*/
      CORBA_exception_type   _major;          

      /*----- External Implementation part - initiated by the user ---*/
      /* File descriptor                                              */
      int                    _fd;             
      /* Size of input buffer                                         */
      int                    _inbufsz;        
      /* Pointer to always dynamically allocated buffer for input     */
      char                  *_inbuf;         
      /* Size of output buffer                                        */
      int                    _outbufsz;       
      /* Pointer to always dynamically allocated buffer for output    */ 
      char                  *_outbuf;        
      /* Size of memory chunks in bytes, used for increasing the output
      buffer, set to >= 32, should be around >= 1024 for performance
      reasons                                                       */ 
      int                    _memchunk;       
      /* Pointer for registered name                                   */
      char                   _regname[256];   
      /* Process identity for caller                                   */
      erlang_pid            *_to_pid;         
      /* Process identity for callee                                  */ 
      erlang_pid            *_from_pid;      

      /*- Internal Implementation part - used by the server/client ---*/
      /* Index for input buffer                                       */
      int                    _iin;            
      /* Index for output buffer                                      */
      int                    _iout;          
      /* Pointer for operation name                                   */
      char                   _operation[256];
      /* Used to count parameters                                    */
      int                    _received;      
      /* Used to identify the caller                                  */
      erlang_pid             _caller;        
      /* Used to identify the call                                     */
      erlang_ref             _unique;         
      /* Exception id field                                           */
      CORBA_char            *_exc_id;        
      /* Exception value field                                        */
      void                  *_exc_value;           

      
      } CORBA_Environment; 
    </code>
    <note>
      <p>Always set the field values <em>_fd</em>, <em>_regname</em>,
        <em>_to_pid</em> and/or <em>*_from_pid</em> to appropriate
        application values. These are not automatically set by the
        stubs.</p>
    </note>
    <warning>
      <p>Never assign static buffers to the buffer pointers, and never
        set the <em>_memchunk</em> field to a value less than
        <em>32</em>.</p>
    </warning>
  </section>

  <section>
    <title>SEE ALSO</title>
    <p>ic(3), ic_c_protocol(3)
      </p>
  </section>
  
</cref>