<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>Andrew Price 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/5285e0ce793cc8c697df10d93927fbe9ca76cb7b">5285e0ce</a></strong>
<div>
<span>by Andrew Price</span>
<i>at 2015-11-06T20:46:15Z</i>
</div>
<pre class='commit-message'>Move the global 'myroom' into struct user</pre>
</li>
<li>
<strong><a href="https://projects.sucs.org/arthur/mw/commit/94013d39a6d6155bad27cc378a7af8b2ef06d111">94013d39</a></strong>
<div>
<span>by Andrew Price</span>
<i>at 2015-11-06T21:16:38Z</i>
</div>
<pre class='commit-message'>Report errors from userdb_open() and fetch_user()</pre>
</li>
<li>
<strong><a href="https://projects.sucs.org/arthur/mw/commit/c30536af79c24adf5249ae06ad4c8e8e44b7ea67">c30536af</a></strong>
<div>
<span>by Andrew Price</span>
<i>at 2015-11-06T21:44:44Z</i>
</div>
<pre class='commit-message'>Use struct user and fetch_user in replay()</pre>
</li>
</ul>
<h4>14 changed files:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
src/client/edit.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-1'>
src/client/folders.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-2'>
src/client/incoming.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-3'>
src/client/main.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-4'>
src/client/script_inst.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-5'>
src/client/talker.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-6'>
src/client/talker_privs.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-7'>
src/client/user.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-8'>
src/client/who.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-9'>
src/rooms.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-10'>
src/server/replay.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-11'>
src/server/servsock.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-12'>
src/user.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-13'>
src/user.h
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://projects.sucs.org/arthur/mw/compare/3f71da2332897f7b51e860a188d847ecfa2aafad...c30536af79c24adf5249ae06ad4c8e8e44b7ea67#diff-0'>
<strong>
src/client/edit.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/client/edit.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/client/edit.c
</span><span style="color: #aaaaaa">@@ -603,6 +603,8 @@ static void users_lastread(int folnum)
</span>   int ufile;
 
        ufile=userdb_open(O_RDWR);
<span style="color: #000000;background-color: #ddffdd">+        if (ufile < 0)
+               return;
</span>   Lock_File(ufile);
        while (read(ufile,&usr,sizeof(usr))>0)
        {
</code></pre>

<br>
</li>
<li id='diff-1'>
<a href='https://projects.sucs.org/arthur/mw/compare/3f71da2332897f7b51e860a188d847ecfa2aafad...c30536af79c24adf5249ae06ad4c8e8e44b7ea67#diff-1'>
<strong>
src/client/folders.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/client/folders.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/client/folders.c
</span><span style="color: #aaaaaa">@@ -80,7 +80,9 @@ void auto_subscribe(int folnum, int state)
</span>   struct person *urec = &usr.record;
        char buff[10];
 
<span style="color: #000000;background-color: #ffdddd">-        ufile=userdb_open(O_RDWR);
</span><span style="color: #000000;background-color: #ddffdd">+   ufile = userdb_open(O_RDWR);
+       if (ufile < 0)
+               return;
</span>   Lock_File(ufile); /*user file*/
        while(get_person(ufile, &usr))
        {
</code></pre>

<br>
</li>
<li id='diff-2'>
<a href='https://projects.sucs.org/arthur/mw/compare/3f71da2332897f7b51e860a188d847ecfa2aafad...c30536af79c24adf5249ae06ad4c8e8e44b7ea67#diff-2'>
<strong>
src/client/incoming.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/client/incoming.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/client/incoming.c
</span><span style="color: #aaaaaa">@@ -36,7 +36,6 @@ extern Alias event_list;
</span> extern Alias onoff_list;
 extern Alias ipc_list;
 extern struct user *user;
<span style="color: #000000;background-color: #ffdddd">-extern struct room myroom;
</span> extern int quietmode;
 extern ipc_connection_t *ipcsock;
 
<span style="color: #aaaaaa">@@ -439,8 +438,8 @@ void handle_mesg()
</span>   while (msg != NULL) {
                if (msg->head.src == SYSTEM_USER) {
                        strcpy(mesg_user.record.name,"System");
<span style="color: #000000;background-color: #ffdddd">-                } else {
-                       fetch_user(&mesg_user, msg->head.src);
</span><span style="color: #000000;background-color: #ddffdd">+           } else if (fetch_user(&mesg_user, msg->head.src) != 0) {
+                       return;
</span>           }
                accept_pipe_cmd(msg, &mesg_user);
 
<span style="color: #aaaaaa">@@ -510,7 +509,8 @@ static void display_content(ipc_message_t *msg)
</span>           whom = "System";
        } else {
                msg_posn = msg->head.src;
<span style="color: #000000;background-color: #ffdddd">-                fetch_user(&msg_user, msg_posn);
</span><span style="color: #000000;background-color: #ddffdd">+           if (fetch_user(&msg_user, msg_posn) != 0)
+                       return;
</span>           whom = msg_user.record.name;
        }
 
<span style="color: #aaaaaa">@@ -976,9 +976,9 @@ static void force_channel(char *newbuff, char *from, unsigned long theirprivs)
</span>                   talk_send_rawbcast(text);
                        user->record.chatmode = cm_set(user, CM_ONCHAT);
 
<span style="color: #000000;background-color: #ffdddd">-                        RoomDestroy(&myroom);
-                       RoomInit(&myroom);
-                       LoadRoom(&myroom, newroom);
</span><span style="color: #000000;background-color: #ddffdd">+                   RoomDestroy(&user->room);
+                       RoomInit(&user->room);
+                       LoadRoom(&user->room, newroom);
</span> 
                        /* force update of user information _before_ scripts are run */
                        update_user(user);
<span style="color: #aaaaaa">@@ -1011,9 +1011,9 @@ static void force_channel(char *newbuff, char *from, unsigned long theirprivs)
</span>                   snprintf(text,MAXTEXTLENGTH-1,"\03315You have been summoned to room %d by %s.",newroom,from);
                        display_message(text, 1, 1);
 
<span style="color: #000000;background-color: #ffdddd">-                        RoomDestroy(&myroom);
-                       RoomInit(&myroom);
-                       LoadRoom(&myroom, newroom);
</span><span style="color: #000000;background-color: #ddffdd">+                   RoomDestroy(&user->room);
+                       RoomInit(&user->room);
+                       LoadRoom(&user->room, newroom);
</span>                   enter_room(newroom);
                }
        }
</code></pre>

<br>
</li>
<li id='diff-3'>
<a href='https://projects.sucs.org/arthur/mw/compare/3f71da2332897f7b51e860a188d847ecfa2aafad...c30536af79c24adf5249ae06ad4c8e8e44b7ea67#diff-3'>
<strong>
src/client/main.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/client/main.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/client/main.c
</span><span style="color: #aaaaaa">@@ -49,9 +49,6 @@
</span> #include "bb.h"
 #include "userio.h"
 #include "who.h"
<span style="color: #000000;background-color: #ffdddd">-
-extern struct room myroom;
-
</span> #include "alias.h"
 extern Alias bind_list;
 extern Alias alias_list;
<span style="color: #aaaaaa">@@ -734,18 +731,11 @@ int main(int argc, char **argv)
</span> 
        InitParser();
        set_rights();
<span style="color: #000000;background-color: #ffdddd">-
</span>   init_colour();
<span style="color: #000000;background-color: #ffdddd">-
-       RoomInit(&myroom);
-
-/*     if (!(rights&65l))  a pleb - timeout of 10 mins
-               user->timeout=600; */
</span><span style="color: #000000;background-color: #ddffdd">+   RoomInit(&user->room);
</span>   update_user(user);
<span style="color: #000000;background-color: #ffdddd">-
</span>   /* run all board init functions */
        RunInitFuncs(0);
<span style="color: #000000;background-color: #ffdddd">-
</span>   /* broadcast board logon signal to other users */
        broadcast_onoffcode(3, autochat, NULL, NULL);
 
<span style="color: #aaaaaa">@@ -917,7 +907,7 @@ void close_down(int exitmode, char *sourceuser, char *reason)
</span> 
        ScriptCleanup();
 
<span style="color: #000000;background-color: #ffdddd">-        RoomDestroy(&myroom);
</span><span style="color: #000000;background-color: #ddffdd">+   RoomDestroy(&user->room);
</span>   ClearStack();
        stop_js();
        alarm_cleanup();
<span style="color: #aaaaaa">@@ -1768,8 +1758,9 @@ char *part_user(const char *text, int status)
</span> 
        if (status==0)
        {
<span style="color: #000000;background-color: #ffdddd">-                if (file!=0) close(file);
-               file=userdb_open(O_RDONLY);
</span><span style="color: #000000;background-color: #ddffdd">+           file = userdb_open(O_RDONLY);
+               if (file < 0)
+                       return NULL;
</span>           len=strlen(text);
        }
 
</code></pre>

<br>
</li>
<li id='diff-4'>
<a href='https://projects.sucs.org/arthur/mw/compare/3f71da2332897f7b51e860a188d847ecfa2aafad...c30536af79c24adf5249ae06ad4c8e8e44b7ea67#diff-4'>
<strong>
src/client/script_inst.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/client/script_inst.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/client/script_inst.c
</span><span style="color: #aaaaaa">@@ -31,9 +31,6 @@
</span> extern struct user *user;
 extern Alias alias_list;
 extern Alias bind_list;
<span style="color: #000000;background-color: #ffdddd">-
-extern struct room myroom;
-
</span> /* current script runaway variable */
 extern long runaway;
 
<span style="color: #aaaaaa">@@ -388,7 +385,7 @@ void scr_roomnum( struct code *pc, int fargc, char **fargv )
</span>                           snprintf(rn, 9, "%d", user->record.room);
                        }
                        /* if room is not hidden, or locked, then return room number */
<span style="color: #000000;background-color: #ffdddd">-                        else if (myroom.hidden<=0 && myroom.locked<=0)
</span><span style="color: #000000;background-color: #ddffdd">+                   else if (user->room.hidden <= 0 && user->room.locked <= 0)
</span>                   {
                                snprintf(rn, 9, "%d", user->record.room);
                        }
</code></pre>

<br>
</li>
<li id='diff-5'>
<a href='https://projects.sucs.org/arthur/mw/compare/3f71da2332897f7b51e860a188d847ecfa2aafad...c30536af79c24adf5249ae06ad4c8e8e44b7ea67#diff-5'>
<strong>
src/client/talker.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/client/talker.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/client/talker.c
</span><span style="color: #aaaaaa">@@ -53,8 +53,6 @@ extern unsigned long loggedin;
</span> extern int quietmode;
 static int runautoexec = 1;
 
<span style="color: #000000;background-color: #ffdddd">-extern struct room myroom;
-
</span> extern CommandList table[];
 extern CommandList chattable[];
 
<span style="color: #aaaaaa">@@ -390,10 +388,10 @@ void t_restart(CommandList *cm, int argc, const char **argv, char *args)
</span>   stop_js();
        setup_js();
 
<span style="color: #000000;background-color: #ffdddd">-        RoomDestroy(&myroom);
</span><span style="color: #000000;background-color: #ddffdd">+   RoomDestroy(&user->room);
</span> 
<span style="color: #000000;background-color: #ffdddd">-        RoomInit(&myroom);
-       LoadRoom(&myroom, user->record.room);
</span><span style="color: #000000;background-color: #ddffdd">+   RoomInit(&user->room);
+       LoadRoom(&user->room, user->record.room);
</span> 
        LoadInitFile(NULL);
 
<span style="color: #aaaaaa">@@ -1146,9 +1144,9 @@ void t_chaton(void)
</span>   urec->chatmode = cm_set(user, CM_ONCHAT);
        update_user(user);
 
<span style="color: #000000;background-color: #ffdddd">-        if (myroom.name!=NULL)
</span><span style="color: #000000;background-color: #ddffdd">+   if (user->room.name!=NULL)
</span>           snprintf(mtext, MAXTEXTLENGTH-1, "\03310%s has just joined talker in %s",
<span style="color: #000000;background-color: #ffdddd">-                         urec->name, myroom.name);
</span><span style="color: #000000;background-color: #ddffdd">+                    urec->name, user->room.name);
</span>   else
                snprintf(mtext, MAXTEXTLENGTH-1, "\03310%s has just joined talker room %d",
                         urec->name, urec->room);
<span style="color: #aaaaaa">@@ -1419,9 +1417,9 @@ int ChangeRoom(char *room, int quiet)
</span>                   user->record.room = i;
                        update_user(user);
 
<span style="color: #000000;background-color: #ffdddd">-                        RoomDestroy(&myroom);
-                       RoomInit(&myroom);
-                       LoadRoom(&myroom, user->record.room);
</span><span style="color: #000000;background-color: #ddffdd">+                   RoomDestroy(&user->room);
+                       RoomInit(&user->room);
+                       LoadRoom(&user->room, user->record.room);
</span> 
                        SAFE_FREE(buff);
                        if (asprintf(&buff, "\03313%s has left to room %d", user->record.name, i) < 0)
</code></pre>

<br>
</li>
<li id='diff-6'>
<a href='https://projects.sucs.org/arthur/mw/compare/3f71da2332897f7b51e860a188d847ecfa2aafad...c30536af79c24adf5249ae06ad4c8e8e44b7ea67#diff-6'>
<strong>
src/client/talker_privs.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/client/talker_privs.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/client/talker_privs.c
</span><span style="color: #aaaaaa">@@ -13,7 +13,6 @@
</span> 
 extern struct user *user;
 extern int quietmode;
<span style="color: #000000;background-color: #ffdddd">-extern struct room myroom;
</span> 
 unsigned long chatmode_describe(unsigned long old, unsigned long new, int ourapl, int theirapl, const char *from)
 {
<span style="color: #aaaaaa">@@ -180,9 +179,9 @@ unsigned long chatmode_describe(unsigned long old, unsigned long new, int ourapl
</span> 
                set_talk_rights();
 
<span style="color: #000000;background-color: #ffdddd">-                if (myroom.name!=NULL)
</span><span style="color: #000000;background-color: #ddffdd">+           if (user->room.name != NULL)
</span>                   snprintf(mtext,MAXTEXTLENGTH-1,"\03310%s has just joined talker in %s",
<span style="color: #000000;background-color: #ffdddd">-                                 user->record.name, myroom.name);
</span><span style="color: #000000;background-color: #ddffdd">+                            user->record.name, user->room.name);
</span>           else
                        snprintf(mtext,MAXTEXTLENGTH-1,"\03310%s has just joined talker room %d",
                                 user->record.name, user->record.room);
</code></pre>

<br>
</li>
<li id='diff-7'>
<a href='https://projects.sucs.org/arthur/mw/compare/3f71da2332897f7b51e860a188d847ecfa2aafad...c30536af79c24adf5249ae06ad4c8e8e44b7ea67#diff-7'>
<strong>
src/client/user.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/client/user.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/client/user.c
</span><span style="color: #aaaaaa">@@ -351,6 +351,9 @@ void list_users(int newonly)
</span>   long logout_time;
 
        file=userdb_open(O_RDONLY);
<span style="color: #000000;background-color: #ddffdd">+        if (file < 0)
+               return;
+
</span>   while (get_person(file, &usr))
        {
                if (!newonly || ( newonly && !u_reg(&usr) ) )
<span style="color: #aaaaaa">@@ -391,6 +394,9 @@ void list_users_since(long date)
</span>   long logout_time;
 
        file=userdb_open(O_RDONLY);
<span style="color: #000000;background-color: #ddffdd">+        if (file < 0)
+               return;
+
</span>   while (get_person(file, &usr))
        {
                if (urec->lastlogout > date)
<span style="color: #aaaaaa">@@ -434,6 +440,9 @@ static void list_users_flags(int flags, int type, int inv)
</span>   int screen_height=screen_h();
 
        file=userdb_open(O_RDONLY);
<span style="color: #000000;background-color: #ddffdd">+        if (file < 0)
+               return;
+
</span>   while (get_person(file,&usr))
        {
                if (type==0) check=urec->status;
</code></pre>

<br>
</li>
<li id='diff-8'>
<a href='https://projects.sucs.org/arthur/mw/compare/3f71da2332897f7b51e860a188d847ecfa2aafad...c30536af79c24adf5249ae06ad4c8e8e44b7ea67#diff-8'>
<strong>
src/client/who.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/client/who.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/client/who.c
</span><span style="color: #aaaaaa">@@ -27,7 +27,6 @@
</span> 
 extern int busy;
 extern struct user *user;
<span style="color: #000000;background-color: #ffdddd">-extern struct room myroom;
</span> 
 char *itime(unsigned long t)
 {
</code></pre>

<br>
</li>
<li id='diff-9'>
<a href='https://projects.sucs.org/arthur/mw/compare/3f71da2332897f7b51e860a188d847ecfa2aafad...c30536af79c24adf5249ae06ad4c8e8e44b7ea67#diff-9'>
<strong>
src/rooms.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/rooms.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/rooms.c
</span><span style="color: #aaaaaa">@@ -4,8 +4,6 @@
</span> #include "rooms.h"
 #include "util.h"
 
<span style="color: #000000;background-color: #ffdddd">-struct room myroom;
-
</span> int isanum(char *a, int *result, int onlydecimal);
 
 void RoomInit(struct room *room)
</code></pre>

<br>
</li>
<li id='diff-10'>
<a href='https://projects.sucs.org/arthur/mw/compare/3f71da2332897f7b51e860a188d847ecfa2aafad...c30536af79c24adf5249ae06ad4c8e8e44b7ea67#diff-10'>
<strong>
src/server/replay.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/server/replay.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/server/replay.c
</span><span style="color: #aaaaaa">@@ -134,19 +134,13 @@ void replay(ipc_connection_t *conn, ipc_message_t *msg)
</span>   json_decref(cmd);
 
        /* who are we doing this for */
<span style="color: #000000;background-color: #ffdddd">-        struct person user;
-       int users_fd = userdb_open(O_RDONLY);
-       lseek(users_fd, conn->user, SEEK_SET);
-       if (read(users_fd, &user, sizeof(user)) <= 0) {
-               close(users_fd);
</span><span style="color: #000000;background-color: #ddffdd">+   struct user user;
+       if (fetch_user(&user, conn->user) != 0) {
</span>           send_error(conn, msg, "Error cannot find your user record");
                return;
        }
<span style="color: #000000;background-color: #ffdddd">-        close(users_fd);
-
-       struct room room;
-       RoomInit(&room);
-       LoadRoom(&room, user.room);
</span><span style="color: #000000;background-color: #ddffdd">+   RoomInit(&user.room);
+       LoadRoom(&user.room, user.record.room);
</span> 
        /* now, go and replay those messages that are appropriate */
        for (;idx != store_next; idx = store_wrap( idx + 1 )) {
<span style="color: #aaaaaa">@@ -160,18 +154,18 @@ void replay(ipc_connection_t *conn, ipc_message_t *msg)
</span> 
                        const char * exclude = json_getstring(j, "exclude");
 
<span style="color: #000000;background-color: #ffdddd">-                        if (exclude != NULL && strcasecmp(exclude, user.name)==0) {
</span><span style="color: #000000;background-color: #ddffdd">+                   if (exclude != NULL && strcasecmp(exclude, user.record.name)==0) {
</span>                           /* thats us ! shhh... */
                                json_decref(j);
                                continue;
                        }
                        json_decref(j);
 
<span style="color: #000000;background-color: #ffdddd">-                        if (user.room == store[idx]->head.dst) {
</span><span style="color: #000000;background-color: #ddffdd">+                   if (user.record.room == store[idx]->head.dst) {
</span>                           /* right room, send it */
                                msg_attach(store[idx], conn);
                        } else
<span style="color: #000000;background-color: #ffdddd">-                        if (room.sproof < 1 && (user.chatmode & CM_GLOBAL)) {
</span><span style="color: #000000;background-color: #ddffdd">+                   if (user.room.sproof < 1 && (cm_test(&user, CM_GLOBAL))) {
</span>                   /* room not soundproof, and user has global on */
                                msg_attach(store[idx], conn);
                        }
<span style="color: #aaaaaa">@@ -184,7 +178,7 @@ void replay(ipc_connection_t *conn, ipc_message_t *msg)
</span> 
                        const char * target = json_getstring(j, "target");
 
<span style="color: #000000;background-color: #ffdddd">-                        if (target!=NULL && strcasecmp(target, user.name)==0) {
</span><span style="color: #000000;background-color: #ddffdd">+                   if (target!=NULL && strcasecmp(target, user.record.name)==0) {
</span>                           /* yes, its for us */
                                msg_attach(store[idx], conn);
                        }
<span style="color: #aaaaaa">@@ -197,7 +191,7 @@ void replay(ipc_connection_t *conn, ipc_message_t *msg)
</span>           msg_attach(store[idx], conn);
        }
 
<span style="color: #000000;background-color: #ffdddd">-        RoomDestroy(&room);
</span><span style="color: #000000;background-color: #ddffdd">+   RoomDestroy(&user.room);
</span> 
        return;
 }
</code></pre>

<br>
</li>
<li id='diff-11'>
<a href='https://projects.sucs.org/arthur/mw/compare/3f71da2332897f7b51e860a188d847ecfa2aafad...c30536af79c24adf5249ae06ad4c8e8e44b7ea67#diff-11'>
<strong>
src/server/servsock.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/server/servsock.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/server/servsock.c
</span><span style="color: #aaaaaa">@@ -434,8 +434,11 @@ void msg_attach_to_channel(ipc_message_t *msg, int channel, const char * exclude
</span>   int users_fd = userdb_open(O_RDONLY);
        struct user user;
        struct person *urec = &user.record;
<span style="color: #000000;background-color: #ffdddd">-
</span>   struct room room;
<span style="color: #000000;background-color: #ddffdd">+
+       if (users_fd < 0)
+               return;
+
</span>   RoomInit(&room);
        LoadRoom(&room, channel);
 
<span style="color: #aaaaaa">@@ -472,8 +475,11 @@ int msg_attach_to_username(ipc_message_t *msg, const char * username)
</span>   struct user user;
        struct person *urec = &user.record;
        int found = 0;
<span style="color: #000000;background-color: #ffdddd">-
</span>   struct list_head *pos;
<span style="color: #000000;background-color: #ddffdd">+
+       if (users_fd < 0)
+               return 0;
+
</span>   list_for_each(pos, &connection_list) {
                ipc_connection_t *c = list_entry(pos, ipc_connection_t, list);
                if (c->state != IPCSTATE_VALID) continue;
<span style="color: #aaaaaa">@@ -497,8 +503,11 @@ void msg_attach_to_all(ipc_message_t *msg)
</span>   int users_fd = userdb_open(O_RDONLY);
        struct user user;
        struct person *urec = &user.record;
<span style="color: #000000;background-color: #ffdddd">-
</span>   struct list_head *pos;
<span style="color: #000000;background-color: #ddffdd">+
+       if (users_fd < 0)
+               return;
+
</span>   list_for_each(pos, &connection_list) {
                ipc_connection_t *c = list_entry(pos, ipc_connection_t, list);
                if (c->state != IPCSTATE_VALID) continue;
<span style="color: #aaaaaa">@@ -683,12 +692,14 @@ void init_server()
</span> 
 ipc_message_t * msg_wholist(void)
 {
<span style="color: #000000;background-color: #ffdddd">-        ipc_message_t * msg = ipcmsg_create(IPC_WHOLIST, SYSTEM_USER);
-
</span>   int users_fd = userdb_open(O_RDONLY);
        struct user user;
        struct person *urec = &user.record;
 
<span style="color: #000000;background-color: #ddffdd">+        if (users_fd < 0)
+               return NULL;
+
+       ipc_message_t * msg = ipcmsg_create(IPC_WHOLIST, SYSTEM_USER);
</span>   json_t * list = json_array();
 
        struct list_head *pos;
<span style="color: #aaaaaa">@@ -735,8 +746,11 @@ int32_t who_find(const char * username)
</span> {
        int users_fd = userdb_open(O_RDONLY);
        struct person user;
<span style="color: #000000;background-color: #ffdddd">-
</span>   struct list_head *pos;
<span style="color: #000000;background-color: #ddffdd">+
+       if (users_fd < 0)
+               return -1;
+
</span>   list_for_each(pos, &connection_list) {
                ipc_connection_t *c = list_entry(pos, ipc_connection_t, list);
                if (c->state != IPCSTATE_VALID) continue;
</code></pre>

<br>
</li>
<li id='diff-12'>
<a href='https://projects.sucs.org/arthur/mw/compare/3f71da2332897f7b51e860a188d847ecfa2aafad...c30536af79c24adf5249ae06ad4c8e8e44b7ea67#diff-12'>
<strong>
src/user.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/user.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/user.c
</span><span style="color: #aaaaaa">@@ -13,10 +13,8 @@
</span> int userdb_open(int flags)
 {
        int ufd = open(USERFILE, flags|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP);
<span style="color: #000000;background-color: #ffdddd">-        if (ufd < 0) {
</span><span style="color: #000000;background-color: #ddffdd">+   if (ufd < 0)
</span>           perror(USERFILE);
<span style="color: #000000;background-color: #ffdddd">-                exit(-1);
-       }
</span>   return ufd;
 }
 
<span style="color: #aaaaaa">@@ -48,20 +46,27 @@ void update_user(struct user *user)
</span>   int outfile;
 
        outfile = userdb_open(O_WRONLY|O_CREAT);
<span style="color: #000000;background-color: #ddffdd">+        if (outfile < 0)
+               return;
</span>   update_user_fd(outfile, user);
        close(outfile);
 }
 
<span style="color: #000000;background-color: #ffdddd">-void fetch_user(struct user *user, int32_t userposn)
</span><span style="color: #000000;background-color: #ddffdd">+int fetch_user(struct user *user, int32_t userposn)
</span> {
        struct person *record = &user->record;
<span style="color: #000000;background-color: #ffdddd">-        int outfile;
</span><span style="color: #000000;background-color: #ddffdd">+        int outfile = userdb_open(O_RDWR|O_CREAT);
+       if (outfile < 0)
+               return 1;
</span> 
<span style="color: #000000;background-color: #ffdddd">-        outfile=userdb_open(O_RDWR|O_CREAT);
-        lseek(outfile, userposn, SEEK_SET);
-        read(outfile,record,sizeof(*record));
</span><span style="color: #000000;background-color: #ddffdd">+        if (pread(outfile, record, sizeof(*record), userposn) != sizeof(*record)) {
+               perror("pread");
+               close(outfile);
+               return 1;
+       }
</span>         close(outfile);
        user->posn = userposn;
<span style="color: #000000;background-color: #ddffdd">+        return 0;
</span> }
 
 static int user_find_name(const char *name, struct user *user, int *found)
</code></pre>

<br>
</li>
<li id='diff-13'>
<a href='https://projects.sucs.org/arthur/mw/compare/3f71da2332897f7b51e860a188d847ecfa2aafad...c30536af79c24adf5249ae06ad4c8e8e44b7ea67#diff-13'>
<strong>
src/user.h
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/user.h
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/user.h
</span><span style="color: #aaaaaa">@@ -2,6 +2,7 @@
</span> #define USER_H
 
 #include <stdint.h>
<span style="color: #000000;background-color: #ddffdd">+#include "rooms.h"
</span> 
 #define NAMESIZE       16      /* username */
 #define PASSWDSIZE     20      /* password (after encryption) */
<span style="color: #aaaaaa">@@ -70,11 +71,12 @@ struct person
</span> struct user {
        int32_t posn;
        struct person record;
<span style="color: #000000;background-color: #ddffdd">+        struct room room;
</span> };
 
 extern int userdb_open(int flags);
 extern void userdb_write(struct user *user);
<span style="color: #000000;background-color: #ffdddd">-extern void fetch_user(struct user *record, int32_t userposn);
</span><span style="color: #000000;background-color: #ddffdd">+extern int fetch_user(struct user *record, int32_t userposn);
</span> extern void update_user(struct user *user);
 extern int update_user_fd(int fd, struct user *user);
 extern int is_old(const char *name, struct user *user);
</code></pre>

<br>
</li>

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

<br>
<a href="https://projects.sucs.org/arthur/mw/compare/3f71da2332897f7b51e860a188d847ecfa2aafad...c30536af79c24adf5249ae06ad4c8e8e44b7ea67">View it on GitLab</a>
<br>
You're receiving this email because of your account on <a href="https://projects.sucs.org/">projects.sucs.org</a>.
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":["merge_requests","issues","commit"],"url":"https://projects.sucs.org/arthur/mw/compare/3f71da2332897f7b51e860a188d847ecfa2aafad...c30536af79c24adf5249ae06ad4c8e8e44b7ea67"}}</script>
</p>
</div>
</body>
</html>