Commit Graph

58 Commits

Author SHA1 Message Date
Andrew Bettison
43e76ec7b5 Change signature of strn_fromprint()
The 'dst' parameter is now (char *) instead of (unsigned char *) because
in general it is used to produce human-readable (ASCII) strings, not
binary data.
2016-10-13 16:23:18 +10:30
Andrew Bettison
41b3e304be Updated some copyright messages and COPYRIGHT.txt 2016-10-13 16:23:18 +10:30
Andrew Bettison
5a77008aa8 Move URI primitives from "str.h" to "uri.h" 2016-09-21 18:47:49 +09:30
Andrew Bettison
5b3d997896 Move Base64 conversions from "str.h" to "base64.h" 2016-09-21 18:47:49 +09:30
Andrew Bettison
cd766cd480 Move numeric conversions from "str.h" to "numeric_str.h" 2016-09-21 18:47:49 +09:30
Andrew Bettison
2c0b8a5ef4 Change #include "sodium.h" to <sodium.h> 2016-09-12 15:25:08 +09:30
Jeremy Lakeman
dc7226b6a5 Remove file hash command 2016-08-16 12:22:13 +09:30
Jeremy Lakeman
e15e332072 Swap from included nacl to host libsodium 2016-05-09 10:32:04 +09:30
Jeremy Lakeman
f2e2b4acb5 Replace nacl & sha methods with versions from libsodium to avoid undefined behaviour 2016-01-27 16:27:04 +10:30
Andrew Bettison
367d54f5f8 Add functions to parse uint16_t 2015-10-01 07:05:17 +09:30
Andrew Bettison
f73cd77185 Change arg of ctype functions from char to int
Consistent with functions defined in <ctype>; now all can be used
as a predicate function with the type int (*)(int).
2015-10-01 07:05:17 +09:30
Andrew Bettison
0a40d9849c Add uri and www-form-uri encode/decode functions 2015-08-17 19:46:50 +09:30
Andrew Bettison
e73d50b48a Refactor "str.h": rename parameters 'dstlen' to 'dstsiz' 2015-08-17 19:43:58 +09:30
Andrew Bettison
7f564e4dcf Make strn_to_xxx() functions consistent
All strn_to_xxx() functions should take a 'size_t len' parameter

All functions that take a 'const char **endp' parameter should
be named parse_xxx(), and should also have a 'ssize_t len' parameter
which can be -1 to indicate a null-terminated string
2015-03-28 04:53:09 +10:30
Andrew Bettison
72345a3b2f Add alloca_sprintf() macro 2015-03-16 22:33:42 +10:30
Andrew Bettison
c1d8383226 Add strn_digest_passphrase()
Uses SHA512 internally
2014-11-14 13:11:44 +10:30
Andrew Bettison
7736a4ceb1 New HTTP RESTful requests: MeshMS read message(s) 2014-06-24 12:11:58 +09:30
Andrew Bettison
c17fb19bd4 Add strn_to_uint32()
Use to implement str_to_unit32()
2014-04-29 12:28:20 +09:30
Andrew Bettison
ad8d02827b Change all str_to_int 'base' args from int to unsigned 2014-04-29 12:18:45 +09:30
Jeremy Lakeman
37e4d65b2a Fix formatting of strings with unknown size 2014-02-12 13:09:17 +10:30
Andrew Bettison
fb74dc6649 Fix bug in Base64 encoding, trailing pad characters 2014-01-28 15:09:43 +10:30
Andrew Bettison
0c88f8bf89 Replace str_to_uint() with str_to_uint32()
Also str_to_int() with str_to_int32()
2013-12-30 16:30:43 +10:30
Andrew Bettison
4af6cf9d6a Fix -Wsign-compare warnings: use size_t or unsigned for byte counts 2013-12-10 16:52:53 +10:30
Andrew Bettison
5226e47ef6 Uniform #ifdef __SERVAL_DNA__... for headers 2013-12-04 17:15:36 +10:30
Andrew Bettison
27052384ed Add Base64URL encode/decode functions 2013-11-18 16:22:55 +10:30
Andrew Bettison
e59a62115b Add base64_encodev() multi-buffer Base64 encoder
Also replace base64_encode_len() inline function with macro
BASE64_ENCODED_LEN()
2013-11-18 11:39:23 +10:30
Andrew Bettison
f2b652c094 Refactor Base64 decoding from HTTP server to str.c
Also add a Base64 encoding function, not tested yet
2013-11-15 17:09:55 +10:30
Andrew Bettison
4fd94783d3 Refactor URI character class functions
To use array lookup instead of boolean OR expressions
2013-11-15 11:19:51 +10:30
Andrew Bettison
9418f9d65d Refactor HTTP string utils into str.[hc]
Improve "str.h" layout and commenting.  Re-implement hexvalue().
2013-11-14 23:13:37 +10:30
Andrew Bettison
1634d68dd0 Format UUID strings as lower case hex 2013-11-13 12:45:02 +10:30
Andrew Bettison
1a413b72db Add str_tolower_inplace() function 2013-10-25 00:20:53 +10:30
Andrew Bettison
95e45f452e Improve str_to_int() et al
Always set *afterp to point to the first invalid character
even if conversion fails
2013-10-25 00:20:53 +10:30
Andrew Bettison
05d4215752 Add 'strlen' argument to strn_fromprint() 2013-10-25 00:19:58 +10:30
Andrew Bettison
609e47faba Add str_to_int() and str_to_uint() 2013-10-16 11:16:04 +10:30
Andrew Bettison
a95ef79139 Use sid_t everywhere
Remove stowSid() at last

Change API of tohex() and strbuf_tohex(), to pass string length instead of
binary byte count.  This allows odd numbers of hex digits to be produced.

Remove alloca_tohex_sid(); replace with alloca_tohex_sid_t()

New alloca_tohex_sid_t_trunc() macro
2013-10-09 18:54:21 +10:30
Andrew Bettison
1c96164b62 Issue #11: uint16_t instead of unsigned short for URI port number 2013-10-08 09:56:54 +10:30
Andrew Bettison
ffafae86b1 Issue #11: replace long long with int64_t 2013-10-07 05:54:46 +10:30
Andrew Bettison
34bbfb9b30 Add strn_fromhex(), improve hexvalue()
Implement fromhex() and fromhexstr() using strn_fromhex()
2013-09-03 17:29:41 +09:30
Andrew Bettison
080ccd957a Replace str_fromprint() with strn_fromprint() 2013-09-02 17:31:13 +09:30
Andrew Bettison
121ae2d609 Improve timeout control in routing tests 2013-04-22 16:01:38 +09:30
Andrew Bettison
133c34325f Fix wrong declaration of strnchr() 2013-02-27 18:10:39 +10:30
Andrew Bettison
14b859616e Add strnchr() to str.c 2013-02-27 15:58:32 +10:30
Andrew Bettison
aeeef0e972 Add uint64_scaled_to_str() function in str.c 2013-02-26 12:59:40 +10:30
Andrew Bettison
5013424ab1 New "str.h" functions: strn_str_cmp(), strn_str_casecmp() 2013-02-13 15:52:44 +10:30
Andrew Bettison
1a3f916cfb Fix 'rhizomeprotocol' test failures
Config option rhizome.direct.peer.count is no longer required.

Bug in new URI parsing code.
2012-12-05 15:23:59 +10:30
Andrew Bettison
fdb3249522 Improve toprint_str() function
If supplied string pointer is null, return "NULL" result instead of SEGV.
2012-11-29 14:32:43 +10:30
Andrew Bettison
494a766b9e Improve str.h and str.c
Move alloca_tohex() from serval.h into str.h so it can be used stand-alone.

Rename str_to_ll_scaled() to str_to_int64_scaled().  Add str_to_uint64_scaled()
and scale_factor().

Add a few more URI parsing functions.  Move some functions out of str.c and
into str.h as inline functions.
2012-11-22 18:15:40 +10:30
Andrew Bettison
960a6293e1 Move str_is_uri() from dataformats.c to str.c
Add lots of URI unpacking functions as well.
2012-11-21 18:08:06 +10:30
Andrew Bettison
c84b7e5db4 Improve str.h functions
Add strn_startswith() and strncase_startswith().

Make all str*_startswith() functions take const char * arguments, to make it
possible to do safe programming with consts.
2012-11-20 18:10:08 +10:30
Andrew Bettison
0e435683f7 Move toprint functions from log.h to str.h
Move alloca_sockaddr() to strbuf_helpers.h

So that stand-alone executables can use them without pulling in the entire
logging framework.
2012-11-20 18:10:08 +10:30