Ejemplo n.º 1
0
Archivo: ossl.c Proyecto: genki/ruby
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;
}
Ejemplo n.º 2
0
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);
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
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 */
}
Ejemplo n.º 5
0
/* 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;
}
Ejemplo n.º 6
0
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;
}
Ejemplo n.º 7
0
/* 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);
}
Ejemplo n.º 8
0
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));
}
Ejemplo n.º 9
0
/*
 * 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;
}
Ejemplo n.º 10
0
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);
}
Ejemplo n.º 11
0
/*
 * 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;
}
Ejemplo n.º 12
0
void
rb_clear_cache(void)
{
    rb_warning("rb_clear_cache() is deprecated.");
    INC_GLOBAL_METHOD_STATE();
    INC_GLOBAL_CONSTANT_STATE();
}
Ejemplo n.º 13
0
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;
}
Ejemplo n.º 14
0
/*
 *  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;
    }
Ejemplo n.º 15
0
Archivo: encoding.c Proyecto: 217/ruby
/*
 * 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;
}
Ejemplo n.º 16
0
/**
 * 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;
}
Ejemplo n.º 17
0
/*
 * call-seq:
 *    ssl.sysread(length) => string
 *    ssl.sysread(length, buffer) => buffer
 *
 * === Parameters
 * * +length+ is a positive integer.
 * * +buffer+ is a string used to store the result.
 */
static VALUE
ossl_ssl_read(int argc, VALUE *argv, VALUE self)
{
  SSL *ssl;
  int ilen, nread = 0;
  VALUE len, str;

  rb_scan_args(argc, argv, "11", &len, &str);
  ilen = NUM2INT(len);

  if(NIL_P(str)) {
    str = rb_str_new(0, ilen);
  } else {
    StringValue(str);
    rb_str_modify(str);
    rb_str_resize(str, ilen);
  }

  if(ilen == 0) return str;

  Data_Get_Struct(self, SSL, ssl);
  int fd = rb_io_fd(ossl_ssl_get_io(self));

  if (ssl) {
    if(SSL_pending(ssl) <= 0)
      rb_thread_wait_fd(fd);
    for (;;) {
      nread = SSL_read(ssl, RSTRING_PTR(str), RSTRING_LEN(str));
      switch(ssl_get_error(ssl, nread)) {
      case SSL_ERROR_NONE:
        goto end;
      case SSL_ERROR_ZERO_RETURN:
        rb_eof_error();
      case SSL_ERROR_WANT_WRITE:
        rb_io_wait_writable(fd);
        continue;
      case SSL_ERROR_WANT_READ:
        rb_io_wait_readable(fd);
        continue;
      case SSL_ERROR_SYSCALL:
        if(ERR_peek_error() == 0 && nread == 0) rb_eof_error();
        rb_sys_fail(0);
      default:
        ossl_raise(eSSLError, "SSL_read:");
      }
    }
  }
  else {
    ID id_sysread = rb_intern("sysread");
    rb_warning("SSL session is not started yet.");
    return rb_funcall(ossl_ssl_get_io(self), id_sysread, 2, len, str);
  }

end:
  rb_str_set_len(str, nread);
  OBJ_TAINT(str);

  return str;
}
static VALUE
ossl_cipher_update_deprecated(VALUE self, VALUE data)
{
    char *cname;

    cname = rb_class2name(rb_obj_class(self));
    rb_warning("%s#<< is deprecated; use %s#update instead", cname, cname);
    return ossl_cipher_update(self, data);
}
Ejemplo n.º 19
0
static VALUE
prenderer_set_stipple(G_GNUC_UNUSED VALUE self,
                      G_GNUC_UNUSED VALUE part,
                      G_GNUC_UNUSED VALUE stipple)
{
    rb_warning("Gdk::PangoRender#set_tipple is not supported (Require pango-1.8.1 or later");

    return self;
}
Ejemplo n.º 20
0
static VALUE
prenderer_set_override_color(G_GNUC_UNUSED VALUE self,
                             G_GNUC_UNUSED VALUE part,
                             G_GNUC_UNUSED VALUE color)
{
    rb_warning("Gdk::PangoRender#set_override_color is not supported (Require pango-1.8.1 or later");

    return self;
}
/*
 *  call-seq:
 *     cipher << data -> string
 *
 *  === Parameters
 *  +data+ is a nonempty string.
 *
 * This method is deprecated and not available in 1.9.x or later.
 */
static VALUE
ossl_cipher_update_deprecated(VALUE self, VALUE data)
{
    const char *cname;

    cname = rb_class2name(rb_obj_class(self));
    rb_warning("%s#<< is deprecated; use %s#update instead", cname, cname);
    return rb_funcall(self, rb_intern("update"), 1, data);
}
Ejemplo n.º 22
0
/* Destroys Channel instances. */
static void grpc_rb_channel_free(void *p) {
    grpc_rb_channel *ch = NULL;
    if (p == NULL) {
        return;
    };
    ch = (grpc_rb_channel *)p;

    /* Deletes the wrapped object if the mark object is Qnil, which indicates
     * that no other object is the actual owner. */
    if (ch->wrapped != NULL && ch->mark == Qnil) {
        grpc_channel_destroy(ch->wrapped);
        rb_warning("channel gc: destroyed the c channel");
    } else {
        rb_warning("channel gc: did not destroy the c channel");
    }

    xfree(p);
}
Ejemplo n.º 23
0
/*
 *  Extern:     rm_warning_handler
 *  Purpose:    called from ImageMagick for a warning
*/
void
rm_warning_handler(const ExceptionType severity, const char *reason, const char *description)
{
    ExceptionType dummy;

    rb_warning("RMagick: %s: `%s'", reason, description);
    dummy = severity;
    dummy = dummy;
}
Ejemplo n.º 24
0
void
rb_alias(VALUE klass, ID name, ID def)
{
    NODE *orig_fbody, *node, *method;
    VALUE singleton = 0;
    st_data_t data;

    rb_frozen_class_p(klass);
    if (klass == rb_cObject) {
	rb_secure(4);
    }
    orig_fbody = search_method(klass, def, 0);
    if (!orig_fbody || !orig_fbody->nd_body) {
	if (TYPE(klass) == T_MODULE) {
	    orig_fbody = search_method(rb_cObject, def, 0);
	}
    }
    if (!orig_fbody || !orig_fbody->nd_body) {
	rb_print_undef(klass, def, 0);
    }
    if (FL_TEST(klass, FL_SINGLETON)) {
	singleton = rb_iv_get(klass, "__attached__");
    }

    orig_fbody->nd_cnt++;

    if (st_lookup(RCLASS_M_TBL(klass), name, &data)) {
	node = (NODE *)data;
	if (node) {
	    if (RTEST(ruby_verbose) && node->nd_cnt == 0 && node->nd_body) {
		rb_warning("discarding old %s", rb_id2name(name));
	    }
	    if (nd_type(node->nd_body->nd_body) == NODE_CFUNC) {
		rb_vm_check_redefinition_opt_method(node);
	    }
	}
    }

    st_insert(RCLASS_M_TBL(klass), name,
	      (st_data_t) NEW_FBODY(
		  method = NEW_METHOD(orig_fbody->nd_body->nd_body,
			     orig_fbody->nd_body->nd_clss,
			     NOEX_WITH_SAFE(orig_fbody->nd_body->nd_noex)), def));
    method->nd_file = (void *)def;

    rb_clear_cache_by_id(name);

    if (!ruby_running) return;

    if (singleton) {
	rb_funcall(singleton, singleton_added, 1, ID2SYM(name));
    }
    else {
	rb_funcall(klass, added, 1, ID2SYM(name));
    }
}
Ejemplo n.º 25
0
static VALUE
bdb_s_log_checkpoint(VALUE obj, VALUE a)
{
#if HAVE_CONST_DB_CHECKPOINT
    return bdb_s_log_put_internal(obj, a, DB_CHECKPOINT);
#else
    rb_warning("BDB::CHECKPOINT is obsolete");
    return bdb_s_log_put_internal(obj, a, 0);
#endif
}
Ejemplo n.º 26
0
static VALUE
rbatkrole_get_localized_name(VALUE self)
{
#ifdef HAVE_ATK_ROLE_GET_LOCALIZED_NAME
    return CSTR2RVAL(atk_role_get_localized_name(RVAL2GENUM(self, ATK_TYPE_ROLE)));
#else
    rb_warning("not supported in this version of ATK.");
    return Qnil;
#endif
}
Ejemplo n.º 27
0
static VALUE
rg_s_set_default_dpi_x_y(VALUE self, VALUE dpi_x, VALUE dpi_y)
{
#ifdef HAVE_RSVG_SET_DEFAULT_DPI_X_Y
    rsvg_set_default_dpi_x_y(NUM2DBL(dpi_x), NUM2DBL(dpi_y));
#else
    rb_warning("rsvg_set_default_dpi_x_y isn't supported in your librsvg");
#endif
    return self;
}
Ejemplo n.º 28
0
static VALUE
rg_s_set_default_dpi(VALUE self, VALUE dpi)
{
#ifdef HAVE_RSVG_SET_DEFAULT_DPI
    rsvg_set_default_dpi(NUM2DBL(dpi));
#else
    rb_warning("rsvg_set_default_dpi isn't supported in your librsvg");
#endif
    return self;
}
Ejemplo n.º 29
0
static VALUE
rb_rsvg_handle_set_dpi_x_y(VALUE self, VALUE dpi_x, VALUE dpi_y)
{
#ifdef HAVE_RSVG_HANDLE_SET_DPI_X_Y
    rsvg_handle_set_dpi_x_y(_SELF(self), NUM2DBL(dpi_x), NUM2DBL(dpi_y));
#else
    rb_warning("rsvg_handle_set_dpi_x_y isn't supported in your librsvg");
#endif
    return self;
}
Ejemplo n.º 30
0
static VALUE
bdb_s_log_curlsn(VALUE obj, VALUE a)
{
#if HAVE_CONST_DB_CURLSN
    return bdb_s_log_put_internal(obj, a, DB_CURLSN);
#else
    rb_warning("BDB::CURLSN is obsolete");
    return bdb_s_log_put_internal(obj, a, 0);
#endif
}