LCOV - code coverage report
Current view: top level - libcdpfgl - query.c (source / functions) Hit Total Coverage
Test: coverage-libcdpfgl.info Lines: 26 26 100.0 %
Date: 2016-02-03 22:31:46 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
       2             : /*
       3             :  *    query.c
       4             :  *    This file is part of "Sauvegarde" project.
       5             :  *
       6             :  *    (C) Copyright 2015 - 2016 Olivier Delhomme
       7             :  *     e-mail : olivier.delhomme@free.fr
       8             :  *
       9             :  *    "Sauvegarde" is free software: you can redistribute it and/or modify
      10             :  *    it under the terms of the GNU General Public License as published by
      11             :  *    the Free Software Foundation, either version 3 of the License, or
      12             :  *    (at your option) any later version.
      13             :  *
      14             :  *    "Sauvegarde" is distributed in the hope that it will be useful,
      15             :  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17             :  *    GNU General Public License for more details.
      18             :  *
      19             :  *    You should have received a copy of the GNU General Public License
      20             :  *    along with "Sauvegarde".  If not, see <http://www.gnu.org/licenses/>
      21             :  */
      22             : 
      23             : /**
      24             :  * @file query.c
      25             :  * This file contains the functions to deal with queries in cdpfglserver and
      26             :  * cdpfglrestore programs
      27             :  */
      28             : 
      29             : #include "libcdpfgl.h"
      30             : 
      31             : 
      32             : 
      33             : /**
      34             :  * Creates a query_t * structure filled with the corresponding data
      35             :  * @param hostname hostname (where to look for)
      36             :  * @param uid uid for the file(s)
      37             :  * @param gid gid for the file(s)
      38             :  * @param owner owner for the file(s) hopefully corresponding to uid
      39             :  * @param group group for the file(s) hopefully corresponding to gid
      40             :  * @param filename is the filename that we are looking for.
      41             :  * @param date is the date at which we want the file's version back.
      42             :  * @param afterdate is the date after which we want the files.
      43             :  * @param beforedate is the date before which we want the files.
      44             :  * @returns a newly allocated query_t * structure filled  with the
      45             :  *          corresponding data that may be freed when no longer needed.
      46             :  */
      47          12 : query_t *init_query_t(gchar *hostname, gchar *uid, gchar *gid, gchar *owner, gchar *group, gchar *filename, gchar *date, gchar *afterdate, gchar *beforedate)
      48             : {
      49          12 :     query_t *query = NULL;
      50             : 
      51          12 :     query = (query_t *) g_malloc0(sizeof(query_t));
      52             : 
      53          12 :     query->hostname = hostname;
      54          12 :     query->uid = uid;
      55          12 :     query->gid = gid;
      56          12 :     query->owner = owner;
      57          12 :     query->group = group;
      58          12 :     query->filename = filename;
      59          12 :     query->date = date;
      60          12 :     query->afterdate = afterdate;
      61          12 :     query->beforedate = beforedate;
      62             : 
      63          12 :     return query;
      64             : }
      65             : 
      66             : 
      67             : /**
      68             :  * Frees a query
      69             :  * @param query is the qery to be freed
      70             :  * @returns NULL;
      71             :  */
      72          12 : gpointer free_query_t(query_t *query)
      73             : {
      74          12 :     if (query != NULL)
      75             :         {
      76          12 :             free_variable(query->hostname);
      77          12 :             free_variable(query->uid);
      78          12 :             free_variable(query->gid);
      79          12 :             free_variable(query->owner);
      80          12 :             free_variable(query->group);
      81          12 :             free_variable(query->filename);
      82          12 :             free_variable(query->date);
      83          12 :             free_variable(query->afterdate);
      84          12 :             free_variable(query->beforedate);
      85          12 :             free_variable(query);
      86             :         }
      87             : 
      88          12 :     return NULL;
      89             : }
      90             : 
      91             : 

Generated by: LCOV version 1.11