summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/utils.c10
-rw-r--r--src/utils/utils.h19
2 files changed, 23 insertions, 6 deletions
diff --git a/src/utils/utils.c b/src/utils/utils.c
index a8d0cb5..29c7ec1 100644
--- a/src/utils/utils.c
+++ b/src/utils/utils.c
@@ -7,7 +7,7 @@
#include "utils/utils.h"
-css_fixed number_from_css_string(const css_string *string,
+css_fixed number_from_lwc_string(lwc_string *string,
bool int_only, size_t *consumed)
{
size_t len;
@@ -17,11 +17,11 @@ css_fixed number_from_css_string(const css_string *string,
int32_t fracpart = 0;
int32_t pwr = 1;
- if (string == NULL || string->len == 0 || consumed == NULL)
+ if (string == NULL || lwc_string_length(string) == 0 || consumed == NULL)
return 0;
- len = string->len;
- ptr = string->data;
+ len = lwc_string_length(string);
+ ptr = (uint8_t *)lwc_string_data(string);
/* number = [+-]? ([0-9]+ | [0-9]* '.' [0-9]+) */
@@ -91,7 +91,7 @@ css_fixed number_from_css_string(const css_string *string,
}
}
- *consumed = ptr - string->data;
+ *consumed = (char *)ptr - lwc_string_data(string);
if (sign > 0) {
/* If the result is larger than we can represent,
diff --git a/src/utils/utils.h b/src/utils/utils.h
index 6a3ddad..4661442 100644
--- a/src/utils/utils.h
+++ b/src/utils/utils.h
@@ -8,7 +8,10 @@
#ifndef css_utils_h_
#define css_utils_h_
+#include <libwapcaplet/libwapcaplet.h>
+
#include <libcss/types.h>
+#include <libcss/errors.h>
#ifndef max
#define max(a,b) ((a)>(b)?(a):(b))
@@ -27,7 +30,7 @@
#define UNUSED(x) ((x)=(x))
#endif
-css_fixed number_from_css_string(const css_string *string, bool int_only,
+css_fixed number_from_lwc_string(lwc_string *string, bool int_only,
size_t *consumed);
static inline bool isDigit(uint8_t c)
@@ -80,4 +83,18 @@ static inline uint32_t charToHex(uint8_t c)
return 0;
}
+static inline css_error
+css_error_from_lwc_error(lwc_error err)
+{
+ switch (err) {
+ case lwc_error_ok:
+ return CSS_OK;
+ case lwc_error_oom:
+ return CSS_NOMEM;
+ case lwc_error_range:
+ return CSS_BADPARM;
+ }
+ return CSS_INVALID;
+}
+
#endif