<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
  img {
    max-width: 100%;
    height: auto;
  }
  p.details {
    font-style:italic;
    color:#777
  }
  .footer p {
    font-size:small;
    color:#777
  }
  pre.commit-message {
    white-space: pre-wrap;
  }
  .file-stats a {
    text-decoration: none;
  }
  .file-stats .new-file {
    color: #090;
  }
  .file-stats .deleted-file {
    color: #B00;
  }
</style>
<body>
<div class='content'>
<h3>Justin Mitchell pushed to branch master at <a href="https://projects.sucs.org/arthur/mw">Justin Mitchell / mw</a></h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://projects.sucs.org/arthur/mw/commit/a9c50f1486d90461b2b9f6c2ff367ede6704d247">a9c50f14</a></strong>
<div>
<span>by Justin Mitchell</span>
<i>at 2016-01-12T18:02:51Z</i>
</div>
<pre class='commit-message'>Only use the variadic json_addstring when its needed</pre>
</li>
</ul>
<h4>3 changed files:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
src/server/actions.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-1'>
src/socket.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-2'>
src/socket.h
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://projects.sucs.org/arthur/mw/commit/a9c50f1486d90461b2b9f6c2ff367ede6704d247#diff-0'>
<strong>
src/server/actions.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/server/actions.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/server/actions.c
</span><span style="color: #aaaaaa">@@ -90,7 +90,7 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg)
</span>           json_addstring(ej, "type", "mrod");
 
                if (success) {
<span style="color: #000000;background-color: #ffdddd">-                        json_addstring(ej, "text", "%s has just dropped the Magic Roundabout of Death on %s",
</span><span style="color: #000000;background-color: #ddffdd">+                   json_vaddstring(ej, "text", "%s has just dropped the Magic Roundabout of Death on %s",
</span>                                  attacker_name, victim_name);
                        json_addstring(ej, "verbose", "You hear a boing in the distance, closely followed by the distant wail of a hurdy-gurdy, which is suddenly terminated by a blood curdling scream, a C major chord explosion and a few curious springing noises...");
 
<span style="color: #aaaaaa">@@ -109,7 +109,7 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg)
</span>                   ipcmsg_destroy(update);
 
                } else {
<span style="color: #000000;background-color: #ffdddd">-                        json_addstring(ej, "text", "%s just tried to MROD %s and failed",
</span><span style="color: #000000;background-color: #ddffdd">+                   json_vaddstring(ej, "text", "%s just tried to MROD %s and failed",
</span>                                  attacker_name, victim_name);
                }
                ipcmsg_json_encode(event, ej);
<span style="color: #aaaaaa">@@ -131,7 +131,7 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg)
</span>           json_addstring(ej, "type", "zod");
 
                if (success) {
<span style="color: #000000;background-color: #ffdddd">-                        json_addstring(ej, "text", "%s has just sent the Zebedee of Death to %s",
</span><span style="color: #000000;background-color: #ddffdd">+                   json_vaddstring(ej, "text", "%s has just sent the Zebedee of Death to %s",
</span>                                  attacker_name, victim_name);
                        json_addstring(ej, "verbose", "You hear a boing in the distance");
 
<span style="color: #aaaaaa">@@ -150,7 +150,7 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg)
</span>                   msg_attach_to_username(update, victim_name);
                        ipcmsg_destroy(update);
                } else {
<span style="color: #000000;background-color: #ffdddd">-                        json_addstring(ej, "text", "%s just tried to ZoD %s and failed",
</span><span style="color: #000000;background-color: #ddffdd">+                   json_vaddstring(ej, "text", "%s just tried to ZoD %s and failed",
</span>                                  attacker_name, victim_name);
                }
                ipcmsg_json_encode(event, ej);
<span style="color: #aaaaaa">@@ -184,7 +184,7 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg)
</span>           json_addstring(ej, "type", "gag");
 
                if (success) {
<span style="color: #000000;background-color: #ffdddd">-                        json_addstring(ej, "text", "%s has just gagged %s with %s",
</span><span style="color: #000000;background-color: #ddffdd">+                   json_vaddstring(ej, "text", "%s has just gagged %s with %s",
</span>                                  attacker_name, victim_name, gag_type(gtnum));
 
                        // change users mode
<span style="color: #aaaaaa">@@ -196,7 +196,7 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg)
</span>                   msg_attach_to_username(update, victim_name);
                        ipcmsg_destroy(update);
                } else {
<span style="color: #000000;background-color: #ffdddd">-                        json_addstring(ej, "text", "%s just tried to gag %s with %s and failed",
</span><span style="color: #000000;background-color: #ddffdd">+                   json_vaddstring(ej, "text", "%s just tried to gag %s with %s and failed",
</span>                                  attacker_name, victim_name, gag_type(gtnum));
                }
                ipcmsg_json_encode(event, ej);
<span style="color: #aaaaaa">@@ -216,7 +216,7 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg)
</span>           json_addstring(ej, "type", "ungag");
 
                if (success) {
<span style="color: #000000;background-color: #ffdddd">-                        json_addstring(ej, "text", "%s has just ungagged %s", attacker_name, victim_name);
</span><span style="color: #000000;background-color: #ddffdd">+                   json_vaddstring(ej, "text", "%s has just ungagged %s", attacker_name, victim_name);
</span> 
                        // change users mode
                        _autofree char *buff=NULL;
<span style="color: #aaaaaa">@@ -227,7 +227,7 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg)
</span>                   msg_attach_to_username(update, victim_name);
                        ipcmsg_destroy(update);
                } else {
<span style="color: #000000;background-color: #ffdddd">-                        json_addstring(ej, "text", "%s just tried to ungag %s and failed",
</span><span style="color: #000000;background-color: #ddffdd">+                   json_vaddstring(ej, "text", "%s just tried to ungag %s and failed",
</span>                                  attacker_name, victim_name);
                }
                ipcmsg_json_encode(event, ej);
</code></pre>

<br>
</li>
<li id='diff-1'>
<a href='https://projects.sucs.org/arthur/mw/commit/a9c50f1486d90461b2b9f6c2ff367ede6704d247#diff-1'>
<strong>
src/socket.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/socket.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/socket.c
</span><span style="color: #aaaaaa">@@ -300,25 +300,31 @@ json_t * json_init(ipc_message_t * msg)
</span> 
 /** add/replace a string value in the base object */
 
<span style="color: #000000;background-color: #ffdddd">-int json_addstring(json_t * js, const char * key, const char * value, ...) __attribute__((format (printf, 3, 4)));
</span><span style="color: #000000;background-color: #ddffdd">+int json_vaddstring(json_t * js, const char * key, const char * value, ...) __attribute__((format (printf, 3, 4)));
</span> 
<span style="color: #000000;background-color: #ffdddd">-int json_addstring(json_t * js, const char * key, const char * value, ...)
</span><span style="color: #000000;background-color: #ddffdd">+int json_vaddstring(json_t * js, const char * key, const char * value, ...)
</span> {
<span style="color: #000000;background-color: #ffdddd">-        json_t * tmp;
</span>   va_list va;
        va_start(va, value);
        _autofree char *text = NULL;
        vasprintf(&text, value, va);
        va_end(va);
 
<span style="color: #000000;background-color: #ddffdd">+        return json_addstring(js, key, text);
+}
+
+int json_addstring(json_t * js, const char * key, const char * value)
+{
+       json_t * tmp;
+
</span>   tmp = json_object_get(js, key);
        if (tmp == NULL) {
<span style="color: #000000;background-color: #ffdddd">-                tmp = json_string(text);
</span><span style="color: #000000;background-color: #ddffdd">+           tmp = json_string(value);
</span>           if (tmp == NULL) return -1;
                json_object_set_new(js, key, tmp);
        } else {
                if (!json_is_string(tmp)) return -1;
<span style="color: #000000;background-color: #ffdddd">-                json_string_set(tmp, text);
</span><span style="color: #000000;background-color: #ddffdd">+           json_string_set(tmp, value);
</span>   }
        return 0;
 }
</code></pre>

<br>
</li>
<li id='diff-2'>
<a href='https://projects.sucs.org/arthur/mw/commit/a9c50f1486d90461b2b9f6c2ff367ede6704d247#diff-2'>
<strong>
src/socket.h
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/socket.h
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/socket.h
</span><span style="color: #aaaaaa">@@ -78,7 +78,8 @@ ipc_message_t *read_socket(ipc_connection_t *conn, int doread);
</span> json_t *ipcmsg_json_decode(ipc_message_t *msg);
 int ipcmsg_json_encode(ipc_message_t *msg, json_t *js);
 json_t *json_init(ipc_message_t *msg);
<span style="color: #000000;background-color: #ffdddd">-int json_addstring(json_t *js, const char *key, const char *value, ...);
</span><span style="color: #000000;background-color: #ddffdd">+int json_vaddstring(json_t *js, const char *key, const char *value, ...);
+int json_addstring(json_t *js, const char *key, const char *value);
</span> int json_addint(json_t *js, const char *key, int value);
 int json_addobject(json_t *js, const char *key, json_t * obj);
 const char *json_getstring(json_t *js, const char *key);
</code></pre>

<br>
</li>

</div>
<div class='footer' style='margin-top: 10px;'>
<p>

<br>
<a href="https://projects.sucs.org/arthur/mw/commit/a9c50f1486d90461b2b9f6c2ff367ede6704d247">View it on GitLab</a>.
<br>
You're receiving this email because of your account on projects.sucs.org.
If you'd like to receive fewer emails, you can adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://projects.sucs.org/arthur/mw/commit/a9c50f1486d90461b2b9f6c2ff367ede6704d247"}}</script>
</p>
</div>
</body>
</html>