diff options
author | David Walter Seikel | 2016-01-17 17:03:56 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-01-17 17:03:56 +1000 |
commit | 4e2030607818d83b4e5987df2d889f64f8dce3b3 (patch) | |
tree | 370625391b847bed4fa05c888448d1b9a18895b6 /src/libraries | |
parent | Bunch of debuggingnesses. (diff) | |
download | SledjHamr-4e2030607818d83b4e5987df2d889f64f8dce3b3.zip SledjHamr-4e2030607818d83b4e5987df2d889f64f8dce3b3.tar.gz SledjHamr-4e2030607818d83b4e5987df2d889f64f8dce3b3.tar.bz2 SledjHamr-4e2030607818d83b4e5987df2d889f64f8dce3b3.tar.xz |
Unify the message sending code a bit.
Diffstat (limited to 'src/libraries')
-rw-r--r-- | src/libraries/SledjHamr.c | 47 | ||||
-rw-r--r-- | src/libraries/SledjHamr.h | 3 |
2 files changed, 1 insertions, 49 deletions
diff --git a/src/libraries/SledjHamr.c b/src/libraries/SledjHamr.c index dff80ee..4d0efbc 100644 --- a/src/libraries/SledjHamr.c +++ b/src/libraries/SledjHamr.c | |||
@@ -88,31 +88,9 @@ static boolean checkConnection(Connection *conn, char *func, connType wanted, bo | |||
88 | return result; | 88 | return result; |
89 | } | 89 | } |
90 | 90 | ||
91 | void sendBack(Connection *conn, const char *SID, const char *message, ...) | 91 | void send2(Connection *conn, const char *SID, const char *message, ...) |
92 | { | ||
93 | va_list args; | ||
94 | // Ecore_Con_Client *client = conn->conn.client.client; | ||
95 | char buf[PATH_MAX * 2]; | ||
96 | int length = strlen(SID); | ||
97 | |||
98 | strncpy(buf, SID, length); | ||
99 | buf[length++] = '.'; | ||
100 | va_start(args, message); | ||
101 | length += vsprintf(&buf[length], message, args); | ||
102 | va_end(args); | ||
103 | buf[length++] = '\n'; | ||
104 | buf[length] = '\0'; | ||
105 | // PD("sendBack(%s", buf); | ||
106 | // ecore_con_client_send(client, buf, length); | ||
107 | // ecore_con_client_flush(client); | ||
108 | //Connection *conn = ecore_con_client_data_get(client); | ||
109 | if (conn) send2(conn, SID, buf); else PE("sendBack() can't find Connection!"); | ||
110 | } | ||
111 | |||
112 | void sendForth(Connection *conn, const char *SID, const char *message, ...) | ||
113 | { | 92 | { |
114 | va_list args; | 93 | va_list args; |
115 | // Ecore_Con_Server *server = conn->conn.server.server; | ||
116 | char buf[PATH_MAX * 2]; | 94 | char buf[PATH_MAX * 2]; |
117 | int length = strlen(SID); | 95 | int length = strlen(SID); |
118 | 96 | ||
@@ -123,29 +101,6 @@ void sendForth(Connection *conn, const char *SID, const char *message, ...) | |||
123 | va_end(args); | 101 | va_end(args); |
124 | buf[length++] = '\n'; | 102 | buf[length++] = '\n'; |
125 | buf[length] = '\0'; | 103 | buf[length] = '\0'; |
126 | // PD("sendForth(%s", buf); | ||
127 | // ecore_con_server_send(server, buf, length); | ||
128 | // ecore_con_server_flush(server); | ||
129 | //Connection *conn = ecore_con_server_data_get(server); | ||
130 | if (conn) send2(conn, SID, buf); else PE("sendForth() can't find Connection!"); | ||
131 | } | ||
132 | |||
133 | void send2(Connection *conn, const char *SID, const char *message, ...) | ||
134 | { | ||
135 | va_list args; | ||
136 | char buf[PATH_MAX * 2]; | ||
137 | int length = strlen(SID); | ||
138 | |||
139 | length = 0; | ||
140 | // strncpy(buf, SID, length); | ||
141 | // buf[length++] = '.'; | ||
142 | va_start(args, message); | ||
143 | // length += vsprintf(&buf[length], message, args); | ||
144 | va_end(args); | ||
145 | strcpy(buf, message); | ||
146 | length = strlen(buf); | ||
147 | // buf[length++] = '\n'; | ||
148 | buf[length] = '\0'; | ||
149 | 104 | ||
150 | // TODO - Should check if this is always gonna be local? Likely not. | 105 | // TODO - Should check if this is always gonna be local? Likely not. |
151 | if (checkConnection(conn, "send2", conn->type, FALSE)) | 106 | if (checkConnection(conn, "send2", conn->type, FALSE)) |
diff --git a/src/libraries/SledjHamr.h b/src/libraries/SledjHamr.h index 326e423..d5e0b1f 100644 --- a/src/libraries/SledjHamr.h +++ b/src/libraries/SledjHamr.h | |||
@@ -66,9 +66,6 @@ struct _Connection | |||
66 | 66 | ||
67 | 67 | ||
68 | void *addMessage(Eina_Clist *list, size_t size, const char *message, ...); | 68 | void *addMessage(Eina_Clist *list, size_t size, const char *message, ...); |
69 | void sendBack(Connection *conn, const char *SID, const char *message, ...); | ||
70 | void sendForth(Connection *conn, const char *SID, const char *message, ...); | ||
71 | |||
72 | void send2(Connection *conn, const char *SID, const char *message, ...); | 69 | void send2(Connection *conn, const char *SID, const char *message, ...); |
73 | Connection *openArms(char *name, const char *address, int port, void *data, Ecore_Event_Handler_Cb _add, Ecore_Event_Handler_Cb _data, Ecore_Event_Handler_Cb _del, streamParser _parser); | 70 | Connection *openArms(char *name, const char *address, int port, void *data, Ecore_Event_Handler_Cb _add, Ecore_Event_Handler_Cb _data, Ecore_Event_Handler_Cb _del, streamParser _parser); |
74 | Connection *reachOut(char *name, char *command, char *address, int port, void *data, Ecore_Event_Handler_Cb _add, Ecore_Event_Handler_Cb _data, Ecore_Event_Handler_Cb _del, streamParser _parser); | 71 | Connection *reachOut(char *name, char *command, char *address, int port, void *data, Ecore_Event_Handler_Cb _add, Ecore_Event_Handler_Cb _data, Ecore_Event_Handler_Cb _del, streamParser _parser); |