]> git.pond.sub.org Git - empserver/blobdiff - src/lib/common/rdsched.c
Update copyright notice
[empserver] / src / lib / common / rdsched.c
index 60ae47410c0bd73c54ab9cb8da6ea6dd0c4990bf..79c5049aa63848b6eb8a37c1d3db134f2b424d2a 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
@@ -28,7 +27,7 @@
  *  rdsched.c: Read update schedule
  *
  *  Known contributors to this file:
- *     Markus Armbruster, 2007-2008
+ *     Markus Armbruster, 2007-2011
  */
 
 #define _XOPEN_SOURCE 500
@@ -64,7 +63,7 @@ int
 read_schedule(char *fname, time_t sched[], int n, time_t t0, time_t anchor)
 {
     FILE *fp;
-    int lno = 0;
+    int ret, lno;
     char buf[1024];
     char *endp;
 
@@ -75,23 +74,26 @@ read_schedule(char *fname, time_t sched[], int n, time_t t0, time_t anchor)
                     fname, strerror(errno));
            return -1;
        }
-    } else {
+    } else
        fp = stdin;
-       fname = "<stdin>";
-    }
 
+    ret = lno = 0;
     sched[0] = 0;
     while (fgets(buf, sizeof(buf), fp) != NULL) {
        ++lno;
        endp = strchr(buf, '#');
        if (endp)
            *endp = 0;
-       if (parse_schedule_line(buf, sched, n, t0, &anchor, fname, lno))
-           return -1;
+       if (parse_schedule_line(buf, sched, n, t0, &anchor,
+                               fname ? fname : "<stdin>", lno)) {
+           ret = -1;
+           break;
+       }
     }
 
-    fclose(fp);
-    return 0;
+    if (fname)
+       fclose(fp);
+    return ret;
 }
 
 /*
@@ -340,7 +342,6 @@ delete_update(time_t t, time_t sched[], int n)
 {
     int i = find_update(t, sched);
     if (t == sched[i])
-       memmove(sched + i, sched + i + 1,
-               (n - 1 - i) * sizeof(*sched));
+       memmove(sched + i, sched + i + 1, (n - 1 - i) * sizeof(*sched));
     return i;
 }