~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_pack.cc

  • Committer: Brian Aker
  • Date: 2009-10-15 00:22:33 UTC
  • mto: (1183.1.11 merge)
  • mto: This revision was merged to the branch mainline in revision 1198.
  • Revision ID: brian@gaz-20091015002233-fa4ao2mbc67wls91
First pass of information engine. OMG, ponies... is it so much easier to
deal with creating and engine.

The list table iterator though... its ass, needs to go. We should also
abstract out share. Very few engines need a custom one. Just say'in

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
 
 
16
 
#include "config.h"
17
 
 
18
 
#include "drizzled/internal/my_sys.h"
19
 
 
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#include "mysys/mysys_priv.h"
 
17
#include <mystrings/m_string.h>
 
18
#include "my_static.h"
 
19
#ifdef HAVE_PWD_H
20
20
#include <pwd.h>
21
 
 
22
 
#include "drizzled/internal/m_string.h"
23
 
#include "my_static.h"
24
 
 
25
 
namespace drizzled
26
 
{
27
 
namespace internal
28
 
{
 
21
#endif
29
22
 
30
23
static char * expand_tilde(char * *path);
31
24
static size_t system_filename(char * to, const char *from);
231
224
{
232
225
  if (path[0][0] == FN_LIBCHAR)
233
226
    return home_dir;                    /* ~/ expanded to home */
234
 
  char *str,save;
235
 
  struct passwd *user_entry;
 
227
#ifdef HAVE_GETPWNAM
 
228
  {
 
229
    char *str,save;
 
230
    struct passwd *user_entry;
236
231
 
237
 
  if (!(str=strchr(*path,FN_LIBCHAR)))
238
 
    str= strchr(*path, '\0');
239
 
  save= *str; *str= '\0';
240
 
  user_entry=getpwnam(*path);
241
 
  *str=save;
242
 
  endpwent();
243
 
  if (user_entry)
244
 
  {
245
 
    *path=str;
246
 
    return user_entry->pw_dir;
 
232
    if (!(str=strchr(*path,FN_LIBCHAR)))
 
233
      str= strchr(*path, '\0');
 
234
    save= *str; *str= '\0';
 
235
    user_entry=getpwnam(*path);
 
236
    *str=save;
 
237
    endpwent();
 
238
    if (user_entry)
 
239
    {
 
240
      *path=str;
 
241
      return user_entry->pw_dir;
 
242
    }
247
243
  }
 
244
#endif
248
245
  return NULL;
249
246
}
250
247
 
290
287
 
291
288
static size_t system_filename(char * to, const char *from)
292
289
{
 
290
#ifndef FN_C_BEFORE_DIR
293
291
  return strlen(strncpy(to,from,FN_REFLEN-1));
 
292
#else   /* VMS */
 
293
 
 
294
        /* change 'dev:lib/xxx' to 'dev:[lib]xxx' */
 
295
        /* change 'dev:xxx' to 'dev:xxx' */
 
296
        /* change './xxx' to 'xxx' */
 
297
        /* change './lib/' or lib/ to '[.lib]' */
 
298
        /* change '/x/y/z to '[x.y]x' */
 
299
        /* change 'dev:/x' to 'dev:[000000]x' */
 
300
 
 
301
  int libchar_found;
 
302
  size_t length;
 
303
  char * to_pos,from_pos,pos;
 
304
  char buff[FN_REFLEN];
 
305
 
 
306
  libchar_found=0;
 
307
  (void) strcpy(buff,from);                      /* If to == from */
 
308
  from_pos= buff;
 
309
  if ((pos=strrchr(from_pos,FN_DEVCHAR)))       /* Skip device part */
 
310
  {
 
311
    pos++;
 
312
    to_pos= strncpy(to,from_pos,(size_t) (pos-from_pos));
 
313
    to_pos+= strlen(to);
 
314
    from_pos=pos;
 
315
  }
 
316
  else
 
317
    to_pos=to;
 
318
 
 
319
  if (from_pos[0] == FN_CURLIB && from_pos[1] == FN_LIBCHAR)
 
320
    from_pos+=2;                                /* Skip './' */
 
321
  if (strchr(from_pos,FN_LIBCHAR))
 
322
  {
 
323
    *(to_pos++) = FN_C_BEFORE_DIR;
 
324
    if (strstr(from_pos,FN_ROOTDIR) == from_pos)
 
325
    {
 
326
      from_pos+=strlen(FN_ROOTDIR);             /* Actually +1 but... */
 
327
      if (! strchr(from_pos,FN_LIBCHAR))
 
328
      {                                         /* No dir, use [000000] */
 
329
        to_pos= strcpy(to_pos,FN_C_ROOT_DIR)+strlen(FN_C_ROOT_DIR);
 
330
        libchar_found++;
 
331
      }
 
332
    }
 
333
    else
 
334
      *(to_pos++)=FN_C_DIR_SEP;                 /* '.' gives current dir */
 
335
 
 
336
    while ((pos=strchr(from_pos,FN_LIBCHAR)))
 
337
    {
 
338
      if (libchar_found++)
 
339
        *(to_pos++)=FN_C_DIR_SEP;               /* Add '.' between dirs */
 
340
      if (strstr(from_pos,FN_PARENTDIR) == from_pos &&
 
341
          from_pos+strlen(FN_PARENTDIR) == pos) {
 
342
        to_pos= strcpy(to_pos,FN_C_PARENT_DIR); /* Found '../' */
 
343
        to_pos+= strlen(FN_C_PARENT_DIR);
 
344
      }
 
345
      else
 
346
      {
 
347
        to_pos= strncpy(to_pos,from_pos,(size_t) (pos-from_pos));
 
348
        to_pos+= strlen(to_pos);
 
349
      }
 
350
      from_pos=pos+1;
 
351
    }
 
352
    *(to_pos++)=FN_C_AFTER_DIR;
 
353
  }
 
354
 
 
355
  strcpy(to_pos, from_pos);
 
356
  length= strlen(to);
 
357
  return(length);
 
358
#endif
294
359
} /* system_filename */
295
360
 
296
361
 
309
374
  (void) strcpy(to + to_length,from+length);
310
375
  return (to);
311
376
} /* intern_filename */
312
 
 
313
 
} /* namespace internal */
314
 
} /* namespace drizzled */