Exemplo n.º 1
0
void Init_sfcc()
{
  const char *conn;
  VALUE cEnvironment; /* class */
  VALUE value; /* wrapped value */
  int rc;
  char *msg;

#ifdef CIMC_NO_CURL_INIT //defined in cimc/cimc.h since version 2.2.4
  char *rails_env = getenv("RAILS_ENV");
#endif

  /**
   * SBLIM sfcc ruby API
   */
  mSfcc = rb_define_module("Sfcc");
  /**
   * SBLIM sfcc CIMC API
   */
  mSfccCim= rb_define_module_under(mSfcc, "Cim");

  /**
   * alloc CimcEnvironment once, store as const
   */
  cEnvironment = rb_define_class_under(mSfccCim, "CimcEnvironment", rb_cObject);
  conn = getenv("RUBY_SFCC_CONNECTION"); /* "SfcbLocal" or "XML" */
  if (!conn) conn = "XML";
  cimcEnv = NewCIMCEnv(conn,
#ifdef CIMC_NO_CURL_INIT
  /* Don't let sfcc init curl if running in Rails env
   * (http://sourceforge.net/tracker/?func=detail&aid=3435363&group_id=128809&atid=712784) */
        rails_env?CIMC_NO_CURL_INIT:
#endif
        0, &rc, &msg);
  if (!cimcEnv) {
    rb_raise(rb_eLoadError, "Cannot local %s cim client library. %d:%s", conn, rc, msg ? msg : "");
  }
  value = Data_Wrap_Struct(cEnvironment, NULL, Exit_sfcc, cimcEnv);
  rb_define_const(mSfccCim, "CIMC_ENV", value);
  cimcEnvType = strdup(conn);
  rb_define_const(mSfccCim, "CIMC_ENV_TYPE", rb_str_new2(cimcEnvType));

  /**
   * Init other sub-classes
   */
  init_cim_string();
  init_cim_object_path();
  init_cim_enumeration();
  init_cim_class();
  init_cim_instance();
  init_cim_data();
  init_cim_type();
  init_cim_flags();
  init_cim_client();
}
Exemplo n.º 2
0
Arquivo: sfcc.c Projeto: wca/ruby-sfcc
void Init_sfcc()
{
  /**
   * SBLIM sfcc ruby API
   */
  mSfcc = rb_define_module("Sfcc");
  /**
   * SBLIM sfcc CIMC API
   */
  mSfccCim= rb_define_module_under(mSfcc, "Cim");

  init_cim_string();
  init_cim_object_path();
  init_cim_enumeration();
  init_cim_class();
  init_cim_instance();
  init_cim_client();
}
Exemplo n.º 3
0
void Init_sfcc()
{
  const char *conn;
  VALUE cEnvironment; /* class */
  VALUE value; /* wrapped value */
  int rc;
  char *msg;

  /**
   * SBLIM sfcc ruby API
   */
  mSfcc = rb_define_module("Sfcc");
  /**
   * SBLIM sfcc CIMC API
   */
  mSfccCim= rb_define_module_under(mSfcc, "Cim");

  /**
   * alloc CimcEnvironment once, store as const
   */
  cEnvironment = rb_define_class_under(mSfccCim, "CimcEnvironment", rb_cObject);
  conn = getenv("RUBY_SFCC_CONNECTION"); /* "SfcbLocal" or "XML" */
  if (!conn) conn = "XML";
  cimcEnv = NewCIMCEnv(conn,0,&rc,&msg);
  if (!cimcEnv) {
    rb_raise(rb_eLoadError, "Cannot local %s cim client library. %d:%s", conn, rc, msg ? msg : "");
  }
  value = Data_Wrap_Struct(cEnvironment, NULL, Exit_sfcc, cimcEnv);
  rb_define_const(mSfccCim, "CIMC_ENV", value);

  /**
   * Init other sub-classes
   */
  init_cim_string();
  init_cim_object_path();
  init_cim_enumeration();
  init_cim_class();
  init_cim_instance();
  init_cim_client();
}