diff options
| author | MySQL Team <mysql@php.net> | 2000-08-22 09:02:46 +0000 | 
|---|---|---|
| committer | MySQL Team <mysql@php.net> | 2000-08-22 09:02:46 +0000 | 
| commit | 4b1380e31c0f6e76c629611c7ba8c4e2e961a2fd (patch) | |
| tree | 853d1881366287956bbfa7edf2f4edc0ae62637e /ext/mysql/libmysql/mf_pack.c | |
| parent | bac08af4cb97ea7e9db18a4267fb070264792f2f (diff) | |
| download | php-git-4b1380e31c0f6e76c629611c7ba8c4e2e961a2fd.tar.gz | |
New files for MySQL 3.23.23 client library. New files are for qouting
using different character sets.
Diffstat (limited to 'ext/mysql/libmysql/mf_pack.c')
| -rw-r--r-- | ext/mysql/libmysql/mf_pack.c | 74 | 
1 files changed, 65 insertions, 9 deletions
| diff --git a/ext/mysql/libmysql/mf_pack.c b/ext/mysql/libmysql/mf_pack.c index 3dab1621f5..bfa9e5d871 100644 --- a/ext/mysql/libmysql/mf_pack.c +++ b/ext/mysql/libmysql/mf_pack.c @@ -1,5 +1,19 @@ -/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -   This file is public domain and comes with NO WARRANTY of any kind */ +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +    +   This library is free software; you can redistribute it and/or +   modify it under the terms of the GNU Library General Public +   License as published by the Free Software Foundation; either +   version 2 of the License, or (at your option) any later version. +    +   This library is distributed in the hope that it will be useful, +   but WITHOUT ANY WARRANTY; without even the implied warranty of +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU +   Library General Public License for more details. +    +   You should have received a copy of the GNU Library General Public +   License along with this library; if not, write to the Free +   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +   MA 02111-1307, USA */  #include "mysys_priv.h"  #include <m_string.h> @@ -39,13 +53,13 @@ void pack_dirname(my_string to, const char *from)    LINT_INIT(buff_length);    if (!(cwd_err= my_getwd(buff,FN_REFLEN,MYF(0))))    { -    buff_length=strlen(buff); +    buff_length= (uint) strlen(buff);      d_length=(uint) (start-to);      if ((start == to ||  	 (buff_length == d_length && !bcmp(buff,start,d_length))) &&  	*start != FN_LIBCHAR && *start)      {						/* Put current dir before */ -      bchange(to,d_length,buff,buff_length,strlen(to)+1); +      bchange(to,d_length,buff,buff_length,(uint) strlen(to)+1);      }    } @@ -54,7 +68,7 @@ void pack_dirname(my_string to, const char *from)      length=0;      if (home_dir)      { -      length=strlen(home_dir); +      length= (uint) strlen(home_dir);        if (home_dir[length-1] == FN_LIBCHAR)  	length--;				/* Don't test last '/' */      } @@ -78,7 +92,7 @@ void pack_dirname(my_string to, const char *from)        }        if (is_prefix(to,buff))        { -	length=strlen(buff); +	length= (uint) strlen(buff);  	if (to[length])  	  (void) strmov_overlapp(to,to+length);	/* Remove everything before */  	else @@ -198,6 +212,44 @@ uint cleanup_dirname(register my_string to, const char *from)  } /* cleanup_dirname */ +	/* +	  On system where you don't have symbolic links, the following +	  code will allow you to create a file:  +	  directory-name.lnk that should contain the real path +	  to the directory.  This will be used if the directory name +	  doesn't exists +	*/ +	   + +my_bool my_use_symdir=0;	/* Set this if you want to use symdirs */ + +#ifdef USE_SYMDIR +void symdirget(char *dir) +{ +  char buff[FN_REFLEN]; +  char *pos=strend(dir); +  if (dir[0] && pos[-1] != FN_DEVCHAR && access(dir, F_OK)) +  { +    FILE *fp; +    char temp= *(--pos);            /* May be "/" or "\" */ +    strmov(pos,".sym"); +    fp = my_fopen(dir, O_RDONLY,MYF(0)); +    *pos++=temp; *pos=0;	  /* Restore old filename */ +    if (fp) +    { +      if (fgets(buff, sizeof(buff), fp)) +      { +	for (pos=strend(buff); +	     pos > buff && (iscntrl(pos[-1]) || isspace(pos[-1])) ; +	     pos --); +	strmake(dir,buff, (uint) (pos-buff)); +      } +      my_fclose(fp,MYF(0)); +    } +  } +} +#endif /* USE_SYMDIR */ +  	/* Unpacks dirname to name that can be used by open... */  	/* Make that last char of to is '/' if from not empty and  	   from doesn't end in FN_DEVCHAR */ @@ -209,11 +261,11 @@ uint unpack_dirname(my_string to, const char *from)  						  /* to may be == from */  {    uint length,h_length; -  char buff[FN_REFLEN+1],*suffix,*tilde_expansion; +  char buff[FN_REFLEN+1+4],*suffix,*tilde_expansion;    DBUG_ENTER("unpack_dirname");    (void) intern_filename(buff,from);		/* Change to intern name */ -  length=strlen(buff);				/* Fix that '/' is last */ +  length= (uint) strlen(buff);			/* Fix that '/' is last */    if (length &&  #ifdef FN_DEVCHAR        buff[length-1] != FN_DEVCHAR && @@ -231,7 +283,7 @@ uint unpack_dirname(my_string to, const char *from)      if (tilde_expansion)      {        length-=(uint) (suffix-buff)-1; -      if (length+(h_length=strlen(tilde_expansion)) <= FN_REFLEN) +      if (length+(h_length= (uint) strlen(tilde_expansion)) <= FN_REFLEN)        {  	if (tilde_expansion[h_length-1] == FN_LIBCHAR)  	  h_length--; @@ -243,6 +295,10 @@ uint unpack_dirname(my_string to, const char *from)        }      }    } +#ifdef USE_SYMDIR +  if (my_use_symdir) +    symdirget(buff); +#endif    DBUG_RETURN(system_filename(to,buff));	/* Fix for open */  } /* unpack_dirname */ | 
