LCOV - code coverage report
Current view: top level - src/lib/srv/mod-udpd - mod-udpd-setup.c (source / functions) Hit Total Coverage
Test: liquidwar6.info Lines: 20 23 87.0 %
Date: 2011-12-24 Functions: 2 2 100.0 %
Branches: 5 10 50.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :   Liquid War 6 is a unique multiplayer wargame.
       3                 :            :   Copyright (C)  2005, 2006, 2007, 2008, 2009, 2010, 2011  Christian Mauduit <ufoot@ufoot.org>
       4                 :            : 
       5                 :            :   This program is free software; you can redistribute it and/or modify
       6                 :            :   it under the terms of the GNU General Public License as published by
       7                 :            :   the Free Software Foundation, either version 3 of the License, or
       8                 :            :   (at your option) any later version.
       9                 :            : 
      10                 :            :   This program is distributed in the hope that it will be useful,
      11                 :            :   but WITHOUT ANY WARRANTY; without even the implied warranty of
      12                 :            :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13                 :            :   GNU General Public License for more details.
      14                 :            : 
      15                 :            :   You should have received a copy of the GNU General Public License
      16                 :            :   along with this program.  If not, see <http://www.gnu.org/licenses/>.
      17                 :            :   
      18                 :            : 
      19                 :            :   Liquid War 6 homepage : http://www.gnu.org/software/liquidwar6/
      20                 :            :   Contact author        : ufoot@ufoot.org
      21                 :            : */
      22                 :            : 
      23                 :            : #ifdef HAVE_CONFIG_H
      24                 :            : #include "config.h"
      25                 :            : #endif
      26                 :            : 
      27                 :            : #include "../srv.h"
      28                 :            : #include "mod-udpd-internal.h"
      29                 :            : 
      30                 :            : _udpd_context_t *
      31                 :         27 : _mod_udpd_init (int argc, char *argv[], lw6srv_listener_t * listener)
      32                 :            : {
      33                 :         27 :   _udpd_context_t *udpd_context = NULL;
      34                 :         27 :   char *data_dir = NULL;
      35                 :         27 :   int ok = 0;
      36                 :            : 
      37                 :         27 :   lw6sys_log (LW6SYS_LOG_INFO, _x_ ("udpd init"));
      38                 :            : 
      39                 :         27 :   udpd_context = (_udpd_context_t *) LW6SYS_CALLOC (sizeof (_udpd_context_t));
      40         [ +  - ]:         27 :   if (udpd_context)
      41                 :            :     {
      42                 :         27 :       data_dir = lw6sys_get_data_dir (argc, argv);
      43         [ +  - ]:         27 :       if (data_dir)
      44                 :            :         {
      45         [ +  - ]:         27 :           if (_mod_udpd_load_data (&(udpd_context->data), data_dir))
      46                 :            :             {
      47                 :         27 :               ok = 1;
      48                 :            :             }
      49                 :         27 :           LW6SYS_FREE (data_dir);
      50                 :            :         }
      51         [ -  + ]:         27 :       if (!ok)
      52                 :            :         {
      53                 :          0 :           _mod_udpd_quit (udpd_context);
      54                 :          0 :           udpd_context = NULL;
      55                 :            :         }
      56                 :            :     }
      57                 :            : 
      58         [ -  + ]:         27 :   if (!udpd_context)
      59                 :            :     {
      60                 :          0 :       lw6sys_log (LW6SYS_LOG_ERROR, _("can't initialize mod_udpd"));
      61                 :            :     }
      62                 :            : 
      63                 :         27 :   return udpd_context;
      64                 :            : }
      65                 :            : 
      66                 :            : void
      67                 :         27 : _mod_udpd_quit (_udpd_context_t * udpd_context)
      68                 :            : {
      69                 :         27 :   lw6sys_log (LW6SYS_LOG_INFO, _x_ ("udpd quit"));
      70                 :         27 :   _mod_udpd_unload_data (&(udpd_context->data));
      71                 :         27 :   LW6SYS_FREE (udpd_context);
      72                 :         27 : }

Generated by: LCOV version 1.9