eina_str_01.c
//Compile with:
//gcc -Wall -o eina_str_01 eina_str_01.c `pkg-config --cflags --libs eina`
#include <stdio.h>
#include <Eina.h>
int main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
char *names = "Calvin;Leoben;D'anna;Simon;Doral;Six;Daniel;Sharon";
char *str;
char *tmp;
char *prologue;
char *part1 = "The Cylons were created by man. They evolved. They rebelled.";
char *part2 = "There are many copies. And they have a plan.";
char **arr;
int i;
char *time_arr;
time_t curr_time;
struct tm *info;
arr = eina_str_split(names, ";", 0);
for (i = 0; arr[i]; i++)
printf("%s\n", arr[i]);
free(arr[0]);
free(arr);
str = malloc(sizeof(char) * 4);
strcpy(str, "bsd");
eina_str_toupper((char **)&str);
printf("%s\n", str);
printf("%s\n", str);
if (eina_str_has_prefix(names, "Calvin"))
printf("Starts with 'Calvin'\n");
if (eina_str_has_suffix(names, "sharon"))
printf("Ends with 'sharon'\n");
if (eina_str_has_extension(names, "sharon"))
printf("Has extension 'sharon'\n");
tmp = eina_str_escape("They'll start going ripe on us pretty soon.");
printf("%s\n", tmp);
free(tmp);
prologue = malloc(sizeof(char) * 106);
eina_str_join_len(prologue, 106, ' ', part1, strlen(part1), part2, strlen(part2));
printf("%s\n", prologue);
eina_strlcpy(str, prologue, 4);
printf("%s\n", str);
free(prologue);
free(str);
str = malloc(sizeof(char) * 14);
sprintf(str, "%s", "cylons+");
eina_strlcat(str, "humans", 14);
printf("%s\n", str);
free(str);
curr_time = time(NULL);
info = localtime(&curr_time);
time_arr = eina_strftime("%d/%m/%Y", info);
printf("Today's Date: %s\n", time_arr);
free(time_arr);
return 0;
}
Eina Utility library.
EINA_API int eina_shutdown(void)
Shuts down the Eina library.
Definition: eina_main.c:379
EINA_API int eina_init(void)
Initializes the Eina library.
Definition: eina_main.c:291
EINA_API void eina_str_tolower(char **str)
Lowercases all the characters in range [A-Z] in the given string.
Definition: eina_str.c:698
EINA_API char * eina_str_escape(const char *str)
Escapes slashes, spaces and apostrophes in strings.
Definition: eina_str.c:648
EINA_API char ** eina_str_split(const char *str, const char *delim, int max_tokens)
Splits a string using a delimiter.
Definition: eina_str.c:452
EINA_API void eina_str_toupper(char **str)
Uppercases all the characters in range [a-z] in the given string.
Definition: eina_str.c:709
EINA_API Eina_Bool eina_str_has_extension(const char *str, const char *ext)
Checks if the given string has the given extension.
Definition: eina_str.c:436
EINA_API Eina_Bool eina_str_has_suffix(const char *str, const char *suffix)
Checks if the given string has the given suffix.
Definition: eina_str.c:430
EINA_API size_t eina_strlcat(char *dst, const char *src, size_t siz)
Appends a c-string.
Definition: eina_str.c:349
EINA_API char * eina_strftime(const char *format, const struct tm *tm)
Creates and update the buffer based on strftime output.
Definition: eina_str.c:383
EINA_API size_t eina_strlcpy(char *dst, const char *src, size_t siz)
Copies a c-string to another.
Definition: eina_str.c:317
EINA_API size_t eina_str_join_len(char *dst, size_t size, char sep, const char *a, size_t a_len, const char *b, size_t b_len)
Joins two strings of known length.
Definition: eina_str.c:458
EINA_API Eina_Bool eina_str_has_prefix(const char *str, const char *prefix)
Checks if the given string has the given prefix.
Definition: eina_str.c:416
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition: eina_types.h:339