config.c revision af062818b47340eef15700d2f0211576ba3506ee
/*
* Configuration parameters shared between Wine server and clients
*
* Copyright 2002 Alexandre Julliard
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
static char *bindir;
static char *dlldir;
static char *datadir;
static char *config_dir;
static char *server_dir;
static char *build_dir;
static char *user_name;
static char *argv0_name;
#ifdef __GNUC__
#endif
/* die on a fatal error */
static void fatal_error( const char *err, ... )
{
exit(1);
}
/* die on a fatal error */
static void fatal_perror( const char *err, ... )
{
perror( " " );
exit(1);
}
/* malloc wrapper */
{
void *res;
return res;
}
/* strdup wrapper */
{
return res;
}
/* remove all trailing slashes from a path name */
static inline void remove_trailing_slashes( char *path )
{
}
/* build a path from the specified dir and name */
{
return ret;
}
/* return the directory that contains the library at run-time */
static char *get_runtime_libdir(void)
{
#ifdef HAVE_DLADDR
char *libdir;
{
return libdir;
}
#endif /* HAVE_DLADDR */
return NULL;
}
/* initialize the server directory value */
{
char *p;
#ifdef HAVE_GETUID
#else
const unsigned int uid = 0;
#endif
else
else
}
/* retrieve the default dll dir */
const char *get_dlldir( const char **default_dlldir )
{
*default_dlldir = DLLDIR;
return dlldir;
}
/* initialize all the paths values */
static void init_paths(void)
{
#ifdef HAVE_GETPWUID
char uid_str[32];
if (pwd)
{
}
if (!user)
{
}
#else /* HAVE_GETPWUID */
fatal_error( "cannot determine your user name, set the USER environment variable\n" );
#endif /* HAVE_GETPWUID */
/* build config_dir */
if (prefix)
{
if (config_dir[0] != '/')
{
}
}
else
{
{
}
}
#ifdef HAVE_GETUID
#endif
}
/* check if basedir is a valid build dir by checking for wineserver and ntdll */
/* helper for running_from_build_dir */
{
/* check for ntdll too to make sure */
return 1;
}
/* check if we are running from the build directory */
{
const char *p;
char *path;
int res;
/* remove last component from basedir */
while (p > basedir && *p == '/') p--;
while (p > basedir && *p != '/') p--;
{
/* remove another component */
while (p > basedir && *p == '/') p--;
while (p > basedir && *p != '/') p--;
{
return NULL;
}
}
return path;
}
/* initialize the argv0 path */
void wine_init_argv0_path( const char *argv0 )
{
const char *p, *basename;
else
basename = p + 1;
if ((libdir = get_runtime_libdir()))
{
{
goto in_build_dir;
}
return;
}
if (!p) return; /* if argv0 doesn't contain a path, don't store anything */
{
}
else
{
/* relative path, make it absolute */
{
{
*cwd++ = '/';
break;
}
}
}
return;
free( argv0_name );
}
/* return the configuration directory ($WINEPREFIX or $HOME/.wine) */
const char *wine_get_config_dir(void)
{
if (!config_dir) init_paths();
return config_dir;
}
/* retrieve the wine data dir */
const char *wine_get_data_dir(void)
{
return datadir;
}
/* retrieve the wine build dir (if we are running from there) */
const char *wine_get_build_dir(void)
{
return build_dir;
}
/* return the full name of the server directory (the one containing the socket) */
const char *wine_get_server_dir(void)
{
if (!server_dir)
{
if (!config_dir) init_paths();
else
{
{
return NULL; /* will have to try again once config_dir has been created */
}
}
}
return server_dir;
}
/* return the current user name */
const char *wine_get_user_name(void)
{
if (!user_name) init_paths();
return user_name;
}
/* return the standard version string */
const char *wine_get_version(void)
{
return PACKAGE_VERSION;
}
/* return the build id string */
const char *wine_get_build_id(void)
{
extern const char wine_build[];
return wine_build;
}
/* exec a binary using the preloader if requested; helper for wine_exec_wine_binary */
{
#ifdef linux
if (use_preloader)
{
static const char preloader[] = "wine-preloader";
char *p, *full_name;
else p++;
/* make a copy of argv */
return;
}
#endif
}
/* exec a wine internal binary (either the wine loader or the wine server) */
{
int use_preloader = 0;
if (!name) /* no name means default loader */
{
name = argv0_name;
use_preloader = 1;
}
{
/* if we are in build dir and name contains a path, try that */
if (build_dir)
{
}
}
/* first, bin directory from the current libdir or argv0 */
if (bindir)
{
}
/* then specified environment variable */
if (env_var)
{
}
/* now search in the Unix path */
{
for (;;)
{
if (!*pos) break;
}
}
/* and finally try BINDIR */
}