~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_lib.c

  • Committer: Brian Aker
  • Date: 2008-07-14 22:07:42 UTC
  • Revision ID: brian@tangent.org-20080714220742-y7fjh1mitrfcgfij
Second pass cleanup on removal of my_uint types

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
/*       Convert MSDOS-TIME to standar time_t (still needed?) */
18
18
 
19
19
#include        "mysys_priv.h"
20
 
#include        <mystrings/m_string.h>
 
20
#include        <m_string.h>
21
21
#include        <my_dir.h>      /* Structs used by my_dir,includes sys/types */
22
22
#include        "mysys_err.h"
23
23
#if defined(HAVE_DIRENT_H)
53
53
#define NAMES_START_SIZE   32768
54
54
 
55
55
 
56
 
static int comp_names(const struct fileinfo *a, const struct fileinfo *b);
 
56
static int      comp_names(struct fileinfo *a,struct fileinfo *b);
57
57
 
58
58
 
59
59
        /* We need this because program don't know with malloc we used */
60
60
 
61
61
void my_dirend(MY_DIR *buffer)
62
62
{
 
63
  DBUG_ENTER("my_dirend");
63
64
  if (buffer)
64
65
  {
65
66
    delete_dynamic((DYNAMIC_ARRAY*)((char*)buffer + 
66
67
                                    ALIGN_SIZE(sizeof(MY_DIR))));
67
68
    free_root((MEM_ROOT*)((char*)buffer + ALIGN_SIZE(sizeof(MY_DIR)) + 
68
69
                          ALIGN_SIZE(sizeof(DYNAMIC_ARRAY))), MYF(0));
69
 
    free((unsigned char*) buffer);
 
70
    my_free((uchar*) buffer,MYF(0));
70
71
  }
71
 
  return;
 
72
  DBUG_VOID_RETURN;
72
73
} /* my_dirend */
73
74
 
74
75
 
75
76
        /* Compare in sort of filenames */
76
77
 
77
 
static int comp_names(const struct fileinfo *a, const struct fileinfo *b)
 
78
static int comp_names(struct fileinfo *a, struct fileinfo *b)
78
79
{
79
80
  return (strcmp(a->name,b->name));
80
81
} /* comp_names */
91
92
  struct dirent *dp;
92
93
  char          tmp_path[FN_REFLEN+1],*tmp_file;
93
94
  char  dirent_tmp[sizeof(struct dirent)+_POSIX_PATH_MAX+1];
 
95
  DBUG_ENTER("my_dir");
 
96
  DBUG_PRINT("my",("path: '%s' MyFlags: %d",path,MyFlags));
94
97
 
95
98
#if !defined(HAVE_READDIR_R)
96
99
  pthread_mutex_lock(&THR_LOCK_open);
110
113
  if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO),
111
114
                            ENTRIES_START_SIZE, ENTRIES_INCREMENT))
112
115
  {
113
 
    free((unsigned char*) buffer);
 
116
    my_free((uchar*) buffer,MYF(0));
114
117
    goto error;
115
118
  }
116
119
  init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE);
118
121
  /* MY_DIR structure is allocated and completly initialized at this point */
119
122
  result= (MY_DIR*)buffer;
120
123
 
121
 
  tmp_file= strchr(tmp_path, '\0');
 
124
  tmp_file=strend(tmp_path);
122
125
 
123
126
  dp= (struct dirent*) dirent_tmp;
124
127
  
133
136
                                               sizeof(struct stat))))
134
137
        goto error;
135
138
      
136
 
      memset(finfo.mystat, 0, sizeof(struct stat));
137
 
      my_stpcpy(tmp_file,dp->d_name);
138
 
      stat(tmp_path, finfo.mystat);
139
 
      if (!(finfo.mystat->st_mode & S_IREAD))
 
139
      bzero(finfo.mystat, sizeof(struct stat));
 
140
      VOID(strmov(tmp_file,dp->d_name));
 
141
      VOID(stat(tmp_path, finfo.mystat));
 
142
      if (!(finfo.mystat->st_mode & MY_S_IREAD))
140
143
        continue;
141
144
    }
142
145
    else
143
146
      finfo.mystat= NULL;
144
147
 
145
 
    if (push_dynamic(dir_entries_storage, (unsigned char*)&finfo))
 
148
    if (push_dynamic(dir_entries_storage, (uchar*)&finfo))
146
149
      goto error;
147
150
  }
148
151
 
156
159
  if (!(MyFlags & MY_DONT_SORT))
157
160
    my_qsort((void *) result->dir_entry, result->number_off_files,
158
161
          sizeof(FILEINFO), (qsort_cmp) comp_names);
159
 
  return(result);
 
162
  DBUG_RETURN(result);
160
163
 
161
164
 error:
162
165
#if !defined(HAVE_READDIR_R)
168
171
  my_dirend(result);
169
172
  if (MyFlags & (MY_FAE | MY_WME))
170
173
    my_error(EE_DIR,MYF(ME_BELL+ME_WAITTANG),path,my_errno);
171
 
  return((MY_DIR *) NULL);
 
174
  DBUG_RETURN((MY_DIR *) NULL);
172
175
} /* my_dir */
173
176
 
174
177
 
190
193
 
191
194
  if (src[0] == 0)
192
195
    src= (char*) ".";                           /* Use empty as current */
193
 
  end=my_stpcpy(dst, src);
 
196
  end=strmov(dst, src);
194
197
  if (end[-1] != FN_LIBCHAR)
195
198
  {
196
199
    end[0]=FN_LIBCHAR;                          /* Add last '/' */