diff --git a/gass/copy/source/globus_gass_copy_glob.c b/gass/copy/source/globus_gass_copy_glob.c index e1717be61..c4ff7ceae 100644 --- a/gass/copy/source/globus_gass_copy_glob.c +++ b/gass/copy/source/globus_gass_copy_glob.c @@ -35,7 +35,7 @@ int globus_l_win_fnmatch( ***********************************************************/ -/* +/* todo: come up with minimal globbing support for windows */ @@ -67,7 +67,7 @@ typedef struct void * entry_user_arg; globus_gass_copy_callback_t op_cb; void * op_cb_arg; -} globus_l_gass_copy_glob_info_t; +} globus_l_gass_copy_glob_info_t; static globus_result_t @@ -83,12 +83,12 @@ static globus_result_t globus_l_gass_copy_glob_parse_ftp_list( globus_l_gass_copy_glob_info_t * info); - + static globus_result_t globus_l_gass_copy_glob_ftp_list( globus_l_gass_copy_glob_info_t * info); - + static void globus_l_gass_copy_ftp_client_op_done_callback( @@ -96,7 +96,7 @@ globus_l_gass_copy_ftp_client_op_done_callback( globus_ftp_client_handle_t * handle, globus_object_t * err); -static +static void globus_l_gass_copy_ftp_client_list_read_callback( void * user_arg, @@ -111,7 +111,7 @@ static globus_result_t globus_l_gass_copy_mkdir_file( char * url); - + static globus_result_t globus_l_gass_copy_mkdir_ftp( @@ -129,14 +129,14 @@ globus_l_gass_copy_urlencode( #define GLOBUS_GASS_COPY_FTP_LIST_BUFFER_SIZE 256*1024 -globus_result_t -globus_gass_copy_glob_expand_url( - globus_gass_copy_handle_t * handle, - const char * url, +globus_result_t +globus_gass_copy_glob_expand_url( + globus_gass_copy_handle_t * handle, + const char * url, globus_gass_copy_attr_t * attr, globus_gass_copy_glob_entry_cb_t entry_cb, void * user_arg) -{ +{ static char * myname = "globus_gass_copy_glob_expand_url"; globus_l_gass_copy_glob_info_t * info; globus_result_t result; @@ -145,22 +145,22 @@ globus_gass_copy_glob_expand_url( int url_len; int path_len; globus_bool_t glob = GLOBUS_TRUE; - globus_gass_copy_glob_stat_t * stat_info; + globus_gass_copy_glob_stat_t * stat_info; char * path; stat_info = (globus_gass_copy_glob_stat_t *) globus_calloc(1, sizeof(globus_gass_copy_glob_stat_t)); - + info = (globus_l_gass_copy_glob_info_t *) globus_malloc(sizeof(globus_l_gass_copy_glob_info_t)); - + info->handle = handle; info->attr = attr; info->url = globus_libc_strdup(url); info->entry_cb = entry_cb; info->entry_user_arg = user_arg; - + retval = globus_url_get_scheme(info->url, &scheme_type); @@ -174,7 +174,7 @@ globus_gass_copy_glob_expand_url( myname)); goto error; } - + /* find start of path so we ignore potential globbing chars in host/port */ url_len = strlen(info->url); if(scheme_type != GLOBUS_URL_SCHEME_FILE && @@ -189,20 +189,20 @@ globus_gass_copy_glob_expand_url( path = info->url; path_len = url_len; } - + /* check if url contains glob characters, and append * if it is a directory */ - + if(strcspn(path, "[]*?") == path_len) - { + { /* no globbing chars in path */ if(info->url[url_len - 1] == '/') - { + { info->url = (char *) globus_realloc( info->url, (url_len + 2) * sizeof(char)); - + info->url[url_len++] = '*'; - info->url[url_len] = '\0'; + info->url[url_len] = '\0'; } else if(handle->always_stat_on_expand) @@ -215,7 +215,7 @@ globus_gass_copy_glob_expand_url( info->url, stat_info, info->entry_user_arg); - + if(stat_info->symlink_target) { globus_free(stat_info->symlink_target); @@ -225,7 +225,7 @@ globus_gass_copy_glob_expand_url( globus_free(stat_info->unique_id); } } - + glob = GLOBUS_FALSE; } else @@ -236,12 +236,12 @@ globus_gass_copy_glob_expand_url( stat_info->mode = -1; stat_info->mdtm = -1; stat_info->size = -1; - + info->entry_cb( info->url, stat_info, info->entry_user_arg); - + glob = GLOBUS_FALSE; result = GLOBUS_SUCCESS; } @@ -256,11 +256,11 @@ globus_gass_copy_glob_expand_url( case GLOBUS_URL_SCHEME_SSHFTP: result = globus_l_gass_copy_glob_expand_ftp_url(info); break; - + case GLOBUS_URL_SCHEME_FILE: result = globus_l_gass_copy_glob_expand_file_url(info); break; - + default: result = globus_error_put( globus_error_construct_string( @@ -269,15 +269,15 @@ globus_gass_copy_glob_expand_url( "[%s]: Globbing not supported with URL scheme.", myname)); goto error; - break; + break; } - } + } globus_free(info->url); globus_free(info); globus_free(stat_info); return result; - + error: globus_free(info->url); globus_free(info); @@ -288,7 +288,7 @@ globus_gass_copy_glob_expand_url( static globus_result_t -globus_l_gass_copy_glob_expand_file_url( +globus_l_gass_copy_glob_expand_file_url( globus_l_gass_copy_glob_info_t * info) { static char * myname = "globus_l_gass_copy_glob_expand_file_url"; @@ -299,7 +299,7 @@ globus_l_gass_copy_glob_expand_file_url( struct stat stat_buf; char unique_id[256]; globus_gass_copy_glob_entry_t type; - globus_gass_copy_glob_stat_t info_stat; + globus_gass_copy_glob_stat_t info_stat; char matched_url[MAXPATHLEN*2]; char * encoded_path; struct dirent * dir_entry; @@ -310,7 +310,7 @@ globus_l_gass_copy_glob_expand_file_url( info->glob_pattern = strrchr(info->base_url, '/'); globus_url_string_hex_decode(info->glob_pattern); - + if(info->glob_pattern == GLOBUS_NULL || *info->glob_pattern == '\0') { result = globus_error_put( @@ -322,7 +322,7 @@ globus_l_gass_copy_glob_expand_file_url( goto error_url; } - *(info->glob_pattern++) = '\0'; + *(info->glob_pattern++) = '\0'; info->base_url_len = strlen(info->base_url); retval = globus_url_parse_loose(info->base_url, &parsed_url); @@ -336,7 +336,7 @@ globus_l_gass_copy_glob_expand_file_url( myname, info->base_url)); goto error_url; - } + } if(stat(parsed_url.url_path, &stat_buf) != 0) { @@ -349,7 +349,7 @@ globus_l_gass_copy_glob_expand_file_url( parsed_url.url_path)); goto error_stat; } - + if(!S_ISDIR(stat_buf.st_mode)) { result = globus_error_put( @@ -374,19 +374,19 @@ globus_l_gass_copy_glob_expand_file_url( parsed_url.url_path)); goto error_open; } - + for(i = 0; globus_libc_readdir_r(dir, &dir_entry) == 0 && dir_entry; i++) { char path[MAXPATHLEN]; - - if(dir_entry->d_name[0] == '.' && (dir_entry->d_name[1] == '\0' || + + if(dir_entry->d_name[0] == '.' && (dir_entry->d_name[1] == '\0' || (dir_entry->d_name[1] == '.' && dir_entry->d_name[2] == '\0'))) { globus_free(dir_entry); continue; - } + } if(fnmatch( info->glob_pattern, @@ -397,7 +397,7 @@ globus_l_gass_copy_glob_expand_file_url( continue; } - snprintf(path, sizeof(path), + snprintf(path, sizeof(path), "%s/%s", parsed_url.url_path, dir_entry->d_name); path[MAXPATHLEN - 1] = '\0'; #ifndef TARGET_ARCH_WIN32 @@ -429,7 +429,7 @@ globus_l_gass_copy_glob_expand_file_url( GLOBUS_NULL, "[%s]: invalid symlink entry in dir: %s", myname, - path)); + path)); globus_free(dir_entry); continue; } @@ -441,35 +441,35 @@ globus_l_gass_copy_glob_expand_file_url( GLOBUS_NULL, "[%s]: unable to find path of symlink in dir: %s", myname, - path)); + path)); globus_free(dir_entry); continue; } - } + } #endif - + if(S_ISDIR(stat_buf.st_mode)) { type = GLOBUS_GASS_COPY_GLOB_ENTRY_DIR; } else - { + { type = GLOBUS_GASS_COPY_GLOB_ENTRY_FILE; - } + } - *unique_id = '\0'; + *unique_id = '\0'; sprintf( unique_id, "%lx-%lx;", - (unsigned long) stat_buf.st_dev, + (unsigned long) stat_buf.st_dev, (unsigned long) stat_buf.st_ino); globus_l_gass_copy_urlencode(dir_entry->d_name, &encoded_path); sprintf( - matched_url, - "%s/%s%s", - info->base_url, + matched_url, + "%s/%s%s", + info->base_url, encoded_path, type == GLOBUS_GASS_COPY_GLOB_ENTRY_DIR ? "/" : ""); @@ -485,7 +485,7 @@ globus_l_gass_copy_glob_expand_file_url( info_stat.mode = stat_buf.st_mode & 07777; info_stat.mdtm = (int) stat_buf.st_mtime; info_stat.size = stat_buf.st_size; - + info->entry_cb( matched_url, &info_stat, @@ -493,13 +493,13 @@ globus_l_gass_copy_glob_expand_file_url( globus_free(dir_entry); } - + closedir(dir); globus_url_destroy(&parsed_url); globus_free(info->base_url); - - return GLOBUS_SUCCESS; - + + return GLOBUS_SUCCESS; + error_stat: error_open: globus_url_destroy(&parsed_url); @@ -508,7 +508,7 @@ globus_l_gass_copy_glob_expand_file_url( globus_free(info->base_url); return result; -} +} static @@ -516,12 +516,12 @@ globus_result_t globus_l_gass_copy_glob_expand_ftp_url( globus_l_gass_copy_glob_info_t * info) { - static char * myname = "globus_l_gass_copy_glob_expand_ftp_url"; - globus_result_t result; + static char * myname = "globus_l_gass_copy_glob_expand_ftp_url"; + globus_result_t result; globus_ftp_client_tristate_t feature_response; globus_ftp_client_features_t features; char * tmp; - + info->base_url = globus_libc_strdup(info->url); @@ -542,12 +542,12 @@ globus_l_gass_copy_glob_expand_ftp_url( *tmp = '\0'; globus_url_string_hex_decode(info->glob_pattern); - + info->base_url_len = strlen(info->base_url); info->list_buffer = GLOBUS_NULL; info->buffer_length = 0; info->err = GLOBUS_NULL; - + globus_mutex_init(&info->mutex, GLOBUS_NULL); globus_cond_init(&info->cond, GLOBUS_NULL); @@ -566,12 +566,12 @@ globus_l_gass_copy_glob_expand_ftp_url( &features, globus_l_gass_copy_ftp_client_op_done_callback, info); - + if(result != GLOBUS_SUCCESS) { goto error_feat; } - + globus_mutex_lock(&info->mutex); while(info->callbacks_left) { @@ -583,55 +583,55 @@ globus_l_gass_copy_glob_expand_ftp_url( info->err = GLOBUS_NULL; } globus_mutex_unlock(&info->mutex); - + if(result != GLOBUS_SUCCESS) { goto error_feat; } result = globus_ftp_client_is_feature_supported( - &features, - &feature_response, + &features, + &feature_response, GLOBUS_FTP_CLIENT_FEATURE_MLST); - + if(result != GLOBUS_SUCCESS) { goto error_feat; } - + if(feature_response == GLOBUS_FTP_CLIENT_TRUE) - { + { info->list_op = GLOBUS_GASS_COPY_FTP_OP_MLSD; } - else + else { info->list_op = GLOBUS_GASS_COPY_FTP_OP_NLST; } - result = globus_l_gass_copy_glob_ftp_list(info); - + result = globus_l_gass_copy_glob_ftp_list(info); + if(result != GLOBUS_SUCCESS) { goto error_list; } - result = globus_l_gass_copy_glob_parse_ftp_list(info); - + result = globus_l_gass_copy_glob_parse_ftp_list(info); + if(result != GLOBUS_SUCCESS) { goto error_list; - } + } if(info->list_buffer != GLOBUS_NULL) - { + { globus_free(info->list_buffer); } - + globus_ftp_client_features_destroy(&features); globus_cond_destroy(&info->cond); globus_mutex_destroy(&info->mutex); - + globus_free(info->base_url); globus_free(info->glob_pattern); @@ -642,7 +642,7 @@ globus_l_gass_copy_glob_expand_ftp_url( error_feat: globus_ftp_client_features_destroy(&features); -error_feat_init: +error_feat_init: globus_cond_destroy(&info->cond); globus_mutex_destroy(&info->mutex); globus_free(info->glob_pattern); @@ -658,13 +658,13 @@ globus_result_t globus_l_gass_copy_glob_ftp_list( globus_l_gass_copy_glob_info_t * info) { - static char * myname = "globus_l_gass_copy_glob_ftp_list"; + static char * myname = "globus_l_gass_copy_glob_ftp_list"; globus_result_t result; globus_byte_t * read_buffer; - + read_buffer = (globus_byte_t *) - globus_malloc(GLOBUS_GASS_COPY_FTP_LIST_BUFFER_SIZE * + globus_malloc(GLOBUS_GASS_COPY_FTP_LIST_BUFFER_SIZE * sizeof(globus_byte_t)); if(read_buffer == GLOBUS_NULL) @@ -676,10 +676,10 @@ globus_l_gass_copy_glob_ftp_list( "[%s]: Memory allocation error", myname)); goto error_malloc; - } + } + - - info->callbacks_left = 2; + info->callbacks_left = 2; if(info->list_op == GLOBUS_GASS_COPY_FTP_OP_MLSD) { result = globus_ftp_client_machine_list( @@ -689,7 +689,7 @@ globus_l_gass_copy_glob_ftp_list( globus_l_gass_copy_ftp_client_op_done_callback, info); } - else + else { result = globus_ftp_client_list( &info->handle->ftp_handle, @@ -714,7 +714,7 @@ globus_l_gass_copy_glob_ftp_list( if(result != GLOBUS_SUCCESS) { globus_ftp_client_abort(&info->handle->ftp_handle); - + globus_mutex_lock(&info->mutex); info->callbacks_left--; while(info->callbacks_left > 0) @@ -722,8 +722,8 @@ globus_l_gass_copy_glob_ftp_list( globus_cond_wait(&info->cond, &info->mutex); } globus_mutex_unlock(&info->mutex); - - goto error_read; + + goto error_read; } globus_mutex_lock(&info->mutex); @@ -745,7 +745,7 @@ globus_l_gass_copy_glob_ftp_list( } if(read_buffer != (globus_byte_t *) info->list_buffer) - { + { globus_free(read_buffer); } @@ -758,7 +758,7 @@ globus_l_gass_copy_glob_ftp_list( error_list: if(read_buffer != GLOBUS_NULL) - { + { globus_free(read_buffer); } if(info->err) @@ -782,7 +782,7 @@ globus_l_gass_copy_ftp_client_op_done_callback( globus_l_gass_copy_glob_info_t * info; info = (globus_l_gass_copy_glob_info_t *) user_arg; - + globus_mutex_lock(&info->mutex); if (err && !info->err) { @@ -791,7 +791,7 @@ globus_l_gass_copy_ftp_client_op_done_callback( info->callbacks_left--; globus_cond_signal(&info->cond); globus_mutex_unlock(&info->mutex); - + return; } @@ -807,7 +807,7 @@ globus_l_gass_copy_ftp_client_cksm_done_callback( info = (globus_l_gass_copy_glob_info_t *) user_arg; if(info->op_cb) { - info->op_cb(info->op_cb_arg, info->handle, err); + info->op_cb(info->op_cb_arg, info->handle, err); } else { @@ -820,9 +820,9 @@ globus_l_gass_copy_ftp_client_cksm_done_callback( globus_cond_signal(&info->cond); globus_mutex_unlock(&info->mutex); } - + globus_free(info); - + return; } @@ -832,7 +832,7 @@ globus_l_gass_copy_mdtm_to_timet( char * mdtm_str, int * time_out) { - char * p; + char * p; struct tm tm; struct tm gmt_now_tm; struct tm * gmt_now_tm_p; @@ -840,17 +840,17 @@ globus_l_gass_copy_mdtm_to_timet( time_t gmt_now; time_t now; time_t file_time; - int rc; + int rc; p = mdtm_str; - + memset(&tm, '\0', sizeof(struct tm)); /* 4 digit year */ rc = sscanf(p, "%04d", &tm.tm_year); if(rc != 1) { - goto error_exit; + goto error_exit; } tm.tm_year -= 1900; p += 4; @@ -859,7 +859,7 @@ globus_l_gass_copy_mdtm_to_timet( rc = sscanf(p, "%02d", &tm.tm_mon); if(rc != 1) { - goto error_exit; + goto error_exit; } tm.tm_mon--; p += 2; @@ -868,7 +868,7 @@ globus_l_gass_copy_mdtm_to_timet( rc = sscanf(p, "%02d", &tm.tm_mday); if(rc != 1) { - goto error_exit; + goto error_exit; } p += 2; @@ -876,7 +876,7 @@ globus_l_gass_copy_mdtm_to_timet( rc = sscanf(p, "%02d", &tm.tm_hour); if(rc != 1) { - goto error_exit; + goto error_exit; } p += 2; @@ -884,7 +884,7 @@ globus_l_gass_copy_mdtm_to_timet( rc = sscanf(p, "%02d", &tm.tm_min); if(rc != 1) { - goto error_exit; + goto error_exit; } p += 2; @@ -892,35 +892,35 @@ globus_l_gass_copy_mdtm_to_timet( rc = sscanf(p, "%02d", &tm.tm_sec); if(rc != 1) { - goto error_exit; + goto error_exit; } p += 2; - + file_time = mktime(&tm); if(file_time == (time_t) -1) { - goto error_exit; + goto error_exit; } - + now = time(&now); if(now == (time_t) -1) { - goto error_exit; + goto error_exit; } - + memset(&gmt_now_tm, '\0', sizeof(struct tm)); gmt_now_tm_p = globus_libc_gmtime_r(&now, &gmt_now_tm); if(gmt_now_tm_p == NULL) { - goto error_exit; + goto error_exit; } - + gmt_now = mktime(&gmt_now_tm); if(gmt_now == (time_t) -1) { - goto error_exit; + goto error_exit; } - + offset = now - gmt_now; *time_out = file_time + offset; @@ -931,7 +931,7 @@ globus_l_gass_copy_mdtm_to_timet( return GLOBUS_FAILURE; } - + static globus_result_t globus_l_gass_copy_glob_parse_mlst_line( @@ -946,7 +946,7 @@ globus_l_gass_copy_glob_parse_mlst_line( char * startfact; char * endfact; char * factval; - + char * unique_id = NULL; char * mode_s = NULL; char * symlink_target = NULL; @@ -955,7 +955,7 @@ globus_l_gass_copy_glob_parse_mlst_line( globus_gass_copy_glob_entry_t type = GLOBUS_GASS_COPY_GLOB_ENTRY_UNKNOWN; startline = line; - + space = strchr(startline, ' '); if(space == GLOBUS_NULL) { @@ -965,49 +965,49 @@ globus_l_gass_copy_glob_parse_mlst_line( GLOBUS_NULL, "[%s]: Bad MLSD response", myname)); - + goto error_invalid_mlsd; } - *space = '\0'; + *space = '\0'; startfact = startline; - + while(startfact != space) { endfact = strchr(startfact, ';'); if(endfact) - { + { *endfact = '\0'; } else - { + { /* older MLST-draft spec says ending fact can be missing the final semicolon... not a problem to support this, - no need to die. (ncftpd does this) - + no need to die. (ncftpd does this) + result = globus_error_put( globus_error_construct_string( GLOBUS_GASS_COPY_MODULE, GLOBUS_NULL, "[%s]: Bad MLSD response", myname)); - + goto error_invalid_mlsd; */ - endfact = space - 1; + endfact = space - 1; } - + factval = strchr(startfact, '='); if(!factval) - { + { result = globus_error_put( globus_error_construct_string( GLOBUS_GASS_COPY_MODULE, GLOBUS_NULL, "[%s]: Bad MLSD response", myname)); - + goto error_invalid_mlsd; } *(factval++) = '\0'; @@ -1016,7 +1016,7 @@ globus_l_gass_copy_glob_parse_mlst_line( { startfact[i] = tolower(startfact[i]); } - + if(strcmp(startfact, "type") == 0) { if(strcasecmp(factval, "dir") == 0) @@ -1030,62 +1030,62 @@ globus_l_gass_copy_glob_parse_mlst_line( else { type = GLOBUS_GASS_COPY_GLOB_ENTRY_OTHER; - } - } + } + } if(strcmp(startfact, "unique") == 0) { - unique_id = factval; - } + unique_id = factval; + } if(strcmp(startfact, "unix.mode") == 0) { - mode_s = factval; + mode_s = factval; } if(strcmp(startfact, "modify") == 0) { - modify_s = factval; - } + modify_s = factval; + } if(strcmp(startfact, "size") == 0) { - size_s = factval; - } + size_s = factval; + } if(strcmp(startfact, "unix.slink") == 0) { - symlink_target = factval; - } - - startfact = endfact + 1; - } + symlink_target = factval; + } + + startfact = endfact + 1; + } + - stat_info->type = type; stat_info->unique_id = globus_libc_strdup(unique_id); stat_info->symlink_target = globus_libc_strdup(symlink_target); stat_info->mode = -1; stat_info->size = -1; stat_info->mdtm = -1; - + if(mode_s) { stat_info->mode = strtoul(mode_s, NULL, 0); } - + if(size_s) { globus_off_t size; int rc; - + rc = sscanf(size_s, "%"GLOBUS_OFF_T_FORMAT, &size); if(rc == 1) { stat_info->size = size; } } - + if(modify_s) { int mdtm; - - if(globus_l_gass_copy_mdtm_to_timet(modify_s, &mdtm) == + + if(globus_l_gass_copy_mdtm_to_timet(modify_s, &mdtm) == GLOBUS_SUCCESS) { stat_info->mdtm = mdtm; @@ -1115,7 +1115,7 @@ globus_l_gass_copy_glob_parse_ftp_list( char * startfact; char * endfact; char * factval; - + char matched_url[4096]; char * encoded_path = NULL; char * unique_id; @@ -1124,10 +1124,10 @@ globus_l_gass_copy_glob_parse_ftp_list( char * modify_s; char * size_s; globus_gass_copy_glob_entry_t type; - globus_gass_copy_glob_stat_t info_stat; - + globus_gass_copy_glob_stat_t info_stat; + startline = info->list_buffer; - + while(startline < (info->list_buffer + info->buffer_length)) { type = GLOBUS_GASS_COPY_GLOB_ENTRY_UNKNOWN; @@ -1136,33 +1136,33 @@ globus_l_gass_copy_glob_parse_ftp_list( symlink_target = GLOBUS_NULL; size_s = GLOBUS_NULL; modify_s = GLOBUS_NULL; - - while(*startline == '\r' || + + while(*startline == '\r' || *startline == '\n') { startline++; - + } - + if(info->list_op == GLOBUS_GASS_COPY_FTP_OP_NLST) { endline = startline; while(endline < info->list_buffer + info->buffer_length && - *endline != '\r' && *endline != '\n') + *endline != '\r' && *endline != '\n') { endline++; - } + } *endline = '\0'; filename = startline; } - else + else { endline = startline; - while(endline + 1 < info->list_buffer + info->buffer_length && + while(endline + 1 < info->list_buffer + info->buffer_length && (*endline != '\r' || *(endline + 1) != '\n')) { endline++; - } + } *endline = '\0'; space = strchr(startline, ' '); @@ -1174,50 +1174,50 @@ globus_l_gass_copy_glob_parse_ftp_list( GLOBUS_NULL, "[%s]: Bad MLSD response", myname)); - + goto error_invalid_mlsd; } - *space = '\0'; + *space = '\0'; filename = space + 1; startfact = startline; - + while(startfact != space) { endfact = strchr(startfact, ';'); if(endfact) - { + { *endfact = '\0'; } else - { + { /* older MLST-draft spec says ending fact can be missing the final semicolon... not a problem to support this, - no need to die. (ncftpd does this) - + no need to die. (ncftpd does this) + result = globus_error_put( globus_error_construct_string( GLOBUS_GASS_COPY_MODULE, GLOBUS_NULL, "[%s]: Bad MLSD response", myname)); - + goto error_invalid_mlsd; */ - endfact = space - 1; + endfact = space - 1; } - + factval = strchr(startfact, '='); if(!factval) - { + { result = globus_error_put( globus_error_construct_string( GLOBUS_GASS_COPY_MODULE, GLOBUS_NULL, "[%s]: Bad MLSD response", myname)); - + goto error_invalid_mlsd; } *(factval++) = '\0'; @@ -1226,7 +1226,7 @@ globus_l_gass_copy_glob_parse_ftp_list( { startfact[i] = tolower(startfact[i]); } - + if(strcmp(startfact, "type") == 0) { if(strcasecmp(factval, "dir") == 0) @@ -1240,31 +1240,31 @@ globus_l_gass_copy_glob_parse_ftp_list( else { type = GLOBUS_GASS_COPY_GLOB_ENTRY_OTHER; - } - } + } + } if(strcmp(startfact, "unique") == 0) { - unique_id = factval; - } + unique_id = factval; + } if(strcmp(startfact, "unix.mode") == 0) { - mode_s = factval; + mode_s = factval; } if(strcmp(startfact, "modify") == 0) { - modify_s = factval; - } + modify_s = factval; + } if(strcmp(startfact, "size") == 0) { - size_s = factval; - } + size_s = factval; + } if(strcmp(startfact, "unix.slink") == 0) { - symlink_target = factval; - } - - startfact = endfact + 1; - } + symlink_target = factval; + } + + startfact = endfact + 1; + } } temp_p = strrchr(filename, '/'); @@ -1272,35 +1272,35 @@ globus_l_gass_copy_glob_parse_ftp_list( { filename = temp_p + 1; } - - *matched_url = '\0'; - + + *matched_url = '\0'; + globus_l_gass_copy_urlencode(filename, &encoded_path); - + if(fnmatch( info->glob_pattern, filename, 0) == 0) { sprintf( - matched_url, + matched_url, "%s%s%s", - info->base_url, + info->base_url, encoded_path, type == GLOBUS_GASS_COPY_GLOB_ENTRY_DIR ? "/" : ""); } - + if(encoded_path) { globus_free(encoded_path); encoded_path = NULL; } - + if(*matched_url && - (type == GLOBUS_GASS_COPY_GLOB_ENTRY_DIR || + (type == GLOBUS_GASS_COPY_GLOB_ENTRY_DIR || type == GLOBUS_GASS_COPY_GLOB_ENTRY_FILE || type == GLOBUS_GASS_COPY_GLOB_ENTRY_UNKNOWN) && - !(filename[0] == '.' && (filename[1] == '\0' || + !(filename[0] == '.' && (filename[1] == '\0' || (filename[1] == '.' && filename[2] == '\0'))) ) { info_stat.type = type; @@ -1309,56 +1309,56 @@ globus_l_gass_copy_glob_parse_ftp_list( info_stat.mode = -1; info_stat.size = -1; info_stat.mdtm = -1; - + if(mode_s) { info_stat.mode = strtoul(mode_s, NULL, 0); } - + if(size_s) { globus_off_t size; int rc; - + rc = sscanf(size_s, "%"GLOBUS_OFF_T_FORMAT, &size); if(rc == 1) { info_stat.size = size; } } - + if(modify_s) { int mdtm; - - if(globus_l_gass_copy_mdtm_to_timet(modify_s, &mdtm) == + + if(globus_l_gass_copy_mdtm_to_timet(modify_s, &mdtm) == GLOBUS_SUCCESS) { info_stat.mdtm = mdtm; } } - + info->entry_cb( matched_url, &info_stat, info->entry_user_arg); } - + startline = endline + 1; - while(startline < info->list_buffer + info->buffer_length && + while(startline < info->list_buffer + info->buffer_length && (*startline == '\r' || *startline == '\n')) { - startline++; + startline++; } } - + return GLOBUS_SUCCESS; - + error_invalid_mlsd: - return result; - + return result; + } @@ -1374,11 +1374,11 @@ globus_l_gass_copy_ftp_client_list_read_callback( globus_off_t offset, globus_bool_t eof) { - static char * myname = "globus_l_gass_copy_ftp_client_list_read_callback"; + static char * myname = "globus_l_gass_copy_ftp_client_list_read_callback"; globus_l_gass_copy_glob_info_t * info; globus_result_t result; char * temp_p = NULL; - + info = (globus_l_gass_copy_glob_info_t *) user_arg; if(err) @@ -1396,7 +1396,7 @@ globus_l_gass_copy_ftp_client_list_read_callback( { if((length + offset) > info->buffer_length) { - temp_p = (char *) + temp_p = (char *) globus_realloc(info->list_buffer, length + offset); if(temp_p == GLOBUS_NULL) { @@ -1408,17 +1408,17 @@ globus_l_gass_copy_ftp_client_list_read_callback( myname)); goto error_malloc; } - + info->list_buffer = temp_p; info->buffer_length = length + offset; - } + } memcpy( info->list_buffer + offset, - buffer, + buffer, length); } - + if(!eof) { result = globus_ftp_client_register_read( @@ -1431,18 +1431,18 @@ globus_l_gass_copy_ftp_client_list_read_callback( if(result != GLOBUS_SUCCESS) { goto error_register_read; - } + } } else { - + globus_mutex_lock(&info->mutex); info->callbacks_left--; globus_cond_signal(&info->cond); globus_mutex_unlock(&info->mutex); - } + } return; @@ -1494,7 +1494,7 @@ globus_l_gass_copy_urlencode( *out_ptr++ = '%'; *out_ptr++ = hex_chars[(*in_ptr >> 4) & 0xF]; *out_ptr++ = hex_chars[*in_ptr & 0xF]; - } + } else { *out_ptr++ = *in_ptr; @@ -1519,12 +1519,12 @@ globus_l_gass_copy_stat_ftp( globus_l_gass_copy_glob_info_t info; globus_byte_t * mlst_buf; globus_size_t mlst_len; - + info.callbacks_left = 1; info.err = GLOBUS_NULL; globus_cond_init(&info.cond, GLOBUS_NULL); globus_mutex_init(&info.mutex, GLOBUS_NULL); - + result = globus_ftp_client_mlst( &handle->ftp_handle, url, @@ -1550,15 +1550,15 @@ globus_l_gass_copy_stat_ftp( result = globus_error_put(info.err); info.err = GLOBUS_NULL; } - + if(result != GLOBUS_SUCCESS) { goto error_mlst; } - + result = globus_l_gass_copy_glob_parse_mlst_line( (char *) mlst_buf, stat_info); - + if(result != GLOBUS_SUCCESS) { goto error_parse; @@ -1586,7 +1586,7 @@ globus_l_gass_copy_stat_file( char * url, globus_gass_copy_glob_stat_t * stat_info) { - static char * myname = "globus_l_gass_copy_stat_file"; + static char * myname = "globus_l_gass_copy_stat_file"; int rc; globus_result_t result; struct stat stat_buf; @@ -1594,9 +1594,9 @@ globus_l_gass_copy_stat_file( char unique_id[256]; globus_gass_copy_glob_entry_t type; char symlink_target[MAXPATHLEN*2]; - + rc = globus_url_parse(url, &parsed_url); - + if(rc != 0) { result = globus_error_put( @@ -1609,7 +1609,7 @@ globus_l_gass_copy_stat_file( rc)); goto error_url; } - + if(parsed_url.url_path == GLOBUS_NULL) { result = globus_error_put( @@ -1621,7 +1621,7 @@ globus_l_gass_copy_stat_file( myname)); goto error_null_path; } - + #ifndef TARGET_ARCH_WIN32 if(lstat(parsed_url.url_path, &stat_buf) != 0) #else @@ -1650,7 +1650,7 @@ globus_l_gass_copy_stat_file( GLOBUS_NULL, "[%s]: invalid symlink entry in dir: %s", myname, - parsed_url.url_path)); + parsed_url.url_path)); goto error_stat; } if(realpath(parsed_url.url_path, symlink_target) == NULL) @@ -1664,7 +1664,7 @@ globus_l_gass_copy_stat_file( parsed_url.url_path)); goto error_stat; } - } + } #endif if(S_ISDIR(stat_buf.st_mode)) @@ -1672,36 +1672,36 @@ globus_l_gass_copy_stat_file( type = GLOBUS_GASS_COPY_GLOB_ENTRY_DIR; } else - { + { type = GLOBUS_GASS_COPY_GLOB_ENTRY_FILE; - } + } - *unique_id = '\0'; + *unique_id = '\0'; sprintf( unique_id, "%lx-%lx;", - (unsigned long) stat_buf.st_dev, + (unsigned long) stat_buf.st_dev, (unsigned long) stat_buf.st_ino); stat_info->type = type; stat_info->unique_id = globus_libc_strdup(unique_id); - stat_info->symlink_target = *symlink_target ? + stat_info->symlink_target = *symlink_target ? globus_libc_strdup(symlink_target) : NULL; stat_info->mode = stat_buf.st_mode & 07777; stat_info->mdtm = (int) stat_buf.st_mtime; stat_info->size = stat_buf.st_size; - - globus_url_destroy(&parsed_url); + + globus_url_destroy(&parsed_url); return GLOBUS_SUCCESS; -error_stat: +error_stat: error_null_path: globus_url_destroy(&parsed_url); - + error_url: return result; - + } globus_result_t @@ -1710,18 +1710,18 @@ globus_gass_copy_stat( char * url, globus_gass_copy_attr_t * attr, globus_gass_copy_glob_stat_t * stat_info) -{ - static char * myname = "globus_gass_copy_stat"; +{ + static char * myname = "globus_gass_copy_stat"; globus_result_t result; globus_gass_copy_url_mode_t url_mode; - + result = globus_gass_copy_get_url_mode(url, &url_mode); if(result != GLOBUS_SUCCESS) { goto error_exit; } - + if(url_mode == GLOBUS_GASS_COPY_URL_MODE_FTP) { result = globus_l_gass_copy_stat_ftp(handle, url, attr, stat_info); @@ -1750,13 +1750,13 @@ globus_gass_copy_stat( url)); goto error_exit; } - + return GLOBUS_SUCCESS; - + error_exit: return result; - + } @@ -1765,18 +1765,18 @@ globus_gass_copy_mkdir( globus_gass_copy_handle_t * handle, char * url, globus_gass_copy_attr_t * attr) -{ - static char * myname = "globus_gass_copy_mkdir"; +{ + static char * myname = "globus_gass_copy_mkdir"; globus_result_t result; globus_gass_copy_url_mode_t url_mode; - + result = globus_gass_copy_get_url_mode(url, &url_mode); if(result != GLOBUS_SUCCESS) { goto error_exit; } - + if(url_mode == GLOBUS_GASS_COPY_URL_MODE_FTP) { result = globus_l_gass_copy_mkdir_ftp(handle, url, attr); @@ -1805,16 +1805,16 @@ globus_gass_copy_mkdir( url)); goto error_exit; } - + return GLOBUS_SUCCESS; - + error_ftp_mkdir: error_file_mkdir: error_exit: return result; - + } @@ -1827,12 +1827,12 @@ globus_l_gass_copy_mkdir_ftp( { globus_result_t result; globus_l_gass_copy_glob_info_t info; - + info.callbacks_left = 1; info.err = GLOBUS_NULL; globus_cond_init(&info.cond, GLOBUS_NULL); globus_mutex_init(&info.mutex, GLOBUS_NULL); - + result = globus_ftp_client_mkdir( &handle->ftp_handle, url, @@ -1856,7 +1856,7 @@ globus_l_gass_copy_mkdir_ftp( result = globus_error_put(info.err); info.err = GLOBUS_NULL; } - + if(result != GLOBUS_SUCCESS) { goto error_mkdir; @@ -1881,13 +1881,13 @@ globus_result_t globus_l_gass_copy_mkdir_file( char * url) { - static char * myname = "globus_l_gass_copy_mkdir_file"; + static char * myname = "globus_l_gass_copy_mkdir_file"; int rc; globus_url_t parsed_url; globus_result_t result; - + rc = globus_url_parse(url, &parsed_url); - + if(rc != 0) { result = globus_error_put( @@ -1900,7 +1900,7 @@ globus_l_gass_copy_mkdir_file( rc)); goto error_url; } - + if(parsed_url.url_path == GLOBUS_NULL) { result = globus_error_put( @@ -1912,7 +1912,7 @@ globus_l_gass_copy_mkdir_file( myname)); goto error_null_path; } - + #ifndef TARGET_ARCH_WIN32 rc = mkdir(parsed_url.url_path, 0777); #else @@ -1932,18 +1932,18 @@ globus_l_gass_copy_mkdir_file( myname)); goto error_mkdir; } - - globus_url_destroy(&parsed_url); + + globus_url_destroy(&parsed_url); return GLOBUS_SUCCESS; -error_mkdir: +error_mkdir: error_null_path: globus_url_destroy(&parsed_url); - + error_url: return result; - + } @@ -1966,19 +1966,19 @@ globus_l_gass_copy_cksm_ftp( info = (globus_l_gass_copy_glob_info_t *) globus_calloc(sizeof(globus_l_gass_copy_glob_info_t), 1); - + info->callbacks_left = 1; info->err = GLOBUS_NULL; info->handle = handle; info->op_cb = callback; info->op_cb_arg = callback_arg; - + if(!callback) { globus_mutex_init(&info->mutex, GLOBUS_NULL); globus_cond_init(&info->cond, GLOBUS_NULL); } - + result = globus_ftp_client_cksm( &handle->ftp_handle, url, @@ -1993,7 +1993,7 @@ globus_l_gass_copy_cksm_ftp( { goto error; } - + if(!callback) { globus_mutex_lock(&info->mutex); @@ -2008,7 +2008,7 @@ globus_l_gass_copy_cksm_ftp( result = globus_error_put(info->err); info->err = GLOBUS_NULL; } - + globus_cond_destroy(&info->cond); globus_mutex_destroy(&info->mutex); @@ -2081,20 +2081,20 @@ globus_l_gass_copy_cksm_file( "url has no path", myname)); goto error_fd; - } - + } + read_left = length; if(length >= 0) { - count = (read_left > GASS_COPY_CKSM_BUFSIZE) ? + count = (read_left > GASS_COPY_CKSM_BUFSIZE) ? GASS_COPY_CKSM_BUFSIZE : read_left; } else { count = GASS_COPY_CKSM_BUFSIZE; } - - fd = open(parsed_url.url_path, O_RDONLY); + + fd = open(parsed_url.url_path, O_RDONLY); if(fd < 0) { result = globus_error_put( @@ -2139,10 +2139,10 @@ globus_l_gass_copy_cksm_file( if (!md) { result = globus_error_put(globus_error_construct_string( - GLOBUS_GASS_COPY_MODULE, - GLOBUS_NULL, - "Unable to use checksum algorithm %s", - algorithm)); + GLOBUS_GASS_COPY_MODULE, + GLOBUS_NULL, + "Unable to use checksum algorithm %s", + algorithm)); goto error_seek; } @@ -2162,9 +2162,9 @@ globus_l_gass_copy_cksm_file( EVP_DigestFinal_ex(mdctx, md_value, &md_len); EVP_MD_CTX_destroy(mdctx); - + close(fd); - + cksmptr = cksm_buff; for (i = 0; i < md_len; i++) { @@ -2173,11 +2173,11 @@ globus_l_gass_copy_cksm_file( cksmptr++; } *cksmptr = '\0'; - + strncpy(cksm, cksm_buff, sizeof(cksm_buff)); - + globus_url_destroy(&parsed_url); - + if(callback) { callback(callback_arg, handle, NULL); @@ -2231,17 +2231,17 @@ globus_gass_copy_cksm_async( globus_gass_copy_callback_t callback, void * callback_arg) { - static char * myname = "globus_gass_copy_cksm"; + static char * myname = "globus_gass_copy_cksm"; globus_result_t result; globus_gass_copy_url_mode_t url_mode; - + result = globus_gass_copy_get_url_mode(url, &url_mode); if(result != GLOBUS_SUCCESS) { goto error_exit; - } + } if(url_mode == GLOBUS_GASS_COPY_URL_MODE_FTP) { @@ -2255,7 +2255,7 @@ globus_gass_copy_cksm_async( algorithm, callback, callback_arg); - + if(result != GLOBUS_SUCCESS) { goto error_ftp_cksm; @@ -2266,7 +2266,7 @@ globus_gass_copy_cksm_async( result = globus_l_gass_copy_cksm_file( handle, url, - cksm, + cksm, offset, length, algorithm, @@ -2294,9 +2294,9 @@ globus_gass_copy_cksm_async( error_ftp_cksm: error_file_cksm: error_exit: - + return result; - + } #ifdef _WIN32 @@ -2308,7 +2308,7 @@ int globus_l_win_fnmatch( globus_list_t *possible_matches_filenames = NULL; globus_list_t *possible_matches_patterns = NULL; int matched = 0; - + globus_list_insert(&possible_matches_filenames, (void *) filename); globus_list_insert(&possible_matches_patterns, (void *) pattern); @@ -2324,7 +2324,7 @@ int globus_l_win_fnmatch( while (*patternp && *filenamep) { - while (*patternp && *filenamep && + while (*patternp && *filenamep && *patternp != '*' && *patternp != '[' && (*patternp == *filenamep ||