[riot-notifications] [RIOT-OS/RIOT] ut_process: initial import of a URI template processor (#16702)

benpicco notifications at github.com
Thu Sep 16 15:57:59 CEST 2021


@benpicco commented on this pull request.



> +        }
+    }
+    for (const char *c = var->value; *c != '\0'; c++) {
+        char enc[sizeof("%00")];
+        size_t enc_len;
+
+        if (has_reserved) {
+            enc_len = _enc_reserved(*c, enc);
+        }
+        else {
+            enc_len = _enc_unreserved(*c, enc);
+        }
+        res = _copy_str(enc, enc_len, &uri[uri_idx], uri_len - uri_idx);
+        if (res < 0) {
+            DEBUG("ut_process: %p(%u) does not fit value encoding %.*s\n",
+                  (void *)uri, (unsigned)uri_len, enc_len, enc);

```suggestion
                  (void *)uri, (unsigned)uri_len, (unsigned)enc_len, enc);
```

> + * @param[in] vars_len      The length of @p vars.
+ * @param[out] uri          The resulting URI.
+ * @param[in, out] uri_len  The maximum length for @p uri on in, the actual
+ *                          length of @p uri on out.
+ *
+ * @return  The length of @p uri on success
+ * @return  -EINVAL, when @p ut is not parseable.
+ * @return  -ENOBUFS, when @p uri_len is too small to fit the resulting URI.
+ *          Potentially broken data will be written to @p uri.
+ */
+int ut_process_extend(const char *ut, size_t ut_len,
+                      const ut_process_var_t *vars, size_t vars_len,
+                      char *uri, size_t *uri_len);
+
+/**
+ * @brief   Extends a URI template by a given value set

Description is the same as for `ut_process_extend()` 

> +#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief   Name-value-pair of a variable for URI template extension
+ */
+typedef struct {
+    const char *name;       /**< name of the variable */
+    const char *value;      /**< value for the variable */
+} ut_process_var_t;
+
+/**
+ * @brief   Extends a URI template by a given value set

What does 'Extend' mean? Since this is the only function this module provides, I would expect it also does some template matching? 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16702#pullrequestreview-756313866
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210916/320e5446/attachment-0001.htm>


More information about the notifications mailing list