Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 238 lines (203 sloc) 6.732 kb
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
1 .output "include/zsockopt.h"
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
2 .for version
3 . for option
4 . if type = "uint64" | type = "int64" | type = "uint32" | type = "int"
5 . option.ctype = "int"
6 . elsif type = "blob"
7 . option.ctype = "char *" # Enforce C strings
8 . mode = "w" # and read-only
9 . else
10 . echo "E: unknown type: $(type)"
11 . endif
12 . endfor
13 .endfor
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
14 /* =========================================================================
15 zsockopt - get/set 0MQ socket options
16
17 GENERATED SOURCE CODE, DO NOT EDIT
18 -------------------------------------------------------------------------
19 Copyright (c) 1991-2011 iMatix Corporation <www.imatix.com>
20 Copyright other contributors as noted in the AUTHORS file.
21
fcaf6e23 » hintjens
2011-06-09 Renamed czmq to CZMQ
22 This file is part of CZMQ, the high-level C binding for 0MQ:
d5d0ec90 » hintjens
2011-04-26 Released czmq v1.0.0
23 http://czmq.zeromq.org.
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
24
a6ea4069 » hintjens
2011-04-07 Handle ETERM when setting socket options
25 This is free software; you can redistribute it and/or modify it under
26 the terms of the GNU Lesser General Public License as published by
27 the Free Software Foundation; either version 3 of the License, or (at
28 your option) any later version.
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
29
30 This software is distributed in the hope that it will be useful, but
a6ea4069 » hintjens
2011-04-07 Handle ETERM when setting socket options
31 WITHOUT ANY WARRANTY; without even the implied warranty of
32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 Lesser General Public License for more details.
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
34
a6ea4069 » hintjens
2011-04-07 Handle ETERM when setting socket options
35 You should have received a copy of the GNU Lesser General Public
36 License along with this program. If not, see
37 <http://www.gnu.org/licenses/>.
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
38 =========================================================================
39 */
40
41 #ifndef __ZSOCKOPT_H_INCLUDED__
42 #define __ZSOCKOPT_H_INCLUDED__
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 // @interface
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
49 .for version
50 #if (ZMQ_VERSION_MAJOR == $(major))
51 // Get socket options
52 . for option
53 . if mode = "rw" | mode = "r"
54 $(ctype)\
55 zsockopt_$(name) (void *socket);
56 . endif
57 . endfor
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
58
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
59 // Set socket options
60 . for option
61 . if mode = "rw" | mode = "w"
62 void zsockopt_set_$(name) (void *socket, $(ctype) $(name));
63 . endif
64 . endfor
644532ff » hintjens
2011-04-09 Added zsocket_set_hwm emulation to 3.x API
65 . for header
66
67 $(string.trim(.):)
68 . endfor
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
69 #endif
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
70
71 .endfor
72 // Self test of this class
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
73 int zsockopt_test (Bool verbose);
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
74 // @end
75
76 #ifdef __cplusplus
77 }
78 #endif
79
80 #endif
81 .output "src/zsockopt.c"
82 /* =========================================================================
83 zsockopt - get/set 0MQ socket options
84
85 GENERATED SOURCE CODE, DO NOT EDIT
86 -------------------------------------------------------------------------
87 Copyright (c) 1991-2011 iMatix Corporation <www.imatix.com>
88 Copyright other contributors as noted in the AUTHORS file.
89
fcaf6e23 » hintjens
2011-06-09 Renamed czmq to CZMQ
90 This file is part of CZMQ, the high-level C binding for 0MQ:
d5d0ec90 » hintjens
2011-04-26 Released czmq v1.0.0
91 http://czmq.zeromq.org.
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
92
a6ea4069 » hintjens
2011-04-07 Handle ETERM when setting socket options
93 This is free software; you can redistribute it and/or modify it under
94 the terms of the GNU Lesser General Public License as published by
95 the Free Software Foundation; either version 3 of the License, or (at
96 your option) any later version.
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
97
98 This software is distributed in the hope that it will be useful, but
a6ea4069 » hintjens
2011-04-07 Handle ETERM when setting socket options
99 WITHOUT ANY WARRANTY; without even the implied warranty of
100 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
101 Lesser General Public License for more details.
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
102
a6ea4069 » hintjens
2011-04-07 Handle ETERM when setting socket options
103 You should have received a copy of the GNU Lesser General Public
104 License along with this program. If not, see
105 <http://www.gnu.org/licenses/>.
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
106 =========================================================================
107 */
108
109 /*
110 @header
111 The zsockopt class provides access to the 0MQ getsockopt/setsockopt API.
112 @discuss
113 This class is generated, using the GSL code generator. See the sockopts
114 XML file, which provides the metadata, and the sockopts.gsl template,
115 which does the work.
116 @end
117 */
118
d5d0ec90 » hintjens
2011-04-26 Released czmq v1.0.0
119 #include "../include/czmq_prelude.h"
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
120 #include "../include/zctx.h"
121 #include "../include/zsocket.h"
122 #include "../include/zsockopt.h"
123
124
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
125 .for version
126 #if (ZMQ_VERSION_MAJOR == $(major))
127 . for option
128 . if mode = "rw" | mode = "w"
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
129 // --------------------------------------------------------------------------
130 // Set socket ZMQ_$(NAME) value
131
132 void
133 zsockopt_set_$(name) (void *socket, $(ctype) $(name))
134 {
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
135 . if ctype = "int"
136 . if type = "uint64"
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
137 uint64_t value = $(name);
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
138 int rc = zmq_setsockopt (socket, ZMQ_$(NAME), &value, sizeof (uint64_t));
139 . elsif type = "int64"
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
140 int64_t value = $(name);
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
141 int rc = zmq_setsockopt (socket, ZMQ_$(NAME), &value, sizeof (int64_t));
142 . elsif type = "uint32"
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
143 uint32_t value = $(name);
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
144 int rc = zmq_setsockopt (socket, ZMQ_$(NAME), &value, sizeof (uint32_t));
145 . else
146 int rc = zmq_setsockopt (socket, ZMQ_$(NAME), &$(name), sizeof (int));
147 . endif
148 . else
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
149 int rc = zmq_setsockopt (socket, ZMQ_$(NAME), $(name), strlen ($(name)));
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
150 . endif
a6ea4069 » hintjens
2011-04-07 Handle ETERM when setting socket options
151 assert (rc == 0 || errno == ETERM);
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
152 }
153
154
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
155 . endif
156 . if mode = "rw" | mode = "r"
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
157 // --------------------------------------------------------------------------
158 // Return socket ZMQ_$(NAME) value
f62f822d » hintjens
2011-04-15 Trivial whitespace fix
159
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
160 $(ctype)
161 zsockopt_$(name) (void *socket)
162 {
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
163 . if type = "uint64"
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
164 uint64_t $(name);
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
165 size_t type_size = sizeof (uint64_t);
166 . elsif type = "int64"
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
167 int64_t $(name);
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
168 size_t type_size = sizeof (int64_t);
169 . elsif type = "uint32"
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
170 uint32_t $(name);
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
171 size_t type_size = sizeof (uint32_t);
172 . elsif type = "int"
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
173 int $(name);
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
174 size_t type_size = sizeof (int);
175 . endif
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
176 zmq_getsockopt (socket, ZMQ_$(NAME), &$(name), &type_size);
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
177 . if type = "int"
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
178 return $(name);
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
179 . else
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
180 return ($(ctype)) $(name);
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
181 . endif
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
182 }
183
184
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
185 . endif
186 . endfor
644532ff » hintjens
2011-04-09 Added zsocket_set_hwm emulation to 3.x API
187 . for source
188 $(string.trim(.):)
189
190 . endfor
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
191 #endif
192
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
193 .endfor
194 // --------------------------------------------------------------------------
195 // Selftest
196
197 int
198 zsockopt_test (Bool verbose)
199 {
200 printf (" * zsockopt: ");
201
202 // @selftest
203 zctx_t *ctx = zctx_new ();
f1b78737 » hintjens
2011-10-11 Cosmetic cleanups
204 assert (ctx);
c4f046e0 » hintjens
2011-07-12 Small changes to work with 0MQ/3.0.0
205 void *socket;
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
206 .for version
207 #if (ZMQ_VERSION_MAJOR == $(major))
208 . for option
c4f046e0 » hintjens
2011-07-12 Small changes to work with 0MQ/3.0.0
209 socket = zsocket_new (ctx, ZMQ_$(TEST));
f1b78737 » hintjens
2011-10-11 Cosmetic cleanups
210 assert (socket);
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
211 . if mode = "rw" | mode = "w"
212 . if ctype = "int"
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
213 zsockopt_set_$(name) (socket, 1);
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
214 . if mode = "rw"
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
215 assert (zsockopt_$(name) (socket) == 1);
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
216 . endif
217 . else
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
218 zsockopt_set_$(name) (socket, "test");
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
219 . endif
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
220 . endif
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
221 . if mode = "rw" | mode = "r"
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
222 zsockopt_$(name) (socket);
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
223 . endif
c4f046e0 » hintjens
2011-07-12 Small changes to work with 0MQ/3.0.0
224 zsocket_destroy (ctx, socket);
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
225 . endfor
644532ff » hintjens
2011-04-09 Added zsocket_set_hwm emulation to 3.x API
226 . for selftest
227
228 $(string.trim(.):)
229 . endfor
12a8ebf2 » hintjens
2011-04-09 Changes for 1.3.1
230 #endif
231
9f90df9c » hintjens
2011-04-07 Added zsocket and zsockopt classes
232 .endfor
233 zctx_destroy (&ctx);
234 // @end
235
236 printf ("OK\\n");
237 return 0;
238 }
Something went wrong with that request. Please try again.