~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_lib.c

  • Committer: Monty Taylor
  • Date: 2008-08-04 19:37:18 UTC
  • mto: (261.2.2 codestyle)
  • mto: This revision was merged to the branch mainline in revision 262.
  • Revision ID: monty@inaugust.com-20080804193718-f0rz13uli4429ozb
Changed gettext_noop() to N_()

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include        "mysys_err.h"
23
23
#if defined(HAVE_DIRENT_H)
24
24
# include <dirent.h>
 
25
# define NAMLEN(dirent) strlen((dirent)->d_name)
25
26
#else
26
27
# define dirent direct
 
28
# define NAMLEN(dirent) (dirent)->d_namlen
27
29
# if defined(HAVE_SYS_NDIR_H)
28
30
#  include <sys/ndir.h>
29
31
# endif
51
53
#define NAMES_START_SIZE   32768
52
54
 
53
55
 
54
 
static int comp_names(const struct fileinfo *a, const struct fileinfo *b);
 
56
static int      comp_names(struct fileinfo *a,struct fileinfo *b);
55
57
 
56
58
 
57
59
        /* We need this because program don't know with malloc we used */
64
66
                                    ALIGN_SIZE(sizeof(MY_DIR))));
65
67
    free_root((MEM_ROOT*)((char*)buffer + ALIGN_SIZE(sizeof(MY_DIR)) + 
66
68
                          ALIGN_SIZE(sizeof(DYNAMIC_ARRAY))), MYF(0));
67
 
    free((unsigned char*) buffer);
 
69
    my_free((uchar*) buffer,MYF(0));
68
70
  }
69
71
  return;
70
72
} /* my_dirend */
72
74
 
73
75
        /* Compare in sort of filenames */
74
76
 
75
 
static int comp_names(const struct fileinfo *a, const struct fileinfo *b)
 
77
static int comp_names(struct fileinfo *a, struct fileinfo *b)
76
78
{
77
79
  return (strcmp(a->name,b->name));
78
80
} /* comp_names */
96
98
 
97
99
  dirp = opendir(directory_file_name(tmp_path,(char *) path));
98
100
  if (dirp == NULL || 
99
 
      ! (buffer= (char *) my_malloc(ALIGN_SIZE(sizeof(MY_DIR)) + 
100
 
                                    ALIGN_SIZE(sizeof(DYNAMIC_ARRAY)) +
101
 
                                    sizeof(MEM_ROOT), MyFlags)))
 
101
      ! (buffer= my_malloc(ALIGN_SIZE(sizeof(MY_DIR)) + 
 
102
                           ALIGN_SIZE(sizeof(DYNAMIC_ARRAY)) +
 
103
                           sizeof(MEM_ROOT), MyFlags)))
102
104
    goto error;
103
105
 
104
106
  dir_entries_storage= (DYNAMIC_ARRAY*)(buffer + ALIGN_SIZE(sizeof(MY_DIR))); 
108
110
  if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO),
109
111
                            ENTRIES_START_SIZE, ENTRIES_INCREMENT))
110
112
  {
111
 
    free((unsigned char*) buffer);
 
113
    my_free((uchar*) buffer,MYF(0));
112
114
    goto error;
113
115
  }
114
116
  init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE);
116
118
  /* MY_DIR structure is allocated and completly initialized at this point */
117
119
  result= (MY_DIR*)buffer;
118
120
 
119
 
  tmp_file= strchr(tmp_path, '\0');
 
121
  tmp_file=strend(tmp_path);
120
122
 
121
123
  dp= (struct dirent*) dirent_tmp;
122
124
  
132
134
        goto error;
133
135
      
134
136
      memset(finfo.mystat, 0, sizeof(struct stat));
135
 
      my_stpcpy(tmp_file,dp->d_name);
136
 
      stat(tmp_path, finfo.mystat);
 
137
      VOID(strmov(tmp_file,dp->d_name));
 
138
      VOID(stat(tmp_path, finfo.mystat));
137
139
      if (!(finfo.mystat->st_mode & S_IREAD))
138
140
        continue;
139
141
    }
140
142
    else
141
143
      finfo.mystat= NULL;
142
144
 
143
 
    if (push_dynamic(dir_entries_storage, (unsigned char*)&finfo))
 
145
    if (push_dynamic(dir_entries_storage, (uchar*)&finfo))
144
146
      goto error;
145
147
  }
146
148
 
188
190
 
189
191
  if (src[0] == 0)
190
192
    src= (char*) ".";                           /* Use empty as current */
191
 
  end=my_stpcpy(dst, src);
 
193
  end=strmov(dst, src);
192
194
  if (end[-1] != FN_LIBCHAR)
193
195
  {
194
196
    end[0]=FN_LIBCHAR;                          /* Add last '/' */