diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f3dee8c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.o +*.gc* +xmlparser.a \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1d72e0a --- /dev/null +++ b/Makefile @@ -0,0 +1,42 @@ +## +## EPITECH PROJECT, 2019 +## xmlparser +## File description: +## Makefile +## + +SRC = src/xmlparser.c \ + src/parsenode.c \ + src/list_utility.c + +OBJ = $(SRC:%.c=%.o) + +INCLUDE = -I ./include + +CFLAGS = $(INCLUDE) -Wall -Wextra -Wshadow + +LDFLAGS = + +CC = gcc + +AR = ar rc + +NAME = xmlparser.a + +all: build + +build: $(OBJ) + $(AR) $(NAME) $(NAME) + +clean: + $(RM) $(OBJ) + +fclean: clean + $(RM) $(NAME) + +re: fclean all + +dbg: CFLAGS += -g +dbg: re + +.PHONY: all build clean fclean diff --git a/include/my.h b/include/my.h new file mode 100644 index 0000000..1b267a5 --- /dev/null +++ b/include/my.h @@ -0,0 +1,121 @@ +/* +** EPITECH PROJECT, 2019 +** My lib +** File description: +** Header file +*/ +#pragma once + +int count_valid_queens_placements(int n); + +int my_compute_power_it(int n, int p); + +int my_compute_power_rec(int n, int p); + +int my_compute_factorial_it(int n); + +int my_compute_factorial_rec(int n); + +int my_compute_square_root(int n); + +char *my_evil_str(char *str); + +int my_find_prime_sup(int n); + +int my_getnbr_base(const char *str, const char *base); + +int my_getnbr(const char *str); + +int my_isneg(int n); + +int my_is_prime(int n); + +void my_print_alpha(void); + +void my_print_comb2(void); + +void my_print_combn(int n); + +void my_print_comb(void); + +void my_print_digits(void); + +void my_print_revalpha(void); + +void my_putchar(char c); + +void my_putlong_base(long n, const char *base); + +void my_putnbr_base(int n, const char *base); + +void my_put_nbr(int n); + +void my_putstr(const char *str); + +void my_revstr(char *str); + +void my_showmem(const char *str); + +void my_showstr(const char *str); + +void my_sort_int_array(int *array); + +int is_letter(char c); + +int is_alpha(char c); + +int is_num(char c); + +int is_digit(char c); + +char *my_strcapitalize(char *str); + +char *my_strcat(char *dest, const char *src); + +int my_strcmp(const char *s1, const char *s2); + +char *my_strchr(char *str, char c); + +char *my_strcpy(char *dest, const char *src); + +int my_str_isalpha(const char *str); + +int is_lowercase(char c); + +int my_str_islower(const char *str); + +int my_str_isnum(const char *str); + +int is_printable(char c); +int my_str_isprintable(const char *str); + +int is_upper(char c); +int my_str_isupper(const char *str); + +int my_strlen(const char *str); + +int my_strlowcase(const char *str); + +char *my_strncat(char *dest, const char *src, int n); + +int my_strncmp(const char *s1, const char *s2, int n); + +char *my_strncpy(char *dest, const char *src, int n); + +char *my_strstr(const char *str, const char *to_find); + +int my_strupcase(const char *str); + +void my_swap(int *a, int *b); + +char *my_strdup(const char *str); + +char **my_str_to_word_array(const char *str); + +int my_show_word_array(const char **words); + +int is_alphanum(char c); + +int first_alphanum(const char *str); + +int index_of(const char *str, char c); \ No newline at end of file diff --git a/include/xml.h b/include/xml.h index beb9770..81334b0 100644 --- a/include/xml.h +++ b/include/xml.h @@ -5,17 +5,27 @@ ** xml */ +typedef struct node node; +typedef struct dictionary dictionary; + #pragma once -typedef struct dictionary +struct dictionary { - char *property; + char *key; char *value; -} dictionary; -typedef struct node + dictionary *next; +}; + +struct node { char *name; dictionary *properties; node *child; -} node; \ No newline at end of file + + node *next; +}; + +dictionary *property_add(dictionary *list, dictionary *property); +node *xml_parsenode(char **nodestr); \ No newline at end of file diff --git a/include/xmlstate.h b/include/xmlstate.h deleted file mode 100644 index f3dd83d..0000000 --- a/include/xmlstate.h +++ /dev/null @@ -1,16 +0,0 @@ -/* -** EPITECH PROJECT, 2019 -** MUL_my_runner_2019 -** File description: -** xmlstate -*/ - -#pragma once - -#include "xml.h" - -typedef struct xmlstate -{ - node valid; - node *current; -} xmlstate; \ No newline at end of file diff --git a/lib/my/Makefile b/lib/my/Makefile new file mode 100644 index 0000000..8700fb3 --- /dev/null +++ b/lib/my/Makefile @@ -0,0 +1,33 @@ +## +## EPITECH PROJECT, 2019 +## Makefile +## File description: +## Lib makefile +## + +SRC = *.c + +OBJ = *.o \ + *.gc* + +LIBOBJ = lib/my/*.o \ + lib/my/libmy.a \ + include/my.h + +all: buildlib + +buildlib: + cp ./my.h ../../include/my.h + gcc -c ./*.c + ar rc ./libmy.a ./*.o + ar rc ../libmy.a ./*.o + +clean: + rm -f $(OBJ) + +fclean: + rm -f $(LIBOBJ) + rm -f libmy.a + rm -f ../libmy.a + +re: fclean all diff --git a/lib/my/alphanum_helper.c b/lib/my/alphanum_helper.c new file mode 100644 index 0000000..25a02b9 --- /dev/null +++ b/lib/my/alphanum_helper.c @@ -0,0 +1,24 @@ +/* +** EPITECH PROJECT, 2019 +** Helper for the task 4 +** File description: +** alphanum_helper +*/ + +int is_alpha(char c); + +int is_digit(char c); + +int is_alphanum(char c) +{ + return (is_alpha(c) || is_digit(c)); +} + +int first_alphanum(const char *str) +{ + for (int i = 0; str[i]; i++) { + if (is_alphanum(str[i])) + return i; + } + return (-1); +} diff --git a/lib/my/index_of.c b/lib/my/index_of.c new file mode 100644 index 0000000..733857c --- /dev/null +++ b/lib/my/index_of.c @@ -0,0 +1,15 @@ +/* +** EPITECH PROJECT, 2019 +** String helper +** File description: +** Index of char in a string +*/ + +int index_of(const char *str, const char c) +{ + for (int i = 0; str[i]; i++) { + if (str[i] == c) + return (i); + } + return (-1); +} \ No newline at end of file diff --git a/lib/my/my.h b/lib/my/my.h new file mode 100644 index 0000000..ca519ec --- /dev/null +++ b/lib/my/my.h @@ -0,0 +1,119 @@ +/* +** EPITECH PROJECT, 2019 +** My lib +** File description: +** Header file +*/ +#pragma once + +int count_valid_queens_placements(int n); + +int my_compute_power_it(int n, int p); + +int my_compute_power_rec(int n, int p); + +int my_compute_factorial_it(int n); + +int my_compute_factorial_rec(int n); + +int my_compute_square_root(int n); + +char *my_evil_str(char *str); + +int my_find_prime_sup(int n); + +int my_getnbr_base(const char *str, const char *base); + +int my_getnbr(const char *str); + +int my_isneg(int n); + +int my_is_prime(int n); + +void my_print_alpha(void); + +void my_print_comb2(void); + +void my_print_combn(int n); + +void my_print_comb(void); + +void my_print_digits(void); + +void my_print_revalpha(void); + +void my_putchar(char c); + +void my_putlong_base(long n, const char *base); + +void my_putnbr_base(int n, const char *base); + +void my_put_nbr(int n); + +void my_putstr(const char *str); + +void my_revstr(char *str); + +void my_showmem(const char *str); + +void my_showstr(const char *str); + +void my_sort_int_array(int *array); + +int is_letter(char c); + +int is_alpha(char c); + +int is_num(char c); + +int is_digit(char c); + +char *my_strcapitalize(char *str); + +char *my_strcat(char *dest, const char *src); + +int my_strcmp(const char *s1, const char *s2); + +char *my_strcpy(const char *str); + +int my_str_isalpha(const char *str); + +int is_lowercase(char c); + +int my_str_islower(const char *str); + +int my_str_isnum(const char *str); + +int is_printable(char c); +int my_str_isprintable(const char *str); + +int is_upper(char c); +int my_str_isupper(const char *str); + +int my_strlen(const char *str); + +int my_strlowcase(const char *str); + +char *my_strncat(char *dest, const char *src, int n); + +int my_strncmp(const char *s1, const char *s2, int n); + +char *my_strncpy(char *dest, const char *src, int n); + +char *my_strstr(const char *str, const char *to_find); + +int my_strupcase(const char *str); + +void my_swap(int *a, int *b); + +char *my_strdup(const char *str); + +char **my_str_to_word_array(const char *str); + +int my_show_word_array(const char **words); + +int is_alphanum(char c); + +int first_alphanum(const char *str); + +int index_of(const char *str, char c); \ No newline at end of file diff --git a/lib/my/my_compte_power_it.c b/lib/my/my_compte_power_it.c new file mode 100644 index 0000000..12a7d26 --- /dev/null +++ b/lib/my/my_compte_power_it.c @@ -0,0 +1,29 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day05_2019 +** File description: +** Power calculator +*/ + +int my_compute_power_it(int nb, int p) +{ + int ret = 1; + int mult = 1; + + if (p < 0) + return 0; + if (nb < 0) { + nb *= -1; + if (p % 2 == 1) + mult = -1; + } + while (p > 0) { + ret *= nb; + p--; + + if (ret < 0) + return (0); + } + + return (ret * mult); +} diff --git a/lib/my/my_compute_factorial_it.c b/lib/my/my_compute_factorial_it.c new file mode 100644 index 0000000..37f87bc --- /dev/null +++ b/lib/my/my_compute_factorial_it.c @@ -0,0 +1,22 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day05_2019 +** File description: +** Factorials +*/ + +int my_compute_factorial_it(int nb) +{ + if (nb < 0) + return 0; + + int ret = 1; + while (nb > 0) { + ret *= nb; + nb--; + + if (ret < 0) + return 0; + } + return ret; +} diff --git a/lib/my/my_compute_factorial_rec.c b/lib/my/my_compute_factorial_rec.c new file mode 100644 index 0000000..de2d6e4 --- /dev/null +++ b/lib/my/my_compute_factorial_rec.c @@ -0,0 +1,25 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day05_2019 +** File description: +** Factorials but in recursive mode +*/ + +int compute(int nb, int ret) +{ + if (ret < 0) + return (0); + + if (nb == 0) + return (ret); + + return (compute(nb - 1, ret * nb)); +} + +int my_compute_factorial_rec(int nb) +{ + if (nb == 0) + return (1); + + return (compute(nb, 1)); +} diff --git a/lib/my/my_compute_power_it.c b/lib/my/my_compute_power_it.c new file mode 100644 index 0000000..12a7d26 --- /dev/null +++ b/lib/my/my_compute_power_it.c @@ -0,0 +1,29 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day05_2019 +** File description: +** Power calculator +*/ + +int my_compute_power_it(int nb, int p) +{ + int ret = 1; + int mult = 1; + + if (p < 0) + return 0; + if (nb < 0) { + nb *= -1; + if (p % 2 == 1) + mult = -1; + } + while (p > 0) { + ret *= nb; + p--; + + if (ret < 0) + return (0); + } + + return (ret * mult); +} diff --git a/lib/my/my_compute_power_rec.c b/lib/my/my_compute_power_rec.c new file mode 100644 index 0000000..47346ca --- /dev/null +++ b/lib/my/my_compute_power_rec.c @@ -0,0 +1,31 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day05_2019 +** File description: +** Power calculator but in recursive mode +*/ + +static int calculate(int nb, int p, int ret) +{ + if (ret < 0) + return 0; + + if (p == 0) + return ret; + + return calculate(nb, p - 1, ret * nb); +} + +int my_compute_power_rec(int nb, int p) +{ + int mult = 1; + + if (p < 0) + return (0); + if (nb < 0) { + nb *= -1; + if (p % 2 == 1) + mult = -1; + } + return (calculate(nb, p, 1) * mult); +} diff --git a/lib/my/my_compute_square_root.c b/lib/my/my_compute_square_root.c new file mode 100644 index 0000000..03ed9f2 --- /dev/null +++ b/lib/my/my_compute_square_root.c @@ -0,0 +1,22 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day05_2019 +** File description: +** Square root calculator +*/ + +int my_compute_square_root(int nb) +{ + if (nb < 0) + return 0; + + for (int i = 0; 1; i++) { + int power = i * i; + if (power == nb) + return i; + else if (power > nb) + return 0; + } + + return 0; +} diff --git a/lib/my/my_evil_str.c b/lib/my/my_evil_str.c new file mode 100644 index 0000000..3487c64 --- /dev/null +++ b/lib/my/my_evil_str.c @@ -0,0 +1,28 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day04_2019 +** File description: +** Reverse string +*/ + +int my_putchar(char c); + +char *my_evil_str(char *str) +{ + int count = 0; + char buf[1598246]; + + while (1) { + buf[count] = str[count]; + if (*(str + count) != '\0') + count++; + else + break; + } + + for (int i = 0; i < count; i++) + str[i] = buf[count - i - 1]; + + str[count + 1] = '\0'; + return str; +} diff --git a/lib/my/my_find_prime_sup.c b/lib/my/my_find_prime_sup.c new file mode 100644 index 0000000..50ca6a8 --- /dev/null +++ b/lib/my/my_find_prime_sup.c @@ -0,0 +1,18 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day05_2019 +** File description: +** Find a prime number greater than the given number +*/ + +int my_is_prime(int n); + +int my_find_prime_sup(int n) +{ + if (n <= 2) + return (2); + while (!my_is_prime(n)) + n++; + + return n; +} diff --git a/lib/my/my_getnbr.c b/lib/my/my_getnbr.c new file mode 100644 index 0000000..65574f0 --- /dev/null +++ b/lib/my/my_getnbr.c @@ -0,0 +1,69 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day04_2019 +** File description: +** Int parser +*/ + +int my_putchar(char c); + +static int parse(const char *str, int digit_count, int neg) +{ + int n = 0; + int add; + for (int power = 0; power < digit_count; power++) { + add = str[digit_count - power - 1] - '0'; + if (power == 10 && add > 2) + return 0; + + add *= neg; + for (int i = 0; i < power; i++) { + add *= 10; + if (add * neg < 0) + return 0; + } + n += add; + + if ((neg == -1 && n > 0) || neg == 1 && n < 0) + return 0; + } + return n; +} + +static int init_print(const char *str, int count, int s_index) +{ + int neg = 1; + + for (char c = str[s_index]; c == '-' || c == '+'; c = str[s_index]) { + if (c == '-') + neg *= -1; + s_index++; + count--; + } + + char buf[count]; + for (int i = 0; i < count; i++) + buf[i] = str[s_index + i]; + + + return parse(buf, count, neg); +} + +int my_getnbr(const char *str) +{ + int count = 0; + int start_index = -1; + char c; + + for (int i = 0; 1; i++) { + c = str[i]; + if (c >= '0' && c <= '9' || c == '-' || c == '+') { + if (start_index == -1) + start_index = i; + count++; + } + else if (count > 0 || c == '\0') + break; + } + return init_print(str, count, start_index); +} diff --git a/lib/my/my_getnbr_base.c b/lib/my/my_getnbr_base.c new file mode 100644 index 0000000..206030c --- /dev/null +++ b/lib/my/my_getnbr_base.c @@ -0,0 +1,75 @@ +/* +** EPITECH PROJECT, 2019 +** Get number with any base +** File description: +** Int library +*/ + +int my_strlen(const char *str); + +int my_compute_power_it(int i, int p); + +static int indexof(char c, const char *str) +{ + for (int i = 0; str[i] != '\0'; i++) { + if (str[i] == c) + return (i); + } + return (-1); +} + +static int parse(char *str, const char *base, long n, int i) +{ + int str_length = my_strlen(str); + int base_length = my_strlen(base); + int power; + int neg = 1; + + if (i < 0) { + neg = -1; + i *= -1; + } + power = my_compute_power_it(base_length, i - 1); + n += indexof(str[str_length - i], base) * power * neg; + if ((n > 0 && neg < 0) || (n < 0 && neg > 0)) + return (0); + if (str_length - i > 0) + return (parse(str, base, n, (i + 1) * neg)); + return (n); +} + +static int get_digit_count(const char *str, const char *base) +{ + int count = 0; + + for (int i = 0; str[i] != '\0'; i++) { + if (indexof(str[i], base) != -1) + count++; + else if (count > 0) + return (count); + } + return (count); +} + +int my_getnbr_base(const char *str, const char *base) +{ + int length = get_digit_count(str, base); + char num[length + 1]; + int start_index = 0; + int neg = 1; + + if (length == 0) + return 0; + for (int i = 0; str[i] != '\0'; i++) { + if (indexof(str[i], base) != -1) { + num[start_index] = str[i]; + start_index++; + } + else if (str[i] == '-') + neg *= -1; + else + break; + } + num[length] = '\0'; + return (parse(num, base, 0, neg)); +} diff --git a/lib/my/my_is_prime.c b/lib/my/my_is_prime.c new file mode 100644 index 0000000..18c5723 --- /dev/null +++ b/lib/my/my_is_prime.c @@ -0,0 +1,26 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day05_2019 +** File description: +** Check if a number is a prime number +*/ + +int my_compute_square_root(int n); + +int my_is_prime(int n) +{ + int square; + + if (n <= 1) + return (0); + if (n == 2) + return (1); + for (int i = 0; i * i <= n; i++) + square = i; + for (int i = 2; i < square + 1; i++) { + if (n % i == 0) + return 0; + } + + return (1); +} diff --git a/lib/my/my_isneg.c b/lib/my/my_isneg.c new file mode 100644 index 0000000..9a91bd3 --- /dev/null +++ b/lib/my/my_isneg.c @@ -0,0 +1,17 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day03_2019 +** File description: +** Task 4 +*/ + +int my_putchar(char c); + +int my_isneg(int n) +{ + if (n < 0) + my_putchar('N'); + else + my_putchar('P'); + return (0); +} diff --git a/lib/my/my_print_alpha.c b/lib/my/my_print_alpha.c new file mode 100644 index 0000000..9139faa --- /dev/null +++ b/lib/my/my_print_alpha.c @@ -0,0 +1,16 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day03_2019 +** File description: +** First task +*/ + +int my_putchar(char c); + +int my_print_alpha(void) +{ + for (char i = 'a'; i <= 'z'; i++) { + my_putchar(i); + } + return (0); +} diff --git a/lib/my/my_print_comb.c b/lib/my/my_print_comb.c new file mode 100644 index 0000000..12b5280 --- /dev/null +++ b/lib/my/my_print_comb.c @@ -0,0 +1,46 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day03_2019 +** File description: +** Task 5 +*/ + +int my_putchar(char c); + +static void print_c(char x, char y, char z) +{ + my_putchar(x); + my_putchar(y); + my_putchar(z); +} + +static void increment_y(char *x, char *y, char *z) +{ + *x = *x + 1; + *y = *x + 1; + *z = *y + 1; +} + +int my_print_comb(void) +{ + char x = '0'; + char y = '1'; + char z = '2'; + + while (1) { + print_c(x, y, z); + z++; + if (z > '9') { + y++; + z = y + 1; + } + if (y > '8') + increment_y(&x, &y, &z); + if (x <= '7') { + my_putchar(','); + my_putchar(' '); + } + else + return 0; + } +} diff --git a/lib/my/my_print_comb2.c b/lib/my/my_print_comb2.c new file mode 100644 index 0000000..fc60b16 --- /dev/null +++ b/lib/my/my_print_comb2.c @@ -0,0 +1,36 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day03_2019 +** File description: +** Task 6 +*/ + +int my_putchar(char c); + +static void print_c2(int i, int j) +{ + my_putchar('0' + i / 10); + my_putchar('0' + i % 10); + my_putchar(' '); + my_putchar('0' + j / 10); + my_putchar('0' + j % 10); + + if (i != 98) { + my_putchar(','); + my_putchar(' '); + } +} + +static void get_group2(int i) +{ + for (int j = i + 1; j <= 99; j++) + print_c2(i, j); +} + +int my_print_comb2(void) +{ + for (int i = 0; i <= 98; i++) + get_group2(i); + + return (0); +} diff --git a/lib/my/my_print_combn.c b/lib/my/my_print_combn.c new file mode 100644 index 0000000..2907386 --- /dev/null +++ b/lib/my/my_print_combn.c @@ -0,0 +1,62 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day03_2019 +** File description: +** Task 9 +*/ + +int my_putchar(char c); + +static int is_nbr_valid(int n, int i) +{ + if (n < 9) { + if (n >= i) + return (0); + else + return (1); + } + int j = n % 10; + + if (j >= i) + return (0); + return is_nbr_valid(n / 10, j); +} + +static void print_cn(int n) +{ + if (n > 9) + print_cn(n / 10); + + my_putchar('0' + n % 10); +} + +static void process_valid_number(int n, int starting, int last_valid) +{ + if (last_valid) { + my_putchar(','); + my_putchar(' '); + } + if (n < starting && starting != 1) + my_putchar('0'); + print_cn(n); +} + +int my_print_combn(int n) +{ + if (n > 10) + return 0; + + int starting = 1; + int last_valid = 0; + + for (int i = 0; i < n - 1; i++) + starting *= 10; + + for (int i = starting / 10; i < starting * 10; i++) { + if (is_nbr_valid(i, 10)) { + process_valid_number(i, starting, last_valid); + last_valid = 1; + } + } + return (0); +} diff --git a/lib/my/my_print_digits.c b/lib/my/my_print_digits.c new file mode 100644 index 0000000..69b9d48 --- /dev/null +++ b/lib/my/my_print_digits.c @@ -0,0 +1,16 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day03_2019 +** File description: +** Task 3 +*/ + +int my_putchar(char n); + +int my_print_digits(void) +{ + for (char i = '0'; i <= '9'; i++) { + my_putchar(i); + } + return (0); +} diff --git a/lib/my/my_print_revalpha.c b/lib/my/my_print_revalpha.c new file mode 100644 index 0000000..c70547f --- /dev/null +++ b/lib/my/my_print_revalpha.c @@ -0,0 +1,16 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day03_2019 +** File description: +** The second task +*/ + +int my_putchar(char c); + +int my_print_revalpha(void) +{ + for (char i = 'z'; i >= 'a'; i--) { + my_putchar(i); + } + return (0); +} diff --git a/lib/my/my_put_nbr.c b/lib/my/my_put_nbr.c new file mode 100644 index 0000000..6291012 --- /dev/null +++ b/lib/my/my_put_nbr.c @@ -0,0 +1,30 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day03_2019 +** File description: +** Task 07 +*/ + +int my_putchar(char c); + +static void get_digit(long digit) +{ + long n = digit; + char c = '0' + n % 10; + if (n > 9) { + n /= 10; + get_digit(n); + } + my_putchar(c); +} + +int my_put_nbr(int n) +{ + long digit = n; + if (n < 0) { + my_putchar('-'); + digit *= -1; + } + get_digit(digit); + return (0); +} diff --git a/lib/my/my_putchar.c b/lib/my/my_putchar.c new file mode 100644 index 0000000..9e71ab6 --- /dev/null +++ b/lib/my/my_putchar.c @@ -0,0 +1,13 @@ +/* +** EPITECH PROJECT, 2019 +** Putchar +** File description: +** Yes +*/ + +#include + +void my_putchar(char c) +{ + write(1, &c, 1); +} diff --git a/lib/my/my_putlong_base.c b/lib/my/my_putlong_base.c new file mode 100644 index 0000000..afdcd5c --- /dev/null +++ b/lib/my/my_putlong_base.c @@ -0,0 +1,38 @@ +/* +** EPITECH PROJECT, 2019 +** Put nbr in a custom base +** File description: +** Might be useful later +*/ + +#include + +int my_strlen(const char *str); + +static void display_a_digit(char c) +{ + write(1, &c, 1); +} + +static void put_digit(long n, int base_length, const char *base) +{ + if (n > base_length - 1) + put_digit(n / base_length, base_length, base); + display_a_digit(base[n % base_length]); +} + +int my_putlong_base(long nbr, const char *base) +{ + int base_length = my_strlen(base); + + if (base_length < 2) { + display_a_digit('0'); + return (0); + } + if (nbr < 0) { + nbr *= -1; + display_a_digit('-'); + } + put_digit(nbr, base_length, base); + return (0); +} diff --git a/lib/my/my_putnbr_base.c b/lib/my/my_putnbr_base.c new file mode 100644 index 0000000..ac6ad41 --- /dev/null +++ b/lib/my/my_putnbr_base.c @@ -0,0 +1,38 @@ +/* +** EPITECH PROJECT, 2019 +** Put nbr in a custom base +** File description: +** Might be useful later +*/ + +#include + +int my_strlen(const char *str); + +static void display_a_digit(char c) +{ + write(1, &c, 1); +} + +static void put_digit(int n, int base_length, const char *base) +{ + if (n > base_length - 1) + put_digit(n / base_length, base_length, base); + display_a_digit(base[n % base_length]); +} + +int my_putnbr_base(int nbr, const char *base) +{ + int base_length = my_strlen(base); + + if (base_length < 2) { + display_a_digit('0'); + return (0); + } + if (nbr < 0) { + nbr *= -1; + display_a_digit('-'); + } + put_digit(nbr, base_length, base); + return (0); +} diff --git a/lib/my/my_putstr.c b/lib/my/my_putstr.c new file mode 100644 index 0000000..62611d5 --- /dev/null +++ b/lib/my/my_putstr.c @@ -0,0 +1,18 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day04_2019 +** File description: +** Put string +*/ + +int my_putchar(char c); + +int my_putstr(const char *str) +{ + for (int i = 0; 1; i++) { + char c = *(str + i); + if (c == '\0') + return (0); + my_putchar(c); + } +} diff --git a/lib/my/my_revstr.c b/lib/my/my_revstr.c new file mode 100644 index 0000000..1de6af6 --- /dev/null +++ b/lib/my/my_revstr.c @@ -0,0 +1,21 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day04_2019 +** File description: +** Reverse string +*/ + +int my_strlen(char *str); + +char *my_revstr(char *str) +{ + int length = my_strlen(str); + char dup[length + 1]; + + for (int i = 0; i < length; i++) + dup[i] = str[i]; + for (int i = 0; i < length; i++) + str[i] = dup[length - 1 - i]; + str[length] = '\0'; + return (str); +} diff --git a/lib/my/my_show_words_array.c b/lib/my/my_show_words_array.c new file mode 100644 index 0000000..f72f5a7 --- /dev/null +++ b/lib/my/my_show_words_array.c @@ -0,0 +1,19 @@ +/* +** EPITECH PROJECT, 2019 +** Show an array of words on the screen +** File description: +** Nothing to say +*/ + +void my_putstr(const char *str); + +void my_putchar(char c); + +int my_show_word_array(const char *words[]) +{ + for (int i = 0; words[i]; i++) { + my_putstr(words[i]); + my_putchar('\n'); + } + return (0); +} diff --git a/lib/my/my_showstr.c b/lib/my/my_showstr.c new file mode 100644 index 0000000..e77f7a6 --- /dev/null +++ b/lib/my/my_showstr.c @@ -0,0 +1,30 @@ +/* +** EPITECH PROJECT, 2019 +** Show Str With non printable values in hexa +** File description: +** Debugger Library +*/ + +#include + +int is_printable(char c); + +int my_putnbr_base(int i, const char *base); + +static void puthex(char c) +{ + char zero = '0'; + if (c < 16) + write(1, &zero, 1); + my_putnbr_base(c, "0123456789ABCDEF"); +} + +int my_showstr(const char *str) +{ + for (int i = 0; str[i] != '\0'; i++) { + if (is_printable(str[i])) + write(1, &str[i], 1); + else + puthex(str[i]); + } +} diff --git a/lib/my/my_sort_int_array.c b/lib/my/my_sort_int_array.c new file mode 100644 index 0000000..73a264e --- /dev/null +++ b/lib/my/my_sort_int_array.c @@ -0,0 +1,23 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day04_2019 +** File description: +** Int array sorter +*/ + +static int sort_linear(int *array, int size) +{ + for (int i = 0; i < size - 1; i++) { + if (array[i] > array[i + 1]) { + int buf = array[i]; + array[i] = array[i + 1]; + array[i + 1] = buf; + } + } +} + +int my_sort_int_array(int *array, int size) +{ + for (int i = 0; i < size; i++) + sort_linear(array, size); +} diff --git a/lib/my/my_str_isalpha.c b/lib/my/my_str_isalpha.c new file mode 100644 index 0000000..046c0fe --- /dev/null +++ b/lib/my/my_str_isalpha.c @@ -0,0 +1,24 @@ +/* +** EPITECH PROJECT, 2019 +** Str is alpha +** File description: +** Duplicate of the string.h (I think) +*/ + +int is_alpha(char c) +{ + if (c >= 'a' && c <= 'z') + return (1); + if (c >= 'A' && c <= 'Z') + return (1); + return (0); +} + +int my_str_isalpha(const char *str) +{ + for (int i = 0; str[i] != '\0'; i++) { + if (!is_alpha(str[i])) + return (0); + } + return (1); +} diff --git a/lib/my/my_str_islower.c b/lib/my/my_str_islower.c new file mode 100644 index 0000000..7ec625d --- /dev/null +++ b/lib/my/my_str_islower.c @@ -0,0 +1,22 @@ +/* +** EPITECH PROJECT, 2019 +** Str is alpha +** File description: +** Duplicate of the string.h (I think) +*/ + +int is_lowercase(char c) +{ + if (c >= 'a' && c <= 'z') + return (1); + return (0); +} + +int my_str_islower(const char *str) +{ + for (int i = 0; str[i] != '\0'; i++) { + if (!is_lowercase(str[i])) + return (0); + } + return (1); +} diff --git a/lib/my/my_str_isnum.c b/lib/my/my_str_isnum.c new file mode 100644 index 0000000..2978430 --- /dev/null +++ b/lib/my/my_str_isnum.c @@ -0,0 +1,22 @@ +/* +** EPITECH PROJECT, 2019 +** Str is alpha +** File description: +** Duplicate of the string.h (I think) +*/ + +int is_digit(char c) +{ + if (c >= '0' && c <= '9') + return (1); + return (0); +} + +int my_str_isnum(const char *str) +{ + for (int i = 0; str[i] != '\0'; i++) { + if (!is_digit(str[i])) + return (0); + } + return (1); +} diff --git a/lib/my/my_str_isprintable.c b/lib/my/my_str_isprintable.c new file mode 100644 index 0000000..13a8f9e --- /dev/null +++ b/lib/my/my_str_isprintable.c @@ -0,0 +1,22 @@ +/* +** EPITECH PROJECT, 2019 +** Str is alpha +** File description: +** Duplicate of the string.h (I think) +*/ + +int is_printable(char c) +{ + if (c >= ' ' && c < 127) + return (1); + return (0); +} + +int my_str_isprintable(const char *str) +{ + for (int i = 0; str[i] != '\0'; i++) { + if (!is_printable(str[i])) + return (0); + } + return (1); +} diff --git a/lib/my/my_str_isupper.c b/lib/my/my_str_isupper.c new file mode 100644 index 0000000..ec4c8f7 --- /dev/null +++ b/lib/my/my_str_isupper.c @@ -0,0 +1,22 @@ +/* +** EPITECH PROJECT, 2019 +** Str is alpha +** File description: +** Duplicate of the string.h (I think) +*/ + +int is_upper(char c) +{ + if (c >= 'A' && c <= 'Z') + return (1); + return (0); +} + +int my_str_isupper(const char *str) +{ + for (int i = 0; str[i] != '\0'; i++) { + if (!is_upper(str[i])) + return (0); + } + return (1); +} diff --git a/lib/my/my_str_to_word_array.c b/lib/my/my_str_to_word_array.c new file mode 100644 index 0000000..7d6984a --- /dev/null +++ b/lib/my/my_str_to_word_array.c @@ -0,0 +1,71 @@ +/* +** EPITECH PROJECT, 2019 +** Convert a string to a char ** +** File description: +** Split with every non alpha-numerical characters +*/ + +#include + +int is_alphanum(char c); + +int first_alphanum(const char *str); + +static int count_words(const char *str) +{ + int count = 1; + int word_length = 0; + + if (first_alphanum(str) == -1) + return (0); + for (int i = first_alphanum(str); str[i + 1]; i++) { + if (!is_alphanum(str[i]) && is_alphanum(str[i + 1])) + count++; + } + return (count); +} + +static int get_word_length(const char *str, int n) +{ + int count = 0; + int word_length = 0; + + for (int i = first_alphanum(str); str[i]; i++) { + if (!is_alphanum(str[i]) && is_alphanum(str[i + 1])) + count++; + else if (count == n && is_alphanum(str[i])) + word_length++; + } + return (word_length); +} + +static char *get_word(const char *str, int n) +{ + int length = get_word_length(str, n); + char *ret = malloc(sizeof(*ret) * (length + 1)); + int count = 0; + int word_length = 0; + + for (int i = first_alphanum(str); word_length != length; i++) { + if (!is_alphanum(str[i]) && is_alphanum(str[i + 1])) + count++; + else if (count == n) { + ret[word_length] = str[i]; + word_length++; + } + } + ret[length] = '\0'; + return (ret); +} + +char **my_str_to_word_array(const char *str) +{ + int count = count_words(str); + char **ret = malloc(sizeof(*ret) * (count + 1)); + + for (int i = 0; i < count; i++) { + ret[i] = get_word(str, i); + } + ret[count] = 0; + return (ret); +} diff --git a/lib/my/my_strcapitalize.c b/lib/my/my_strcapitalize.c new file mode 100644 index 0000000..65b932f --- /dev/null +++ b/lib/my/my_strcapitalize.c @@ -0,0 +1,32 @@ +/* +** EPITECH PROJECT, 2019 +** ToUpercase +** File description: +** string.h +*/ + +int is_num(char c) +{ + return (c >= '0' && c <= '9'); +} + +int is_letter(char c) +{ + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); +} + +char *my_strcapitalize(char *str) +{ + int capitalize_next = 1; + + for (int i = 0; str[i] != '\0'; i++) { + if (capitalize_next && str[i] > 'a' && str[i] < 'z') + str[i] += 'A' - 'a'; + + if (is_num(str[i]) || is_letter(str[i])) + capitalize_next = 1; + else + capitalize_next = 0; + } + return (str); +} diff --git a/lib/my/my_strcat.c b/lib/my/my_strcat.c new file mode 100644 index 0000000..1bc8e8e --- /dev/null +++ b/lib/my/my_strcat.c @@ -0,0 +1,19 @@ +/* +** EPITECH PROJECT, 2019 +** String cat +** File description: +** The end of the string.h lib +*/ + +int my_strlen(const char *dest); + +char *my_strcat(char *dest, const char *src) +{ + int i; + int dest_length = my_strlen(dest); + + for (i = 0; src[i]; i++) + dest[dest_length + i] = src[i]; + dest[dest_length + i] = '\0'; + return (dest); +} diff --git a/lib/my/my_strchr.c b/lib/my/my_strchr.c new file mode 100644 index 0000000..8bd6717 --- /dev/null +++ b/lib/my/my_strchr.c @@ -0,0 +1,17 @@ +/* +** EPITECH PROJECT, 2019 +** MUL_my_runner_2019 +** File description: +** my_strchr +*/ + +#include "stddef.h" + +char *my_strchr(char *str, char c) +{ + for (int i = 0; str[i]; i++) { + if (str[i] == c) + return (&str[i]); + } + return (NULL); +} \ No newline at end of file diff --git a/lib/my/my_strcmp.c b/lib/my/my_strcmp.c new file mode 100644 index 0000000..e3a4972 --- /dev/null +++ b/lib/my/my_strcmp.c @@ -0,0 +1,25 @@ +/* +** EPITECH PROJECT, 2019 +** StrCmp +** File description: +** String.h duplicate +*/ + +int my_strcmp(const char *str1, const char *str2) +{ + int i; + int ret; + + for (i = 0; str1[i] != '\0'; i++) { + if (str2[i] == '\0') + return str1[i]; + ret = str1[i] - str2[i]; + if (ret != 0) + return (ret); + } + + if (str2[i] == '\0') + return (0); + else + return -str2[i]; +} diff --git a/lib/my/my_strcpy.c b/lib/my/my_strcpy.c new file mode 100644 index 0000000..a1bf550 --- /dev/null +++ b/lib/my/my_strcpy.c @@ -0,0 +1,16 @@ +/* +** EPITECH PROJECT, 2019 +** String copy +** File description: +** Copy an entire string +*/ + +char *my_strcpy(char *dest, const char *src) +{ + int i; + + for (i = 0; src[i] != '\0'; i++) + dest[i] = src[i]; + dest[i] = '\0'; + return (dest); +} diff --git a/lib/my/my_strdup.c b/lib/my/my_strdup.c new file mode 100644 index 0000000..1ae14cc --- /dev/null +++ b/lib/my/my_strdup.c @@ -0,0 +1,21 @@ +/* +** EPITECH PROJECT, 2019 +** Str dup replicate +** File description: +** MALLOC YES +*/ + +#include + +int my_strlen(const char *src); + +char *my_strdup(const char *src) +{ + int length = my_strlen(src); + char *ret = malloc(sizeof(char) * (length + 1)); + + for (int i = 0; i < length; i++) + ret[i] = src[i]; + ret[length] = '\0'; + return (ret); +} diff --git a/lib/my/my_strlen.c b/lib/my/my_strlen.c new file mode 100644 index 0000000..38b1ae0 --- /dev/null +++ b/lib/my/my_strlen.c @@ -0,0 +1,16 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day04_2019 +** File description: +** Strlen +*/ + +int my_strlen(const char *str) +{ + if (str == 0) + return (0); + for (int i = 0; 1; i++) { + if (*(str + i) == '\0') + return i; + } +} diff --git a/lib/my/my_strlowcase.c b/lib/my/my_strlowcase.c new file mode 100644 index 0000000..54adc9b --- /dev/null +++ b/lib/my/my_strlowcase.c @@ -0,0 +1,15 @@ +/* +** EPITECH PROJECT, 2019 +** ToUpercase +** File description: +** string.h +*/ + +char *my_strlowcase(char *str) +{ + for (int i = 0; str[i] != '\0'; i++) { + if (str[i] > 'A' && str[i] < 'Z') + str[i] += 'a' - 'A'; + } + return (str); +} diff --git a/lib/my/my_strncat.c b/lib/my/my_strncat.c new file mode 100644 index 0000000..7e5622d --- /dev/null +++ b/lib/my/my_strncat.c @@ -0,0 +1,19 @@ +/* +** EPITECH PROJECT, 2019 +** String N Cat +** File description: +** End of the string.h lib +*/ + +int my_strlen(const char *str); + +char *my_strncat(char *dest, const char *src, int n) +{ + int i; + int dest_length = my_strlen(dest); + + for (i = 0; i < n && src[i]; i++) + dest[dest_length + i] = src[i]; + dest[dest_length + i] = '\0'; + return (dest); +} diff --git a/lib/my/my_strncmp.c b/lib/my/my_strncmp.c new file mode 100644 index 0000000..c5918a1 --- /dev/null +++ b/lib/my/my_strncmp.c @@ -0,0 +1,25 @@ +/* +** EPITECH PROJECT, 2019 +** StrNCmp +** File description: +** String.h duplicate +*/ + +int my_strncmp(const char *str1, const char *str2, int n) +{ + int i; + int ret; + + for (i = 0; i < n && str1[i] != '\0'; i++) { + if (str2[i] == '\0') + return str1[i]; + ret = str1[i] - str2[i]; + if (ret != 0) + return (ret); + } + + if (i == n || str2[i] == '\0') + return (0); + else + return -str2[i]; +} diff --git a/lib/my/my_strncpy.c b/lib/my/my_strncpy.c new file mode 100644 index 0000000..cd39de4 --- /dev/null +++ b/lib/my/my_strncpy.c @@ -0,0 +1,21 @@ +/* +** EPITECH PROJECT, 2019 +** String copy n first chars +** File description: +** Same but different +*/ + +char *my_strncpy(char *dest, const char* src, int n) +{ + int overflow = 0; + + for (int i = 0; i < n; i++) { + if (overflow) + dest[i] = '\0'; + else { + dest[i] = src[i]; + overflow = (src[i] == '\0'); + } + } + return (dest); +} diff --git a/lib/my/my_strstr.c b/lib/my/my_strstr.c new file mode 100644 index 0000000..b93e9a8 --- /dev/null +++ b/lib/my/my_strstr.c @@ -0,0 +1,26 @@ +/* +** EPITECH PROJECT, 2019 +** StrStr duplicate +** File description: +** A search in string function +*/ + +char *my_strstr(char *str, const char *to_find) +{ + int i; + int search_index = 0; + + for (i = 0; str[i] != '\0'; i++) { + if (to_find[search_index] == '\0') + return (str + i - search_index); + if (str[i] == to_find[search_index]) + search_index++; + else if (str[i] == to_find[0]) + search_index = 1; + else + search_index = 0; + } + if (to_find[search_index] == '\0') + return (str + i - search_index); + return 0; +} diff --git a/lib/my/my_strupcase.c b/lib/my/my_strupcase.c new file mode 100644 index 0000000..e2e87cc --- /dev/null +++ b/lib/my/my_strupcase.c @@ -0,0 +1,15 @@ +/* +** EPITECH PROJECT, 2019 +** ToUpercase +** File description: +** string.h +*/ + +char *my_strupcase(char *str) +{ + for (int i = 0; str[i] != '\0'; i++) { + if (str[i] > 'a' && str[i] < 'z') + str[i] += 'A' - 'a'; + } + return (str); +} diff --git a/lib/my/my_swap.c b/lib/my/my_swap.c new file mode 100644 index 0000000..84ff01c --- /dev/null +++ b/lib/my/my_swap.c @@ -0,0 +1,13 @@ +/* +** EPITECH PROJECT, 2019 +** CPool_Day04_2019 +** File description: +** Swap int +*/ + +void my_swap(int *a, int *b) +{ + int n = *a; + *a = *b; + *b = n; +} diff --git a/parseline.c b/parseline.c deleted file mode 100644 index 3057198..0000000 --- a/parseline.c +++ /dev/null @@ -1,13 +0,0 @@ -/* -** EPITECH PROJECT, 2019 -** MUL_my_runner_2019 -** File description: -** parseline -*/ - -#include "xmlstate.h" - -void xml_parseline(xmlstate state, char *line) -{ - if (line) -} \ No newline at end of file diff --git a/src/list_utility.c b/src/list_utility.c new file mode 100644 index 0000000..36ef735 --- /dev/null +++ b/src/list_utility.c @@ -0,0 +1,24 @@ +/* +** EPITECH PROJECT, 2019 +** xmlparser +** File description: +** list_utility +*/ + +#include "xml.h" +#include + +dictionary *property_add(dictionary *list, dictionary *property) +{ + dictionary *listconst = list; + + if (!list) + return (property); + else { + while (list->next) + list = list->next; + list->next = property; + property->next = NULL; + } + return (listconst); +} \ No newline at end of file diff --git a/src/parsenode.c b/src/parsenode.c new file mode 100644 index 0000000..88d6592 --- /dev/null +++ b/src/parsenode.c @@ -0,0 +1,117 @@ +/* +** EPITECH PROJECT, 2019 +** MUL_my_runner_2019 +** File description: +** parseline +*/ + +#include "xml.h" +#include "my.h" +#include +#include + +char *xml_getname(char **nodestr, bool *has_parameters) +{ + char *p = my_strchr(*nodestr, ' '); + char *name; + + if ((*nodestr)[0] != '<') + return (NULL); + if (p) { + *has_parameters = true; + } else { + *has_parameters = false; + p = my_strchr(*nodestr, '>'); + if (!p) + return (NULL); + } + *p = '\0'; + name = my_strdup(*nodestr); + *nodestr = p + 1; + return (name); +} + +dictionary *xml_getproperty(char **nodestr) +{ + dictionary *property = malloc(sizeof(dictionary)); + char *p; + + if (!property) + return (NULL); + p = my_strchr(*nodestr, '='); + if (!p) + return (NULL); + *p = '\0'; + property->key = my_strdup(*nodestr); + *nodestr = p + 1; + if ((*nodestr)[0] != '"') + return (NULL); + *nodestr += 1; + p = my_strchr(*nodestr, '"'); + if (!p) + return (NULL); + *p = '\0'; + property->value = my_strdup(*nodestr); + *nodestr = p + 1; + return (property); +} + +dictionary *xml_getproperties(char **nodestr, bool *can_have_child) +{ + dictionary *properties = NULL; + dictionary *property = NULL; + + while ((*nodestr)[0] != '>') { + property = xml_getproperty(nodestr); + if (!property) + return (NULL); + properties = property_add(properties, property); + if ((*nodestr)[0] == ' ') + *nodestr += 1; + if ((*nodestr)[0] == '/') { + *nodestr += 1; + *can_have_child = true; + } + else + *can_have_child = false; + } + return (properties); +} + +int xml_checkclosing(node *n, char **nodestr) +{ + if ((*nodestr)[0] != '<' || (*nodestr)[1] != '/') + return (-1); + if (my_strstr(*nodestr, n->name) != *nodestr + 2) + return (-1); + *nodestr += 2 + my_strlen(n->name); + if ((*nodestr)[0] != '>') + return (-1); + *nodestr += 1; + return (0); +} + +node *xml_parsenode(char **nodestr) +{ + node *n = malloc(sizeof(node)); + bool has_next_value; + + if (!n) + return (NULL); + n->name = xml_getname(nodestr, &has_next_value); + if (has_next_value) { + if (!(n->properties = xml_getproperties(nodestr, &has_next_value))) + return (NULL); + } + else + n->properties = NULL; + if (has_next_value) { + if (!(n->child = xml_parsenode(nodestr))) + return (NULL); + } else + n->child = NULL; + if (!n->name || xml_checkclosing(n, nodestr) < 0) + return (NULL); + n->next = xml_parsenode(nodestr); + return (n); +} \ No newline at end of file diff --git a/src/xmlparser.c b/src/xmlparser.c new file mode 100644 index 0000000..cac1be5 --- /dev/null +++ b/src/xmlparser.c @@ -0,0 +1,37 @@ +/* +** EPITECH PROJECT, 2019 +** MUL_my_runner_2019 +** File description: +** xmlparser +*/ + +#include "xml.h" +#include +#include +#include +#include + +node *xmlparse(char *path) +{ + node *n = NULL; + int fd = open(path, O_RDONLY); + struct stat stats; + char *nodestr; + char *strconst; + int count; + + if (fd < 0) + return (NULL); + fstat(fd, &stats); + nodestr = malloc(stats.st_size); + if (nodestr) { + count = read(fd, nodestr, stats.st_size); + if (count == stats.st_size) { + strconst = nodestr; + n = xml_parsenode(&nodestr); + } + free(strconst); + } + close(fd); + return (n); +} \ No newline at end of file diff --git a/xmlparser.c b/xmlparser.c deleted file mode 100644 index 8e684c5..0000000 --- a/xmlparser.c +++ /dev/null @@ -1,25 +0,0 @@ -/* -** EPITECH PROJECT, 2019 -** MUL_my_runner_2019 -** File description: -** xmlparser -*/ - -#include "xml.h" -#include "xmlstate.h" -#include - -node *xmlparse(char *path) -{ - FILE *file = fopen(path, "r"); - char *line = NULL; - xmlstate state; - - if (!file) - return (NULL); - while ((line = getline(line, 0, file))) { - xml_parseline(state, line); - } - fclose(file); - return (state.valid); -} \ No newline at end of file