Branch: Tag:

2008-06-28

2008-06-28 19:23:06 by Martin Stjernholm <mast@lysator.liu.se>

If the path to the master is relative then resolve it relative to the exe
file on windows. This allows us to skip the binary patching of the binary.

Rev: src/configure.in:1.1056
Rev: src/main.c:1.230

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: main.c,v 1.229 2008/06/05 15:10:45 mast Exp $ + || $Id: main.c,v 1.230 2008/06/28 19:23:06 mast Exp $   */      #include "global.h"
153:       if(!master_location[CONSTANT_STRLEN(MASTER_COOKIE)])    { -  sprintf(master_location + CONSTANT_STRLEN(MASTER_COOKIE), +  SNPRINTF (master_location + CONSTANT_STRLEN(MASTER_COOKIE), +  sizeof (master_location) - CONSTANT_STRLEN (MASTER_COOKIE),    DEFAULT_MASTER,    PIKE_MAJOR_VERSION,    PIKE_MINOR_VERSION,    PIKE_BUILD_VERSION);    }    -  + #ifdef __NT__ +  if (master_location[CONSTANT_STRLEN (MASTER_COOKIE)] != '/' && +  master_location[CONSTANT_STRLEN (MASTER_COOKIE)] != '\\') { +  char exepath[MAXPATHLEN]; +  if (!GetModuleFileName (NULL, exepath, _MAX_PATH)) +  fprintf (stderr, "Failed to get path to exe file: %d\n", +  GetLastError()); +  else { +  char tmp[MAXPATHLEN * 2]; +  char *p = strrchr (exepath, '\\'); +  if (p) *p = 0; +  SNPRINTF (tmp, sizeof (tmp), "%s/%s", exepath, +  master_location + CONSTANT_STRLEN (MASTER_COOKIE)); +  strncpy (master_location + CONSTANT_STRLEN (MASTER_COOKIE), tmp, +  sizeof (master_location) - CONSTANT_STRLEN (MASTER_COOKIE)); +  } +  } + #endif +     TRACE((stderr, "Default master at \"%s\"...\n",    master_location + CONSTANT_STRLEN(MASTER_COOKIE)));   }