axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dami...@apache.org
Subject svn commit: r374258 - in /webservices/axis2/trunk/c/modules/platforms/windows: axis2_dir_windows.h axis2_uuid_gen_windows.h dir_windows.c uuid_gen_windows.c
Date Thu, 02 Feb 2006 05:17:48 GMT
Author: damitha
Date: Wed Feb  1 21:17:38 2006
New Revision: 374258

URL: http://svn.apache.org/viewcvs?rev=374258&view=rev
Log:
added dir and uuid for windows

Added:
    webservices/axis2/trunk/c/modules/platforms/windows/axis2_dir_windows.h   (with props)
    webservices/axis2/trunk/c/modules/platforms/windows/axis2_uuid_gen_windows.h   (with props)
    webservices/axis2/trunk/c/modules/platforms/windows/dir_windows.c   (with props)
    webservices/axis2/trunk/c/modules/platforms/windows/uuid_gen_windows.c   (with props)

Added: webservices/axis2/trunk/c/modules/platforms/windows/axis2_dir_windows.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/platforms/windows/axis2_dir_windows.h?rev=374258&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/platforms/windows/axis2_dir_windows.h (added)
+++ webservices/axis2/trunk/c/modules/platforms/windows/axis2_dir_windows.h Wed Feb  1 21:17:38
2006
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef READDIR_H
+#define READDIR_H
+#include <search.h>
+#include <string.h>
+#include <io.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <windows.h>
+#include <axis2_defines.h>
+
+
+/* struct dirent - same as Unix dirent.h */
+AXIS2_DECLARE_DATA struct dirent 
+{
+	long				d_ino;						/* inode number (always 1 in WIN32) */
+	off_t				d_off;					/* offset to this dirent */
+	unsigned short		d_reclen;		/* length of d_name */
+	char				d_name[_MAX_FNAME + 1];	/* filename (null terminated) */
+	/*unsigned char		d_type;*/		/*type of file*/
+};
+
+
+/* def struct DIR - different from Unix DIR */
+AXIS2_DECLARE_DATA typedef struct
+{
+	long				handle;						/* _findfirst/_findnext handle */
+	short				offset;						/* offset into directory */
+	short				finished;						/* 1 if there are not more files */
+	struct _finddata_t	fileinfo;		/* from _findfirst/_findnext */
+	char				*dirname;						/* the dir we are reading */
+	struct dirent		dent;					/* the dirent to return */
+} DIR;
+
+/* Function prototypes */
+
+/**
+  * open a directory on a given name
+  * returns a DIR if successful, or NULL if the path cannot be opened
+  */
+AXIS2_DECLARE (DIR *) opendir(const char *);
+
+/**
+  * Close the directory stream DIRP.
+  * Return 0 if successful, -1 otherwise.
+  */
+AXIS2_DECLARE(int) closedir(DIR *);
+
+/**
+  * Read a directory entry from DIRP.  Return a pointer to a `struct
+  * dirent' describing the entry, or NULL for EOF or error.
+  */
+AXIS2_DECLARE(struct dirent *) readdir(DIR *);
+
+/**
+  * Reentrant version of `readdir'
+  */
+AXIS2_DECLARE(int) readdir_r(DIR *, struct dirent *, struct dirent **);
+
+/**
+  * Rewind DIRP to the beginning of the directory.
+  */
+AXIS2_DECLARE(int) rewinddir(DIR *);
+
+/**
+  * Scan the directory DIR
+  *  Returns the number of entries selected, or -1 on error
+  */
+AXIS2_DECLARE(int) scandir(const char *_dirname, struct dirent **__namelist[], int (*selector)
(const struct dirent *entry), int (*compare) (const struct dirent **a, const struct dirent
**b));
+
+/**
+  * Compare two `struct dirent's alphabetically
+  */
+AXIS2_IMPORT int alphasort(const struct dirent **__d1, const struct dirent **__d2);
+
+#endif /* READDIR_H */

Propchange: webservices/axis2/trunk/c/modules/platforms/windows/axis2_dir_windows.h
------------------------------------------------------------------------------
    svn:executable = *

Added: webservices/axis2/trunk/c/modules/platforms/windows/axis2_uuid_gen_windows.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/platforms/windows/axis2_uuid_gen_windows.h?rev=374258&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/platforms/windows/axis2_uuid_gen_windows.h (added)
+++ webservices/axis2/trunk/c/modules/platforms/windows/axis2_uuid_gen_windows.h Wed Feb 
1 21:17:38 2006
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AXIS2_UDDI_GEN_WINDOWS_H
+#define AXIS2_UDDI_GEN_WINDOWS_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <axis2_defines.h>
+
+/* Function prototypes */
+
+/**
+  * Generate universally unique id
+  * @return a char pointer to uuid
+  */
+AXIS2_DECLARE(axis2_char_t *) axis2_platform_uuid_gen();
+
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* AXIS2_UDDI_GEN_WINDOWS_H */
\ No newline at end of file

Propchange: webservices/axis2/trunk/c/modules/platforms/windows/axis2_uuid_gen_windows.h
------------------------------------------------------------------------------
    svn:executable = *

Added: webservices/axis2/trunk/c/modules/platforms/windows/dir_windows.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/platforms/windows/dir_windows.c?rev=374258&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/platforms/windows/dir_windows.c (added)
+++ webservices/axis2/trunk/c/modules/platforms/windows/dir_windows.c Wed Feb  1 21:17:38
2006
@@ -0,0 +1,240 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <malloc.h>
+#include <string.h>
+#include <errno.h>
+
+#include "axis2_dir_windows.h"
+
+/*dirent.h style mehtods for win32*/
+
+DIR * AXIS2_CALL opendir(const char *_dirname)
+{
+	DIR		*dirp;
+	char	*filespec;
+	long	handle;
+	int		index;
+
+	filespec = malloc(strlen(_dirname) + 2 + 1);
+	strcpy(filespec, _dirname);
+	index = (int)strlen(filespec) - 1;
+	if (index >= 0 && (filespec[index] == '/' || 
+	   (filespec[index] == '\\' && !IsDBCSLeadByte(filespec[index-1]))))
+		filespec[index] = '\0';
+	strcat(filespec, "/*");
+
+	dirp = (DIR *) malloc(sizeof(DIR));
+	dirp->offset = 0;
+	dirp->finished = 0;
+
+	if ((handle = _findfirst(filespec, &(dirp->fileinfo))) < 0) 
+	{
+		if (errno == ENOENT || errno == EINVAL) 
+			dirp->finished = 1;
+		else 
+		{
+			free(dirp);
+			free(filespec);
+			return NULL;
+		}
+	}
+	dirp->dirname = strdup(_dirname);
+	dirp->handle = handle;
+	free(filespec);
+
+	return dirp;
+}
+
+int AXIS2_CALL closedir(DIR *_dirp)
+{
+	int iret = -1;
+	if (!_dirp)
+		return iret;
+	iret = _findclose(_dirp->handle);
+	if (iret == 0 && _dirp->dirname)
+		free(_dirp->dirname);
+	if (iret == 0 && _dirp)
+		free(_dirp);
+
+	return iret;
+}
+
+struct dirent * AXIS2_CALL readdir(DIR *_dirp)
+{
+	if (!_dirp || _dirp->finished)
+		return NULL;
+
+	if (_dirp->offset != 0) 
+	{
+		if (_findnext(_dirp->handle, &(_dirp->fileinfo)) < 0) 
+		{
+			_dirp->finished = 1;
+			return NULL;
+		}
+	}
+	_dirp->offset++;
+
+	strcpy(_dirp->dent.d_name, _dirp->fileinfo.name);/*, _MAX_FNAME+1);*/
+	_dirp->dent.d_ino = 1;
+	_dirp->dent.d_reclen = (unsigned short)strlen(_dirp->dent.d_name);
+	_dirp->dent.d_off = _dirp->offset;
+
+	return &(_dirp->dent);
+}
+
+int AXIS2_CALL readdir_r(DIR *_dirp, struct dirent *_entry, struct dirent **__result)
+{
+	if (!_dirp || _dirp->finished) 
+	{
+		*__result = NULL;
+		return -1;
+	}
+
+	if (_dirp->offset != 0) 
+	{
+		if (_findnext(_dirp->handle, &(_dirp->fileinfo)) < 0) 
+		{
+			_dirp->finished = 1;
+			*__result = NULL;
+			return -1;
+		}
+	}
+	_dirp->offset++;
+
+	strcpy(_dirp->dent.d_name, _dirp->fileinfo.name);/*, _MAX_FNAME+1);*/
+	_dirp->dent.d_ino = 1;
+	_dirp->dent.d_reclen = (unsigned short)strlen(_dirp->dent.d_name);
+	_dirp->dent.d_off = _dirp->offset;
+
+	memcpy(_entry, &_dirp->dent, sizeof(*_entry));
+
+	*__result = &_dirp->dent;
+
+	return 0;
+}
+
+
+int AXIS2_CALL rewinddir(DIR *dirp)
+{
+	char	*filespec;
+	long	handle;
+	int		index;
+
+	_findclose(dirp->handle);
+
+	dirp->offset = 0;
+	dirp->finished = 0;
+
+	filespec = malloc(strlen(dirp->dirname) + 2 + 1);
+	strcpy(filespec, dirp->dirname);
+	index = (int)(strlen(filespec) - 1);
+	if (index >= 0 && (filespec[index] == '/' || filespec[index] == '\\'))
+		filespec[index] = '\0';
+	strcat(filespec, "/*");
+
+	if ((handle = _findfirst(filespec, &(dirp->fileinfo))) < 0) 
+	{
+		if (errno == ENOENT || errno == EINVAL)
+			dirp->finished = 1;
+	}
+	dirp->handle = handle;
+	free(filespec);
+
+	return 0;
+}
+
+int alphasort(const struct dirent **__d1, const struct dirent **__d2)
+{
+	return strcoll((*__d1)->d_name,(*__d2)->d_name);
+}
+
+
+int AXIS2_CALL scandir(const char *_dirname, struct dirent **__namelist[], int (*selector)
(const struct dirent *entry), int (*compare) (const struct dirent **__d1, const struct dirent
**__d2))
+{
+	DIR				*dirp = NULL;
+	struct dirent	**vector = NULL;
+	struct dirent	*dp = NULL;
+	int				vector_size = 0;
+	int				nfiles = 0;
+
+	if (__namelist == NULL) 
+	{
+		return -1;
+	}
+
+	if (!(dirp = opendir(_dirname))) 
+	{
+		return -1;
+	}
+
+	while ((dp = readdir(dirp)) != NULL) 
+	{
+		int dsize = 0;
+		struct dirent *newdp = NULL;
+
+		if (selector && (*selector)(dp) == 0) 
+		{
+			continue;
+		}
+
+		if (nfiles == vector_size) 
+		{
+			struct dirent **newv;
+			if (vector_size == 0) 
+			{
+				vector_size = 10;
+			} 
+			else 
+			{ 
+				vector_size *= 2;
+			}
+
+			newv = (struct dirent **) realloc (vector, vector_size * sizeof (struct dirent *));
+			if (!newv) {
+				return -1;
+			}
+			vector = newv;
+		}
+
+		dsize = (int)sizeof (struct dirent) + (int)((strlen(dp->d_name) + 1) * sizeof(char));
+		newdp = (struct dirent *) malloc(dsize);
+
+		if (newdp == NULL) 
+		{
+			while (nfiles-- > 0) 
+			{
+				free(vector[nfiles]);
+			}
+			free(vector);
+			return -1;	
+		}
+
+		vector[nfiles++] = (struct dirent *) memcpy(newdp, dp, dsize);
+	}
+
+	closedir(dirp);
+
+	*__namelist = vector;
+
+	if (compare) 
+	{
+		qsort (*__namelist, nfiles, sizeof(struct dirent *), compare);
+	}
+
+	return nfiles;
+}

Propchange: webservices/axis2/trunk/c/modules/platforms/windows/dir_windows.c
------------------------------------------------------------------------------
    svn:executable = *

Added: webservices/axis2/trunk/c/modules/platforms/windows/uuid_gen_windows.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/platforms/windows/uuid_gen_windows.c?rev=374258&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/platforms/windows/uuid_gen_windows.c (added)
+++ webservices/axis2/trunk/c/modules/platforms/windows/uuid_gen_windows.c Wed Feb  1 21:17:38
2006
@@ -0,0 +1,52 @@
+/*
+ *   Copyright 2004-2004 The Apache Software Foundation.
+// (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#include "axis2_uuid_gen_windows.h"
+#include <rpc.h>
+#include <stdio.h>
+#include <string.h>
+
+
+AXIS2_DECLARE(axis2_char_t *)  axis2_platform_uuid_gen()
+{
+	RPC_STATUS			retval;   
+    UUID				uuid;
+	unsigned char		*str;
+	axis2_char_t		*retstr;
+	
+	retval = UuidCreate(&uuid);
+	if (retval == RPC_S_UUID_LOCAL_ONLY)
+		printf("warning - unique within computer \n");
+	else if (retval == RPC_S_UUID_NO_ADDRESS)
+	{
+		printf("error\n");
+		return NULL;
+	}
+
+	retval = UuidToStringA(&uuid,&str);
+	if (retval == RPC_S_OK)
+	{
+		retstr = strdup(str);
+		RpcStringFree(&str);
+	}
+	else if (retval == RPC_S_OUT_OF_MEMORY)
+	{
+		printf("system is out of memory \n");
+		return NULL;
+	}
+    return retstr;
+}
\ No newline at end of file

Propchange: webservices/axis2/trunk/c/modules/platforms/windows/uuid_gen_windows.c
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message