vere: rename u3_unix_{safe,cane}

This commit is contained in:
Jōshin 2022-01-31 12:25:42 -06:00
parent 60f1a44910
commit 443315f401
No known key found for this signature in database
GPG Key ID: A8BE5A9A521639D0
7 changed files with 27 additions and 27 deletions

View File

@ -72,7 +72,7 @@ _main_repath(c3_c* pax_c)
fprintf(stderr, "invalid path %s\n", pax_c); fprintf(stderr, "invalid path %s\n", pax_c);
return 0; return 0;
} }
c3_assert(u3_unix_safe(fas_c + 1)); c3_assert(u3_unix_cane(fas_c + 1));
*fas_c = 0; *fas_c = 0;
dir_c = realpath(pax_c, 0); dir_c = realpath(pax_c, 0);
*fas_c = '/'; *fas_c = '/';

View File

@ -125,24 +125,24 @@
/* Asserting unix fs wrappers. /* Asserting unix fs wrappers.
*/ */
// defined in vere/io/unix.c. // defined in vere/io/unix.c.
c3_t u3_unix_safe(const c3_c* pax_c); c3_t u3_unix_cane(const c3_c* pax_c);
# define c3_open(a, ...) ({ \ # define c3_open(a, ...) ({ \
c3_assert(u3_unix_safe(a)); \ c3_assert(u3_unix_cane(a)); \
open(a, __VA_ARGS__);}) open(a, __VA_ARGS__);})
# define c3_opendir(a) ({ \ # define c3_opendir(a) ({ \
c3_assert(u3_unix_safe(a)); \ c3_assert(u3_unix_cane(a)); \
opendir(a);}) opendir(a);})
# define c3_mkdir(a, b) ({ \ # define c3_mkdir(a, b) ({ \
c3_assert(u3_unix_safe(a)); \ c3_assert(u3_unix_cane(a)); \
mkdir(a, b);}) mkdir(a, b);})
# define c3_rmdir(a) ({ \ # define c3_rmdir(a) ({ \
c3_assert(u3_unix_safe(a)); \ c3_assert(u3_unix_cane(a)); \
rmdir(a);}) rmdir(a);})
# define c3_unlink(a) ({ \ # define c3_unlink(a) ({ \
c3_assert(u3_unix_safe(a)); \ c3_assert(u3_unix_cane(a)); \
unlink(a);}) unlink(a);})
# define c3_fopen(a, b) ({ \ # define c3_fopen(a, b) ({ \
c3_assert(u3_unix_safe(a)); \ c3_assert(u3_unix_cane(a)); \
fopen(a, b);}) fopen(a, b);})
#endif /* ifndef C3_DEFS_H */ #endif /* ifndef C3_DEFS_H */

View File

@ -1168,10 +1168,10 @@
/** Storage, new school. /** Storage, new school.
**/ **/
/* u3_unix_safe(): true iff (unix) path is canonical. /* u3_unix_cane(): true iff (unix) path is canonical.
*/ */
c3_t c3_t
u3_unix_safe(const c3_c* pax_c); u3_unix_cane(const c3_c* pax_c);
/* u3_unix_initial_into_card(): create initial filesystem sync card. /* u3_unix_initial_into_card(): create initial filesystem sync card.
*/ */

View File

@ -15,29 +15,29 @@ _test_safe()
{ {
c3_i ret_i = 1; c3_i ret_i = 1;
if ( !u3_unix_safe("a") || if ( !u3_unix_cane("a") ||
!u3_unix_safe("a/b") || !u3_unix_cane("a/b") ||
!u3_unix_safe("a/b/c/defg/h/ijklmnop") ) !u3_unix_cane("a/b/c/defg/h/ijklmnop") )
{ {
fprintf(stderr, "_safe fail 1\n"); fprintf(stderr, "_safe fail 1\n");
ret_i = 0; ret_i = 0;
} }
if ( u3_unix_safe("") || if ( u3_unix_cane("") ||
u3_unix_safe(".") || u3_unix_cane(".") ||
u3_unix_safe("..") || u3_unix_cane("..") ||
u3_unix_safe("/.") || u3_unix_cane("/.") ||
u3_unix_safe("a/b/c//") || u3_unix_cane("a/b/c//") ||
u3_unix_safe("a/b/.") || u3_unix_cane("a/b/.") ||
u3_unix_safe("/././../.") || u3_unix_cane("/././../.") ||
u3_unix_safe("/../etc") ) u3_unix_cane("/../etc") )
{ {
fprintf(stderr, "_safe fail 2\r\n"); fprintf(stderr, "_safe fail 2\r\n");
ret_i = 0; ret_i = 0;
} }
if ( !u3_unix_safe(".a") || if ( !u3_unix_cane(".a") ||
!u3_unix_safe("/.a.b.c/..c") ) !u3_unix_cane("/.a.b.c/..c") )
{ {
fprintf(stderr, "_safe fail 3\r\n"); fprintf(stderr, "_safe fail 3\r\n");
ret_i = 0; ret_i = 0;

View File

@ -42,7 +42,7 @@ u3_lmdb_init(const c3_c* pax_c, size_t siz_i)
MDB_env* env_u; MDB_env* env_u;
c3_w ret_w; c3_w ret_w;
c3_assert(u3_unix_safe(pax_c)); c3_assert(u3_unix_cane(pax_c));
if ( (ret_w = mdb_env_create(&env_u)) ) { if ( (ret_w = mdb_env_create(&env_u)) ) {
mdb_logerror(stderr, ret_w, "lmdb: init fail"); mdb_logerror(stderr, ret_w, "lmdb: init fail");

View File

@ -84,7 +84,7 @@ u3_foil_folder(const c3_c* pax_c)
uv_dirent_t den_u; uv_dirent_t den_u;
c3_i err_i; c3_i err_i;
c3_assert(u3_unix_safe(pax_c)); c3_assert(u3_unix_cane(pax_c));
/* open directory, synchronously /* open directory, synchronously
*/ */

View File

@ -73,10 +73,10 @@ struct _u3_ufil;
void void
u3_unix_ef_look(u3_unix* unx_u, u3_noun mon, u3_noun all); u3_unix_ef_look(u3_unix* unx_u, u3_noun mon, u3_noun all);
/* u3_unix_safe(): true iff (unix) path is canonical. /* u3_unix_cane(): true iff (unix) path is canonical.
*/ */
c3_t c3_t
u3_unix_safe(const c3_c* pax_c) u3_unix_cane(const c3_c* pax_c)
{ {
if ( 0 == pax_c ) { if ( 0 == pax_c ) {
return 0; return 0;