cleanup a bit, still ugly as balls - sub - subscene.com subtitle search
(HTM) git clone git://git.codemadness.org/sub
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit c6c55a3959b52efb220890462fcc419ec8fafd4e
(DIR) parent 0f97d1bd0a8f55ffad37d17e5d7080576e6db684
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 19 Oct 2014 12:54:25 +0000
cleanup a bit, still ugly as balls
Diffstat:
M sub-search | 2 +-
M sub.c | 40 ++++++++++++++-----------------
2 files changed, 19 insertions(+), 23 deletions(-)
---
(DIR) diff --git a/sub-search b/sub-search
@@ -15,4 +15,4 @@ query="$1"
url="http://subscene.com/subtitles/release"
ep=$(getep "${url}")
-curl --get --data-urlencode "q=${query}" --data-urlencode "r=true" "${url}" | ./sub | grep -i 'LANG:en' | grep -i "${ep}" | grep -i "${name}"
+curl --get --data-urlencode "q=${query}" --data-urlencode "r=true" "${url}" | ./sub | grep -i 'LANG:en' | grep -i "${ep}"
(DIR) diff --git a/sub.c b/sub.c
@@ -25,17 +25,20 @@ static char curclass[64];
static char spanclass[64];
static int
-istag(const char *s1, const char *s2) {
+istag(const char *s1, const char *s2)
+{
return !strcasecmp(s1, s2);
}
static int
-isattr(const char *s1, const char *s2) {
+isattr(const char *s1, const char *s2)
+{
return !strcasecmp(s1, s2);
}
static void
-xml_handler_data(XMLParser *p, const char *data, size_t datalen) {
+xml_handler_data(XMLParser *p, const char *data, size_t datalen)
+{
char *s = "";
char buf[1024];
size_t len;
@@ -43,7 +46,7 @@ xml_handler_data(XMLParser *p, const char *data, size_t datalen) {
if(!curclass[0])
return;
- /* skip leading space */
+ /* skip leading space */
for(s = (char *)data; *s && isspace(*s); s++);
strlcpy(buf, s, sizeof(buf));
for(s = buf; *s; s++) {
@@ -61,38 +64,31 @@ xml_handler_data(XMLParser *p, const char *data, size_t datalen) {
s = buf;
if(!strlen(s))
return;
- /* link */
if(strcmp(curclass, "a1") == 0) {
+ /* link */
if(strcmp(spanclass, "") == 0) {
strlcpy(sub.title, s, sizeof(sub.title));
} else {
strlcpy(sub.lang, s, sizeof(sub.lang));
}
- }
- /* files */
- if(strcmp(curclass, "a3") == 0) {
+ } else if(strcmp(curclass, "a3") == 0) {
+ /* files */
sub.files = atoi(s);
- }
-
- /* hearing impaired? */
- if(strcmp(curclass, "a41") == 0) {
+ } else if(strcmp(curclass, "a41") == 0) {
+ /* hearing impaired? */
sub.hi = 1;
- }
- /*if(strcmp(curclass, "a40") == 0) {
- sub.hi = 0;
- }*/
- /* author / user profile */
- if(strcmp(curclass, "a5") == 0) {
+ } else if(strcmp(curclass, "a5") == 0) {
+ /* author / user profile */
strlcpy(sub.author, s, sizeof(sub.author));
- }
- /* description */
- if(strcmp(curclass, "a6") == 0) {
+ } else if(strcmp(curclass, "a6") == 0) {
+ /* description */
strlcpy(sub.description, s, sizeof(sub.description));
}
}
static void
-xml_handler_start_element(XMLParser *p, const char *tag, size_t taglen) {
+xml_handler_start_element(XMLParser *p, const char *tag, size_t taglen)
+{
(void)p;
(void)taglen;