summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-10-19 00:30:52 -0400
committerNick Mathewson <nickm@torproject.org>2009-10-19 00:30:52 -0400
commit465d4e1cd10a995cff571b42b4f008811590c314 (patch)
tree7265957e1c41b7e9112eee6346835ff38cf24cd5 /src/common
parent5ef97ddd42dfd51fc296bb51b612780aec09c5c7 (diff)
downloadtor-465d4e1cd10a995cff571b42b4f008811590c314.tar.gz
tor-465d4e1cd10a995cff571b42b4f008811590c314.zip
Document some formerly undocumented functions.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/util.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/common/util.c b/src/common/util.c
index d05c308fe8..8f10d2175c 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -2307,7 +2307,8 @@ expand_filename(const char *filename)
#define MAX_SCANF_WIDTH 9999
-/** DOCDOC */
+/** Helper: given an ASCII-encoded decimal digit, return its numeric value.
+ * NOTE: requires that its input be in-bounds. */
static int
digit_to_num(char d)
{
@@ -2316,7 +2317,10 @@ digit_to_num(char d)
return num;
}
-/** DOCDOC */
+/** Helper: Read an unsigned int from *<b>bufp</b> of up to <b>width</b>
+ * characters. (Handle arbitrary width if <b>width</b> is less than 0.) On
+ * success, store the result in <b>out</b>, advance bufp to the next
+ * character, and return 0. On failure, return -1. */
static int
scan_unsigned(const char **bufp, unsigned *out, int width)
{
@@ -2343,7 +2347,9 @@ scan_unsigned(const char **bufp, unsigned *out, int width)
return 0;
}
-/** DOCDOC */
+/** Helper: copy up to <b>width</b> non-space characters from <b>bufp</b> to
+ * <b>out</b>. Make sure <b>out</b> is nul-terminated. Advance <b>bufp</b>
+ * to the next non-space character or the EOS. */
static int
scan_string(const char **bufp, char *out, int width)
{
@@ -2432,7 +2438,12 @@ tor_vsscanf(const char *buf, const char *pattern, va_list ap)
* and store the results in the corresponding argument fields. Differs from
* sscanf in that it: Only handles %u and %Ns. Does not handle arbitrarily
* long widths. %u does not consume any space. Is locale-independent.
- * Returns -1 on malformed patterns. */
+ * Returns -1 on malformed patterns.
+ *
+ * (As with other local-independent functions, we need this to parse data that
+ * is in ASCII without worrying that the C library's locale-handling will make
+ * miscellaneous characters look like numbers, spaces, and so on.)
+ */
int
tor_sscanf(const char *buf, const char *pattern, ...)
{