]> Kevux Git Server - fll/commitdiff
Cleanup: Rename f_account functions in attempt to be easier to read.
authorKevin Day <thekevinday@gmail.com>
Sun, 16 Jan 2022 21:15:09 +0000 (15:15 -0600)
committerKevin Day <thekevinday@gmail.com>
Sun, 16 Jan 2022 21:15:09 +0000 (15:15 -0600)
I originally tried to group the logic by "name" and "id".
This becomes confusing when there is "group name" and "user name" or "group id" and "user id".
The function name with the structure "f_account_id_group_by_name" is intended to be understood as get id of group by name for account.
However, because account is in front (part of f_account) it could be easily misread as get account id by name with some spurious "group" injected.
This is clearly a bad interpretation but that interpretation is easy to think of.

Drop "user" because "account" and "user" should be synonymous.
Move "group" to the left in all cases to designate that this is about "group" associated with account.
Now f_account_group_id_by_name sounds more like get id of group by name for account.

17 files changed:
level_0/f_account/c/account.c
level_0/f_account/c/account.h
level_0/f_account/data/build/settings-tests
level_0/f_account/tests/c/test-account-group_id_by_name.c [moved from level_0/f_account/tests/c/test-account-id_group_by_name.c with 77% similarity]
level_0/f_account/tests/c/test-account-group_id_by_name.h [moved from level_0/f_account/tests/c/test-account-id_group_by_name.h with 59% similarity]
level_0/f_account/tests/c/test-account-group_name_by_id.c [moved from level_0/f_account/tests/c/test-account-name_group_by_id.c with 78% similarity]
level_0/f_account/tests/c/test-account-group_name_by_id.h [moved from level_0/f_account/tests/c/test-account-name_group_by_id.h with 59% similarity]
level_0/f_account/tests/c/test-account-id_by_name.c [moved from level_0/f_account/tests/c/test-account-id_user_by_name.c with 75% similarity]
level_0/f_account/tests/c/test-account-id_by_name.h [moved from level_0/f_account/tests/c/test-account-id_user_by_name.h with 56% similarity]
level_0/f_account/tests/c/test-account-name_by_id.c [moved from level_0/f_account/tests/c/test-account-name_user_by_id.c with 78% similarity]
level_0/f_account/tests/c/test-account-name_by_id.h [moved from level_0/f_account/tests/c/test-account-name_user_by_id.h with 56% similarity]
level_0/f_account/tests/c/test-account.c
level_0/f_account/tests/c/test-account.h
level_3/controller/c/controller/private-controller.c
level_3/controller/c/controller/private-controller.h
level_3/controller/c/rule/private-rule.c
level_3/fake/c/private-make.c

index c51c1f34a597288398e1a761ef8c2b1bd99a4c9c..5088951fd1eb9ee7cfae46f4fedb38b2e0b3e2fa 100644 (file)
@@ -5,8 +5,8 @@
 extern "C" {
 #endif
 
-#ifndef _di_f_account_by_name_
-  f_status_t f_account_by_name(const f_string_t name, f_account_t *account) {
+#ifndef _di_f_account_by_id_
+  f_status_t f_account_by_id(const uid_t id, f_account_t *account) {
     #ifndef _di_level_0_parameter_checking_
       if (!account) return F_status_set_error(F_parameter);
     #endif // _di_level_0_parameter_checking_
@@ -32,11 +32,11 @@ extern "C" {
         length = F_account_pwd_length_fallback_first_d;
       }
 
-      // Must be set to 0 to avoid problems due to the design of getpwnam()/getpwnam_r().
+      // Must be set to 0 to avoid problems due to the design of getpwuid()/getpwuid_r().
       errno = 0;
 
       char buffer[length];
-      const int result = getpwnam_r(name, &password, buffer, length, &pointer);
+      const int result = getpwuid_r(id, &password, buffer, length, &pointer);
 
       if (result) {
         if (errno == EINTR) return F_status_set_error(F_interrupt);
@@ -65,7 +65,7 @@ extern "C" {
 
     char buffer[F_account_pwd_length_fallback_second_d];
 
-    const int result = getpwnam_r(name, &password, buffer, length, &pointer);
+    const int result = getpwuid_r(id, &password, buffer, length, &pointer);
 
     if (result) {
       if (errno == EINTR) return F_status_set_error(F_interrupt);
@@ -84,10 +84,10 @@ extern "C" {
 
     return private_f_account_from_passwd(password, length, account);
   }
-#endif // _di_f_account_by_name_
+#endif // _di_f_account_by_id_
 
-#ifndef _di_f_account_by_id_
-  f_status_t f_account_by_id(const uid_t id, f_account_t *account) {
+#ifndef _di_f_account_by_name_
+  f_status_t f_account_by_name(const f_string_t name, f_account_t *account) {
     #ifndef _di_level_0_parameter_checking_
       if (!account) return F_status_set_error(F_parameter);
     #endif // _di_level_0_parameter_checking_
@@ -113,11 +113,11 @@ extern "C" {
         length = F_account_pwd_length_fallback_first_d;
       }
 
-      // Must be set to 0 to avoid problems due to the design of getpwuid()/getpwuid_r().
+      // Must be set to 0 to avoid problems due to the design of getpwnam()/getpwnam_r().
       errno = 0;
 
       char buffer[length];
-      const int result = getpwuid_r(id, &password, buffer, length, &pointer);
+      const int result = getpwnam_r(name, &password, buffer, length, &pointer);
 
       if (result) {
         if (errno == EINTR) return F_status_set_error(F_interrupt);
@@ -146,7 +146,7 @@ extern "C" {
 
     char buffer[F_account_pwd_length_fallback_second_d];
 
-    const int result = getpwuid_r(id, &password, buffer, length, &pointer);
+    const int result = getpwnam_r(name, &password, buffer, length, &pointer);
 
     if (result) {
       if (errno == EINTR) return F_status_set_error(F_interrupt);
@@ -165,10 +165,10 @@ extern "C" {
 
     return private_f_account_from_passwd(password, length, account);
   }
-#endif // _di_f_account_by_id_
+#endif // _di_f_account_by_name_
 
-#ifndef _di_f_account_id_group_by_name_
-  f_status_t f_account_id_group_by_name(const f_string_t name, gid_t *id) {
+#ifndef _di_f_account_group_id_by_name_
+  f_status_t f_account_group_id_by_name(const f_string_t name, gid_t *id) {
     #ifndef _di_level_0_parameter_checking_
       if (!id) return F_status_set_error(F_parameter);
     #endif // _di_level_0_parameter_checking_
@@ -242,32 +242,36 @@ extern "C" {
 
     return F_none;
   }
-#endif // _di_f_account_id_group_by_name_
+#endif // _di_f_account_group_id_by_name_
 
-#ifndef _di_f_account_id_user_by_name_
-  f_status_t f_account_id_user_by_name(const f_string_t name, uid_t *id) {
+#ifndef _di_f_account_group_name_by_id_
+  f_status_t f_account_group_name_by_id(const gid_t id, f_string_dynamic_t *name) {
     #ifndef _di_level_0_parameter_checking_
-      if (!id) return F_status_set_error(F_parameter);
+      if (!name) return F_status_set_error(F_parameter);
     #endif // _di_level_0_parameter_checking_
 
+    name->used = 0;
+
+    f_status_t status = F_none;
+
     const size_t length_max = sysconf(_SC_GETPW_R_SIZE_MAX);
 
     // Pointer seems pointless except that it is used to determine if the name was found.
-    struct passwd password;
-    struct passwd *pointer = 0;
+    struct group group_data;
+    struct group *pointer = 0;
 
-    size_t length = length_max;
+    size_t length = length_max + 1;
 
     {
       if (length == -1) {
         length = F_account_pwd_length_fallback_first_d;
       }
 
-      // Must be set to 0 to avoid problems due to the design of getpwnam()/getpwnam_r().
+      // Must be set to 0 to avoid problems due to the design of getpwuid()/getpwuid_r().
       errno = 0;
 
       char buffer[length];
-      const int result = getpwnam_r(name, &password, buffer, length, &pointer);
+      const int result = getgrgid_r(id, &group_data, buffer, length, &pointer);
 
       if (result) {
         if (errno == EINTR) return F_status_set_error(F_interrupt);
@@ -288,7 +292,15 @@ extern "C" {
           return F_exist_not;
         }
 
-        *id = password.pw_uid;
+        const f_array_length_t name_length = strnlen(group_data.gr_name, length);
+
+        macro_f_string_dynamic_t_resize(status, (*name), name_length + 1);
+        if (F_status_is_error(status)) return status;
+
+        memcpy(name->string, group_data.gr_name, name_length);
+
+        name->string[name_length] = 0;
+        name->used = name_length;
 
         return F_none;
       }
@@ -298,7 +310,7 @@ extern "C" {
 
     char buffer[F_account_pwd_length_fallback_second_d];
 
-    const int result = getpwnam_r(name, &password, buffer, length, &pointer);
+    const int result = getgrgid_r(id, &group_data, buffer, length, &pointer);
 
     if (result) {
       if (errno == EINTR) return F_status_set_error(F_interrupt);
@@ -315,40 +327,44 @@ extern "C" {
       return F_exist_not;
     }
 
-    *id = password.pw_uid;
+    const f_array_length_t name_length = strnlen(group_data.gr_name, length);
+
+    macro_f_string_dynamic_t_resize(status, (*name), name_length + 1);
+    if (F_status_is_error(status)) return status;
+
+    memcpy(name->string, group_data.gr_name, name_length);
+
+    name->string[name_length] = 0;
+    name->used = name_length;
 
     return F_none;
   }
-#endif // _di_f_account_id_user_by_name_
+#endif // _di_f_account_group_name_by_id_
 
-#ifndef _di_f_account_name_group_by_id_
-  f_status_t f_account_name_group_by_id(const gid_t id, f_string_dynamic_t *name) {
+#ifndef _di_f_account_id_by_name_
+  f_status_t f_account_id_by_name(const f_string_t name, uid_t *id) {
     #ifndef _di_level_0_parameter_checking_
-      if (!name) return F_status_set_error(F_parameter);
+      if (!id) return F_status_set_error(F_parameter);
     #endif // _di_level_0_parameter_checking_
 
-    name->used = 0;
-
-    f_status_t status = F_none;
-
     const size_t length_max = sysconf(_SC_GETPW_R_SIZE_MAX);
 
     // Pointer seems pointless except that it is used to determine if the name was found.
-    struct group group_data;
-    struct group *pointer = 0;
+    struct passwd password;
+    struct passwd *pointer = 0;
 
-    size_t length = length_max + 1;
+    size_t length = length_max;
 
     {
       if (length == -1) {
         length = F_account_pwd_length_fallback_first_d;
       }
 
-      // Must be set to 0 to avoid problems due to the design of getpwuid()/getpwuid_r().
+      // Must be set to 0 to avoid problems due to the design of getpwnam()/getpwnam_r().
       errno = 0;
 
       char buffer[length];
-      const int result = getgrgid_r(id, &group_data, buffer, length, &pointer);
+      const int result = getpwnam_r(name, &password, buffer, length, &pointer);
 
       if (result) {
         if (errno == EINTR) return F_status_set_error(F_interrupt);
@@ -369,15 +385,7 @@ extern "C" {
           return F_exist_not;
         }
 
-        const f_array_length_t name_length = strnlen(group_data.gr_name, length);
-
-        macro_f_string_dynamic_t_resize(status, (*name), name_length + 1);
-        if (F_status_is_error(status)) return status;
-
-        memcpy(name->string, group_data.gr_name, name_length);
-
-        name->string[name_length] = 0;
-        name->used = name_length;
+        *id = password.pw_uid;
 
         return F_none;
       }
@@ -387,7 +395,7 @@ extern "C" {
 
     char buffer[F_account_pwd_length_fallback_second_d];
 
-    const int result = getgrgid_r(id, &group_data, buffer, length, &pointer);
+    const int result = getpwnam_r(name, &password, buffer, length, &pointer);
 
     if (result) {
       if (errno == EINTR) return F_status_set_error(F_interrupt);
@@ -404,22 +412,14 @@ extern "C" {
       return F_exist_not;
     }
 
-    const f_array_length_t name_length = strnlen(group_data.gr_name, length);
-
-    macro_f_string_dynamic_t_resize(status, (*name), name_length + 1);
-    if (F_status_is_error(status)) return status;
-
-    memcpy(name->string, group_data.gr_name, name_length);
-
-    name->string[name_length] = 0;
-    name->used = name_length;
+    *id = password.pw_uid;
 
     return F_none;
   }
-#endif // _di_f_account_name_group_by_id_
+#endif // _di_f_account_id_by_name_
 
-#ifndef _di_f_account_name_user_by_id_
-  f_status_t f_account_name_user_by_id(const uid_t id, f_string_dynamic_t *name) {
+#ifndef _di_f_account_name_by_id_
+  f_status_t f_account_name_by_id(const uid_t id, f_string_dynamic_t *name) {
     #ifndef _di_level_0_parameter_checking_
       if (!name) return F_status_set_error(F_parameter);
     #endif // _di_level_0_parameter_checking_
@@ -513,7 +513,7 @@ extern "C" {
 
     return F_none;
   }
-#endif // _di_f_account_name_user_by_id_
+#endif // _di_f_account_name_by_id_
 
 #ifdef __cplusplus
 } // extern "C"
index 9b553aec4680afb04b42bea9e97f654c52a6f241..bb9770cc53390388e1439cbe560983e2011f737b 100644 (file)
@@ -33,11 +33,10 @@ extern "C" {
 #endif
 
 /**
- * Get the user account by the user name.
+ * Get the user account by the user id.
  *
- * @param name
- *   The user name.
- *   The name must be NULL terminated.
+ * @param id
+ *   The id of the user.
  * @param account
  *   This is replaced with by the account information.
  *   All strings will be NULL terminated.
@@ -54,17 +53,18 @@ extern "C" {
  *   F_parameter (with error bit) if a parameter is invalid.
  *   F_failure (with error bit) on any other error.
  *
- * @see getpwnam_r()
+ * @see getpwuid_r()
  */
-#ifndef _di_f_account_by_name_
-  extern f_status_t f_account_by_name(const f_string_t name, f_account_t *account);
-#endif // _di_f_account_by_name_
+#ifndef _di_f_account_by_id_
+  extern f_status_t f_account_by_id(const uid_t id, f_account_t *account);
+#endif // _di_f_account_by_id_
 
 /**
- * Get the user account by the user id.
+ * Get the user account by the user name.
  *
- * @param id
- *   The id of the user.
+ * @param name
+ *   The user name.
+ *   The name must be NULL terminated.
  * @param account
  *   This is replaced with by the account information.
  *   All strings will be NULL terminated.
@@ -81,11 +81,11 @@ extern "C" {
  *   F_parameter (with error bit) if a parameter is invalid.
  *   F_failure (with error bit) on any other error.
  *
- * @see getpwuid_r()
+ * @see getpwnam_r()
  */
-#ifndef _di_f_account_by_id_
-  extern f_status_t f_account_by_id(const uid_t id, f_account_t *account);
-#endif // _di_f_account_by_id_
+#ifndef _di_f_account_by_name_
+  extern f_status_t f_account_by_name(const f_string_t name, f_account_t *account);
+#endif // _di_f_account_by_name_
 
 /**
  * Get the account group id by the group name.
@@ -110,18 +110,18 @@ extern "C" {
  *
  * @see getgrnam_r()
  */
-#ifndef _di_f_account_id_group_by_name_
-  extern f_status_t f_account_id_group_by_name(const f_string_t name, gid_t *id);
-#endif // _di_f_account_id_group_by_name_
+#ifndef _di_f_account_group_id_by_name_
+  extern f_status_t f_account_group_id_by_name(const f_string_t name, gid_t *id);
+#endif // _di_f_account_group_id_by_name_
 
 /**
- * Get the user account id by the user name.
+ * Get the account group name by the group id.
  *
- * @param name
- *   The user name.
- *   The name must be NULL terminated.
  * @param id
- *   The id associated with the given name.
+ *   The id of the group.
+ * @param name
+ *   This is replaced with by the group name.
+ *   The name will be NULL terminated.
  *
  * @return
  *   F_none on success.
@@ -135,20 +135,20 @@ extern "C" {
  *   F_parameter (with error bit) if a parameter is invalid.
  *   F_failure (with error bit) on any other error.
  *
- * @see getpwnam_r()
+ * @see getgrgid_r()
  */
-#ifndef _di_f_account_id_user_by_name_
-  extern f_status_t f_account_id_user_by_name(const f_string_t name, uid_t *id);
-#endif // _di_f_account_id_user_by_name_
+#ifndef _di_f_account_group_name_by_id_
+  extern f_status_t f_account_group_name_by_id(const gid_t id, f_string_dynamic_t *name);
+#endif // _di_f_account_group_name_by_id_
 
 /**
- * Get the account group name by the group id.
+ * Get the user account id by the user name.
  *
- * @param id
- *   The id of the group.
  * @param name
- *   This is replaced with by the group name.
- *   The name will be NULL terminated.
+ *   The user name.
+ *   The name must be NULL terminated.
+ * @param id
+ *   The id associated with the given name.
  *
  * @return
  *   F_none on success.
@@ -162,11 +162,11 @@ extern "C" {
  *   F_parameter (with error bit) if a parameter is invalid.
  *   F_failure (with error bit) on any other error.
  *
- * @see getgrgid_r()
+ * @see getpwnam_r()
  */
-#ifndef _di_f_account_name_group_by_id_
-  extern f_status_t f_account_name_group_by_id(const gid_t id, f_string_dynamic_t *name);
-#endif // _di_f_account_name_group_by_id_
+#ifndef _di_f_account_id_by_name_
+  extern f_status_t f_account_id_by_name(const f_string_t name, uid_t *id);
+#endif // _di_f_account_id_by_name_
 
 /**
  * Get the user account name by the user id.
@@ -191,9 +191,9 @@ extern "C" {
  *
  * @see getpwuid_r()
  */
-#ifndef _di_f_account_name_user_by_id_
-  extern f_status_t f_account_name_user_by_id(const uid_t id, f_string_dynamic_t *name);
-#endif // _di_f_account_name_user_by_id_
+#ifndef _di_f_account_name_by_id_
+  extern f_status_t f_account_name_by_id(const uid_t id, f_string_dynamic_t *name);
+#endif // _di_f_account_name_by_id_
 
 #ifdef __cplusplus
 } // extern "C"
index c623264ba75b4e508cce8d8422603fec8f42c105..7792817d8586d007f189ecd2434f6592bbc35ae9 100644 (file)
@@ -19,7 +19,7 @@ build_libraries -lc -lcmocka
 build_libraries-individual -lf_memory -lf_string -lf_type_array -lf_account
 build_libraries-level -lfll_0
 build_libraries-monolithic -lfll
-build_sources_program test-account-by_id.c test-account-by_name.c test-account-id_group_by_name.c test-account-id_user_by_name.c test-account-name_group_by_id.c test-account-name_user_by_id.c test-account.c
+build_sources_program test-account-by_id.c test-account-by_name.c test-account-group_name_by_id.c test-account-group_id_by_name.c test-account-id_by_name.c test-account-name_by_id.c test-account.c
 build_script no
 build_shared yes
 build_static no
similarity index 77%
rename from level_0/f_account/tests/c/test-account-id_group_by_name.c
rename to level_0/f_account/tests/c/test-account-group_id_by_name.c
index 0d8900381849ef8a3ed3507edcca728d99927ec1..954e5b3ef7c8153023193a3ce5da23fe960b47dd 100644 (file)
@@ -1,11 +1,11 @@
 #include "test-account.h"
-#include "test-account-id_group_by_name.h"
+#include "test-account-group_id_by_name.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-void test__f_account_id_group_by_name__fails(void **state) {
+void test__f_account_group_id_by_name__fails(void **state) {
 
   const long size = 20;
   char *name = "name";
@@ -37,13 +37,13 @@ void test__f_account_id_group_by_name__fails(void **state) {
     will_return(__wrap_getgrnam_r, true);
     will_return(__wrap_getgrnam_r, errnos[i]);
 
-    const f_status_t status = f_account_id_group_by_name(name, &gid);
+    const f_status_t status = f_account_group_id_by_name(name, &gid);
 
     assert_int_equal(F_status_set_fine(status), statuss[i]);
   } // for
 }
 
-void test__f_account_id_group_by_name__not_found(void **state) {
+void test__f_account_group_id_by_name__not_found(void **state) {
 
   const long size = 20;
   struct group group_data;
@@ -56,26 +56,26 @@ void test__f_account_id_group_by_name__not_found(void **state) {
     will_return(__wrap_getgrnam_r, &group_data);
     will_return(__wrap_getgrnam_r, (struct group *) 0);
 
-    const f_status_t status = f_account_id_group_by_name(name, &gid);
+    const f_status_t status = f_account_group_id_by_name(name, &gid);
 
     assert_int_equal(status, F_exist_not);
   }
 }
 
 #ifndef _di_level_0_parameter_checking_
-  void test__f_account_id_group_by_name__parameter_checking(void **state) {
+  void test__f_account_group_id_by_name__parameter_checking(void **state) {
 
     const f_string_t name = f_string_t_initialize;
 
     {
-      const f_status_t status = f_account_id_group_by_name(name, 0);
+      const f_status_t status = f_account_group_id_by_name(name, 0);
 
       assert_int_equal(F_status_set_fine(status), F_parameter);
     }
   }
 #endif // _di_level_0_parameter_checking_
 
-void test__f_account_id_group_by_name__works(void **state) {
+void test__f_account_group_id_by_name__works(void **state) {
 
   const long size = 20;
   struct group group_data;
@@ -94,7 +94,7 @@ void test__f_account_id_group_by_name__works(void **state) {
     will_return(__wrap_getgrnam_r, &group_data);
     will_return(__wrap_getgrnam_r, &pointer);
 
-    const f_status_t status = f_account_id_group_by_name(group_data.gr_name, &gid);
+    const f_status_t status = f_account_group_id_by_name(group_data.gr_name, &gid);
 
     assert_int_equal(status, F_none);
     assert_int_equal(gid, group_data.gr_gid);
similarity index 59%
rename from level_0/f_account/tests/c/test-account-id_group_by_name.h
rename to level_0/f_account/tests/c/test-account-group_id_by_name.h
index e1fe41d61b1c0839db3598bfede5e8c69b7397da..75121c2e9843380a317875f7789c62575b381414 100644 (file)
 /**
  * Test that function fails.
  *
- * @see f_account_id_group_by_name()
+ * @see f_account_group_id_by_name()
  */
-extern void test__f_account_id_group_by_name__fails(void **state);
+extern void test__f_account_group_id_by_name__fails(void **state);
 
 /**
  * Test that function works but the group does not exist.
  *
- * @see f_account_id_group_by_name()
+ * @see f_account_group_id_by_name()
  */
-extern void test__f_account_id_group_by_name__not_found(void **state);
+extern void test__f_account_group_id_by_name__not_found(void **state);
 
 /**
  * Test that parameter checking works as expected.
  *
- * @see f_account_id_group_by_name()
+ * @see f_account_group_id_by_name()
  */
 #ifndef _di_level_0_parameter_checking_
-  extern void test__f_account_id_group_by_name__parameter_checking(void **state);
+  extern void test__f_account_group_id_by_name__parameter_checking(void **state);
 #endif // _di_level_0_parameter_checking_
 
 /**
  * Test that function works.
  *
- * @see f_account_id_group_by_name()
+ * @see f_account_group_id_by_name()
  */
-extern void test__f_account_id_group_by_name__works(void **state);
+extern void test__f_account_group_id_by_name__works(void **state);
 
 #endif // _TEST__F_account_id_group_by_name_
similarity index 78%
rename from level_0/f_account/tests/c/test-account-name_group_by_id.c
rename to level_0/f_account/tests/c/test-account-group_name_by_id.c
index 6103838a288bcbbf9798061ef82e4cca7955c1a1..f5dccf22cddb5f2eef096e8528cae01af51a189b 100644 (file)
@@ -1,11 +1,11 @@
 #include "test-account.h"
-#include "test-account-name_group_by_id.h"
+#include "test-account-group_name_by_id.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-void test__f_account_name_group_by_id__fails(void **state) {
+void test__f_account_group_name_by_id__fails(void **state) {
 
   const long size = 20;
   gid_t gid = 0;
@@ -37,7 +37,7 @@ void test__f_account_name_group_by_id__fails(void **state) {
     will_return(__wrap_getgrgid_r, true);
     will_return(__wrap_getgrgid_r, errnos[i]);
 
-    const f_status_t status = f_account_name_group_by_id(gid, &name);
+    const f_status_t status = f_account_group_name_by_id(gid, &name);
 
     assert_int_equal(F_status_set_fine(status), statuss[i]);
   } // for
@@ -45,7 +45,7 @@ void test__f_account_name_group_by_id__fails(void **state) {
   f_string_dynamic_resize(0, &name);
 }
 
-void test__f_account_name_group_by_id__not_found(void **state) {
+void test__f_account_group_name_by_id__not_found(void **state) {
 
   const long size = 20;
   struct group group_data;
@@ -58,7 +58,7 @@ void test__f_account_name_group_by_id__not_found(void **state) {
     will_return(__wrap_getgrgid_r, &group_data);
     will_return(__wrap_getgrgid_r, (struct group *) 0);
 
-    const f_status_t status = f_account_name_group_by_id(gid, &name);
+    const f_status_t status = f_account_group_name_by_id(gid, &name);
 
     assert_int_equal(status, F_exist_not);
   }
@@ -67,17 +67,17 @@ void test__f_account_name_group_by_id__not_found(void **state) {
 }
 
 #ifndef _di_level_0_parameter_checking_
-  void test__f_account_name_group_by_id__parameter_checking(void **state) {
+  void test__f_account_group_name_by_id__parameter_checking(void **state) {
 
     {
-      const f_status_t status = f_account_name_group_by_id(0, 0);
+      const f_status_t status = f_account_group_name_by_id(0, 0);
 
       assert_int_equal(F_status_set_fine(status), F_parameter);
     }
   }
 #endif // _di_level_0_parameter_checking_
 
-void test__f_account_name_group_by_id__works(void **state) {
+void test__f_account_group_name_by_id__works(void **state) {
 
   const long size = 20;
   struct group group_data;
@@ -97,7 +97,7 @@ void test__f_account_name_group_by_id__works(void **state) {
     will_return(__wrap_getgrgid_r, &group_data);
     will_return(__wrap_getgrgid_r, &pointer);
 
-    const f_status_t status = f_account_name_group_by_id(gid, &name);
+    const f_status_t status = f_account_group_name_by_id(gid, &name);
 
     assert_int_equal(status, F_none);
     assert_string_equal(name.string, group_data.gr_name);
similarity index 59%
rename from level_0/f_account/tests/c/test-account-name_group_by_id.h
rename to level_0/f_account/tests/c/test-account-group_name_by_id.h
index d4ff4a127a6e8b3eb1fa39bae1b8652356aea1a6..a5f017d44944713b834d554349e65ebb1fc4e84b 100644 (file)
 /**
  * Test that function fails.
  *
- * @see f_account_name_group_by_id()
+ * @see f_account_group_name_by_id()
  */
-extern void test__f_account_name_group_by_id__fails(void **state);
+extern void test__f_account_group_name_by_id__fails(void **state);
 
 /**
  * Test that function works but the group does not exist.
  *
- * @see f_account_name_group_by_id()
+ * @see f_account_group_name_by_id()
  */
-extern void test__f_account_name_group_by_id__not_found(void **state);
+extern void test__f_account_group_name_by_id__not_found(void **state);
 
 /**
  * Test that parameter checking works as expected.
  *
- * @see f_account_name_group_by_id()
+ * @see f_account_group_name_by_id()
  */
 #ifndef _di_level_0_parameter_checking_
-  extern void test__f_account_name_group_by_id__parameter_checking(void **state);
+  extern void test__f_account_group_name_by_id__parameter_checking(void **state);
 #endif // _di_level_0_parameter_checking_
 
 /**
  * Test that function works.
  *
- * @see f_account_name_group_by_id()
+ * @see f_account_group_name_by_id()
  */
-extern void test__f_account_name_group_by_id__works(void **state);
+extern void test__f_account_group_name_by_id__works(void **state);
 
 #endif // _TEST__F_account_name_group_by_id_
similarity index 75%
rename from level_0/f_account/tests/c/test-account-id_user_by_name.c
rename to level_0/f_account/tests/c/test-account-id_by_name.c
index 4549f82d0de0ec03a2b8557e78628f88a1ea69e6..eeea2ae541820eb319d0cca4871a2eb4e340b85d 100644 (file)
@@ -1,11 +1,11 @@
 #include "test-account.h"
-#include "test-account-id_user_by_name.h"
+#include "test-account-id_by_name.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-void test__f_account_id_user_by_name__fails(void **state) {
+void test__f_account_id_by_name__fails(void **state) {
 
   const long size = 20;
   char *name = "name";
@@ -37,13 +37,13 @@ void test__f_account_id_user_by_name__fails(void **state) {
     will_return(__wrap_getpwnam_r, true);
     will_return(__wrap_getpwnam_r, errnos[i]);
 
-    const f_status_t status = f_account_id_user_by_name(name, &uid);
+    const f_status_t status = f_account_id_by_name(name, &uid);
 
     assert_int_equal(F_status_set_fine(status), statuss[i]);
   } // for
 }
 
-void test__f_account_id_user_by_name__not_found(void **state) {
+void test__f_account_id_by_name__not_found(void **state) {
 
   const long size = 20;
   struct passwd password;
@@ -56,26 +56,26 @@ void test__f_account_id_user_by_name__not_found(void **state) {
     will_return(__wrap_getpwnam_r, &password);
     will_return(__wrap_getpwnam_r, (struct passwd *) 0);
 
-    const f_status_t status = f_account_id_user_by_name(name, &uid);
+    const f_status_t status = f_account_id_by_name(name, &uid);
 
     assert_int_equal(status, F_exist_not);
   }
 }
 
 #ifndef _di_level_0_parameter_checking_
-  void test__f_account_id_user_by_name__parameter_checking(void **state) {
+  void test__f_account_id_by_name__parameter_checking(void **state) {
 
     const f_string_t name = f_string_t_initialize;
 
     {
-      const f_status_t status = f_account_id_user_by_name(name, 0);
+      const f_status_t status = f_account_id_by_name(name, 0);
 
       assert_int_equal(F_status_set_fine(status), F_parameter);
     }
   }
 #endif // _di_level_0_parameter_checking_
 
-void test__f_account_id_user_by_name__works(void **state) {
+void test__f_account_id_by_name__works(void **state) {
 
   const long size = 20;
   struct passwd password;
@@ -96,7 +96,7 @@ void test__f_account_id_user_by_name__works(void **state) {
     will_return(__wrap_getpwnam_r, &password);
     will_return(__wrap_getpwnam_r, &pointer);
 
-    const f_status_t status = f_account_id_user_by_name(password.pw_name, &uid);
+    const f_status_t status = f_account_id_by_name(password.pw_name, &uid);
 
     assert_int_equal(status, F_none);
     assert_int_equal(uid, password.pw_uid);
similarity index 56%
rename from level_0/f_account/tests/c/test-account-id_user_by_name.h
rename to level_0/f_account/tests/c/test-account-id_by_name.h
index 77866627bf7efee79c398f4ae9572ba1fbb0803f..97534c0c5ac0689da664e72eb4cedf4cd63e2a17 100644 (file)
 /**
  * Test that function fails.
  *
- * @see f_account_id_user_by_name()
+ * @see f_account_id_by_name()
  */
-extern void test__f_account_id_user_by_name__fails(void **state);
+extern void test__f_account_id_by_name__fails(void **state);
 
 /**
  * Test that function works but the group does not exist.
  *
- * @see f_account_id_user_by_name()
+ * @see f_account_id_by_name()
  */
-extern void test__f_account_id_user_by_name__not_found(void **state);
+extern void test__f_account_id_by_name__not_found(void **state);
 
 /**
  * Test that parameter checking works as expected.
  *
- * @see f_account_id_user_by_name()
+ * @see f_account_id_by_name()
  */
 #ifndef _di_level_0_parameter_checking_
-  extern void test__f_account_id_user_by_name__parameter_checking(void **state);
+  extern void test__f_account_id_by_name__parameter_checking(void **state);
 #endif // _di_level_0_parameter_checking_
 
 /**
  * Test that function works.
  *
- * @see f_account_id_user_by_name()
+ * @see f_account_id_by_name()
  */
-extern void test__f_account_id_user_by_name__works(void **state);
+extern void test__f_account_id_by_name__works(void **state);
 
 #endif // _TEST__F_account_id_user_by_name_
similarity index 78%
rename from level_0/f_account/tests/c/test-account-name_user_by_id.c
rename to level_0/f_account/tests/c/test-account-name_by_id.c
index 80dcc6bdd3b9295bd3f56d7b864a03eec142d459..d6889128ef072d365bbd8b7c03d56d9796fe07ce 100644 (file)
@@ -1,11 +1,11 @@
 #include "test-account.h"
-#include "test-account-name_user_by_id.h"
+#include "test-account-name_by_id.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-void test__f_account_name_user_by_id__fails(void **state) {
+void test__f_account_name_by_id__fails(void **state) {
 
   const long size = 20;
   uid_t uid = 0;
@@ -37,7 +37,7 @@ void test__f_account_name_user_by_id__fails(void **state) {
     will_return(__wrap_getpwuid_r, true);
     will_return(__wrap_getpwuid_r, errnos[i]);
 
-    const f_status_t status = f_account_name_user_by_id(uid, &name);
+    const f_status_t status = f_account_name_by_id(uid, &name);
 
     assert_int_equal(F_status_set_fine(status), statuss[i]);
   } // for
@@ -45,7 +45,7 @@ void test__f_account_name_user_by_id__fails(void **state) {
   f_string_dynamic_resize(0, &name);
 }
 
-void test__f_account_name_user_by_id__not_found(void **state) {
+void test__f_account_name_by_id__not_found(void **state) {
 
   const long size = 20;
   struct passwd password;
@@ -58,7 +58,7 @@ void test__f_account_name_user_by_id__not_found(void **state) {
     will_return(__wrap_getpwuid_r, &password);
     will_return(__wrap_getpwuid_r, (struct passwd *) 0);
 
-    const f_status_t status = f_account_name_user_by_id(uid, &name);
+    const f_status_t status = f_account_name_by_id(uid, &name);
 
     assert_int_equal(status, F_exist_not);
   }
@@ -67,17 +67,17 @@ void test__f_account_name_user_by_id__not_found(void **state) {
 }
 
 #ifndef _di_level_0_parameter_checking_
-  void test__f_account_name_user_by_id__parameter_checking(void **state) {
+  void test__f_account_name_by_id__parameter_checking(void **state) {
 
     {
-      const f_status_t status = f_account_name_user_by_id(0, 0);
+      const f_status_t status = f_account_name_by_id(0, 0);
 
       assert_int_equal(F_status_set_fine(status), F_parameter);
     }
   }
 #endif // _di_level_0_parameter_checking_
 
-void test__f_account_name_user_by_id__works(void **state) {
+void test__f_account_name_by_id__works(void **state) {
 
   const long size = 20;
   struct passwd password;
@@ -99,7 +99,7 @@ void test__f_account_name_user_by_id__works(void **state) {
     will_return(__wrap_getpwuid_r, &password);
     will_return(__wrap_getpwuid_r, &pointer);
 
-    const f_status_t status = f_account_name_user_by_id(uid, &name);
+    const f_status_t status = f_account_name_by_id(uid, &name);
 
     assert_int_equal(status, F_none);
     assert_string_equal(name.string, password.pw_name);
similarity index 56%
rename from level_0/f_account/tests/c/test-account-name_user_by_id.h
rename to level_0/f_account/tests/c/test-account-name_by_id.h
index e80814a3e04c83a8f392805b896bb2f0d822b40b..994763daf417af0ec1f5b9e4fac91f960b950969 100644 (file)
 /**
  * Test that function fails.
  *
- * @see f_account_name_user_by_id()
+ * @see f_account_name_by_id()
  */
-extern void test__f_account_name_user_by_id__fails(void **state);
+extern void test__f_account_name_by_id__fails(void **state);
 
 /**
  * Test that function works but the group does not exist.
  *
- * @see f_account_name_user_by_id()
+ * @see f_account_name_by_id()
  */
-extern void test__f_account_name_user_by_id__not_found(void **state);
+extern void test__f_account_name_by_id__not_found(void **state);
 
 /**
  * Test that parameter checking works as expected.
  *
- * @see f_account_name_user_by_id()
+ * @see f_account_name_by_id()
  */
 #ifndef _di_level_0_parameter_checking_
-  extern void test__f_account_name_user_by_id__parameter_checking(void **state);
+  extern void test__f_account_name_by_id__parameter_checking(void **state);
 #endif // _di_level_0_parameter_checking_
 
 /**
  * Test that function works.
  *
- * @see f_account_name_user_by_id()
+ * @see f_account_name_by_id()
  */
-extern void test__f_account_name_user_by_id__works(void **state);
+extern void test__f_account_name_by_id__works(void **state);
 
 #endif // _TEST__F_account_name_user_by_id_
index 74bbc837ac4ecb471eeebbefe9d7382e5be28e01..88ba73dddedd5e3508ce22d1dd86cbb5afafedfd 100644 (file)
@@ -27,29 +27,29 @@ int main(void) {
     cmocka_unit_test(test__f_account_by_name__not_found),
     cmocka_unit_test(test__f_account_by_name__works),
 
-    cmocka_unit_test(test__f_account_id_group_by_name__fails),
-    cmocka_unit_test(test__f_account_id_group_by_name__not_found),
-    cmocka_unit_test(test__f_account_id_group_by_name__works),
+    cmocka_unit_test(test__f_account_group_id_by_name__fails),
+    cmocka_unit_test(test__f_account_group_id_by_name__not_found),
+    cmocka_unit_test(test__f_account_group_id_by_name__works),
 
-    cmocka_unit_test(test__f_account_id_user_by_name__fails),
-    cmocka_unit_test(test__f_account_id_user_by_name__not_found),
-    cmocka_unit_test(test__f_account_id_user_by_name__works),
+    cmocka_unit_test(test__f_account_group_name_by_id__fails),
+    cmocka_unit_test(test__f_account_group_name_by_id__not_found),
+    cmocka_unit_test(test__f_account_group_name_by_id__works),
 
-    cmocka_unit_test(test__f_account_name_group_by_id__fails),
-    cmocka_unit_test(test__f_account_name_group_by_id__not_found),
-    cmocka_unit_test(test__f_account_name_group_by_id__works),
+    cmocka_unit_test(test__f_account_id_by_name__fails),
+    cmocka_unit_test(test__f_account_id_by_name__not_found),
+    cmocka_unit_test(test__f_account_id_by_name__works),
 
-    cmocka_unit_test(test__f_account_name_user_by_id__fails),
-    cmocka_unit_test(test__f_account_name_user_by_id__not_found),
-    cmocka_unit_test(test__f_account_name_user_by_id__works),
+    cmocka_unit_test(test__f_account_name_by_id__fails),
+    cmocka_unit_test(test__f_account_name_by_id__not_found),
+    cmocka_unit_test(test__f_account_name_by_id__works),
 
     #ifndef _di_level_0_parameter_checking_
       cmocka_unit_test(test__f_account_by_id__parameter_checking),
       cmocka_unit_test(test__f_account_by_name__parameter_checking),
-      cmocka_unit_test(test__f_account_id_group_by_name__parameter_checking),
-      cmocka_unit_test(test__f_account_id_user_by_name__parameter_checking),
-      cmocka_unit_test(test__f_account_name_group_by_id__parameter_checking),
-      cmocka_unit_test(test__f_account_name_user_by_id__parameter_checking),
+      cmocka_unit_test(test__f_account_group_id_by_name__parameter_checking),
+      cmocka_unit_test(test__f_account_group_name_by_id__parameter_checking),
+      cmocka_unit_test(test__f_account_id_by_name__parameter_checking),
+      cmocka_unit_test(test__f_account_name_by_id__parameter_checking),
     #endif // _di_level_0_parameter_checking_
   };
 
index 030f92f82daf82a584fb3db3565b06a26ad09aaf..214002e25d74dc26b183c5e9d99bcf94935ee215 100644 (file)
 // test includes.
 #include "test-account-by_id.h"
 #include "test-account-by_name.h"
-#include "test-account-id_group_by_name.h"
-#include "test-account-id_user_by_name.h"
-#include "test-account-name_group_by_id.h"
-#include "test-account-name_user_by_id.h"
+#include "test-account-group_id_by_name.h"
+#include "test-account-group_name_by_id.h"
+#include "test-account-id_by_name.h"
+#include "test-account-name_by_id.h"
 
 #ifdef __cplusplus
 extern "C" {
index 4febf9698b616746300f2312e34c6be756a17cf7..b77761125610467523aa05c936d1678cc0bfd080 100644 (file)
@@ -326,7 +326,7 @@ extern "C" {
         status = controller_dynamic_rip_nulless_terminated(buffer, range, &cache->action.generic);
         if (F_status_is_error(status)) return status;
 
-        status = f_account_id_user_by_name(cache->action.generic.string, id);
+        status = f_account_id_by_name(cache->action.generic.string, id);
         if (F_status_is_error(status)) return status;
 
         if (status == F_exist_not) {
@@ -360,7 +360,7 @@ extern "C" {
         status = controller_dynamic_rip_nulless_terminated(buffer, range, &cache->action.generic);
         if (F_status_is_error(status)) return status;
 
-        status = f_account_id_group_by_name(cache->action.generic.string, id);
+        status = f_account_group_id_by_name(cache->action.generic.string, id);
         if (F_status_is_error(status)) return status;
 
         if (status == F_exist_not) {
index a0fd07bd9597f01acb3c3e0d76714e65e63202d7..a79927e2577cc537b56d972e6ed57fb933514d7c 100644 (file)
@@ -227,10 +227,10 @@ extern "C" {
  *   F_exist_not (with error bit) if failed to match the name to an ID.
  *   F_number_too_large (with error bit) if the given ID is too large.
  *
- *   Errors (with error bit) from: f_account_id_user_by_name().
+ *   Errors (with error bit) from: f_account_id_by_name().
  *   Errors (with error bit) from: fl_conversion_string_to_number_unsigned().
  *
- * @see f_account_id_user_by_name()
+ * @see f_account_id_by_name()
  * @see fl_conversion_string_to_number_unsigned()
  */
 #ifndef _di_controller_get_id_user_
@@ -254,10 +254,10 @@ extern "C" {
  *   F_exist_not (with error bit) if failed to match the name to an ID.
  *   F_number_too_large (with error bit) if the given ID is too large.
  *
- *   Errors (with error bit) from: f_account_id_group_by_name().
+ *   Errors (with error bit) from: f_account_group_id_by_name().
  *   Errors (with error bit) from: fl_conversion_string_to_number_unsigned().
  *
- * @see f_account_id_group_by_name()
+ * @see f_account_group_id_by_name()
  * @see fl_conversion_string_to_number_unsigned()
  */
 #ifndef _di_controller_get_id_group_
index 2e695befcd8d06e7493360f8dd6695ced6b2e759..6dcc56dcd7e7a0b0692e03e96954fb8b5c352c16 100644 (file)
@@ -5017,7 +5017,7 @@ extern "C" {
 
               cache->action.line_action = ++cache->action.line_item;
 
-              controller_rule_print_error(global.thread, global.main->error, cache->action, status, "f_account_id_group_by_name", F_true, F_false);
+              controller_rule_print_error(global.thread, global.main->error, cache->action, status, "f_account_group_id_by_name", F_true, F_false);
 
               controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status));
             }
index ddd39e463c0333b2a461b3b0a311c4085b88dcb3..537b4cc3881bdfb0f7e1de46522cf2544901468f 100644 (file)
@@ -60,10 +60,10 @@ extern "C" {
       status = F_status_set_fine(status);
 
       if (status == F_number) {
-        status = f_account_id_group_by_name(buffer.string, id);
+        status = f_account_group_id_by_name(buffer.string, id);
 
         if (F_status_is_error(status)) {
-          fll_error_print(print, F_status_set_fine(status), "f_account_id_group_by_name", F_true);
+          fll_error_print(print, F_status_set_fine(status), "f_account_group_id_by_name", F_true);
 
           return F_status_set_error(status);
         }
@@ -151,10 +151,10 @@ extern "C" {
       status = F_status_set_fine(status);
 
       if (status == F_number) {
-        status = f_account_id_user_by_name(buffer.string, id);
+        status = f_account_id_by_name(buffer.string, id);
 
         if (F_status_is_error(status)) {
-          fll_error_print(print, status, "f_account_id_user_by_name", F_true);
+          fll_error_print(print, status, "f_account_id_by_name", F_true);
 
           return F_status_set_error(status);
         }