summaryrefslogtreecommitdiff
path: root/sfeed_opml_import.c
AgeCommit message (Collapse)Author
2023-04-14slightly reduce stack size for entitiesHiltjo Posthuma
A numeric entity could be 5 bytes, so use a round number of 8 bytes.
2022-03-29compatibility: reduce the assumption the builtin libc locale is ASCII-compatibleHiltjo Posthuma
This is not clearly defined by the C99 standard. Define ctype-like macros to force it to be ASCII / UTF-8 (not extended ASCII or something like noticed on OpenBSD 3.8). (In practise modern libc libraries are all ASCII and UTF-8-compatible. Otherwise this would break many programs)
2022-03-28compatibility: replace iscntrl with own ISCNTRL macroHiltjo Posthuma
It is unspecified if the C locale iscntrl is compatible with ASCII or not. Noticed when testing on OpenBSD 3.8 which uses extended ASCII and also uses the C1 range for control-characters. This breaks support with UTF-8. Reference: https://en.wikipedia.org/wiki/C0_and_C1_control_codes#C1_control_codes_for_general_use C1 table. Force an own definition of an ASCII-compatible control-character range since sfeed expects input to be UTF-8 (or converted from iconv) and so output to be UTF-8 aswell.
2022-03-15stricter error checking in file streams (input, output)Hiltjo Posthuma
This also makes the programs exit with a non-zero status when a read or write error occurs. This makes checking the exit status more reliable in scripts. A simple example to simulate a disk with no space left: curl -s 'https://codemadness.org/atom.xml' | sfeed > f /mnt/test: write failed, file system is full echo $? 0 Which now produces: curl -s 'https://codemadness.org/atom.xml' | sfeed > f /mnt/test: write failed, file system is full write error: <stdout> echo $? 1 Tested with a small mfs on OpenBSD, fstab entry: swap /mnt/test mfs rw,nodev,nosuid,-s=1M 0 0
2021-06-01portability and standards: add BSD-like err() and errx() functionsHiltjo Posthuma
These are BSD functions. - HaikuOS now compiles without having to use libbsd. - Tested on SerenityOS (for fun), which doesn't have these functions (yet). With a small change to support wcwidth() sfeed works on SerenityOS.
2021-01-16sfeed_opml_import: minor code-style improvementsHiltjo Posthuma
2020-01-24cleanup some includesHiltjo Posthuma
2020-01-18sfeed_opml_import: use code-style pattern similar to other programsHiltjo Posthuma
2019-11-24sfeed_opml_import: improve import with nested <outline>Hiltjo Posthuma
This nested format is used by Mozilla Thunderbird: <outline title=""> <outline type="rss" title="" text="" xmlUrl=""/> </outline> other tests: - newsboat -e uses the title attribute, not text. - rss2email 3.x, r2e opmlexport uses type, text and xmlUrl (correct).
2019-07-20use the same XML handler names as the fields and shorten variable namesHiltjo Posthuma
Use the same XML handlers names as the fields to improve readability a bit. This is also consistent across all the programs using xml.c. Shorten the variable names aswell.
2019-04-06optimization: define GETNEXT as an inline macroHiltjo Posthuma
This reduces much function call overhead. getnext is defined in xml.h for inline optimization. sfeed only uses one XML parser context per program, this allows further optimizations of the compiler also. On OpenBSD it was noticable because of retpoline etc function call overhead. Using clang and a 500MB test XML file reduces processing time from +- 12s to 5s. Tested using some crazy optimization flags: SFEED_CFLAGS = -O3 -std=c99 -DGETNEXT=getchar_unlocked -fno-ret-protector \ -mno-retpoline -static A GETNEXT macro is also nice for programs which mmap(2) some big XML file. Then you can simply define: #define GETNEXT() (off >= len ? EOF : reg[off++])
2018-09-07fix many undefined behaviour in usage of ctype functionsHiltjo Posthuma
- cast all ctype(3) function argument to (unsigned char) to avoid UB POSIX says: "The c argument is an int, the value of which the application shall ensure is a character representable as an unsigned char or equal to the value of the macro EOF. If the argument has any other value, the behavior is undefined." Many libc cast implicitly the value, but NetBSD does not, which is probably the correct thing to interpret it. - no need to cast for putchar + rename some fputc(..., stdout) to putchar POSIX says: "The fputc() function shall write the byte specified by c (converted to an unsigned char) to the output stream pointed to by stream [...]" Major thanks to Leonardo Taccari <iamleot@gmail.com> for reporting and testing it on NetBSD!
2018-08-22remove stdint.h includeHiltjo Posthuma
the uint* types in XML are not exposed anymore.
2018-06-24sfeed_opml_import: escape ' properlyHiltjo Posthuma
the shell escape \' was a mistake.
2018-03-11include <sys/types.h> for types size_t, ssize_t etcHiltjo Posthuma
This makes sure xml.c in particular can be compiled without further feature macros.
2017-12-10sfeed_opml_import/sfeed_opml_export: allow " and \ in fieldsHiltjo Posthuma
make sure to escape them.
2017-04-27simplify pledge stubHiltjo Posthuma
2016-08-06add USE_PLEDGE, remove pledge dummy functionHiltjo Posthuma
2016-03-10remove cast of unused variablesHiltjo Posthuma
2016-02-27various improvementsHiltjo Posthuma
- pledge tools and add define to enable it on platforms that support it, currently only OpenBSD 5.9+ - separate getline and parseline functionality. - use murmur3 hash instead of jenkins1: faster and less collisions. - make some error messages a bit more clear, for example with path truncation. - some small cleanups, move printutf8pad to util.
2016-01-31sfeed_opml_import: fix compatHiltjo Posthuma
2015-08-22xml: simplify XML readerHiltjo Posthuma
2015-08-22sfeed_update: simplify path (only $sfeedpath now)Hiltjo Posthuma
2015-08-22sfeed_opml_import: does not need util but may need compat.h for strlcpy, strlcatHiltjo Posthuma
2015-08-22sfeed_opml_import: improve importHiltjo Posthuma
- support attribute entities better. - escape some characters (it's still recommended to check the output ofcourse).
2015-08-14sfeed_opml_import: does not need util functionsHiltjo Posthuma
2015-08-14xml: separate reader context from parserHiltjo Posthuma
also: - rename xmlparser_ prefix to xml_. - make xml_parse public, this allows a custom reader like a direct mmap, see: XMLParser.getnext and (optionall) XMLParser.getnext_data. - improve the README text.
2015-08-06general cleanupsHiltjo Posthuma
2015-08-05sfeed_opml_import: change to new config (feeds directory) + simplifyHiltjo Posthuma
2015-07-29improve includes (dont include headers in .h), fix build on LinuxHiltjo Posthuma
2015-07-28improve code-style and consistencyHiltjo Posthuma
2015-05-16xml: adjust for API change: read from fdHiltjo Posthuma
2015-01-02cleanupHiltjo Posthuma
- dont free at end (not needed in our case). - use 0 and 1 instead of EXIT_SUCCESS, EXIT_FAILURE. - use err (from err.h) instead of custom die().
2014-11-11code style, use actual column width of charHiltjo Posthuma
2014-06-28compile with -Wextra, ignore unused parametersHiltjo Posthuma
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-04-02sfeed_opml_import: fix buildHiltjo Posthuma
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-04-02sfeed_opml_import: use strlcpyHiltjo Posthuma
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-04-01fix crlf newlines, add fp arg to xmlparser_initHiltjo Posthuma
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-03-31new versionHiltjo Posthuma
lots of things changed, but cleanup todo. changelog and consistent stream of small updates will come in the future. Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2013-06-14sfeed_opml_import: format code, wordwrapHiltjo Posthuma
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2013-05-20add basesiteurl, simplify sfeed_update a bitHiltjo Posthuma
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2013-05-20sfeed_opml_import: dont use dynamic allocation, assumes sane lengths and ↵Hiltjo Posthuma
just use a static buffer Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2013-05-20sfeed_opml_import: use own XML parserHiltjo Posthuma
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2012-08-03sfeed_opml_import: use new exec name for errorsHiltjo Posthuma
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2012-08-03Rename sfeed_opml_config to sfeed_opml_importHiltjo Posthuma
Because I'm adding a sfeed_opml_export script. Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>