<commit_before>#include <radcli.h>

VALUE c_adenroll;

// Free function for the Adcli::AdEnroll class.
static void radenroll_free (RUBY_ADENROLL *ptr) {
    if(!ptr)
        return;
    adcli_enroll_unref (ptr->enroll);
    free (ptr);
}

// Allocation function for the Adcli:AdEnroll class.
static VALUE radenroll_allocate (VALUE klass) {
    RUBY_ADENROLL *ptr = malloc (sizeof(RUBY_ADENROLL));
    memset (ptr, 0, sizeof(RUBY_ADENROLL));
    return Data_Wrap_Struct (klass, 0, radenroll_free, ptr);
}

/*
 * call-seq:
 *  conn_object = Adcli::AdConn.connect('YOUR.REALM.COM')
 *  Adcli::AdEnroll.new(conn_object)
 * 
 * Creates and returns a new Adcli::AdEnroll object. 
 */
static VALUE radenroll_initialize (VALUE self, VALUE ad_conn) {
    RUBY_ADCONN *ptr_conn;
    RUBY_ADENROLL *ptr_enroll;
    Data_Get_Struct (ad_conn, RUBY_ADCONN, ptr_conn);
    Data_Get_Struct (self, RUBY_ADENROLL, ptr_enroll);
    adcli_enroll *enroll = adcli_enroll_new (ptr_conn->conn);
    ptr_enroll->enroll = enroll;
    return self;
}

/*
 * call-seq:
 *  
 *  adenroll.get_computer_name # => hostname.your.realm.com
 * 
 * Creates and returns the computer name.
 */
static VALUE radenroll_get_computer_name (VALUE self) {
    RUBY_ADENROLL *ptr_enroll;
    const char *c_computer_name = NULL;
    Data_Get_Struct (self ,RUBY_ADENROLL, ptr_enroll);
    c_computer_name  = adcli_enroll_get_computer_name (ptr_enroll->enroll);
    return rb_str_new_cstr (c_computer_name);
}

/*
 * call-seq:
 *  
 *  adenroll.set_computer_name('hostname')
 * 
 * Set the computer name to do the enroll operation on (join or delete).
 */
static VALUE radenroll_set_computer_name (VALUE self, VALUE value) {
    RUBY_ADENROLL *ptr_enroll;
    adcli_enroll *enroll;
    adcli_result res;
    const char *c_value = StringValuePtr (value);
    Data_Get_Struct (self, RUBY_ADENROLL, ptr_enroll);
    enroll = ptr_enroll->enroll;
    adcli_enroll_set_computer_name (enroll, c_value);
    return self;
}

/*
 * call-seq:
 * 
 *  adenroll.set_domain_ou('OU=Testing,DC=domain,DC=example,DC=com')
 * 
 * Set the domain organizational unit.
 * 
 */
static VALUE radenroll_set_domain_ou (VALUE self, VALUE value) {
    RUBY_ADENROLL *ptr_enroll;
    adcli_enroll *enroll;
    adcli_result res;
    const char *c_value = StringValuePtr(value);
    Data_Get_Struct (self, RUBY_ADENROLL, ptr_enroll);
    adcli_enroll_set_domain_out(enroll, c_value);
    enroll = ptr_enroll->enroll;
    return self;
}

/*
 * call-seq:
 *  
 *  adenroll.get_computer_password
 * 
 * Gets the computer password 
 */
static VALUE radenroll_get_computer_password (VALUE self) {
    RUBY_ADENROLL *ptr_enroll;
    const char *c_computer_password = NULL;
    Data_Get_Struct (self ,RUBY_ADENROLL, ptr_enroll);
    c_computer_password = adcli_enroll_get_computer_password (ptr_enroll->enroll);
    return rb_str_new_cstr (c_computer_password);
}

/*
 * call-seq:
 *  
 *  adenroll.set_computer_password('computer-password')
 * 
 * Sets the computer password 
 */
static VALUE radenroll_set_computer_password (VALUE self, VALUE value) {
    RUBY_ADENROLL *ptr_enroll;
    adcli_enroll *enroll;
    adcli_result res;
    const char *c_value = StringValuePtr (value);
    Data_Get_Struct (self, RUBY_ADENROLL, ptr_enroll);
    enroll = ptr_enroll->enroll;
    adcli_enroll_set_computer_password (enroll, c_value);
    return self;
}

/*
 * call-seq:
 *  
 *  adenroll.join
 * 
 * Joins a new computer to the Active Directory domain. Creates a machine account and sets a password for it.
 */                 
static VALUE radenroll_join (VALUE self) {
    RUBY_ADENROLL *ptr_enroll;
    adcli_result res;
    Data_Get_Struct (self, RUBY_ADENROLL, ptr_enroll);
    res = adcli_enroll_join (ptr_enroll->enroll, ADCLI_ENROLL_NO_KEYTAB);
    if (res != ADCLI_SUCCESS) {
        fprintf(stderr, "failed to join: %s", adcli_get_last_error());
    }<commit_msg>Fix warnings for unused variables in radenroll.c<commit_after>#include <radcli.h>

VALUE c_adenroll;

// Free function for the Adcli::AdEnroll class.
static void radenroll_free (RUBY_ADENROLL *ptr) {
    if(!ptr)
        return;
    adcli_enroll_unref (ptr->enroll);
    free (ptr);
}

// Allocation function for the Adcli:AdEnroll class.
static VALUE radenroll_allocate (VALUE klass) {
    RUBY_ADENROLL *ptr = malloc (sizeof(RUBY_ADENROLL));
    memset (ptr, 0, sizeof(RUBY_ADENROLL));
    return Data_Wrap_Struct (klass, 0, radenroll_free, ptr);
}

/*
 * call-seq:
 *  conn_object = Adcli::AdConn.connect('YOUR.REALM.COM')
 *  Adcli::AdEnroll.new(conn_object)
 * 
 * Creates and returns a new Adcli::AdEnroll object. 
 */
static VALUE radenroll_initialize (VALUE self, VALUE ad_conn) {
    RUBY_ADCONN *ptr_conn;
    RUBY_ADENROLL *ptr_enroll;
    Data_Get_Struct (ad_conn, RUBY_ADCONN, ptr_conn);
    Data_Get_Struct (self, RUBY_ADENROLL, ptr_enroll);
    adcli_enroll *enroll = adcli_enroll_new (ptr_conn->conn);
    ptr_enroll->enroll = enroll;
    return self;
}

/*
 * call-seq:
 *  
 *  adenroll.get_computer_name # => hostname.your.realm.com
 * 
 * Creates and returns the computer name.
 */
static VALUE radenroll_get_computer_name (VALUE self) {
    RUBY_ADENROLL *ptr_enroll;
    const char *c_computer_name = NULL;
    Data_Get_Struct (self ,RUBY_ADENROLL, ptr_enroll);
    c_computer_name  = adcli_enroll_get_computer_name (ptr_enroll->enroll);
    return rb_str_new_cstr (c_computer_name);
}

/*
 * call-seq:
 *  
 *  adenroll.set_computer_name('hostname')
 * 
 * Set the computer name to do the enroll operation on (join or delete).
 */
static VALUE radenroll_set_computer_name (VALUE self, VALUE value) {
    RUBY_ADENROLL *ptr_enroll;
    adcli_enroll *enroll;
    const char *c_value = StringValuePtr (value);
    Data_Get_Struct (self, RUBY_ADENROLL, ptr_enroll);
    enroll = ptr_enroll->enroll;
    adcli_enroll_set_computer_name (enroll, c_value);
    return self;
}

/*
 * call-seq:
 * 
 *  adenroll.set_domain_ou('OU=Testing,DC=domain,DC=example,DC=com')
 * 
 * Set the domain organizational unit.
 * 
 */
static VALUE radenroll_set_domain_ou (VALUE self, VALUE value) {
    RUBY_ADENROLL *ptr_enroll;
    adcli_enroll *enroll;

    Data_Get_Struct (self, RUBY_ADENROLL, ptr_enroll);

    const char *c_value = StringValuePtr(value);
    enroll = ptr_enroll->enroll;
    adcli_enroll_set_domain_ou(enroll, c_value);
    
    return self;
}

/*
 * call-seq:
 *  
 *  adenroll.get_computer_password
 * 
 * Gets the computer password 
 */
static VALUE radenroll_get_computer_password (VALUE self) {
    RUBY_ADENROLL *ptr_enroll;
    const char *c_computer_password = NULL;
    Data_Get_Struct (self ,RUBY_ADENROLL, ptr_enroll);
    c_computer_password = adcli_enroll_get_computer_password (ptr_enroll->enroll);
    return rb_str_new_cstr (c_computer_password);
}

/*
 * call-seq:
 *  
 *  adenroll.set_computer_password('<PASSWORD>')
 * 
 * Sets the computer password 
 */
static VALUE radenroll_set_computer_password (VALUE self, VALUE value) {
    RUBY_ADENROLL *ptr_enroll;
    adcli_enroll *enroll;

    Data_Get_Struct (self, RUBY_ADENROLL, ptr_enroll);

    enroll = ptr_enroll->enroll;
    const char *c_value = StringValuePtr (value);

    adcli_enroll_set_computer_password (enroll, c_value);

    return self;
}

/*
 * call-seq:
 *  
 *  adenroll.join
 * 
 * Joins a new computer to the Active Directory domain. Creates a machine account and sets a password for it.
 */                 
static VALUE radenroll_join (VALUE self) {
    RUBY_ADENROLL *ptr_enroll;
    adcli_result res;
    Data_Get_Struct (self, RUBY_ADENROLL, ptr_enroll);
    res = adcli_enroll_join (ptr_enroll->enroll, ADCLI_ENROLL_NO_KEYTAB);
    if (res != ADCLI_SUCCESS) {
        fprintf(stderr, "failed to join: %s", adcli_get_last_error());
    }
{'fraction_non_alphanumeric': 0.10121509824198552, 'fraction_numerical': 0.000517063081695967, 'mean_word_length': 3.9916129032258065, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7112298', 'n_tokens_mistral': 2998, 'n_tokens_neox': 2861, 'n_words': 602}