Changeset 22 for trunk/src/sh_files.c


Ignore:
Timestamp:
Feb 23, 2006, 12:03:58 AM (19 years ago)
Author:
rainer
Message:

Minor code revisions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_files.c

    r20 r22  
    7272#define FIL__  _("sh_files.c")
    7373
    74 extern int safe_logger (int signal, int method, pid_t thepid);
    75 
    7674extern int flag_err_debug;
    7775extern int flag_err_info;
    7876
    79 int sh_files_reportonce(char * c)
     77int sh_files_reportonce(const char * c)
    8078{
    8179  int i;
     
    8684}
    8785   
    88 int sh_files_fulldetail(char * c)
     86int sh_files_fulldetail(const char * c)
    8987{
    9088  int i;
     
    156154static int        sh_files_fullpath  (char * testdir, char * d_name,
    157155                                      char * statpath);
    158 static int        sh_files_pushdir   (int class, char * str_s);
    159 static int        sh_files_pushfile  (int class, char * str_s);
     156static int        sh_files_pushdir   (int class, const char * str_s);
     157static int        sh_files_pushfile  (int class, const char * str_s);
    160158static int        sh_files_checkdir  (int class, int rdepth, char * dirName,
    161159                                      char * relativeName);
     
    446444
    447445
    448 int sh_files_pushfile_prelink (char * str_s)
     446int sh_files_pushfile_prelink (const char * str_s)
    449447{
    450448  return (sh_files_pushfile (SH_LEVEL_PRELINK, str_s));
    451449}
    452450
    453 int sh_files_pushfile_user0 (char * str_s)
     451int sh_files_pushfile_user0 (const char * str_s)
    454452{
    455453  return (sh_files_pushfile (SH_LEVEL_USER0, str_s));
     
    457455
    458456
    459 int sh_files_pushfile_user1 (char * str_s)
     457int sh_files_pushfile_user1 (const char * str_s)
    460458{
    461459  return (sh_files_pushfile (SH_LEVEL_USER1, str_s));
     
    463461
    464462
    465 int sh_files_pushfile_ro (char * str_s)
     463int sh_files_pushfile_ro (const char * str_s)
    466464{
    467465  return (sh_files_pushfile (SH_LEVEL_READONLY, str_s));
    468466}
    469467
    470 int sh_files_pushfile_attr (char * str_s)
     468int sh_files_pushfile_attr (const char * str_s)
    471469{
    472470  return (sh_files_pushfile (SH_LEVEL_ATTRIBUTES, str_s));
    473471}
    474472
    475 int sh_files_pushfile_log (char * str_s)
     473int sh_files_pushfile_log (const char * str_s)
    476474{
    477475  return (sh_files_pushfile (SH_LEVEL_LOGFILES, str_s));
    478476}
    479477
    480 int sh_files_pushfile_glog (char * str_s)
     478int sh_files_pushfile_glog (const char * str_s)
    481479{
    482480  return (sh_files_pushfile (SH_LEVEL_LOGGROW, str_s));
    483481}
    484482
    485 int sh_files_pushfile_noig (char * str_s)
     483int sh_files_pushfile_noig (const char * str_s)
    486484{
    487485  return (sh_files_pushfile (SH_LEVEL_NOIGNORE, str_s));
    488486}
    489487
    490 int sh_files_pushfile_allig (char * str_s)
     488int sh_files_pushfile_allig (const char * str_s)
    491489{
    492490  return (sh_files_pushfile (SH_LEVEL_ALLIGNORE, str_s));
     
    511509/* set mask(class)
    512510 */
    513 static int sh_files_parse_mask (unsigned long * mask, char * str)
     511static int sh_files_parse_mask (unsigned long * mask, const char * str)
    514512{
    515513  int l, i = 0, act = 0, k = 0;
     
    602600}
    603601
    604 int sh_files_redef_prelink(char * str)
     602int sh_files_redef_prelink(const char * str)
    605603{
    606604  return (sh_files_parse_mask(&mask_PRELINK, str));
    607605}
    608 int sh_files_redef_user0(char * str)
     606int sh_files_redef_user0(const char * str)
    609607{
    610608  return (sh_files_parse_mask(&mask_USER0, str));
    611609}
    612 int sh_files_redef_user1(char * str)
     610int sh_files_redef_user1(const char * str)
    613611{
    614612  return (sh_files_parse_mask(&mask_USER1, str));
    615613}
    616 int sh_files_redef_readonly(char * str)
     614int sh_files_redef_readonly(const char * str)
    617615{
    618616  return (sh_files_parse_mask(&mask_READONLY, str));
    619617}
    620 int sh_files_redef_loggrow(char * str)
     618int sh_files_redef_loggrow(const char * str)
    621619{
    622620  return (sh_files_parse_mask(&mask_LOGGROW, str));
    623621}
    624 int sh_files_redef_logfiles(char * str)
     622int sh_files_redef_logfiles(const char * str)
    625623{
    626624  return (sh_files_parse_mask(&mask_LOGFILES, str));
    627625}
    628 int sh_files_redef_attributes(char * str)
     626int sh_files_redef_attributes(const char * str)
    629627{
    630628  return (sh_files_parse_mask(&mask_ATTRIBUTES, str));
    631629}
    632 int sh_files_redef_noignore(char * str)
     630int sh_files_redef_noignore(const char * str)
    633631{
    634632  return (sh_files_parse_mask(&mask_NOIGNORE, str));
    635633}
    636 int sh_files_redef_allignore(char * str)
     634int sh_files_redef_allignore(const char * str)
    637635{
    638636  return (sh_files_parse_mask(&mask_ALLIGNORE, str));
     
    725723      if (zfileList == NULL)
    726724        {
    727           (void) safe_logger (0, 0, getpid());
     725          (void) safe_logger (0, 0, NULL);
    728726          aud__exit(FIL__, __LINE__, EXIT_FAILURE);
    729727        }
     
    734732  if (-1 == ret)
    735733    {
    736       (void) safe_logger (0, 0, getpid());
     734      (void) safe_logger (0, 0, NULL);
    737735      aud__exit(FIL__, __LINE__, EXIT_FAILURE);
    738736    }
     
    745743
    746744
    747 static int sh_files_pushfile (int class, char * str_s)
    748 {
     745static int sh_files_pushfile (int class, const char * str_s)
     746{
     747  int     len;
    749748  char  * tmp;
    750   int     len;
     749  char  * p;
    751750#ifdef HAVE_GLOB_H
    752   glob_t  pglob;
    753751  int     globstatus = -1;
    754752  unsigned int     gloop;
     753  glob_t  pglob;
    755754#endif
    756755
     
    808807       * special case of the root directory.
    809808       */
    810       if (str_s[len-1] == '/' && len > 1)
     809      p = sh_util_strdup (str_s);
     810      if (p[len-1] == '/' && len > 1)
    811811        {
    812           str_s[len-1] = '\0';
     812          p[len-1] = '\0';
    813813          --len;
    814814        }
     
    817817
    818818#ifdef HAVE_GLOB_H
    819   if (0 == sh_files_has_metachar(str_s))
    820     {
    821       sh_files_push_file_int (class, str_s, len);
     819  if (0 == sh_files_has_metachar(p))
     820    {
     821      sh_files_push_file_int (class, p, len);
    822822    }
    823823  else
    824824    {
    825825      pglob.gl_offs = 0;
    826       globstatus    = glob (str_s, 0, sh_files_globerr, &pglob);
     826      globstatus    = glob (p, 0, sh_files_globerr, &pglob);
    827827
    828828      if (globstatus == 0 && pglob.gl_pathc > 0)
     
    834834      else
    835835        {
    836           tmp = sh_util_safe_name (str_s);
     836          tmp = sh_util_safe_name (p);
    837837
    838838          if (pglob.gl_pathc == 0
     
    869869
    870870#else
    871   sh_files_push_file_int (class, str_s, len);
    872 #endif
    873 
     871  sh_files_push_file_int (class, p, len);
     872#endif
     873
     874  SH_FREE(p);
    874875  SL_RETURN((0),_("sh_files_pushfile"));
    875876}
     
    10281029}
    10291030
    1030 int sh_files_pushdir_prelink (char * str_s)
     1031int sh_files_pushdir_prelink (const char * str_s)
    10311032{
    10321033  return (sh_files_pushdir (SH_LEVEL_PRELINK, str_s));
    10331034}
    10341035
    1035 int sh_files_pushdir_user0 (char * str_s)
     1036int sh_files_pushdir_user0 (const char * str_s)
    10361037{
    10371038  return (sh_files_pushdir (SH_LEVEL_USER0, str_s));
    10381039}
    10391040
    1040 int sh_files_pushdir_user1 (char * str_s)
     1041int sh_files_pushdir_user1 (const char * str_s)
    10411042{
    10421043  return (sh_files_pushdir (SH_LEVEL_USER1, str_s));
    10431044}
    10441045
    1045 int sh_files_pushdir_attr (char * str_s)
     1046int sh_files_pushdir_attr (const char * str_s)
    10461047{
    10471048  return (sh_files_pushdir (SH_LEVEL_ATTRIBUTES, str_s));
    10481049}
    10491050
    1050 int sh_files_pushdir_ro (char * str_s)
     1051int sh_files_pushdir_ro (const char * str_s)
    10511052{
    10521053  return (sh_files_pushdir (SH_LEVEL_READONLY, str_s));
    10531054}
    10541055
    1055 int sh_files_pushdir_log (char * str_s)
     1056int sh_files_pushdir_log (const char * str_s)
    10561057{
    10571058  return (sh_files_pushdir (SH_LEVEL_LOGFILES, str_s));
    10581059}
    10591060
    1060 int sh_files_pushdir_glog (char * str_s)
     1061int sh_files_pushdir_glog (const char * str_s)
    10611062{
    10621063  return (sh_files_pushdir (SH_LEVEL_LOGGROW, str_s));
    10631064}
    10641065
    1065 int sh_files_pushdir_noig (char * str_s)
     1066int sh_files_pushdir_noig (const char * str_s)
    10661067{
    10671068  return (sh_files_pushdir (SH_LEVEL_NOIGNORE, str_s));
    10681069}
    10691070
    1070 int sh_files_pushdir_allig (char * str_s)
     1071int sh_files_pushdir_allig (const char * str_s)
    10711072{
    10721073  return (sh_files_pushdir (SH_LEVEL_ALLIGNORE, str_s));
     
    11201121      if (tree == NULL)
    11211122        {
    1122           (void) safe_logger (0, 0, getpid());
     1123          (void) safe_logger (0, 0, NULL);
    11231124          aud__exit(FIL__, __LINE__, EXIT_FAILURE);
    11241125        }
     
    11331134  if (-1 == ret)
    11341135    {
    1135       (void) safe_logger (0, 0, getpid());
     1136      (void) safe_logger (0, 0, NULL);
    11361137      aud__exit(FIL__, __LINE__, EXIT_FAILURE);
    11371138    }
     
    11431144}
    11441145
    1145 static int sh_files_pushdir (int class, char * str_s)
     1146static int sh_files_pushdir (int class, const char * str_s)
    11461147{
    11471148  char  * tmp;
     
    11491150  int     rdepth = 0;
    11501151  char  * tail = NULL;
     1152  char  * p;
    11511153
    11521154#ifdef HAVE_GLOB_H
     
    11661168    SL_RETURN((-1), _("sh_files_pushdir"));
    11671169 
    1168 
    1169   if (str_s[0] != '/')
    1170     {
    1171       rdepth = strtol(str_s, &tail, 10);
    1172       if (tail == str_s)
    1173         SL_RETURN((-1), _("sh_files_pushdir"));
     1170  p = sh_util_strdup (str_s);
     1171
     1172  if (p[0] != '/')
     1173    {
     1174      rdepth = strtol(p, &tail, 10);
     1175      if (tail == p)
     1176        {
     1177          SH_FREE(p);
     1178          SL_RETURN((-1), _("sh_files_pushdir"));
     1179        }
    11741180    }
    11751181  else
    1176     tail   = str_s;
     1182    tail   = p;
    11771183 
    11781184
    1179   if (rdepth < (-1) || tail == str_s || rdepth > 99)
     1185  if (rdepth < (-1) || tail == p || rdepth > 99)
    11801186    rdepth = (-2);
    11811187
     
    11881194                       tmp);
    11891195      SH_FREE(tmp);
     1196      SH_FREE(p);
    11901197      SL_RETURN((-1), _("sh_files_pushdir"));
    11911198    }
    11921199  else if (len < 1)
    11931200    {
     1201      SH_FREE(p);
    11941202      SL_RETURN((-1), _("sh_files_pushdir"));
    11951203    }
     
    12001208                       tmp);
    12011209      SH_FREE(tmp);
     1210      SH_FREE(p);
    12021211      SL_RETURN((-1), _("sh_files_pushdir"));
    12031212    }
     
    12681277#endif
    12691278
     1279  SH_FREE(p);
    12701280  SL_RETURN((0), _("sh_files_pushdir"));
    12711281
     
    13221332/* Simply sets our boolean as to whether this check is active
    13231333 */
    1324 int sh_files_check_hardlinks (char * opt)
     1334int sh_files_check_hardlinks (const char * opt)
    13251335{
    13261336  int i;
     
    13381348static struct sh_hle_struct * sh_hl_exc = NULL;
    13391349
    1340 int sh_files_hle_reg (char * str)
     1350int sh_files_hle_reg (const char * str)
    13411351{
    13421352  long   offset;
Note: See TracChangeset for help on using the changeset viewer.