本文整理汇总了C++中rb_warning函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_warning函数的具体用法?C++ rb_warning怎么用?C++ rb_warning使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_warning函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ossl_pem_passwd_cb
int
ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd)
{
int len, status = 0;
VALUE rflag, pass;
if (pwd || !rb_block_given_p())
return PEM_def_callback(buf, max_len, flag, pwd);
while (1) {
/*
* when the flag is nonzero, this passphrase
* will be used to perform encryption; otherwise it will
* be used to perform decryption.
*/
rflag = flag ? Qtrue : Qfalse;
pass = rb_protect(ossl_pem_passwd_cb0, rflag, &status);
if (status) return -1; /* exception was raised. */
len = RSTRING_LEN(pass);
if (len < 4) { /* 4 is OpenSSL hardcoded limit */
rb_warning("password must be longer than 4 bytes");
continue;
}
if (len > max_len) {
rb_warning("password must be shorter then %d bytes", max_len-1);
continue;
}
memcpy(buf, RSTRING_PTR(pass), len);
break;
}
return len;
}
示例2: nurat_to_f
static VALUE
nurat_to_f(VALUE self)
{
VALUE num, den;
int minus = 0;
long nl, dl, ml, ne, de;
int e;
double f;
{
get_dat1(self);
if (f_zero_p(dat->num))
return rb_float_new(0.0);
num = dat->num;
den = dat->den;
}
if (f_negative_p(num)) {
num = f_negate(num);
minus = 1;
}
nl = i_ilog2(num);
dl = i_ilog2(den);
ml = (long)(log(DBL_MAX) / log(2.0) - 1); /* should be a static */
ne = 0;
if (nl > ml) {
ne = nl - ml;
num = f_rshift(num, LONG2NUM(ne));
}
de = 0;
if (dl > ml) {
de = dl - ml;
den = f_rshift(den, LONG2NUM(de));
}
e = (int)(ne - de);
if ((e > DBL_MAX_EXP) || (e < DBL_MIN_EXP)) {
rb_warning("%s out of Float range", rb_obj_classname(self));
return rb_float_new(e > 0 ? HUGE_VAL : 0.0);
}
f = NUM2DBL(num) / NUM2DBL(den);
if (minus)
f = -f;
f = ldexp(f, e);
if (isinf(f) || isnan(f))
rb_warning("%s out of Float range", rb_obj_classname(self));
return rb_float_new(f);
}
示例3: rb_rsvg_handle_initialize
static VALUE
rb_rsvg_handle_initialize(int argc, VALUE *argv, VALUE self)
{
RsvgHandle *handle;
VALUE gz;
rb_scan_args(argc, argv, "01", &gz);
#if LIBRSVG_CHECK_VERSION(2, 11, 0)
handle = rsvg_handle_new();
#else
if (RVAL2CBOOL(gz)) {
# ifdef HAVE_LIBRSVG_RSVG_GZ_H
handle = rsvg_handle_new_gz();
# else
rb_warning("gz handling is not supported in your librsvg");
handle = rsvg_handle_new();
# endif
} else {
handle = rsvg_handle_new();
}
#endif
#ifdef RSVG_TYPE_HANDLE
G_INITIALIZE(self, handle);
#else
DATA_PTR(self) = handle;
#endif
rb_ivar_set(self, id_closed, Qfalse);
return Qnil;
}
示例4: ossl_engine_s_load
static VALUE
ossl_engine_s_load(int argc, VALUE *argv, VALUE klass)
{
#if !defined(HAVE_ENGINE_LOAD_BUILTIN_ENGINES)
return Qnil;
#else
VALUE name;
rb_scan_args(argc, argv, "01", &name);
if(NIL_P(name)){
ENGINE_load_builtin_engines();
return Qtrue;
}
StringValue(name);
#ifndef OPENSSL_NO_STATIC_ENGINE
OSSL_ENGINE_LOAD_IF_MATCH(dynamic);
OSSL_ENGINE_LOAD_IF_MATCH(cswift);
OSSL_ENGINE_LOAD_IF_MATCH(chil);
OSSL_ENGINE_LOAD_IF_MATCH(atalla);
OSSL_ENGINE_LOAD_IF_MATCH(nuron);
OSSL_ENGINE_LOAD_IF_MATCH(ubsec);
OSSL_ENGINE_LOAD_IF_MATCH(aep);
OSSL_ENGINE_LOAD_IF_MATCH(sureware);
OSSL_ENGINE_LOAD_IF_MATCH(4758cca);
#endif
#ifdef HAVE_ENGINE_LOAD_OPENBSD_DEV_CRYPTO
OSSL_ENGINE_LOAD_IF_MATCH(openbsd_dev_crypto);
#endif
OSSL_ENGINE_LOAD_IF_MATCH(openssl);
rb_warning("no such builtin loader for `%s'", RSTRING_PTR(name));
return Qnil;
#endif /* HAVE_ENGINE_LOAD_BUILTIN_ENGINES */
}
示例5: initialize_loader
/* Image Data in Memory */
static VALUE
initialize_loader(int argc, VALUE *argv, VALUE self)
{
GdkPixbufLoader* loader;
GError* error = NULL;
VALUE arg1, is_mime_type;
rb_scan_args(argc, argv, "02", &arg1, &is_mime_type);
if (NIL_P(arg1)) {
loader = gdk_pixbuf_loader_new();
} else {
if (is_mime_type == Qtrue) {
#if RBGDK_PIXBUF_CHECK_VERSION(2,4,0)
loader = gdk_pixbuf_loader_new_with_mime_type(RVAL2CSTR(arg1), &error);
#else
rb_warning("Not supported GTK+-2.0/2.2.");
loader = gdk_pixbuf_loader_new();
#endif
} else {
/* Default behavior */
loader = gdk_pixbuf_loader_new_with_type(RVAL2CSTR(arg1), &error);
}
if(error) RAISE_GERROR(error);
}
G_INITIALIZE(self, loader);
return Qnil;
}
示例6: rb_rsvg_handle_get_pixbuf
static VALUE
rb_rsvg_handle_get_pixbuf(int argc, VALUE *argv, VALUE self)
{
VALUE id;
VALUE rb_pixbuf;
GdkPixbuf *pixbuf = NULL;
rb_scan_args(argc, argv, "01", &id);
if (NIL_P(id)) {
pixbuf = rsvg_handle_get_pixbuf(_SELF(self));
} else {
#ifdef HAVE_RSVG_HANDLE_GET_PIXBUF_SUB
pixbuf = rsvg_handle_get_pixbuf_sub(_SELF(self),
(const char *)RVAL2CSTR(id));
#else
rb_warning("rsvg_handle_get_pixbuf_sub isn't "
"supported in your librsvg");
#endif
}
rb_pixbuf = GOBJ2RVAL(pixbuf);
if (pixbuf)
g_object_unref(pixbuf);
return rb_pixbuf;
}
示例7: grpc_rb_completion_queue_shutdown_drain
/* Shuts down and drains the completion queue if necessary.
*
* This is done when the ruby completion queue object is about to be GCed.
*/
static void grpc_rb_completion_queue_shutdown_drain(grpc_completion_queue *cq) {
next_call_stack next_call;
grpc_completion_type type;
int drained = 0;
MEMZERO(&next_call, next_call_stack, 1);
grpc_completion_queue_shutdown(cq);
next_call.cq = cq;
next_call.event.type = GRPC_QUEUE_TIMEOUT;
/* TODO: the timeout should be a module level constant that defaults
* to gpr_inf_future(GPR_CLOCK_REALTIME).
*
* - at the moment this does not work, it stalls. Using a small timeout like
* this one works, and leads to fast test run times; a longer timeout was
* causing unnecessary delays in the test runs.
*
* - investigate further, this is probably another example of C-level cleanup
* not working consistently in all cases.
*/
next_call.timeout = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros(5e3, GPR_TIMESPAN));
do {
rb_thread_call_without_gvl(grpc_rb_completion_queue_next_no_gil,
(void *)&next_call, NULL, NULL);
type = next_call.event.type;
if (type == GRPC_QUEUE_TIMEOUT) break;
if (type != GRPC_QUEUE_SHUTDOWN) {
++drained;
rb_warning("completion queue shutdown: %d undrained events", drained);
}
} while (type != GRPC_QUEUE_SHUTDOWN);
}
示例8: rbglib_m_utf8_validate
static VALUE
rbglib_m_utf8_validate(G_GNUC_UNUSED VALUE self, VALUE str)
{
rb_warning("GLib.utf8_validate is deprecated. Use GLib::UTF8.validate instead.");
StringValue(str);
return CBOOL2RVAL(g_utf8_validate(RSTRING_PTR(str), RSTRING_LEN(str), NULL));
}
示例9: ossl_sslctx_get_ciphers
/*
* call-seq:
* ctx.ciphers => [[name, version, bits, alg_bits], ...]
*/
static VALUE
ossl_sslctx_get_ciphers(VALUE self)
{
SSL_CTX *ctx;
STACK_OF(SSL_CIPHER) *ciphers;
SSL_CIPHER *cipher;
VALUE ary;
int i, num;
Data_Get_Struct(self, SSL_CTX, ctx);
if(!ctx){
rb_warning("SSL_CTX is not initialized.");
return Qnil;
}
ciphers = ctx->cipher_list;
if (!ciphers)
return rb_ary_new();
num = sk_SSL_CIPHER_num(ciphers);
ary = rb_ary_new2(num);
for(i = 0; i < num; i++){
cipher = sk_SSL_CIPHER_value(ciphers, i);
rb_ary_push(ary, ossl_ssl_cipher_to_ary(cipher));
}
return ary;
}
示例10: exec_tmpl
static VALUE exec_tmpl(VALUE module, VALUE self, VALUE output)
{
writer_functype writer;
struct tmplpro_param* proparam;
setup_internal(self);
proparam = process_tmplpro_options(self);
switch (TYPE(output)) {
case T_STRING:
writer = &write_chars_to_string;
break;
case T_FILE:
writer = &write_chars_to_file;
break;
default:
rb_warning("bad file descriptor. Use output=stdout\n");
writer = &write_chars_to_file;
output = rb_stdout;
}
tmplpro_set_option_WriterFuncPtr(proparam, writer);
tmplpro_set_option_ext_writer_state(proparam, (ABSTRACT_WRITER *)output);
int retval = tmplpro_exec_tmpl(proparam);
release_tmplpro_options(proparam);
return INT2FIX(retval);
}
示例11: ossl_ssl_get_peer_cert_chain
/*
* call-seq:
* ssl.peer_cert_chain => [cert, ...] or nil
*/
static VALUE
ossl_ssl_get_peer_cert_chain(VALUE self)
{
SSL *ssl;
STACK_OF(X509) *chain;
X509 *cert;
VALUE ary;
int i, num;
Data_Get_Struct(self, SSL, ssl);
if(!ssl){
rb_warning("SSL session is not started yet.");
return Qnil;
}
chain = SSL_get_peer_cert_chain(ssl);
if(!chain) return Qnil;
num = sk_X509_num(chain);
ary = rb_ary_new2(num);
for (i = 0; i < num; i++){
cert = sk_X509_value(chain, i);
rb_ary_push(ary, ossl_x509_new(cert));
}
return ary;
}
示例12: load_lock
static char *
load_lock(const char *ftptr)
{
st_data_t data;
st_table *loading_tbl = get_loading_table();
if (!st_lookup(loading_tbl, (st_data_t)ftptr, &data)) {
/* partial state */
ftptr = ruby_strdup(ftptr);
data = (st_data_t)rb_thread_shield_new();
st_insert(loading_tbl, (st_data_t)ftptr, data);
return (char *)ftptr;
}
else if (RB_TYPE_P((VALUE)data, T_IMEMO) && imemo_type((VALUE)data) == imemo_memo) {
struct MEMO *memo = MEMO_CAST(data);
void (*init)(void) = (void (*)(void))memo->u3.func;
data = (st_data_t)rb_thread_shield_new();
st_insert(loading_tbl, (st_data_t)ftptr, data);
(*init)();
return (char *)"";
}
if (RTEST(ruby_verbose)) {
rb_warning("loading in progress, circular require considered harmful - %s", ftptr);
rb_backtrace_print_to(rb_stderr);
}
switch (rb_thread_shield_wait((VALUE)data)) {
case Qfalse:
data = (st_data_t)ftptr;
st_insert(loading_tbl, data, (st_data_t)rb_thread_shield_new());
return 0;
case Qnil:
return 0;
}
return (char *)ftptr;
}
示例13: handle_exception
/*
* Static: handle_exception
* Purpose: called when rm_check_exception determines that we need
* to either issue a warning message or raise an exception.
* This function allocates a bunch of stack so we don't call
* it unless we have to.
*/
static void
handle_exception(ExceptionInfo *exception, Image *imglist, ErrorRetention retention)
{
char reason[500];
char desc[500];
char msg[sizeof(reason)+sizeof(desc)+20];
memset(msg, 0, sizeof(msg));
// Handle simple warning
if (exception->severity < ErrorException)
{
#if defined(HAVE_SNPRINTF)
snprintf(msg, sizeof(msg)-1, "RMagick: %s%s%s",
#else
sprintf(msg, "RMagick: %.500s%s%.500s",
#endif
GetLocaleExceptionMessage(exception->severity, exception->reason),
exception->description ? ": " : "",
exception->description ? GetLocaleExceptionMessage(exception->severity, exception->description) : "");
msg[sizeof(msg)-1] = '\0';
rb_warning(msg);
// Caller deletes ExceptionInfo...
return;
}
示例14: set_default_internal
/*
* call-seq:
* Encoding.default_internal = enc or nil
*
* Sets default internal encoding.
* Or removes default internal encoding when passed nil.
*/
static VALUE
set_default_internal(VALUE klass, VALUE encoding)
{
rb_warning("setting Encoding.default_internal");
rb_enc_set_default_internal(encoding);
return encoding;
}
示例15: ImageList_map
/**
* Call MapImages.
*
* Ruby usage:
* - @verbatim ImageList#map(reference) @endverbatim
* - @verbatim ImageList#map(reference, dither) @endverbatim
*
* Notes:
* - Default dither is false
* - Sets \@scene to self.scene
*
* @param argc number of input arguments
* @param argv array of input arguments
* @param self this object
* @return a new ImageList with mapped images.
*/
VALUE
ImageList_map(int argc, VALUE *argv, VALUE self)
{
Image *images, *new_images = NULL;
Image *map;
unsigned int dither = MagickFalse;
VALUE scene, new_imagelist, t;
ExceptionInfo *exception;
#if defined(HAVE_REMAPIMAGES)
QuantizeInfo quantize_info;
rb_warning("ImageList#map is deprecated. Use ImageList#remap instead.");
#endif
switch (argc)
{
case 2:
dither = RTEST(argv[1]);
case 1:
t = rm_cur_image(argv[0]);
map = rm_check_destroyed(t);
break;
default:
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc);
break;
}
// Convert image array to image sequence, clone image sequence.
exception = AcquireExceptionInfo();
images = images_from_imagelist(self);
new_images = CloneImageList(images, exception);
rm_split(images);
rm_check_exception(exception, new_images, DestroyOnError);
(void) DestroyExceptionInfo(exception);
rm_ensure_result(new_images);
// Call ImageMagick
#if defined(HAVE_REMAPIMAGES)
GetQuantizeInfo(&quantize_info);
quantize_info.dither = dither;
(void) RemapImages(&quantize_info, new_images, map);
#else
(void) MapImages(new_images, map, dither);
#endif
rm_check_image_exception(new_images, DestroyOnError);
// Set @scene in new ImageList object to same value as in self.
new_imagelist = rm_imagelist_from_images(new_images);
scene = rb_iv_get(self, "@scene");
(void) imagelist_scene_eq(new_imagelist, scene);
RB_GC_GUARD(scene);
RB_GC_GUARD(new_imagelist);
RB_GC_GUARD(t);
return new_imagelist;
}