Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
user.h
Go to the documentation of this file.
1#ifndef USER_H
2#define USER_H
3
4#include <stddef.h> // for size_t
5
6/**
7 * @brief Structure representing a GitHub user.
8 */
9typedef struct {
10 const char *login; ///< GitHub username
11 const char *name; ///< Full name
12 const char *company; ///< Company name
13 const char *location; ///< User's location
14} User;
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20/**
21 * @brief Fetch GitHub user information for a given username.
22 *
23 * @param username GitHub username to fetch.
24 * @return User structure populated with user information.
25 *
26 * The returned User must be freed with user_free().
27 */
28User fetch_github_user(const char *username);
29
30/**
31 * @brief Print GitHub user information to standard output.
32 *
33 * @param user Pointer to a User structure.
34 */
35void print_github_user(const User *user);
36
37/**
38 * @brief Free dynamically allocated memory in a User structure.
39 *
40 * @param user Pointer to a User structure to free.
41 *
42 * After calling, the fields inside User will be set to NULL.
43 */
44void user_free(User *user); // New function to free dynamically allocated memory
45
46#ifdef __cplusplus
47}
48#endif
49
50#endif
Structure representing a GitHub user.
Definition user.h:9
const char * name
Full name.
Definition user.h:11
const char * login
GitHub username.
Definition user.h:10
const char * location
User's location.
Definition user.h:13
const char * company
Company name.
Definition user.h:12
void print_github_user(const User *user)
Print GitHub user information to standard output.
Definition user.c:230
User fetch_github_user(const char *username)
Fetch GitHub user information for a given username.
Definition user.c:130
void user_free(User *user)
Free dynamically allocated memory in a User structure.