diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2009-01-14 20:41:17 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2009-01-14 20:41:17 (GMT) |
commit | ea92781324c5ab1553d99e555f1bce477789e65b (patch) | |
tree | b308dc8ff72558b3edb0211cfd674241b99f1c96 | |
parent | 6564dbcfaa09da479cc5e393693799e329fc1330 (diff) | |
download | hdf5-ea92781324c5ab1553d99e555f1bce477789e65b.zip hdf5-ea92781324c5ab1553d99e555f1bce477789e65b.tar.gz hdf5-ea92781324c5ab1553d99e555f1bce477789e65b.tar.bz2 |
[svn-r16316] Added support for OpenVMS pathname for external links.
Tested on jam. Tested v1.8 on OpenVMS.
-rw-r--r-- | src/H5Lexternal.c | 4 | ||||
-rw-r--r-- | src/H5private.h | 15 | ||||
-rw-r--r-- | src/H5system.c | 28 | ||||
-rw-r--r-- | test/links.c | 116 | ||||
-rw-r--r-- | test/stab.c | 2 | ||||
-rw-r--r-- | vms/src/h5pubconf.h | 3 |
6 files changed, 138 insertions, 30 deletions
diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 2c6b3a3..8637429 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -121,6 +121,8 @@ H5L_getenv_prefix_name(char **env_prefix/*in,out*/) * * Programmer: Vailin Choi, April 2, 2008 * + * Modification: Raymond Lu, 14 Jan. 2009 + * Added support for OpenVMS pathname --------------------------------------------------------------------------*/ static herr_t H5L_build_name(char *prefix, char *file_name, char **full_name/*out*/) @@ -140,8 +142,10 @@ H5L_build_name(char *prefix, char *file_name, char **full_name/*out*/) /* Copy the prefix into the buffer */ HDstrcpy(*full_name, prefix); +#ifndef H5_VMS if (!CHECK_DELIMITER(prefix[prefix_len-1])) HDstrcat(*full_name, DIR_SEPS); +#endif /* Add the external link's filename to the prefix supplied */ HDstrcat(*full_name, file_name); diff --git a/src/H5private.h b/src/H5private.h index 63bbcf4..2f75f86 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1375,8 +1375,7 @@ extern char *strdup(const char *s); #define HDpthread_self_ulong() ((unsigned long)pthread_self()) #endif /* HDpthread_self_ulong */ - -#ifdef H5_HAVE_WINDOW_PATH +#if defined(H5_HAVE_WINDOW_PATH) /* directory delimiter for Windows: slash and backslash are acceptable on Windows */ #define DIR_SLASH_SEPC '/' @@ -1397,6 +1396,18 @@ extern char *strdup(const char *s); (ptr = slash); \ } +#elif defined(H5_HAVE_VMS_PATH) + +/* OpenVMS pathname: <disk name>$<partition>:[path]<file name> + * i.g. SYS$SYSUSERS:[LU.HDF5.SRC]H5system.c */ +#define DIR_SEPC '.' +#define DIR_SEPS "." +#define CHECK_DELIMITER(SS) (SS == DIR_SEPC) +#define CHECK_ABSOLUTE(NAME) (strrchr(NAME, ':') && strrchr(NAME, '[')) +#define CHECK_ABS_DRIVE(NAME) (0) +#define CHECK_ABS_PATH(NAME) (0) +#define GET_LAST_DELIMITER(NAME, ptr) ptr = strrchr(NAME, ']'); + #else #define DIR_SEPC '/' diff --git a/src/H5system.c b/src/H5system.c index 8f91e2f..8956e9b 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -597,9 +597,12 @@ HDremove_all(const char *fname) * * Programmer: Vailin Choi * April 2, 2008 - * Modifications: 2nd Oct, 2008; Vailin Choi + * Modifications: 2nd Oct, 2008; Vailin Choi * Remove compiler warning for "if condition" - * + * + * Raymond Lu + * 14 Jan. 2009 + * Add support for OpenVMS pathname *------------------------------------------------------------------------- */ #define MAX_PATH_LEN 1024 @@ -620,6 +623,8 @@ H5_build_extpath(const char *name, char **extpath/*out*/) /* * Unix: name[0] is a "/" * Windows: name[0-2] is "<drive letter>:\" or "<drive-letter>:/" + * OpenVMS: <disk name>$<partition>:[path]<file name> + * i.g. SYS$SYSUSERS:[LU.HDF5.SRC]H5system.c */ if (CHECK_ABSOLUTE(name)) { if ((full_path=H5MM_strdup(name)) == NULL) @@ -634,6 +639,7 @@ H5_build_extpath(const char *name, char **extpath/*out*/) * Windows: name[0-1] is "<drive-letter>:" * Get current working directory on the drive specified in NAME * Unix: does not apply + * OpenVMS: does not apply */ if (CHECK_ABS_DRIVE(name)) { drive = name[0] - 'A' + 1; @@ -643,12 +649,13 @@ H5_build_extpath(const char *name, char **extpath/*out*/) * Windows: name[0] is a '/' or '\' * Get current drive * Unix: does not apply + * OpenVMS: does not apply */ } else if (CHECK_ABS_PATH(name) && ((drive=HDgetdrive()) != 0)) { sprintf(cwdpath, "%c:%c", (drive+'A'-1), name[0]); retcwd = cwdpath; HDstrcpy(new_name, &name[1]); - } else /* totally relative for both Unix and Windows: get current working directory */ + } else /* totally relative for Unix, Windows, and OpenVMS: get current working directory */ retcwd = HDgetcwd(cwdpath, MAX_PATH_LEN); if (retcwd != NULL) { @@ -659,9 +666,24 @@ H5_build_extpath(const char *name, char **extpath/*out*/) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDstrcpy(full_path, cwdpath); +#ifdef H5_VMS + /* If the file name contains relative path, cut off the beginning bracket. Also cut off the + * ending bracket of CWDPATH to combine the full path name. i.g. + * cwdpath = SYS$SYSUSERS:[LU.HDF5.TEST] + * new_name = [.tmp]extlinks.h5 + * full_path = SYS$SYSUSERS:[LU.HDF5.TEST.tmp]extlinks.h5 + */ + if(new_name[0] == '[') { + char *tmp = new_name; + full_path[cwdlen-1] = '\0'; + HDstrcat(full_path, ++tmp); + } else + HDstrcat(full_path, new_name); +#else if (!CHECK_DELIMITER(cwdpath[cwdlen-1])) HDstrcat(full_path, DIR_SEPS); HDstrcat(full_path, new_name); +#endif } } diff --git a/test/links.c b/test/links.c index d807352..36dba41 100644 --- a/test/links.c +++ b/test/links.c @@ -35,6 +35,7 @@ /* File for external link test. Created with gen_udlinks.c */ #define LINKED_FILE "be_extlink2.h5" +#ifdef H5_VMS const char *FILENAME[] = { "links0", "links1", @@ -48,10 +49,56 @@ const char *FILENAME[] = { "links6", /* 9 */ "links7", /* 10 */ "links8", /* 11 */ - "extlinks0", /* 12: main files */ - "tmp/extlinks0", /* 13: */ - "extlinks1", /* 14: target files */ - "tmp/extlinks1", /* 15: */ + "extlinks0", /* 12: main files */ + "[.tmp]extlinks0", /* 13: */ + "extlinks1", /* 14: target files */ + "[.tmp]extlinks1", /* 15: */ + "extlinks2", /* 16: */ + "[.tmp]extlinks2", /* 17: */ + "extlinks3", /* 18: */ + "[.tmp]extlinks3", /* 19: */ + "extlinks4", /* 20: */ + "[.tmp]extlinks4", /* 21: */ + "extlinks5", /* 22: */ + "[.tmp]extlinks6", /* 23: */ + "extlinks7", /* 24: */ + "[.tmp]extlinks7", /* 25: */ + "[.tmp]extlinks8", /* 26: */ + "extlinks9", /* 27: */ + "[.tmp]extlinks9", /* 28: */ + "extlinks10", /* 29: */ /* TESTS for windows */ + "[.tmp]extlinks10", /* 30: */ + "[.tmp]extlinks11", /* 31: */ + "[.tmp]extlinks12", /* 32: */ + "extlinks13", /* 33: */ + "[.tmp]extlinks13", /* 34: */ + "[.tmp]extlinks14", /* 35: */ + "[.tmp]extlinks15", /* 36: */ + "extlinks16A", /* 37: */ /* TESTS for H5P_set_elink_fapl */ + "extlinks16B", /* 38: */ + "extlinks17", /* 39: */ + NULL +}; + +#define TMPDIR "[.tmp]" +#else +const char *FILENAME[] = { + "links0", + "links1", + "links2", + "links3", + "links4a", /* 4 */ + "links4b", /* 5 */ + "links4c", /* 6 */ + "links4d", /* 7 */ + "links5", /* 8 */ + "links6", /* 9 */ + "links7", /* 10 */ + "links8", /* 11 */ + "extlinks0", /* 12: main files */ + "tmp/extlinks0", /* 13: */ + "extlinks1", /* 14: target files */ + "tmp/extlinks1", /* 15: */ "extlinks2", /* 16: */ "tmp/extlinks2", /* 17: */ "extlinks3", /* 18: */ @@ -83,7 +130,9 @@ const char *FILENAME[] = { NULL }; -#define TMPDIR "tmp" +#define TMPDIR "tmp" +#endif + #define FAMILY_SIZE 1024 #define CORE_INCREMENT 1024 #define NUM400 400 @@ -2825,6 +2874,37 @@ external_link_prefix(hid_t fapl, hbool_t new_format) /*------------------------------------------------------------------------- + * Function: fix_ext_filename + * + * Purpose: Internal function to append path to file name. It handles + * path name of Unix, Windows, and OpenVMS. + * + * Return: void + * + * Programmer: Raymond Lu + * 14 Jan. 2009 + *------------------------------------------------------------------------- + */ +static void +fix_ext_filename(char *path_name, char *cwd, const char *file_name) +{ + HDstrcpy(path_name, cwd); + +#ifdef H5_VMS + if(file_name[0] == '[') { + char *tmp = file_name; + path_name[strlen(cwd)-1] = '\0'; + HDstrcat(path_name, ++tmp); + } else + HDstrcat(path_name, file_name); +#else + HDstrcat(path_name, "/"); + HDstrcat(path_name, file_name); +#endif +} + + +/*------------------------------------------------------------------------- * Function: external_link_abs_mainpath: test 3 * * Purpose: 1. target link: "extlinks3" @@ -2871,10 +2951,9 @@ external_link_abs_mainpath(hid_t fapl, hbool_t new_format) * set up name for main file: * Linux: "/CWD/tmp/extlinks0" * Window: "<cur drive>:/CWD/tmp/extlinks0" + * OpenVMS: "<cur disk>$<partition>:[CWD.tmp]extlinks0" */ - HDstrcpy(tmpname, cwdpath); - HDstrcat(tmpname, "/"); - HDstrcat(tmpname, FILENAME[13]); + fix_ext_filename(tmpname, cwdpath, FILENAME[13]); h5_fixname(tmpname, fapl, filename1, sizeof filename1); /* Create the target file */ @@ -3052,9 +3131,7 @@ external_link_cwd(hid_t fapl, hbool_t new_format) * Linux: "/CWD/tmp/extlinks0" * Windows: "<cur drive>:/CWD/tmp/extlinks0" */ - HDstrcpy(tmpname, cwdpath); - HDstrcat(tmpname, "/"); - HDstrcat(tmpname, FILENAME[13]); + fix_ext_filename(tmpname, cwdpath, FILENAME[13]); h5_fixname(tmpname, fapl, filename1, sizeof filename1); /* Create the target file */ @@ -3147,9 +3224,7 @@ external_link_abstar(hid_t fapl, hbool_t new_format) * Linux: "/CWD/tmp/extlinks6" * Windows: "<cur drive>:/CWD/tmp/extlinks6" */ - HDstrcpy(tmpname, cwdpath); - HDstrcat(tmpname, "/"); - HDstrcat(tmpname, FILENAME[23]); + fix_ext_filename(tmpname, cwdpath, FILENAME[23]); h5_fixname(tmpname, fapl, filename2, sizeof filename2); /* set up name for target file: "tmp/extlinks6" */ @@ -3246,9 +3321,7 @@ external_link_abstar_cur(hid_t fapl, hbool_t new_format) * Linux: "/CWD/tmp/extlinks7" * Windows: "<cur drive>:/CWD/tmp/extlinks7" */ - HDstrcpy(tmpname, cwdpath); - HDstrcat(tmpname, "/"); - HDstrcat(tmpname, FILENAME[25]); + fix_ext_filename(tmpname, cwdpath, FILENAME[25]); h5_fixname(tmpname, fapl, filename2, sizeof filename2); /* Create the target file */ @@ -3539,9 +3612,7 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) * Linux: "/CWD/tmp/extlinks0" * Windows: "<cur drive>:/CWD/tmp/extlinks0" */ - HDstrcpy(tmpname, cwdpath); - HDstrcat(tmpname, "/"); - HDstrcat(tmpname, FILENAME[13]); + fix_ext_filename(tmpname, cwdpath, FILENAME[13]); h5_fixname(tmpname, fapl, filename1, sizeof filename1); /* create "family" fapl */ @@ -3741,9 +3812,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) * Linux: "/CWD/tmp/extlinks0" * Windows: "<cur drive>:/CWD/tmp/extlinks0" */ - HDstrcpy(tmpname, cwdpath); - HDstrcat(tmpname, "/"); - HDstrcat(tmpname, FILENAME[13]); + fix_ext_filename(tmpname, cwdpath, FILENAME[13]); h5_fixname(tmpname, fapl, filename1, sizeof filename1); /* create fapl for the target file to be a "core" file */ @@ -12645,6 +12714,7 @@ main(void) nerrors += ud_hard_links(fapl2) < 0 ? 1 : 0; /* requires new format groups */ nerrors += ud_link_reregister(fapl2) < 0 ? 1 : 0; /* requires new format groups */ } /* end if */ + nerrors += ud_callbacks(my_fapl, new_format) < 0 ? 1 : 0; nerrors += ud_link_errors(my_fapl, new_format) < 0 ? 1 : 0; nerrors += lapl_udata(my_fapl, new_format) < 0 ? 1 : 0; diff --git a/test/stab.c b/test/stab.c index 9ce3cfe..b57b542 100644 --- a/test/stab.c +++ b/test/stab.c @@ -856,7 +856,6 @@ no_compact(hid_t fapl2) /* Verify that file is correct size */ if(file_size != empty_size) TEST_ERROR - PASSED(); return 0; @@ -1153,4 +1152,3 @@ error: puts("*** TESTS FAILED ***"); return 1; } - diff --git a/vms/src/h5pubconf.h b/vms/src/h5pubconf.h index 34dbac1..4892ebe 100644 --- a/vms/src/h5pubconf.h +++ b/vms/src/h5pubconf.h @@ -349,6 +349,9 @@ /* Define to 1 if you have the `waitpid' function. */ /*#undefine H5_HAVE_WAITPID */ +/* Define if your system has OpenVMS path name. This macro is added by hand. */ +#define H5_HAVE_VMS_PATH 1 + /* Define to 1 if you have the <winsock.h> header file. */ /* #undef H5_HAVE_WINSOCK_H */ |