diff options
author | David Walter Seikel | 2012-02-12 02:32:40 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-02-12 02:32:40 +1000 |
commit | acb0d0eb1311adf035876a450699b9dff004c5eb (patch) | |
tree | d037da7777d2525f2e4702f22a2f3bbd0abf105e /LuaSL | |
parent | Little clean ups. (diff) | |
download | SledjHamr-acb0d0eb1311adf035876a450699b9dff004c5eb.zip SledjHamr-acb0d0eb1311adf035876a450699b9dff004c5eb.tar.gz SledjHamr-acb0d0eb1311adf035876a450699b9dff004c5eb.tar.bz2 SledjHamr-acb0d0eb1311adf035876a450699b9dff004c5eb.tar.xz |
Make sendBack and Forth varargs.
Diffstat (limited to 'LuaSL')
-rw-r--r-- | LuaSL/src/LuaSL.h | 4 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_utilities.c | 28 |
2 files changed, 24 insertions, 8 deletions
diff --git a/LuaSL/src/LuaSL.h b/LuaSL/src/LuaSL.h index 723f00d..9f55e2a 100644 --- a/LuaSL/src/LuaSL.h +++ b/LuaSL/src/LuaSL.h | |||
@@ -64,8 +64,8 @@ typedef struct | |||
64 | 64 | ||
65 | void loggingStartup(gameGlobals *game); | 65 | void loggingStartup(gameGlobals *game); |
66 | char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut); | 66 | char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut); |
67 | void sendBack(gameGlobals *game, Ecore_Con_Client *client, const char *SID, const char *message); | 67 | void sendBack(gameGlobals *game, Ecore_Con_Client *client, const char *SID, const char *message, ...); |
68 | void sendForth(gameGlobals *game, const char *SID, const char *message); | 68 | void sendForth(gameGlobals *game, const char *SID, const char *message, ...); |
69 | float timeDiff(struct timeval *now, struct timeval *then); | 69 | float timeDiff(struct timeval *now, struct timeval *then); |
70 | 70 | ||
71 | #include "LuaSL_LSL_tree.h" | 71 | #include "LuaSL_LSL_tree.h" |
diff --git a/LuaSL/src/LuaSL_utilities.c b/LuaSL/src/LuaSL_utilities.c index ab4ea65..e43bdeb 100644 --- a/LuaSL/src/LuaSL_utilities.c +++ b/LuaSL/src/LuaSL_utilities.c | |||
@@ -66,20 +66,36 @@ char *getDateTime(struct tm **nowOut, char *dateOut, time_t *timeOut) | |||
66 | return (dateTime); | 66 | return (dateTime); |
67 | } | 67 | } |
68 | 68 | ||
69 | void sendBack(gameGlobals *game, Ecore_Con_Client *client, const char *SID, const char *message) | 69 | void sendBack(gameGlobals *game, Ecore_Con_Client *client, const char *SID, const char *message, ...) |
70 | { | 70 | { |
71 | va_list args; | ||
71 | char buf[PATH_MAX]; | 72 | char buf[PATH_MAX]; |
72 | 73 | int length = strlen(SID); | |
73 | sprintf(buf, "%s.%s\n", SID, message); | 74 | |
75 | strncpy(buf, SID, length); | ||
76 | buf[length++] = '.'; | ||
77 | va_start(args, message); | ||
78 | length += vsprintf(&buf[length], message, args); | ||
79 | va_end(args); | ||
80 | buf[length++] = '\n'; | ||
81 | buf[length++] = '\0'; | ||
74 | ecore_con_client_send(client, buf, strlen(buf)); | 82 | ecore_con_client_send(client, buf, strlen(buf)); |
75 | ecore_con_client_flush(client); | 83 | ecore_con_client_flush(client); |
76 | } | 84 | } |
77 | 85 | ||
78 | void sendForth(gameGlobals *game, const char *SID, const char *message) | 86 | void sendForth(gameGlobals *game, const char *SID, const char *message, ...) |
79 | { | 87 | { |
88 | va_list args; | ||
80 | char buf[PATH_MAX]; | 89 | char buf[PATH_MAX]; |
81 | 90 | int length = strlen(SID); | |
82 | snprintf(buf, sizeof(buf), "%s.%s\n", SID, message); | 91 | |
92 | strncpy(buf, SID, length); | ||
93 | buf[length++] = '.'; | ||
94 | va_start(args, message); | ||
95 | length += vsprintf(&buf[length], message, args); | ||
96 | va_end(args); | ||
97 | buf[length++] = '\n'; | ||
98 | buf[length++] = '\0'; | ||
83 | ecore_con_server_send(game->server, buf, strlen(buf)); | 99 | ecore_con_server_send(game->server, buf, strlen(buf)); |
84 | ecore_con_server_flush(game->server); | 100 | ecore_con_server_flush(game->server); |
85 | } | 101 | } |