[ekg2-commit] r4116 - in trunk: ekg plugins/feed plugins/ioctld plugins/ncurses: trunk/ekg/commands.c trunk/ekg/themes.c trunk/ekg/themes.h trunk/ekg/vars.c trunk/plugins/feed/feed.c trunk/plugins/ioctld/main.c trunk/plugins/ncurses/contacts.c trunk/plugins/ncurses/old.c

SVN commit svn w toxygen.net
Śro, 16 Lip 2008, 18:35:56 CEST


Author: darkjames
Date: 2008-07-16 18:35:56 +0200 (Wed, 16 Jul 2008)
New Revision: 4116

Modified:
   trunk/ekg/commands.c
   trunk/ekg/themes.c
   trunk/ekg/themes.h
   trunk/ekg/vars.c
   trunk/plugins/feed/feed.c
   trunk/plugins/ioctld/main.c
   trunk/plugins/ncurses/contacts.c
   trunk/plugins/ncurses/old.c
Log:
- use format_ok(format) instead of strcmp(format, "")



Modified: trunk/ekg/commands.c
===================================================================
--- trunk/ekg/commands.c	2008-07-16 12:51:15 UTC (rev 4115)
+++ trunk/ekg/commands.c	2008-07-16 16:35:56 UTC (rev 4116)
@@ -486,7 +486,7 @@
 
 			t = localtime(&s->last_conn);
 			format = format_find((t->tm_yday == now_days) ? "show_status_last_conn_event_today" : "show_status_last_conn_event");
-			if (format[0] && !strftime(buf, sizeof(buf), format, t))
+			if (format_ok(format) && !strftime(buf, sizeof(buf), format, t))
 				xstrcpy(buf, "TOOLONG");
 
 			printq((s->connected) ? "show_status_connected_since" : "show_status_disconnected_since", buf);
@@ -495,7 +495,7 @@
 
 	t = localtime(&ekg_started);
 	format = format_find((t->tm_yday == now_days) ? "show_status_ekg_started_today" : "show_status_ekg_started");
-	if (format[0] && !strftime(buf1, sizeof(buf1), format, t))
+	if (format_ok(format) && !strftime(buf1, sizeof(buf1), format, t))
 		xstrcpy(buf1, "TOOLONG");
 
 	printq("show_status_ekg_started_since", buf1);
@@ -1431,10 +1431,9 @@
 			char buf[100];		
 
 			status_time = localtime(&(u->status_time));
-	        	if (!strftime(buf, sizeof(buf), format_find("user_info_status_time_format") ,status_time) && xstrlen(format_find("user_info_status_time_format"))>0)
+	        	if (!strftime(buf, sizeof(buf), format_find("user_info_status_time_format") ,status_time) && format_exists("user_info_status_time_format"))
 				xstrcpy(buf, "TOOLONG");
 
-
 			printq("user_info_status_time", buf);
 		}
 
@@ -1476,7 +1475,7 @@
 			
 			if (u->last_seen) {
 				last_seen_time = localtime(&(u->last_seen));
-				if (!strftime(buf, sizeof(buf), format_find("user_info_last_seen_time"), last_seen_time) && xstrlen(format_find("user_info_last_seen_time"))>0)
+				if (!strftime(buf, sizeof(buf), format_find("user_info_last_seen_time"), last_seen_time) && format_exists("user_info_last_seen_time"))
 					xstrcpy(buf, "TOOLONG");
 				printq("user_info_last_seen", buf);
 			} else
@@ -2774,22 +2773,18 @@
 		for (ul = s->userlist; ul; ul = ul->next) {
 			userlist_t *u = ul;
 			const char *format;
-			char *tmp;
 
 			if (!u->nickname)
 				continue;
 		
 			format = format_find(ekg_status_label(u->status, NULL, "quick_list_"));
 
-			if (!xstrcmp(format, ""))	/* format_find returns "" if not found! */
-				continue;
+			if (format_ok(format)) {
+				char *tmp = format_string(format, u->nickname);
+				string_append(list, tmp);
 
-			if (!(tmp = format_string(format, u->nickname)))
-				continue;
-
-			string_append(list, tmp);
-
-			xfree(tmp);
+				xfree(tmp);
+			}
 		}
 	}
 
@@ -3152,8 +3147,7 @@
 			gettimeofday(&tv, NULL);
 
 			at_time = localtime((time_t *) &t->ends.tv_sec);
-			if (!strftime(tmp, sizeof(tmp), format_find("at_timestamp"), at_time)
-					&& xstrlen(format_string("at_timestamp"))>0)
+			if (!strftime(tmp, sizeof(tmp), format_find("at_timestamp"), at_time) && format_exists("at_timestamp"))
 				xstrcpy(tmp, "TOOLONG");
 
 			if (t->persist) {
@@ -3756,8 +3750,7 @@
 				continue;
 
 			tm = localtime(&ll->time);
-			if (!strftime(buf, sizeof(buf), format_find("last_list_timestamp"), tm)
-					&& xstrlen(format_find("last_list_timestamp"))>0)
+			if (!strftime(buf, sizeof(buf), format_find("last_list_timestamp"), tm) && format_exists("last_list_timestamp"))
 				xstrcpy(buf, "TOOLONG");
 
 			if (show_sent && !ll->type && !(ll->sent_time - config_time_deviation <= ll->time && ll->time <= ll->sent_time + config_time_deviation)) {
@@ -3821,7 +3814,7 @@
 			tm = localtime(&m->time);
 
 			/* [if queue_list_timestamp_f != "", (format_find() returns "" if format not found]] && if strftime() fails */
-			if (queue_list_timestamp_f[0] && !strftime(buf, sizeof(buf), queue_list_timestamp_f, tm))
+			if (format_ok(queue_list_timestamp_f) && !strftime(buf, sizeof(buf), queue_list_timestamp_f, tm))
 				xstrcpy(buf, "TOOLONG");	/* use 'TOOLONG' */
 
 			printq("queue_list_message", buf, m->rcpts, m->message);

Modified: trunk/ekg/themes.c
===================================================================
--- trunk/ekg/themes.c	2008-07-16 12:51:15 UTC (rev 4115)
+++ trunk/ekg/themes.c	2008-07-16 16:35:56 UTC (rev 4116)
@@ -107,7 +107,7 @@
 
 		xfree(name2);
 
-		if (tmp[0] != '\0')
+		if (format_ok(tmp))
 			return tmp;
 	}
 
@@ -117,7 +117,7 @@
 
 		xfree(name2);
 
-		if (tmp[0] != '\0')
+		if (format_ok(tmp))
 			return tmp;
 	}
 

Modified: trunk/ekg/themes.h
===================================================================
--- trunk/ekg/themes.h	2008-07-16 12:51:15 UTC (rev 4115)
+++ trunk/ekg/themes.h	2008-07-16 16:35:56 UTC (rev 4116)
@@ -57,6 +57,8 @@
 
 void format_add(const char *name, const char *value, int replace);
 const char *format_find(const char *name);
+#define format_ok(format_find_result) 	(format_find_result[0])
+#define format_exists(format)		(format_ok(format_find(format)))
 char *format_string(const char *format, ...);
 
 void theme_init();

Modified: trunk/ekg/vars.c
===================================================================
--- trunk/ekg/vars.c	2008-07-16 12:51:15 UTC (rev 4115)
+++ trunk/ekg/vars.c	2008-07-16 16:35:56 UTC (rev 4116)
@@ -657,7 +657,7 @@
 
 	string_free(s, 1);
 	
-	if (xstrcmp(format_find("help_set_footer"), ""))
+	if (format_exists("help_set_footer"))
 		print("help_set_footer", name);
 
 	fclose(f);

Modified: trunk/plugins/feed/feed.c
===================================================================
--- trunk/plugins/feed/feed.c	2008-07-16 12:51:15 UTC (rev 4115)
+++ trunk/plugins/feed/feed.c	2008-07-16 16:35:56 UTC (rev 4116)
@@ -180,7 +180,7 @@
 			}
 
 			formatka = saprintf("feed_server_header_%s", tmp);
-			if ((!xstrcmp(format_find(formatka), ""))) { xfree(formatka); formatka = NULL; }
+			if (!format_exists(formatka)) { xfree(formatka); formatka = NULL; }
 	
 			formated = format_string(format_find(formatka ? formatka : "feed_server_header_generic"), tmp, value ? value+1 : "");
 			print_window_w(targetwnd, 1, "feed_message_body", formated ? formated : tmp);
@@ -206,7 +206,7 @@
 			}
 
 			formatka = saprintf("feed_message_header_%s", tmp);
-			if ((!xstrcmp(format_find(formatka), ""))) { xfree(formatka); formatka = NULL; }
+			if (!format_exists(formatka)) { xfree(formatka); formatka = NULL; }
 	
 			formated = format_string(format_find(formatka ? formatka : "feed_message_header_generic"), tmp, value ? value+1 : "");
 			print_window_w(targetwnd, 1, "feed_message_body", formated ? formated : tmp);
@@ -239,7 +239,9 @@
 					if (i > 0) 			/* buggy clients quote:   >>>>>aaaa */
 					{
 						quote_name = saprintf("nntp_message_quote_level%d", i+1);
-						if (!xstrcmp(f = format_find(quote_name), "")) {
+
+						f = format_find(quote_name);
+						if (!format_ok(f)) {
 							debug("[NNTP, QUOTE] format: %s not found, using global one...\n", quote_name);
 							f = format_find("nntp_message_quote_level");
 						}

Modified: trunk/plugins/ioctld/main.c
===================================================================
--- trunk/plugins/ioctld/main.c	2008-07-16 12:51:15 UTC (rev 4115)
+++ trunk/plugins/ioctld/main.c	2008-07-16 16:35:56 UTC (rev 4116)
@@ -157,7 +157,7 @@
 	if (!xisdigit(*seq)) {
 		const char *tmp = format_find(seq);
 
-		if (tmp[0] == '\0') {
+		if (!format_ok(tmp)) {
 			printq("events_seq_not_found", seq);
 			return -1;
 		}

Modified: trunk/plugins/ncurses/contacts.c
===================================================================
--- trunk/plugins/ncurses/contacts.c	2008-07-16 12:51:15 UTC (rev 4115)
+++ trunk/plugins/ncurses/contacts.c	2008-07-16 16:35:56 UTC (rev 4116)
@@ -212,7 +212,7 @@
 		footer = format_find("contacts_footer");
 	}
 
-	if (xstrcmp(header, ""))
+	if (format_ok(header))
 		ncurses_backlog_add(w, fstring_new_format(header, group));
 
 	if (all == 1) {
@@ -337,7 +337,7 @@
 			if (!count) {
 				snprintf(tmp, sizeof(tmp), "contacts_%s_header", status_t);
 				format = format_find(tmp);
-				if (xstrcmp(format, ""))
+				if (format_ok(format))
 					ncurses_backlog_add(w, fstring_new_format(format));
 				footer_status = status_t;
 			}
@@ -372,7 +372,7 @@
 			snprintf(tmp, sizeof(tmp), "contacts_%s_footer", footer_status);
 			format = format_find(tmp);
 
-			if (xstrcmp(format, ""))
+			if (format_ok(format))
 				ncurses_backlog_add(w, fstring_new_format(format));
 		}
 
@@ -381,7 +381,7 @@
 	}
 
 after_loop:
-	if (xstrcmp(footer, ""))
+	if (format_ok(footer))
 		ncurses_backlog_add(w, fstring_new_format(footer, group));
 	if (all)
 		LIST_DESTROY2(sorted_all, NULL);

Modified: trunk/plugins/ncurses/old.c
===================================================================
--- trunk/plugins/ncurses/old.c	2008-07-16 12:51:15 UTC (rev 4115)
+++ trunk/plugins/ncurses/old.c	2008-07-16 16:35:56 UTC (rev 4116)
@@ -1707,7 +1707,7 @@
 		if (!y) {
 			p = format_find("header1");
 
-			if (!xstrcmp(p, ""))
+			if (!format_ok(p))
 				p = format_find("header");
 		} else {
 			char *tmp = saprintf("header%d", y + 1);
@@ -1724,7 +1724,7 @@
 		if (!y) {
 			p = format_find("statusbar1");
 
-			if (!xstrcmp(p, ""))
+			if (!format_ok(p))
 				p = format_find("statusbar");
 		} else {
 			char *tmp = saprintf("statusbar%d", y + 1);
@@ -2929,7 +2929,7 @@
 	} else {
 		const char *f = format_find("ncurses_prompt_none");
 
-		if (xstrcmp(f, "")) {
+		if (format_ok(f)) {
 			n->prompt = format_string(f);
 			n->prompt_len = xstrlen(n->prompt);
 



Więcej informacji o liście dyskusyjnej ekg2-commit