* cygheap_malloc.h: New file.
* cygheap.h: Remove stuff now included in cygheap_malloc.h and include that file. Make cygheap_init a standard c++ function. Remove unneeded child_info declaration. * path.h: Include cygheap_malloc.h. Remove extra cstrdup declaration. (path_conv): Reorganize to group variables together. (path_conv::path): Make const char *. (path_conv::known_suffix): Ditto. (path_conv::normalized_path): Ditto. (path_conv::path_conv): Reorganize initializers to reflect new element ordering. (path_conv::get_win32): Change return value to const char *. (path_conv::set_path): Move back here from spawn.cc. (parh_conv::modifiable_path): New function. * path.cc (path_conv::add_ext_from_sym): Accommodate const'ness of known_suffixes. (path_conv::set_normalized_path): Ditto for normalized_path. (path_conv::check): Use modifiable_path whereever we need to modify the path element. Use set_path to set the path. (path_conv::~path_conv): Accommodate new const'ness. * spawn.cc (perhaps_suffix): Declare ext as const since that's what is being returned. (path_conv::set_path): Move back to path.h. * winf.f (linebuf): Perform minor cleanup. (linebuf::fromargv): Change second parameter to const. * winf.cc (linebuf::fromargv): Ditto.
This commit is contained in:
@@ -11,6 +11,7 @@ details. */
|
||||
|
||||
#include "devices.h"
|
||||
#include "mount.h"
|
||||
#include "cygheap_malloc.h"
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
@@ -83,8 +84,6 @@ enum path_types
|
||||
PATH_SOCKET = 0x40000000
|
||||
};
|
||||
|
||||
extern "C" char *__stdcall cstrdup (const char *) __attribute__ ((regparm(1)));
|
||||
|
||||
class symlink_info;
|
||||
|
||||
class path_conv
|
||||
@@ -95,10 +94,12 @@ class path_conv
|
||||
PWCHAR wide_path;
|
||||
UNICODE_STRING uni_path;
|
||||
void add_ext_from_sym (symlink_info&);
|
||||
DWORD symlink_length;
|
||||
const char *path;
|
||||
public:
|
||||
|
||||
unsigned path_flags;
|
||||
char *known_suffix;
|
||||
const char *known_suffix;
|
||||
const char *normalized_path;
|
||||
int error;
|
||||
device dev;
|
||||
|
||||
@@ -165,39 +166,39 @@ class path_conv
|
||||
|
||||
path_conv (const device& in_dev)
|
||||
: fileattr (INVALID_FILE_ATTRIBUTES), wide_path (NULL), path_flags (0),
|
||||
known_suffix (NULL), error (0), dev (in_dev), normalized_path (NULL)
|
||||
known_suffix (NULL), normalized_path (NULL), error (0), dev (in_dev)
|
||||
{
|
||||
path = cstrdup (in_dev.native);
|
||||
}
|
||||
|
||||
path_conv (int, const char *src, unsigned opt = PC_SYM_FOLLOW,
|
||||
const suffix_info *suffixes = NULL)
|
||||
: wide_path (NULL), normalized_path (NULL), path (NULL)
|
||||
: wide_path (NULL), path (NULL), normalized_path (NULL)
|
||||
{
|
||||
check (src, opt, suffixes);
|
||||
}
|
||||
|
||||
path_conv (const UNICODE_STRING *src, unsigned opt = PC_SYM_FOLLOW,
|
||||
const suffix_info *suffixes = NULL)
|
||||
: wide_path (NULL), normalized_path (NULL), path (NULL)
|
||||
: wide_path (NULL), path (NULL), normalized_path (NULL)
|
||||
{
|
||||
check (src, opt | PC_NULLEMPTY, suffixes);
|
||||
}
|
||||
|
||||
path_conv (const char *src, unsigned opt = PC_SYM_FOLLOW,
|
||||
const suffix_info *suffixes = NULL)
|
||||
: wide_path (NULL), normalized_path (NULL), path (NULL)
|
||||
: wide_path (NULL), path (NULL), normalized_path (NULL)
|
||||
{
|
||||
check (src, opt | PC_NULLEMPTY, suffixes);
|
||||
}
|
||||
|
||||
path_conv ()
|
||||
: fileattr (INVALID_FILE_ATTRIBUTES), wide_path (NULL), path_flags (0),
|
||||
known_suffix (NULL), error (0), normalized_path (NULL), path (NULL)
|
||||
: fileattr (INVALID_FILE_ATTRIBUTES), wide_path (NULL), path (NULL),
|
||||
path_flags (0), known_suffix (NULL), normalized_path (NULL), error (0)
|
||||
{}
|
||||
|
||||
~path_conv ();
|
||||
inline char *get_win32 () { return path; }
|
||||
inline const char *get_win32 () { return path; }
|
||||
PUNICODE_STRING get_nt_native_path ();
|
||||
POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &attr,
|
||||
SECURITY_ATTRIBUTES &sa);
|
||||
@@ -232,17 +233,22 @@ class path_conv
|
||||
bool fs_is_cdrom () const {return fs.is_cdrom ();}
|
||||
bool fs_is_mvfs () const {return fs.is_mvfs ();}
|
||||
ULONG fs_serial_number () const {return fs.serial_number ();}
|
||||
inline char *set_path (const char *p);
|
||||
inline const char *set_path (const char *p)
|
||||
{
|
||||
if (path)
|
||||
cfree (modifiable_path ());
|
||||
char *new_path = (char *) cmalloc_abort (HEAP_STR, strlen (p) + 7);
|
||||
strcpy (new_path, p);
|
||||
return path = new_path;
|
||||
}
|
||||
void fillin (HANDLE h);
|
||||
bool is_binary ();
|
||||
|
||||
unsigned __stdcall ndisk_links (DWORD);
|
||||
char *normalized_path;
|
||||
void set_normalized_path (const char *) __attribute__ ((regparm (2)));
|
||||
DWORD get_symlink_length () { return symlink_length; };
|
||||
private:
|
||||
DWORD symlink_length;
|
||||
char *path;
|
||||
char *modifiable_path () {return (char *) path;}
|
||||
};
|
||||
|
||||
/* Symlink marker */
|
||||
|
Reference in New Issue
Block a user