X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=src%2Furl.c;h=68725032a4bd1a11d9e36610f2a6b51ea41a22ed;hb=7b546f2a11460bed09b61116c8be38f8decf0440;hp=f968dae1a94fa7c6dea11b3e4ec4ac3b42609bc8;hpb=05e575979531e1f5597562e99294b0f00a8537ac;p=smdp.git diff --git a/src/url.c b/src/url.c index f968dae..6872503 100644 --- a/src/url.c +++ b/src/url.c @@ -136,3 +136,23 @@ static void url_print(url_t *u) { int url_get_amount(void) { return index_max; } + +int url_count_inline(const char *line) { + int count = 0; + const char *i = line; + + for (; *i; i++) { + if (*i == '\\') { + i++; + } else if ( *i == '[' && *(i+1) != ']') { + while (*i && *i != ']') i++; + i++; + if (*i == '(' && strchr(i, ')')) { + count ++; + i = strchr(i, ')'); + } + } + } + + return count; +}