Sha256: 78291c274fe091db6fc5a91fcbb840d7ef8fa9ac72567188513f01cc546064b9

Contents?: true

Size: 699 Bytes

Versions: 3

Compression:

Stored size: 699 Bytes

Contents

#include "ruby.h"
#include <charguess.h>

#ifndef RSTRING_PTR
#include "intern.h"
#define RSTRING_PTR(s) (RSTRING(s)->ptr) 
#endif

static VALUE mCharGuess;

static VALUE cg_s_guess(VALUE klass, VALUE str) {
  const char*ptr;
  int ret;
  Check_Type(str, T_STRING);
  ret = CharGuessInit();
  ptr = GuessChardet((const char *)RSTRING_PTR(str));
  ret = CharGuessDone();
  return ptr ? rb_str_new2(ptr) : Qnil;
}

void Init_charguess()
{
  ID id;
  
  id = rb_intern("CharGuess");
  if (rb_const_defined(rb_cObject, id)) {
    mCharGuess = rb_const_get(rb_cObject, id);
  } else {
    mCharGuess = rb_define_module("CharGuess");
  }
  rb_define_module_function(mCharGuess, "guess", cg_s_guess, 1);
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
charguess-1.3.20111021164500 ext/charguess/charguess.c
charguess-1.3.20110226181011 ext/charguess/charguess.c
charguess-1.3.20110215234539 ext/charguess/charguess.c