Add initial project structure and files
This commit is contained in:
33
include/cli.h
Normal file
33
include/cli.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef CLI_H
|
||||
#define CLI_H
|
||||
|
||||
/*
|
||||
* Result structure containing command status and message
|
||||
*/
|
||||
typedef struct {
|
||||
int success; // 0 for failure, 1 for success
|
||||
char *message; // Result or error message
|
||||
} cli_result_t;
|
||||
|
||||
/*
|
||||
* cli_print_help - Prints the cli's usage text to stdout.
|
||||
*/
|
||||
void cli_print_help(void);
|
||||
|
||||
/*
|
||||
* cli_execute - Parse arguments and execute the command
|
||||
* @argc: Argument count
|
||||
* @argv: Argument array
|
||||
*
|
||||
* Returns: cli_result_t with status and message.
|
||||
* Caller must free message with string_free().
|
||||
*/
|
||||
cli_result_t cli_execute(int argc, char *argv[]);
|
||||
|
||||
/*
|
||||
* cli_print_result - Print a result to stdout
|
||||
* @result: Result structure from cli_execute
|
||||
*/
|
||||
void cli_print_result(const cli_result_t *result);
|
||||
|
||||
#endif
|
||||
0
include/kv_store.h
Normal file
0
include/kv_store.h
Normal file
49
include/string.h
Normal file
49
include/string.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef STRING_H
|
||||
#define STRING_H
|
||||
|
||||
/*
|
||||
* string_copy - Allocate and copy a string
|
||||
* @src: Source string to copy
|
||||
*
|
||||
* Returns: Newly allocated copy of src, or NULL on failure.
|
||||
* Caller must free the returned pointer.
|
||||
*/
|
||||
char *string_copy(const char *src);
|
||||
|
||||
/*
|
||||
* string_compare - Compare two strings
|
||||
* @str1: First string
|
||||
* @str2: Second string
|
||||
*
|
||||
* Returns: 0 if equal, negative if str1 < str2, positive if str1 > str2.
|
||||
*/
|
||||
int string_compare(const char *str1, const char *str2);
|
||||
|
||||
/*
|
||||
* string_trim - Allocate and return a trimmed copy of a string
|
||||
* @str: String to trim
|
||||
*
|
||||
* Returns: Newly allocated copy of str with leading and trailing whitespace
|
||||
* removed, or NULL on failure. Caller must free the returned pointer.
|
||||
*/
|
||||
char *string_trim(const char *str);
|
||||
|
||||
/*
|
||||
* string_search - Search if a string contains a different string.
|
||||
* @src: Source string to search
|
||||
* @search: String to search for
|
||||
*
|
||||
* Returns: -1 if not found, zero-based index of the searched string if found.
|
||||
* Returns -1 if search string is empty or NULL.
|
||||
*/
|
||||
int string_search(const char *src, const char *search);
|
||||
|
||||
/*
|
||||
* string_free - Free a string allocated by string functions
|
||||
* @str: String to free (NULL-safe)
|
||||
*
|
||||
* Safe to call with NULL; does nothing in that case.
|
||||
*/
|
||||
void string_free(const char *str);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user