Adding binary and hexa get

This commit is contained in:
AnonymusRaccoon
2020-01-04 16:55:28 +01:00
parent b9cd425416
commit 9262589054
4 changed files with 39 additions and 0 deletions
+1
View File
@@ -13,6 +13,7 @@ SRC = src/xmlparser.c \
src/rawnode.c \
src/xml_destroy.c \
src/xmlget.c \
src/strangeget.c \
src/floatutils.c \
src/child.c
+2
View File
@@ -6,6 +6,8 @@
*/
#pragma once
int my_str_islower_or_num(const char *str);
int count_valid_queens_placements(int n);
char *my_strchr(char *str, char c);
+2
View File
@@ -31,6 +31,8 @@ node *xml_parse(const char *path);
node *xml_getnode(node *parent, const char *name);
char *xml_getproperty(node *n, const char *key);
int xml_getintprop(node *n, const char *key);
int xml_getbinaprop(node *n, const char *key);
int xml_gethexaprop(node *n, const char *key);
float xml_getfloatprop(node *n, const char *key);
int xml_getchildcount(node *n);
void xml_destroy(node *n);
+34
View File
@@ -0,0 +1,34 @@
/*
** EPITECH PROJECT, 2020
** Twac
** File description:
** strangeget
*/
#include "xml.h"
#include "my.h"
int xml_gethexaprop(node *n, const char *key)
{
char *prop = xml_getproperty(n, key);
if (!prop || my_strlen(prop) == 0)
return (0);
if (prop[0] == '0' && prop[1] == 'x')
prop += 2;
if (my_str_islower_or_num(prop))
return (my_getnbr_base(prop, "0123456789abcdef"));
else
return (my_getnbr_base(prop, "0123456789ABCDEF"));
}
int xml_getbinaprop(node *n, const char *key)
{
char *prop = xml_getproperty(n, key);
if (!prop || my_strlen(prop) == 0)
return (0);
if (prop[0] == '0' && prop[1] == 'b')
prop += 2;
return (my_getnbr_base(prop, "01"));
}