|
@@ -1658,59 +1658,15 @@ const struct setting_type setting_type_string __setting_type = {
|
1658
|
1658
|
.format = format_string_setting,
|
1659
|
1659
|
};
|
1660
|
1660
|
|
1661
|
|
-/**
|
1662
|
|
- * Parse URI-encoded string setting value
|
|
1661
|
+/** A URI-encoded string setting type
|
1663
|
1662
|
*
|
1664
|
|
- * @v type Setting type
|
1665
|
|
- * @v value Formatted setting value
|
1666
|
|
- * @v buf Buffer to contain raw value
|
1667
|
|
- * @v len Length of buffer
|
1668
|
|
- * @ret len Length of raw value, or negative error
|
|
1663
|
+ * This setting type is obsolete; the name ":uristring" is retained to
|
|
1664
|
+ * avoid breaking existing scripts.
|
1669
|
1665
|
*/
|
1670
|
|
-static int parse_uristring_setting ( const struct setting_type *type __unused,
|
1671
|
|
- const char *value, void *buf, size_t len ){
|
1672
|
|
- char tmp[ len + 1 /* NUL */ ];
|
1673
|
|
- size_t raw_len;
|
1674
|
|
-
|
1675
|
|
- /* Decode to temporary buffer (including NUL) */
|
1676
|
|
- raw_len = uri_decode ( value, tmp, sizeof ( tmp ) );
|
1677
|
|
-
|
1678
|
|
- /* Copy to output buffer (excluding NUL) */
|
1679
|
|
- if ( len > raw_len )
|
1680
|
|
- len = raw_len;
|
1681
|
|
- memcpy ( buf, tmp, len );
|
1682
|
|
-
|
1683
|
|
- return raw_len;
|
1684
|
|
-}
|
1685
|
|
-
|
1686
|
|
-/**
|
1687
|
|
- * Format URI-encoded string setting value
|
1688
|
|
- *
|
1689
|
|
- * @v type Setting type
|
1690
|
|
- * @v raw Raw setting value
|
1691
|
|
- * @v raw_len Length of raw setting value
|
1692
|
|
- * @v buf Buffer to contain formatted value
|
1693
|
|
- * @v len Length of buffer
|
1694
|
|
- * @ret len Length of formatted value, or negative error
|
1695
|
|
- */
|
1696
|
|
-static int format_uristring_setting ( const struct setting_type *type __unused,
|
1697
|
|
- const void *raw, size_t raw_len,
|
1698
|
|
- char *buf, size_t len ) {
|
1699
|
|
- char tmp[ raw_len + 1 /* NUL */ ];
|
1700
|
|
-
|
1701
|
|
- /* Copy to temporary buffer and terminate */
|
1702
|
|
- memcpy ( tmp, raw, raw_len );
|
1703
|
|
- tmp[raw_len] = '\0';
|
1704
|
|
-
|
1705
|
|
- /* Encode directly into output buffer */
|
1706
|
|
- return uri_encode ( tmp, buf, len, URI_FRAGMENT );
|
1707
|
|
-}
|
1708
|
|
-
|
1709
|
|
-/** A URI-encoded string setting type */
|
1710
|
1666
|
const struct setting_type setting_type_uristring __setting_type = {
|
1711
|
1667
|
.name = "uristring",
|
1712
|
|
- .parse = parse_uristring_setting,
|
1713
|
|
- .format = format_uristring_setting,
|
|
1668
|
+ .parse = parse_string_setting,
|
|
1669
|
+ .format = format_string_setting,
|
1714
|
1670
|
};
|
1715
|
1671
|
|
1716
|
1672
|
/**
|