Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 78b5e16d1b
Fetching contributors…

Cannot retrieve contributors at this time

291 lines (253 sloc) 7.977 kb
.output "include/zsockopt.h"
.for version
. for option
. if type = "uint64" | type = "int64" | type = "uint32" | type = "int"
. option.ctype = "int"
. elsif type = "blob"
. option.ctype = "char *" # Enforce C strings
. else
. echo "E: unknown type: $(type)"
. endif
. endfor
.endfor
/* =========================================================================
zsockopt - get/set 0MQ socket options
GENERATED SOURCE CODE, DO NOT EDIT
-------------------------------------------------------------------------
Copyright (c) 1991-2012 iMatix Corporation <www.imatix.com>
Copyright other contributors as noted in the AUTHORS file.
This file is part of CZMQ, the high-level C binding for 0MQ:
http://czmq.zeromq.org.
This is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at
your option) any later version.
This software is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program. If not, see
<http://www.gnu.org/licenses/>.
=========================================================================
*/
#ifndef __ZSOCKOPT_H_INCLUDED__
#define __ZSOCKOPT_H_INCLUDED__
#ifdef __cplusplus
extern "C" {
#endif
// @interface
.for version
#if (ZMQ_VERSION_MAJOR == $(major))
// Get socket options
. for option
. if defined (.minor)
# if (ZMQ_VERSION_MINOR == $(minor))
. endif
. if mode = "rw" | mode = "r"
. if type = "blob"
// Returns freshly allocated string, free when done
. endif
CZMQ_EXPORT $(ctype) zsocket_$(name) (void *socket);
. endif
. if defined (.minor)
# endif
. endif
. endfor
// Set socket options
. for option
. if defined (.minor)
# if (ZMQ_VERSION_MINOR == $(minor))
. endif
. if mode = "rw" | mode = "w"
CZMQ_EXPORT void zsocket_set_$(name) (void *socket, $(ctype) $(name));
. endif
. if defined (.minor)
# endif
. endif
. endfor
. for header
$(string.trim(.):)
. endfor
#endif
.endfor
// Self test of this class
int zsockopt_test (Bool verbose);
// @end
.for version
// Deprecated function names
#if (ZMQ_VERSION_MAJOR == $(major))
. for option
. if defined (.minor)
# if (ZMQ_VERSION_MINOR == $(minor))
. endif
. if mode = "rw" | mode = "r"
#define zsockopt_$(name) zsocket_$(name)
. endif
. if mode = "rw" | mode = "w"
#define zsockopt_set_$(name) zsocket_set_$(name)
. endif
. if defined (.minor)
# endif
. endif
. endfor
#endif
.endfor
#ifdef __cplusplus
}
#endif
#endif
.output "src/zsockopt.c"
/* =========================================================================
zsockopt - get/set 0MQ socket options
GENERATED SOURCE CODE, DO NOT EDIT
-------------------------------------------------------------------------
Copyright (c) 1991-2012 iMatix Corporation <www.imatix.com>
Copyright other contributors as noted in the AUTHORS file.
This file is part of CZMQ, the high-level C binding for 0MQ:
http://czmq.zeromq.org.
This is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at
your option) any later version.
This software is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program. If not, see
<http://www.gnu.org/licenses/>.
=========================================================================
*/
/*
@header
The zsockopt class provides access to the 0MQ getsockopt/setsockopt API.
@discuss
This class is generated, using the GSL code generator. See the sockopts
XML file, which provides the metadata, and the sockopts.gsl template,
which does the work.
@end
*/
#include "../include/czmq_prelude.h"
#include "../include/zctx.h"
#include "../include/zsocket.h"
#include "../include/zsockopt.h"
.for version
#if (ZMQ_VERSION_MAJOR == $(major))
. for option
. if defined (.minor)
# if (ZMQ_VERSION_MINOR == $(minor))
. endif
. if mode = "rw" | mode = "w"
// --------------------------------------------------------------------------
// Set socket ZMQ_$(NAME) value
void
zsocket_set_$(name) (void *socket, $(ctype) $(name))
{
# if !defined (ZMQ_$(NAME))
# define ZMQ_$(NAME) 999 // Using an out-of-date libzmq
# endif
. if ctype = "int"
. if type = "uint64"
uint64_t value = $(name);
int rc = zmq_setsockopt (socket, ZMQ_$(NAME), &value, sizeof (uint64_t));
. elsif type = "int64"
int64_t value = $(name);
int rc = zmq_setsockopt (socket, ZMQ_$(NAME), &value, sizeof (int64_t));
. elsif type = "uint32"
uint32_t value = $(name);
int rc = zmq_setsockopt (socket, ZMQ_$(NAME), &value, sizeof (uint32_t));
. else
int rc = zmq_setsockopt (socket, ZMQ_$(NAME), &$(name), sizeof (int));
. endif
. else
int rc = zmq_setsockopt (socket, ZMQ_$(NAME), $(name), strlen ($(name)));
. endif
assert (rc == 0 || errno == ETERM);
}
. endif
. if mode = "rw" | mode = "r"
// --------------------------------------------------------------------------
// Return socket ZMQ_$(NAME) value
$(ctype)
zsocket_$(name) (void *socket)
{
. if type = "uint64"
uint64_t $(name);
size_t option_len = sizeof (uint64_t);
. elsif type = "int64"
int64_t $(name);
size_t option_len = sizeof (int64_t);
. elsif type = "uint32"
uint32_t $(name);
size_t option_len = sizeof (uint32_t);
. elsif type = "int"
int $(name);
size_t option_len = sizeof (int);
. elsif type = "blob"
size_t option_len = 255;
char *$(name) = zmalloc (option_len);
. endif
zmq_getsockopt (socket, ZMQ_$(NAME), &$(name), &option_len);
. if type = "int"
return $(name);
. else
return ($(ctype)) $(name);
. endif
}
. endif
. if defined (.minor)
# endif
. endif
. endfor
. for source
$(string.trim(.):)
. endfor
#endif
.endfor
// --------------------------------------------------------------------------
// Selftest
int
zsockopt_test (Bool verbose)
{
printf (" * zsockopt: ");
// @selftest
zctx_t *ctx = zctx_new ();
assert (ctx);
void *socket;
.for version
#if (ZMQ_VERSION_MAJOR == $(major))
. for option
. if defined (.minor)
# if (ZMQ_VERSION_MINOR == $(minor))
. endif
socket = zsocket_new (ctx, ZMQ_$(TEST));
assert (socket);
. if mode = "rw" | mode = "w"
. if ctype = "int"
zsocket_set_$(name) (socket, 1);
. if mode = "rw"
assert (zsocket_$(name) (socket) == 1);
. endif
. else
zsocket_set_$(name) (socket, "test");
. endif
. endif
. if mode = "rw" | mode = "r"
zsocket_$(name) (socket);
. endif
zsocket_destroy (ctx, socket);
. if defined (.minor)
# endif
. endif
. endfor
. for selftest
$(string.trim(.):)
. endfor
#endif
.endfor
zctx_destroy (&ctx);
// @end
printf ("OK\\n");
return 0;
}
Jump to Line
Something went wrong with that request. Please try again.