<commit_before>/*
 * Copyright 1999-2006 University of Chicago
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "globus_common.h"
#include "globus_gss_assist.h"

static
globus_result_t
globus_l_hostname_lookup_hostname_to_address_string(
    char *                              hostname,
    globus_list_t **                    out_list)                              
{
    globus_addrinfo_t                   hints;
    globus_addrinfo_t *                 addrinfo;
    globus_addrinfo_t *                 ai;
    globus_result_t                     result;
    globus_list_t *                     list = NULL;
    
    memset(&hints, 0, sizeof(globus_addrinfo_t));
    hints.ai_family = PF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_protocol = 0;

    result = globus_libc_getaddrinfo(hostname, NULL, &hints, &addrinfo);
    if(result != GLOBUS_SUCCESS || addrinfo == NULL || 
        addrinfo->ai_addr == NULL)
    {
        goto error_exit;
    }
    ai = addrinfo;
    while(ai != NULL)
    {
        char                            buffer[NI_MAXHOST];
        result = globus_libc_getnameinfo(
            (const globus_sockaddr_t *) ai->ai_addr,
            buffer,
            sizeof(buffer),
            NULL,
            0,
            GLOBUS_NI_NUMERICHOST);
        if(result != GLOBUS_SUCCESS)
        {
            globus_libc_freeaddrinfo(addrinfo);
            globus_list_destroy_all(list, free);
            goto error_exit;
        }
        
        globus_list_insert(&list, globus_libc_strdup(buffer));
        ai = ai->ai_next;
    }      
    globus_libc_freeaddrinfo(addrinfo);    
    
    *out_list = list;
    return GLOBUS_SUCCESS;
    
error_exit:
    return result;
}


int
main(
    int                                 argc,
    char **                             argv)
{
    globus_module_activate(GLOBUS_COMMON_MODULE);
    globus_module_activate(GLOBUS_GSI_GSSAPI_MODULE);
    globus_module_activate(GLOBUS_GSI_GSS_ASSIST_MODULE);

    char                                realhostname[NI_MAXHOST];
    globus_result_t                     result = GLOBUS_SUCCESS;
    char *                              hostname;
    gss_name_t                          gssname;
    char *                              numeric;
    OM_uint32                           min_stat;
    OM_uint32                           maj_stat;
    gss_buffer_desc                     subject_buf = GSS_C_EMPTY_BUFFER;
    gss_OID                             mech_type;
    globus_list_t *                     list = NULL;
    globus_list_t *                     list_p = NULL;
    char *                              hostenv;
    
    if(argc < 2)
    {
        hostname = globus_malloc(1024);
        globus_libc_gethostname(hostname, 1024);
    }
    else if(argc == 2 && *argv[1] != '-')
    {
        hostname = globus_libc_strdup(argv[1]);
    }
    else
    {<commit_msg>silly aix and her _syntax_ requirements<commit_after>/*
 * Copyright 1999-2006 University of Chicago
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "globus_common.h"
#include "globus_gss_assist.h"

static
globus_result_t
globus_l_hostname_lookup_hostname_to_address_string(
    char *                              hostname,
    globus_list_t **                    out_list)                              
{
    globus_addrinfo_t                   hints;
    globus_addrinfo_t *                 addrinfo;
    globus_addrinfo_t *                 ai;
    globus_result_t                     result;
    globus_list_t *                     list = NULL;
    
    memset(&hints, 0, sizeof(globus_addrinfo_t));
    hints.ai_family = PF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_protocol = 0;

    result = globus_libc_getaddrinfo(hostname, NULL, &hints, &addrinfo);
    if(result != GLOBUS_SUCCESS || addrinfo == NULL || 
        addrinfo->ai_addr == NULL)
    {
        goto error_exit;
    }
    ai = addrinfo;
    while(ai != NULL)
    {
        char                            buffer[NI_MAXHOST];
        result = globus_libc_getnameinfo(
            (const globus_sockaddr_t *) ai->ai_addr,
            buffer,
            sizeof(buffer),
            NULL,
            0,
            GLOBUS_NI_NUMERICHOST);
        if(result != GLOBUS_SUCCESS)
        {
            globus_libc_freeaddrinfo(addrinfo);
            globus_list_destroy_all(list, free);
            goto error_exit;
        }
        
        globus_list_insert(&list, globus_libc_strdup(buffer));
        ai = ai->ai_next;
    }      
    globus_libc_freeaddrinfo(addrinfo);    
    
    *out_list = list;
    return GLOBUS_SUCCESS;
    
error_exit:
    return result;
}


int
main(
    int                                 argc,
    char **                             argv)
{
    char                                realhostname[NI_MAXHOST];
    globus_result_t                     result = GLOBUS_SUCCESS;
    char *                              hostname;
    gss_name_t                          gssname;
    char *                              numeric;
    OM_uint32                           min_stat;
    OM_uint32                           maj_stat;
    gss_buffer_desc                     subject_buf = GSS_C_EMPTY_BUFFER;
    gss_OID                             mech_type;
    globus_list_t *                     list = NULL;
    globus_list_t *                     list_p = NULL;
    char *                              hostenv;

    globus_module_activate(GLOBUS_COMMON_MODULE);
    globus_module_activate(GLOBUS_GSI_GSSAPI_MODULE);
    globus_module_activate(GLOBUS_GSI_GSS_ASSIST_MODULE);
    
    if(argc < 2)
    {
        hostname = globus_malloc(1024);
        globus_libc_gethostname(hostname, 1024);
    }
    else if(argc == 2 && *argv[1] != '-')
    {
        hostname = globus_libc_strdup(argv[1]);
    }
    else
    {
{'fraction_non_alphanumeric': 0.07230320699708455, 'fraction_numerical': 0.009037900874635569, 'mean_word_length': 1.59297052154195, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4431010', 'n_tokens_mistral': 2093, 'n_tokens_neox': 2009, 'n_words': 431}