[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quran project maintainer



On 7/22/07, Nadim Shaikli <shaikli at yahoo dot com> wrote:
Ahmed, could you please provide (or upload somewhere) a patch
of the changes you note ?  This certainly should not be a single
short/effort, do please continue to contribute via patches or
directly into the repository (with the maintainers' OK).

Salam 3alikom,

sorry i didn't post this earlier, it's just that i didn't get any
replies before, so i worked alone.
i don't have any access whatsoever, so i'll just post the patch here.

couple of things,
i used to work on the source *before* the latest libspeex patches by
Ben Khalifa (used to jst use compiler -I options;), i changed my patch
in hast (it still compiles fine)

in my last message  i didn't mention something important:

MEMEORY ALLOCATION
In libquran the caller usually frees memory allocated by the library
*not* the caller! the library allocates some memory, gives you a
pointer to it, when you're done, you should free it.
under linux this (usually) will not be a problem.
under Win32 its a big problem!
under windows many versions of the C runtime library exist side by
side (it's a mess really), usually binaries compiled under mingw will
use the 6.0 runtime version.
so say you're using VC8, your programs calls the libquran dll, if you
try to free memory allocated by the library (thats malloc from version
6), using your program (thats free version8). You get an access
violation exception, coz you're freeing memory you didn't allocate.
usually it is *not* a good idea to free memory we didn't allocate,
that's why i added quran_free for use in such scenario

any way here is the patch:


? autom4te.cache
? config.sub
? libtool
? stamp-h1
Index: globals.c
===================================================================
RCS file: /home/arabeyes/cvs/projects/quran/libquran/globals.c,v
retrieving revision 1.4
diff -u -p -r1.4 globals.c
--- globals.c	21 Jul 2003 18:46:40 -0000	1.4
+++ globals.c	23 Jul 2007 03:38:05 -0000
@@ -1,6 +1,6 @@
/* libquran - Holy Quran library
 * Copyright (C) 2002, 2003 Arabeyes, Mohammad DAMT
- * $Id: globals.c,v 1.4 2003-07-21 18:46:40 yousif Exp $
+ * $Id: globals.c,v 1.4 2003/07/21 18:46:40 yousif Exp $
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
@@ -22,6 +22,12 @@

#include <string.h>

+#ifdef _WIN32
+#include<dirent.h>
+#include<stdlib.h>
+#include<sys/types.h>
+#endif
+
#include "quran.h"
#include "globals.h"

@@ -114,3 +120,91 @@ int text_file_to_index(int lang, const c
	}
	return LIBQURAN_NO_SUCH_TEXT;
}
+
+#ifdef _WIN32
+
+int scandir(const char *dir, struct dirent ***namelist,
+            int (*select)(const struct dirent *),
+            int (*compar)(const struct dirent **, const struct dirent **)) {
+  DIR *d;
+  struct dirent *entry;
+  register int i=0;
+  size_t entrysize;
+
+  if ((d=opendir(dir)) == NULL)
+     return(-1);
+
+  *namelist=NULL;
+  while ((entry=readdir(d)) != NULL)
+  {
+    if (select == NULL || (select != NULL && (*select)(entry)))
+    {
+      *namelist=(struct dirent **)realloc((void *)(*namelist),
+                 (size_t)((i+1)*sizeof(struct dirent *)));
+	if (*namelist == NULL) return(-1);
+	entrysize=sizeof(struct dirent)-sizeof(entry->d_name)+strlen(entry->d_name)+1;
+	(*namelist)[i]=(struct dirent *)malloc(entrysize);
+	if ((*namelist)[i] == NULL) return(-1);
+	memcpy((*namelist)[i], entry, entrysize);
+	i++;
+    }
+  }
+  if (closedir(d)) return(-1);
+  if (i == 0) return(-1);
+  if (compar != NULL)
+    qsort((void *)(*namelist), (size_t)i, sizeof(struct dirent *), compar);
+
+  return(i);
+}
+
+int alphasort(const struct dirent **a, const struct dirent **b) {
+  return(strcmp((*a)->d_name, (*b)->d_name));
+}
+
+
+char * strndup (const char *s, size_t n) {
+  size_t len = strnlen (s, n);
+  char *new = malloc (len + 1);
+
+  if (new == NULL)
+    return NULL;
+
+  new[len] = '\0';
+  return (char *) memcpy (new, s, len);
+}
+
+size_t strnlen (const char *string, size_t maxlen) {
+  const char *end = memchr (string, '\0', maxlen);
+  return end ? (size_t) (end - string) : maxlen;
+}
+
+
+
+char *strtok_r(char *str, const char *delim, char **saveptr)
+{
+    char *token;
+    if (str)
+        *saveptr = str;
+    token = *saveptr;
+
+    if (!token)
+        return NULL;
+
+    token += strspn(token, delim);
+    *saveptr = strpbrk(token, delim);
+    if (*saveptr)
+        *(*saveptr)++ = '\0';
+
+    return *token ? token : NULL;
+}
+
+LIBQURAN_SCOPE void free_q(void* memblock) {
+	free(memblock);
+}
+
+LIBQURAN_SCOPE void *malloc_q(size_t size) {
+	return malloc(size);
+}
+
+#endif
+
Index: globals.h
===================================================================
RCS file: /home/arabeyes/cvs/projects/quran/libquran/globals.h,v
retrieving revision 1.5
diff -u -p -r1.5 globals.h
--- globals.h	8 Jul 2003 03:59:36 -0000	1.5
+++ globals.h	23 Jul 2007 03:38:05 -0000
@@ -1,6 +1,6 @@
/* libquran - Holy Quran library
 * Copyright (C) 2002, 2003 Arabeyes, Mohammad DAMT
- * $Id: globals.h,v 1.5 2003-07-08 03:59:36 damt Exp $
+ * $Id: globals.h,v 1.5 2003/07/08 03:59:36 damt Exp $
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
@@ -41,6 +41,14 @@ int langcode_to_index(const char *, libq
int audiopackage_to_index(int, const char *, libquran_ctx *);
int text_file_to_index(int, const char *, libquran_ctx *);

+#ifdef _WIN32
+int scandir(const char *, struct dirent ***, int (*)(const struct
dirent *), int (*)(const struct dirent **, const struct dirent **));
+int alphasort(const struct dirent **, const struct dirent **);
+char * strndup (const char *, size_t);
+size_t strnlen (const char *, size_t);
+char *strtok_r(char *, const char *, char **);
+#endif
+
#ifdef __cplusplus
}
#endif
Index: init.c
===================================================================
RCS file: /home/arabeyes/cvs/projects/quran/libquran/init.c,v
retrieving revision 1.7
diff -u -p -r1.7 init.c
--- init.c	29 Dec 2005 19:03:49 -0000	1.7
+++ init.c	23 Jul 2007 03:38:05 -0000
@@ -1,6 +1,6 @@
/* libquran - Holy Quran library
 * Copyright (C) 2002, 2003 Arabeyes, Mohammad DAMT
- * $Id: init.c,v 1.7 2005-12-29 19:03:49 yousif Exp $
+ * $Id: init.c,v 1.7 2005/12/29 19:03:49 yousif Exp $
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
@@ -51,7 +51,7 @@
 * \sa quran_free(), LIBQURAN_SUCCEEDED, LIBQURAN_XML_FAILED,
LIBQURAN_NO_DATADIR, LIBQURAN_NO_LANGS, LIBQURAN_NO_CONF,
LIBQURAN_NOT_INITIALIZED, LIBQURAN_ALREADY_INITIALIZED
 **/

-int quran_init(libquran_ctx * ctx) {
+LIBQURAN_SCOPE int quran_init(libquran_ctx * ctx) {

	DIR *dir;
	int return_value;
@@ -105,7 +105,7 @@ int quran_init(libquran_ctx * ctx) {
 *
 * \sa quran_init()
 **/
-void quran_free(libquran_ctx *ctx) {
+LIBQURAN_SCOPE void quran_free(libquran_ctx *ctx) {

	int i,j;

@@ -184,18 +184,27 @@ int load_conf_file(libquran_ctx *ctx) {
		 file_handle = fopen("/etc/quran","r");
	}
#else
-#ifdef _MINGW
+#ifdef _WIN32
	file_handle = fopen("C:\\WINDOWS\\quran.rc","r");
	if (file_handle == NULL) {
		file_handle = fopen("C:\\WINNT\\quran.rc","r");
	}
-#endif // _MINGW
+#endif // _WIN32
#endif // _!WIN32
	if (file_handle==NULL) {
		/* LibQuran configuration file not found */
		return LIBQURAN_NO_CONF;
	}
+	
+#ifndef _WIN32	
	getline(&temp, &n, file_handle);
+#else
+#ifdef _WIN32
+	temp = (char *)malloc(1000);
+	fgets(temp, 1000, file_handle);
+#endif // _WIN32
+#endif // _!WIN32
+
	fclose(file_handle);
	file_handle = NULL;
	if (temp) {
@@ -204,7 +213,7 @@ int load_conf_file(libquran_ctx *ctx) {
		trimmed = temp;
	 	/* left trim whitespace */
		for (n = 0; n < len ; n --) {
-			if (index (whitespace, trimmed [n]) != NULL) {
+			if (strchr (whitespace, trimmed [n]) != NULL) {
				start ++;
			} else {
	 			break;
@@ -217,7 +226,7 @@ int load_conf_file(libquran_ctx *ctx) {

	 	/* right trim whitespace */
		for (n = len - 1; n >= 0 ; n --) {
-			if (index (whitespace, trimmed [n]) != NULL) {
+			if (strchr (whitespace, trimmed [n]) != NULL) {
	 			len --;
			} else {
	 			break;
@@ -485,7 +494,7 @@ int generate_languages_list(libquran_ctx
			char *temp = malloc (strlen (ctx->libquran.data_directory) +
strlen (lang_list[i]->d_name) + 2);

			if (temp) {
-#if defined(_WIN32) && defined (_MINGW)
+#if defined(_WIN32)
				sprintf (temp, "%s\\%s\0", ctx->libquran.data_directory,
lang_list[i]->d_name);
#else
				sprintf (temp, "%s/%s\0", ctx->libquran.data_directory,
lang_list[i]->d_name);
@@ -511,7 +520,7 @@ int generate_languages_list(libquran_ctx
						     1 /* '\0' */
			    			    );

-#if defined(_WIN32) && defined(_MINGW)
+#if defined(_WIN32)
		    sprintf(conf_xml,"%s\\%s\\conf.xml",
ctx->libquran.data_directory, lang_list[i]->d_name);
#else
		    sprintf(conf_xml,"%s/%s/conf.xml",
ctx->libquran.data_directory, lang_list[i]->d_name);
@@ -605,7 +614,7 @@ int select_lang_package(const char *dir,
	temp = malloc (strlen (dir) + 10);
	memset (temp, 0, strlen (dir) + 10);
	strncpy (temp, dir, strlen (dir));
-#if defined(_WIN32) && defined(_MINGW)
+#if defined(_WIN32)
	strncat(temp, "\\conf.xml", 9);
#else
	strncat(temp, "/conf.xml", 9);
Index: init.h
===================================================================
RCS file: /home/arabeyes/cvs/projects/quran/libquran/init.h,v
retrieving revision 1.3
diff -u -p -r1.3 init.h
--- init.h	8 Jul 2003 03:59:36 -0000	1.3
+++ init.h	23 Jul 2007 03:38:05 -0000
@@ -1,6 +1,6 @@
/* libquran - Holy Quran library
 * Copyright (C) 2002, 2003 Arabeyes, Mohammad DAMT
- * $Id: init.h,v 1.3 2003-07-08 03:59:36 damt Exp $
+ * $Id: init.h,v 1.3 2003/07/08 03:59:36 damt Exp $
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
Index: quran.h
===================================================================
RCS file: /home/arabeyes/cvs/projects/quran/libquran/quran.h,v
retrieving revision 1.19
diff -u -p -r1.19 quran.h
--- quran.h	18 Jul 2007 23:22:41 -0000	1.19
+++ quran.h	23 Jul 2007 03:38:05 -0000
@@ -1,6 +1,6 @@
/* libquran - Holy Quran library
 * Copyright (C) 2002, 2003 Arabeyes, Mohammad DAMT
- * $Id: quran.h,v 1.19 2007-07-18 23:22:41 adn Exp $
+ * $Id: quran.h,v 1.18 2005/12/29 19:03:49 yousif Exp $
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
@@ -37,6 +37,22 @@ extern "C" {
#include <ogg/ogg.h>
#endif

+
+#ifdef _WIN32
+#ifdef DLL_EXPORT
+#define LIBQURAN_SCOPE __declspec(dllexport)
+#else
+#ifdef LIBQURAN_DLL_IMPORT
+#define LIBQURAN_SCOPE extern __declspec(dllimport)
+#endif
+#endif
+#endif
+
+#ifndef LIBQURAN_SCOPE
+#define LIBQURAN_SCOPE extern
+#endif
+
+
/*! frame size */
#define MAX_FRAME_SIZE 2000

@@ -53,22 +69,22 @@ extern "C" {
#define BUFF_SIZE 10000

/* return values that can be returned by quran_init() */
-#define LIBQURAN_SUCCEEDED              0   /*!< Initialization succeeded.  */
-#define LIBQURAN_XML_FAILED            -1   /*!< Failed initializing
the XML Parser. */
-#define LIBQURAN_NO_DATADIR            -2   /*!< Failed opening the
data directory. */
-#define LIBQURAN_NO_LANGS              -3   /*!< Could not find any
quran translation. */
-#define LIBQURAN_NO_CONF               -4   /*!< Could not find the
configuration file. */
-#define LIBQURAN_NOT_INITIALIZED       -5   /*!< Failed initializing. */
-#define LIBQURAN_ALREADY_INITIALIZED   -6   /*!< 'libquran' is
already initialized. */
-#define LIBQURAN_INVALID_PACKAGE_CONF  -8   /*!< Failed opening the
conf.xml file for a language package. */
-#define LIBQURAN_NO_SUCH_LANG	       -9   /*!< The language requested
is not available. */
-#define LIBQURAN_NO_SUCH_AUDIO_PACKAGE -10  /*!< The audio package
requested is not available. */
-#define LIBQURAN_NO_SUCH_TEXT	       -11  /*!< The text/translation
requested is not available. */
-#define LIBQURAN_NO_MEM				   -12 /*!< not enough memory */
-#define LIBQURAN_FILE_OPEN_FAILED      -13 /*!< error opening file */
+#define LIBQURAN_SUCCEEDED                0   /*!< Initialization
succeeded.  */
+#define LIBQURAN_XML_FAILED              -1   /*!< Failed
initializing the XML Parser. */
+#define LIBQURAN_NO_DATADIR              -2   /*!< Failed opening the
data directory. */
+#define LIBQURAN_NO_LANGS                -3   /*!< Could not find any
quran translation. */
+#define LIBQURAN_NO_CONF                 -4   /*!< Could not find the
configuration file. */
+#define LIBQURAN_NOT_INITIALIZED         -5   /*!< Failed initializing. */
+#define LIBQURAN_ALREADY_INITIALIZED     -6   /*!< 'libquran' is
already initialized. */
+#define LIBQURAN_INVALID_PACKAGE_CONF    -8   /*!< Failed opening the
conf.xml file for a language package. */
+#define LIBQURAN_NO_SUCH_LANG	           -9   /*!< The language
requested is not available. */
+#define LIBQURAN_NO_SUCH_AUDIO_PACKAGE   -10  /*!< The audio package
requested is not available. */
+#define LIBQURAN_NO_SUCH_TEXT	           -11  /*!< The
text/translation requested is not available. */
+#define LIBQURAN_NO_MEM				           -12 /*!< not enough memory */
+#define LIBQURAN_FILE_OPEN_FAILED        -13 /*!< error opening file */
/* return values that can be returned by quran_search_* */
#define LIBQURAN_ERROR_INVALID_ARGUMENTS -14
-#define LIBQURAN_ERROR_OUT_OF_RANGE -15
+#define LIBQURAN_ERROR_OUT_OF_RANGE      -15

/*! Match exact (100 %). Used for similarity */
#define EXACT_MATCH 100
@@ -204,27 +220,29 @@ typedef struct {
} libquran_ctx;

/* prototypes for published functions */
-int quran_init(libquran_ctx *);
-void quran_free();
-quran *quran_open(const char *, const char *, libquran_ctx *);
-quran *quran_open_index(int, int, libquran_ctx *);
-char *quran_read_verse(const quran *, int, int, libquran_ctx *);
-void quran_close(quran *, libquran_ctx *);
-ayainfo * quran_verse_info (int , int );
-sura_info * quran_sura_info(int);
-char * quran_recitor_name(const char *, const char *);
-quran_audio * quran_audio_open(const char *, const char *, const int,
const int, libquran_ctx *);
-quran_audio * quran_audio_open_index(int, int, const int, const int,
libquran_ctx *);
-int quran_audio_play(quran_audio *, int (*)(quran_audio *));
-void quran_audio_stop(quran_audio *);
-void quran_audio_close(quran_audio *, libquran_ctx *);
-int quran_search_quran(quran *, const char *, int, int, libquran_ctx *);
-int quran_search_sura(quran *, const char *, int, int, int, libquran_ctx *);
-int quran_search_hezb(quran *, const char *, int, int, int, libquran_ctx *);
-int quran_search_juzz(quran *, const char *, int, int, int, libquran_ctx *);
-int quran_search_part(quran *, const char *, int, int, int, int, int,
int, libquran_ctx *);
-results_struct **quran_get_search_results(libquran_ctx *);
-void quran_free_search_results(libquran_ctx *);
+LIBQURAN_SCOPE int              quran_init(libquran_ctx *);
+LIBQURAN_SCOPE void             quran_free();
+LIBQURAN_SCOPE quran*           quran_open(const char *, const char
*, libquran_ctx *);
+LIBQURAN_SCOPE quran*           quran_open_index(int, int, libquran_ctx *);
+LIBQURAN_SCOPE char*            quran_read_verse(const quran *, int,
int, libquran_ctx *);
+LIBQURAN_SCOPE void             quran_close(quran *, libquran_ctx *);
+LIBQURAN_SCOPE ayainfo*         quran_verse_info (int , int );
+LIBQURAN_SCOPE sura_info*       quran_sura_info(int);
+LIBQURAN_SCOPE quran_audio*     quran_audio_open(const char *, const
char *, const int, const int, libquran_ctx *);
+LIBQURAN_SCOPE quran_audio*     quran_audio_open_index(int, int,
const int, const int, libquran_ctx *);
+LIBQURAN_SCOPE int              quran_audio_play(quran_audio *, int
(*)(quran_audio *));
+LIBQURAN_SCOPE void             quran_audio_stop(quran_audio *);
+LIBQURAN_SCOPE void             quran_audio_close(quran_audio *,
libquran_ctx *);
+LIBQURAN_SCOPE int              quran_search_quran(quran *, const
char *, int, int, libquran_ctx *);
+LIBQURAN_SCOPE int              quran_search_sura(quran *, const char
*, int, int, int, libquran_ctx *);
+LIBQURAN_SCOPE int              quran_search_hezb(quran *, const char
*, int, int, int, libquran_ctx *);
+LIBQURAN_SCOPE int              quran_search_juzz(quran *, const char
*, int, int, int, libquran_ctx *);
+LIBQURAN_SCOPE int              quran_search_part(quran *, const char
*, int, int, int, int, int, int, libquran_ctx *);
+LIBQURAN_SCOPE results_struct** quran_get_search_results(libquran_ctx *);
+LIBQURAN_SCOPE void             quran_free_search_results(libquran_ctx *);
+LIBQURAN_SCOPE void 						free_q(void*);
+LIBQURAN_SCOPE void*						malloc_q(size_t);
+//LIBQURAN_SCOPE char*            quran_recitor_name(const char *,
const char *);


#ifdef __cplusplus
Index: quran_install_component.c
===================================================================
RCS file: /home/arabeyes/cvs/projects/quran/libquran/quran_install_component.c,v
retrieving revision 1.1
diff -u -p -r1.1 quran_install_component.c
--- quran_install_component.c	29 Dec 2005 19:03:49 -0000	1.1
+++ quran_install_component.c	23 Jul 2007 03:38:05 -0000
@@ -1,6 +1,6 @@
/* libquran - Holy Quran library
 * Copyright (C) 2002, 2005 Arabeyes, Mohammad DAMT
- * $Id: quran_install_component.c,v 1.1 2005-12-29 19:03:49 yousif Exp $
+ * $Id: quran_install_component.c,v 1.1 2005/12/29 19:03:49 yousif Exp $
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
@@ -35,7 +35,7 @@
 *    (i.e. the actual quran.ar.xml file)
 */

-
+#ifndef _WIN32

#include <stdio.h>
#include <string.h>
@@ -368,3 +368,13 @@ char * create_lang_dir(char * language_c
	// Should never get here
	return NULL;
}
+
+#endif //!_WIN32
+
+#ifdef _WIN32
+
+int main(int argc, char * argv[]) {
+	return 0;	
+}
+
+#endif
Index: quranaudio.c
===================================================================
RCS file: /home/arabeyes/cvs/projects/quran/libquran/quranaudio.c,v
retrieving revision 1.6
diff -u -p -r1.6 quranaudio.c
--- quranaudio.c	18 Jul 2007 23:22:41 -0000	1.6
+++ quranaudio.c	23 Jul 2007 03:38:06 -0000
@@ -1,6 +1,6 @@
/* libquran - Holy Quran library
 * Copyright (C) 2002, 2003 Arabeyes, Mohammad DAMT
- * $Id: quranaudio.c,v 1.6 2007-07-18 23:22:41 adn Exp $
+ * $Id: quranaudio.c,v 1.5 2005/12/29 19:03:49 yousif Exp $
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
@@ -52,7 +52,7 @@
 *
 * \sa quran_audio_open_index(), quran_audio_play(),
quran_audio_stop(), quran_audio_close()
 **/
-quran_audio *quran_audio_open(const char *lang, const char *package,
const int sura_no, const int aya_no, libquran_ctx *ctx) {
+LIBQURAN_SCOPE quran_audio *quran_audio_open(const char *lang, const
char *package, const int sura_no, const int aya_no, libquran_ctx *ctx)
{

	int lang_index;
	int audio_package_index;
@@ -97,7 +97,7 @@ quran_audio *quran_audio_open(const char
 *
 * \sa quran_audio_open(), quran_audio_play(), quran_audio_stop(),
quran_audio_close()
 **/
-quran_audio *quran_audio_open_index(const int lang, const int audio,
const int sura_no, const int aya_no, libquran_ctx *ctx) {
+LIBQURAN_SCOPE quran_audio *quran_audio_open_index(const int lang,
const int audio, const int sura_no, const int aya_no, libquran_ctx
*ctx) {

	quran_audio *qa=NULL;
	char *audio_filename;
@@ -127,10 +127,12 @@ quran_audio *quran_audio_open_index(cons
						strlen(ctx->libquran.data_directory) +
						strlen(ctx->libquran.avail_langs[lang].code) +
						3 /* 3 slashes */ +
-						strlen(ctx->libquran.avail_langs[lang].avail_audio_packages[audio].filename));
+						strlen(ctx->libquran.avail_langs[lang].avail_audio_packages[audio].filename)
+
+						1 /* '\0' */
+						);

	/* Generate this absolute path of the filename */
-#if defined(_WIN32) && defined(_MINGW)
+#if defined(_WIN32)
	sprintf(audio_filename, "%s\\%s\\%s\\s%03da%03d.spx",
ctx->libquran.data_directory,
#else
	sprintf(audio_filename, "%s/%s/%s/s%03da%03d.spx",
ctx->libquran.data_directory,
@@ -142,7 +144,7 @@ quran_audio *quran_audio_open_index(cons
	qa = (quran_audio *)malloc(sizeof(quran_audio));

	/* Open the Speex file and save its handle in quran_audio struct */
-	qa->spxfile = fopen(audio_filename,"r");
+	qa->spxfile = fopen(audio_filename,"rb");

	/* The absolute path of the filename is not needed anymore, so free it */
	free(audio_filename);
@@ -183,7 +185,7 @@ quran_audio *quran_audio_open_index(cons
 *
 * \sa quran_audio_open(), quran_audio_stop(), quran_audio_close()
 **/
-int quran_audio_play(quran_audio *qa, int (*callback)(quran_audio *)) {
+LIBQURAN_SCOPE int quran_audio_play(quran_audio *qa, int
(*callback)(quran_audio *)) {

	/* The callback function must exist */
	if (callback==NULL) {
@@ -212,7 +214,7 @@ int quran_audio_play(quran_audio *qa, in
 *
 * \sa quran_audio_open(), quran_audio_play(), quran_audio_close()
 **/
-void quran_audio_stop(quran_audio *qa) {
+LIBQURAN_SCOPE void quran_audio_stop(quran_audio *qa) {

	if (qa->playing == 1) {
		qa->playing = 0;
@@ -228,7 +230,7 @@ void quran_audio_stop(quran_audio *qa) {
 * \param libquran_ctx quran context
 * \sa quran_audio_open()
 **/
-void quran_audio_close(quran_audio *qa, libquran_ctx *ctx) {
+LIBQURAN_SCOPE void quran_audio_close(quran_audio *qa, libquran_ctx *ctx) {

	// TODO: Is it not better to check first if the audio is closed?
	// You know, accessing a deleted object can cause some beautiful crashes ;-)
Index: qurandata.c
===================================================================
RCS file: /home/arabeyes/cvs/projects/quran/libquran/qurandata.c,v
retrieving revision 1.8
diff -u -p -r1.8 qurandata.c
--- qurandata.c	21 Jul 2003 18:46:40 -0000	1.8
+++ qurandata.c	23 Jul 2007 03:38:06 -0000
@@ -1,6 +1,6 @@
/* libquran - Holy Quran library
 * Copyright (C) 2002, 2003 Arabeyes, Mohammad DAMT
- * $Id: qurandata.c,v 1.8 2003-07-21 18:46:40 yousif Exp $
+ * $Id: qurandata.c,v 1.8 2003/07/21 18:46:40 yousif Exp $
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
@@ -97,7 +97,7 @@ const int aya_numbers[AMOUNT_SURAS]= {7,
 *
 * \sa quran_open_index(), quran_read_verse(), quran_close()
 **/
-quran *quran_open(const char * lang, const char * text_file,
libquran_ctx *ctx) {
+LIBQURAN_SCOPE quran *quran_open(const char * lang, const char *
text_file, libquran_ctx *ctx) {

	int lang_index;
	int text_file_index;
@@ -139,7 +139,7 @@ quran *quran_open(const char * lang, con
 *
 * \sa quran_open(), quran_read_verse(), quran_close()
 **/
-quran * quran_open_index(const int lang, const int text, libquran_ctx *ctx) {
+LIBQURAN_SCOPE quran * quran_open_index(const int lang, const int
text, libquran_ctx *ctx) {

	quran *temp;
	char *location;
@@ -169,7 +169,8 @@ quran * quran_open_index(const int lang,
	location = (char *)malloc(strlen(ctx->libquran.data_directory) +
				  strlen(ctx->libquran.avail_langs[lang].code) +
				  strlen(ctx->libquran.avail_langs[lang].avail_texts[text].filename) +
-				  2  /* 2 slashes */
+				  2 +  /* 2 slashes */
+				  1   /* '\0' */
				 );


@@ -182,7 +183,7 @@ quran * quran_open_index(const int lang,
	}

	/* Quran XML file path */
-#if defined(_WIN32) && defined(_MINGW)
+#if defined(_WIN32)
	sprintf(location,"%s\\%s\\%s", ctx->libquran.data_directory,
#else
	sprintf(location,"%s/%s/%s", ctx->libquran.data_directory,
@@ -202,6 +203,7 @@ quran * quran_open_index(const int lang,
	/* Set properties */
	temp->credits = NULL;
	temp->has_search_tag = 0;
+	temp->encoding = NULL;

	/* Load Quran from the opended file */
	build_sura(temp);
@@ -226,7 +228,7 @@ quran * quran_open_index(const int lang,
 *
 * \sa quran_open(), quran_close()
 **/
-char *quran_read_verse(const quran *q, int sura_no, int aya_no,
libquran_ctx *ctx) {
+LIBQURAN_SCOPE char *quran_read_verse(const quran *q, int sura_no,
int aya_no, libquran_ctx *ctx) {

	int i;
	char *aya_read=NULL;
@@ -278,7 +280,7 @@ char *quran_read_verse(const quran *q, i
 *
 * \sa quran_read_verse(), quran_close()
 **/
-void quran_close(quran *q, libquran_ctx *ctx) {
+LIBQURAN_SCOPE void quran_close(quran *q, libquran_ctx *ctx) {

	int i;

@@ -326,7 +328,7 @@ void quran_close(quran *q, libquran_ctx
 *
 * \sa quran_verse_info()
 **/
-sura_info *quran_sura_info(int sura_no) {
+LIBQURAN_SCOPE sura_info *quran_sura_info(int sura_no) {
	
	sura_info *temp = (sura_info*) malloc(sizeof(sura_info));

@@ -357,7 +359,7 @@ sura_info *quran_sura_info(int sura_no)
 *
 * \sa quran_sura_info()
 **/
-ayainfo * quran_verse_info(int sura_no, int aya_no) {
+LIBQURAN_SCOPE ayainfo * quran_verse_info(int sura_no, int aya_no) {
	
	int count = 0;
	int tempcalc = 0;
Index: search.c
===================================================================
RCS file: /home/arabeyes/cvs/projects/quran/libquran/search.c,v
retrieving revision 1.6
diff -u -p -r1.6 search.c
--- search.c	8 Jul 2003 03:59:36 -0000	1.6
+++ search.c	23 Jul 2007 03:38:06 -0000
@@ -1,6 +1,6 @@
/* libquran - Holy Quran library
 * Copyright (C) 2002, 2003 Arabeyes, Mohammad DAMT
- * $Id: search.c,v 1.6 2003-07-08 03:59:36 damt Exp $
+ * $Id: search.c,v 1.6 2003/07/08 03:59:36 damt Exp $
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
@@ -52,7 +52,7 @@
 * \sa searchTypes, EXACT_MATCH, quran_get_search_results(),
quran_free_search_results(),
 *     quran_search_sura(), quran_search_juzz(), quran_search_hezb(),
quran_search_part()
 **/
-int quran_search_quran(quran *q, const char *search_string, int type,
int similarity, libquran_ctx *ctx) {
+LIBQURAN_SCOPE int quran_search_quran(quran *q, const char
*search_string, int type, int similarity, libquran_ctx *ctx) {

	int begin_sura, begin_aya, end_sura, end_aya;

@@ -82,7 +82,7 @@ int quran_search_quran(quran *q, const c
 * \sa searchTypes, EXACT_MATCH, quran_get_search_results(),
quran_free_search_results(),
 *     quran_search_quran(), quran_search_juzz(),
quran_search_hezb(), quran_search_part()
 **/
-int quran_search_sura(quran *q, const char *search_string, int
sura_no, int type, int similarity, libquran_ctx *ctx) {
+LIBQURAN_SCOPE int quran_search_sura(quran *q, const char
*search_string, int sura_no, int type, int similarity, libquran_ctx
*ctx) {

	int begin_sura, begin_aya, end_sura, end_aya;

@@ -117,7 +117,7 @@ int quran_search_sura(quran *q, const ch
 * \sa searchTypes, EXACT_MATCH, quran_get_search_results(),
quran_free_search_results(),
 *     quran_search_quran(), quran_search_sura(),
quran_search_hezb(), quran_search_part()
 **/
-int quran_search_juzz(quran *q, const char *search_string, int
juzz_no, int type, int similarity, libquran_ctx *ctx) {
+LIBQURAN_SCOPE int quran_search_juzz(quran *q, const char
*search_string, int juzz_no, int type, int similarity, libquran_ctx
*ctx) {

	int begin_sura, begin_aya, end_sura, end_aya;

@@ -157,7 +157,7 @@ int quran_search_juzz(quran *q, const ch
 * \sa searchTypes, EXACT_MATCH, quran_get_search_results(),
quran_free_search_results(),
 *     quran_search_quran(), quran_search_sura(),
quran_search_juzz(), quran_search_part()
 **/
-int quran_search_hezb(quran *q, const char *search_string, int
hezb_no, int type, int similarity, libquran_ctx *ctx) {
+LIBQURAN_SCOPE int quran_search_hezb(quran *q, const char
*search_string, int hezb_no, int type, int similarity, libquran_ctx
*ctx) {

	int begin_sura, begin_aya, end_sura, end_aya;
	
@@ -200,7 +200,7 @@ int quran_search_hezb(quran *q, const ch
 * \sa searchTypes, EXACT_MATCH, quran_get_search_results(),
quran_free_search_results(),
 *     quran_search_quran(), quran_search_sura(),
quran_search_juzz(), quran_search_hezb()
 **/
-int quran_search_part(quran *q, const char *search_string, int
begin_sura, int begin_aya, int end_sura, int end_aya, int type, int
similarity, libquran_ctx *ctx) {
+LIBQURAN_SCOPE int quran_search_part(quran *q, const char
*search_string, int begin_sura, int begin_aya, int end_sura, int
end_aya, int type, int similarity, libquran_ctx *ctx) {

	int match_count = 0;
	int current_aya_no = 0;
@@ -308,7 +308,7 @@ int quran_search_part(quran *q, const ch
 * \sa quran_free_search_results(), quran_search_quran(), quran_search_sura(),
 *     quran_search_juzz(), quran_search_hezb(), quran_search_part()
 **/
-results_struct **quran_get_search_results(libquran_ctx *ctx) {
+LIBQURAN_SCOPE results_struct **quran_get_search_results(libquran_ctx *ctx) {

	return ctx->results;
}
@@ -321,7 +321,7 @@ results_struct **quran_get_search_result
 * \sa quran_get_search_results(), quran_search_quran(), quran_search_sura(),
 *     quran_search_juzz(), quran_search_hezb(), quran_search_part()
 **/
-void quran_free_search_results(libquran_ctx *ctx) {
+LIBQURAN_SCOPE void quran_free_search_results(libquran_ctx *ctx) {

	results_struct *results_current, *results_delete;

Index: testquran.c
===================================================================
RCS file: /home/arabeyes/cvs/projects/quran/libquran/testquran.c,v
retrieving revision 1.15
diff -u -p -r1.15 testquran.c
--- testquran.c	29 Dec 2005 19:03:49 -0000	1.15
+++ testquran.c	23 Jul 2007 03:38:06 -0000
@@ -1,3 +1,7 @@
+#ifdef _WIN32
+#define LIBQURAN_DLL_IMPORT
+#endif
+
#include <stdio.h>

#include <quran.h>
@@ -27,7 +31,7 @@ int main() {
	fprintf(stdout,"Sura 1 Verse 1: %s\n",a);
	free(a);
	quran_close(q, &ctx);
-	quran_free();
+	quran_free(&ctx);
	return 0;
}