Changeset 425 for trunk/src/sh_ignore.c


Ignore:
Timestamp:
Feb 20, 2013, 7:30:02 PM (12 years ago)
Author:
katerina
Message:

Fix for tickets #329, #330, #331, #332

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_ignore.c

    r333 r425  
    5353static struct sh_ignore_list * sh_del_ign = NULL;
    5454static struct sh_ignore_list * sh_new_ign = NULL;
     55static struct sh_ignore_list * sh_mod_ign = NULL;
    5556
    5657static struct sh_ignore_list * sh_ignore_add_int(struct sh_ignore_list * list,
     
    118119}
    119120
     121int sh_ignore_add_mod (const char * addpath)
     122{
     123  if ((addpath == NULL) || (addpath[0] != '/'))
     124    {
     125      return -1;
     126    }
     127  sh_mod_ign = sh_ignore_add_int (sh_mod_ign, addpath);
     128  return 0;
     129}
     130
    120131static int sh_ignore_chk_int (struct sh_ignore_list * list,
    121132                              const char * chkpath)
     
    159170}
    160171
     172int sh_ignore_chk_mod (const char * chkpath)
     173{
     174  return (sh_ignore_chk_int(sh_mod_ign, chkpath));
     175}
     176
    161177int sh_ignore_clean (void)
    162178{
     
    191207    }
    192208
     209  new = sh_mod_ign;
     210
     211  while (new)
     212    {
     213      sh_mod_ign = new->next;
     214#ifdef HAVE_REGEX_H
     215      regfree (&(new->preg));
     216#else
     217      SH_FREE(new->path);
     218#endif
     219      SH_FREE(new);
     220      new        = sh_mod_ign;
     221    }
     222
    193223  return 0;
    194224}
     
    205235  CuAssertTrue(tc, NULL == sh_del_ign);
    206236  CuAssertTrue(tc, NULL == sh_new_ign);
     237  CuAssertTrue(tc, NULL == sh_mod_ign);
    207238 
    208239  ret = sh_ignore_add_del ("/var/log/foo/.*");
    209240  CuAssertTrue(tc, 0 == ret);
     241
    210242  CuAssertPtrNotNull(tc, sh_del_ign);
     243  CuAssertTrue(tc, NULL == sh_new_ign);
     244  CuAssertTrue(tc, NULL == sh_mod_ign);
    211245
    212246  ret = sh_ignore_chk_del ("/var/log/foo/test");
    213247  CuAssertTrue(tc, S_TRUE == ret);
    214   CuAssertTrue(tc, NULL == sh_new_ign);
    215248 
    216249  ret = sh_ignore_chk_del ("/var/log/footest");
     
    223256  CuAssertTrue(tc, NULL == sh_del_ign);
    224257  CuAssertTrue(tc, NULL == sh_new_ign);
     258  CuAssertTrue(tc, NULL == sh_mod_ign);
    225259 
    226260  ret = sh_ignore_add_new ("/var/log/foo/.*");
    227261  CuAssertTrue(tc, 0 == ret);
     262
    228263  CuAssertPtrNotNull(tc, sh_new_ign);
    229264  CuAssertTrue(tc, NULL == sh_del_ign);
     265  CuAssertTrue(tc, NULL == sh_mod_ign);
    230266
    231267  ret = sh_ignore_chk_new ("/var/log/foo/test");
     
    241277  CuAssertTrue(tc, NULL == sh_new_ign);
    242278  CuAssertTrue(tc, NULL == sh_del_ign);
     279  CuAssertTrue(tc, NULL == sh_mod_ign);
     280
     281  ret = sh_ignore_add_mod ("/var/log/foo/.*");
     282  CuAssertTrue(tc, 0 == ret);
     283
     284  CuAssertPtrNotNull(tc, sh_mod_ign);
     285  CuAssertTrue(tc, NULL == sh_del_ign);
     286  CuAssertTrue(tc, NULL == sh_new_ign);
     287
     288  ret = sh_ignore_chk_mod ("/var/log/foo/test");
     289  CuAssertTrue(tc, S_TRUE == ret);
     290 
     291  ret = sh_ignore_chk_mod ("/var/log/footest");
     292  CuAssertTrue(tc, S_FALSE == ret);
     293
     294  ret = sh_ignore_chk_mod ("/my/var/log/footest");
     295  CuAssertTrue(tc, S_FALSE == ret);
     296
     297  sh_ignore_clean();
     298  CuAssertTrue(tc, NULL == sh_new_ign);
     299  CuAssertTrue(tc, NULL == sh_del_ign);
     300  CuAssertTrue(tc, NULL == sh_mod_ign);
    243301
    244302#else
Note: See TracChangeset for help on using the changeset viewer.