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.
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_
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);
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);
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_
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);
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);
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_
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);
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;
}
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);
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);
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;
}
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);
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_
return F_none;
}
-#endif // _di_f_account_name_user_by_id_
+#endif // _di_f_account_name_by_id_
#ifdef __cplusplus
} // 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.
* 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.
* 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.
*
* @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.
* 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.
* 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.
*
* @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"
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
#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";
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;
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;
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);
/**
* 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_
#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;
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
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;
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);
}
}
#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;
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);
/**
* 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_
#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";
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;
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;
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);
/**
* 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_
#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;
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
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;
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);
}
}
#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;
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);
/**
* 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_
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_
};
// 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" {
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) {
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) {
* 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_
* 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_
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));
}
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);
}
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);
}