/*
 * FileDummy Sample C Header File
 * user.h — declarations for user management module
 */

#ifndef USER_H
#define USER_H

#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

/* ── Constants ─────────────────────────────── */
#define MAX_NAME_LEN 100
#define MAX_EMAIL_LEN 255
#define MAX_USERS 1000

/* ── Type definitions ──────────────────────── */
typedef enum {
    ROLE_ADMIN = 0,
    ROLE_USER = 1,
    ROLE_GUEST = 2
} UserRole;

typedef struct User {
    int id;
    char name[MAX_NAME_LEN];
    char email[MAX_EMAIL_LEN];
    UserRole role;
} User;

typedef struct UserList {
    User users[MAX_USERS];
    int count;
} UserList;

/* ── Function declarations ─────────────────── */
UserList *user_list_create(void);
void user_list_free(UserList *list);

int user_list_add(UserList *list, const char *name, const char *email, UserRole role);
User *user_list_find(const UserList *list, int id);
int user_list_remove(UserList *list, int id);

void user_list_print(const UserList *list);
void user_list_sort_by_name(UserList *list);

/* ── Utility functions ─────────────────────── */
const char *user_role_string(UserRole role);
int user_validate_email(const char *email);

#ifdef __cplusplus
}
#endif

#endif /* USER_H */
