mirror of
https://github.com/zoriya/xmlParser.git
synced 2026-05-26 15:47:42 +00:00
Adding binary and hexa get
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
@@ -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"));
|
||||
}
|
||||
Reference in New Issue
Block a user