r5884 - software/gofind

Miriam Ruiz baby-guest at alioth.debian.org
Thu Feb 21 09:32:44 UTC 2008


Author: baby-guest
Date: 2008-02-21 09:32:44 +0000 (Thu, 21 Feb 2008)
New Revision: 5884

Added:
   software/gofind/LICENSE
   software/gofind/common.h
   software/gofind/slre.txt
   software/gofind/utf8.h
Modified:
   software/gofind/CuTest.sh
   software/gofind/Makefile
   software/gofind/filter.cpp
   software/gofind/slre.c
   software/gofind/slre.h
   software/gofind/taghandler.cpp
   software/gofind/utf8.c
Log:
Initial development for the shell/console part of the system.



Modified: software/gofind/CuTest.sh
===================================================================
--- software/gofind/CuTest.sh	2008-02-21 09:29:06 UTC (rev 5883)
+++ software/gofind/CuTest.sh	2008-02-21 09:32:44 UTC (rev 5884)
@@ -38,6 +38,7 @@
 cat $FILES | grep '^TEST_FUNCTION Test' | 
     sed -e 's/(.*$//' \
         -e 's/$/(CuTest*);/' \
+        -e 's/^TEST_FUNCTION /void /' \
         -e 's/^/extern /'
 
 echo \

Added: software/gofind/LICENSE
===================================================================
--- software/gofind/LICENSE	                        (rev 0)
+++ software/gofind/LICENSE	2008-02-21 09:32:44 UTC (rev 5884)
@@ -0,0 +1,54 @@
+Copyright statements:
+
+Copyright (C) 2007  Miriam Ruiz <little_miry at yahoo.es>
+
+ColResizeBrowser (C) Greg Ercolano <erco at seriss.com>
+URL: http://seriss.com/people/erco/fltk/
+
+VersatileBrowser uses ColResizeBrowser, written by Greg Ercolano, licensed
+under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+
+
+License applicable to all the code inside this directory:
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This package 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this package; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+
+
+From:  "Greg Ercolano" <erco at seriss.com>
+To:    Miriam Ruiz <little.miry at gmail.com>
+Date:  21-jun-2007 22:04
+Topic: "Re: Question about ColResizeBrowser"
+
+Miriam Ruiz wrote:
+> Hi,
+>
+> I found your example "An Interactively Resizable Fl_Browser" in
+> http://seriss.com/people/erco/fltk/ , and I want to use it as a base for
+> developing a GPL'ed package viewer for Debian. I don't know under which
+> license you let it use, so I have to ask you first. Will you let me use,
+> modify and distribute my code based on yours under the GPL license? (I'll
+> keep you in the copyright notice, of course).
+
+Hi Miry,
+
+Sure, you have my permission to use it in your GPL'd app, no problem.
+
+Sure, keep the attribution in the header, and assume it's all under
+GPL. Add a GPL header if you like; I would put GPL headers on them
+if it wasn't for the headers would make the examples too large.

Modified: software/gofind/Makefile
===================================================================
--- software/gofind/Makefile	2008-02-21 09:29:06 UTC (rev 5883)
+++ software/gofind/Makefile	2008-02-21 09:32:44 UTC (rev 5884)
@@ -1,27 +1,36 @@
-OBJS= test_aux.o test_Engine.o test_Environment.o test_filter.o \
-	test_goplay.o test_pkgbrowser.o test_taghandler.o \
-	test_ui.o test_windows.o CuTest.o test_main.o
+all: gofind
 
-CFLAGS= -O2 -g -I.. -I/usr/include/tagcoll-2.0.7 `fltk-config --cxxflags --use-images` -Wall
-LDFLAGS= -lept -lept-core -lapt-pkg -lxapian -ltagcoll2 -lz -lwibble `fltk-config --ldflags --use-images`
+CFLAGS= -O2 -g `pkg-config libtagcoll2 --cflags` -Wall -Werror
+LDFLAGS= 
+LIBS= -lept -lept-core -lapt-pkg -lxapian `pkg-config libtagcoll2 --libs`
 
-test: $(OBJS)
-	g++ -o $@ $(LDFLAGS) $+
+OBJS= Engine.o Environment.o filter.o gofind.o taghandler.o slre.o utf8.o
 
-test_main.c:
+gofind: $(OBJS)
+	g++ -o $@ $+ $(LDFLAGS) $(LIBS)
+
+%.o: %.cpp
+	g++ -o $@ -c $+ $(CFLAGS)
+
+%.o: %.c
+	gcc -o $@ -c $+ $(CFLAGS)
+
+TEST_OBJS=  filter.test.o taghandler.test.o slre.test.o utf8.test.o CuTest.o test.o
+
+test: $(TEST_OBJS)
+	g++ -o $@ $+ $(LDFLAGS) $(LIBS)
+
+test.c:
 	sh CuTest.sh > $@
 
-test_main.o: test_main.c
-	gcc -o $@ $(CFLAGS) -DUNIT_TEST -c $+
+test.o: test.c
+	gcc -o $@ -DUNIT_TEST -c $+ $(CFLAGS)
 
-test_%.o: %.cpp
-	g++ -o $@ $(CFLAGS) -DUNIT_TEST -c $+
+%.test.o: %.cpp
+	g++ -o $@ -DUNIT_TEST -c $+ $(CFLAGS)
 
-%.o: %.cpp
-	g++ -o $@ $(CFLAGS) -DUNIT_TEST -c $+
+%.test.o: %.c
+	gcc -o $@ -DUNIT_TEST -c $+ $(CFLAGS)
 
-%.o: %.c
-	gcc -o $@ $(CFLAGS) -DUNIT_TEST -c $+
-
 clean:
-	rm -f test test_main.c test_*.o
+	rm -f gofind test test.c *.o

Added: software/gofind/common.h
===================================================================
--- software/gofind/common.h	                        (rev 0)
+++ software/gofind/common.h	2008-02-21 09:32:44 UTC (rev 5884)
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2007  Enrico Zini <enrico at debian.org>
+ * Copyright (C) 2007  Miriam Ruiz <little_miry at yahoo.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _games_common_h
+#define _games_common_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define USE_UTF8
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#define APPNAME PACKAGE_NAME
+#else
+//#warning No config.h found: using fallback values
+#define APPNAME __FILE__
+#define PACKAGE_VERSION "unknown"
+#define VERSION "0.0"
+#endif
+
+#ifdef UNIT_TEST
+#include "CuTest.h"
+#endif
+
+#ifdef USE_GETTEXT
+#include <libintl.h>
+#define _(String) gettext (String)
+#else
+#define _(String) String
+#endif
+
+#ifndef DATADIR
+#define DATADIR "/usr/share/goplay"
+#endif
+
+#ifndef HTMLDIR
+#define HTMLDIR DATADIR "/html"
+#endif
+
+#ifndef FILE_NO_SCREENSHOT
+#define FILE_NO_SCREENSHOT DATADIR "/no_screenshot.png"
+#endif
+
+#ifndef FILE_STARS_ON
+#define FILE_STARS_ON DATADIR "/stars_on.png"
+#endif
+
+#ifndef FILE_STARS_OFF
+#define FILE_STARS_OFF DATADIR "/stars_off.png"
+#endif
+
+#ifndef FILE_PEOPLE_ON
+#define FILE_PEOPLE_ON DATADIR "/people_on.png"
+#endif
+
+#ifndef FILE_PEOPLE_OFF
+#define FILE_PEOPLE_OFF DATADIR "/people_off.png"
+#endif
+
+#ifndef THUMBNAILSDIR
+#define THUMBNAILSDIR "/usr/share/games/thumbnails"
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#define ERROR_PRINTF(...) { fprintf(stderr, "%s:%s:%u Error: ", __FILE__, __PRETTY_FUNCTION__, __LINE__); fprintf(stderr,__VA_ARGS__); fflush(stderr); }
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Modified: software/gofind/filter.cpp
===================================================================
--- software/gofind/filter.cpp	2008-02-21 09:29:06 UTC (rev 5883)
+++ software/gofind/filter.cpp	2008-02-21 09:32:44 UTC (rev 5884)
@@ -16,13 +16,11 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "common.h"
+
 #include "filter.h"
 #include "taghandler.h"
 
-#ifdef UNIT_TEST
-#include "CuTest.h"
-#endif
-
 #include <string>
 #include <ept/debtags/tag.h>
 

Modified: software/gofind/slre.c
===================================================================
--- software/gofind/slre.c	2008-02-21 09:29:06 UTC (rev 5883)
+++ software/gofind/slre.c	2008-02-21 09:32:44 UTC (rev 5884)
@@ -8,6 +8,15 @@
  * this stuff is worth it, you can buy me a beer in return.
  */
 
+/* Webpage: http://slre.sourceforge.net/ */
+
+#include "common.h"
+#include "slre.h"
+
+#ifdef USE_UTF8
+#include "utf8.h"
+#endif
+
 #include <stdio.h>
 #include <assert.h>
 #include <ctype.h>
@@ -15,8 +24,6 @@
 #include <string.h>
 #include <errno.h>
 
-#include "slre.h"
-
 enum {END, BRANCH, ANY, EXACT, ANYOF, ANYBUT, OPEN, CLOSE, BOL, EOL,
 	STAR, PLUS, STARQ, PLUSQ, QUEST, SPACE, NONSPACE, DIGIT};
 
@@ -60,7 +67,7 @@
  *	data_offset, and has length data_length.
  *
  * OPEN capture_number, CLOSE capture_number
- *	If the user have passed 'struct cap' array for captures, OPEN
+ *	If the user have passed 'struct slre_capture' array for captures, OPEN
  *	records the beginning of the matched substring (cap->ptr), CLOSE
  *	sets the length (cap->len) for respective capture_number.
  *
@@ -75,8 +82,7 @@
 
 static const char *meta_chars = "|.^$*+?()[\\";
 
-static void
-print_character_set(FILE *fp, const unsigned char *p, int len)
+static void print_character_set(FILE *fp, const unsigned char *p, int len)
 {
 	int	i;
 
@@ -97,8 +103,7 @@
 	}
 }
 
-void
-slre_dump(const struct slre *r, FILE *fp)
+void slre_dump(const struct slre_pattern *r, FILE *fp)
 {
 	int	i, j, ch, op, pc;
 
@@ -141,8 +146,7 @@
 	}
 }
 
-static void
-set_jump_offset(struct slre *r, int pc, int offset)
+static void set_jump_offset(struct slre_pattern *r, int pc, int offset)
 {
 	assert(offset < r->code_size);
 
@@ -153,8 +157,7 @@
 	}
 }
 
-static void
-emit(struct slre *r, int code)
+static void emit(struct slre_pattern *r, int code)
 {
 	if (r->code_size >= (int) (sizeof(r->code) / sizeof(r->code[0])))
 		r->err_str = "RE is too long (code overflow)";
@@ -162,8 +165,7 @@
 		r->code[r->code_size++] = (unsigned char) code;
 }
 
-static void
-store_char_in_data(struct slre *r, int ch)
+static void store_char_in_data(struct slre_pattern *r, int ch)
 {
 	if (r->data_size >= (int) sizeof(r->data))
 		r->err_str = "RE is too long (data overflow)";
@@ -171,8 +173,7 @@
 		r->data[r->data_size++] = ch;
 }
 
-static void
-exact(struct slre *r, const char **re)
+static void exact(struct slre_pattern *r, const char **re)
 {
 	int	old_data_size = r->data_size;
 
@@ -184,8 +185,7 @@
 	emit(r, r->data_size - old_data_size);
 }
 
-static int
-get_escape_char(const char **re)
+static int get_escape_char(const char **re)
 {
 	int	res;
 
@@ -203,8 +203,7 @@
 	return (res);
 }
 
-static void
-anyof(struct slre *r, const char **re)
+static void anyof(struct slre_pattern *r, const char **re)
 {
 	int	esc, old_data_size = r->data_size, op = ANYOF;
 
@@ -240,16 +239,14 @@
 	r->err_str = "No closing ']' bracket";
 }
 
-static void
-relocate(struct slre *r, int begin, int shift)
+static void relocate(struct slre_pattern *r, int begin, int shift)
 {
 	emit(r, END);
 	memmove(r->code + begin + shift, r->code + begin, r->code_size - begin);
 	r->code_size += shift;
 }
 
-static void
-quantifier(struct slre *r, int prev, int op)
+static void quantifier(struct slre_pattern *r, int prev, int op)
 {
 	if (r->code[prev] == EXACT && r->code[prev + 2] > 1) {
 		r->code[prev + 2]--;
@@ -263,8 +260,7 @@
 	set_jump_offset(r, prev + 1, prev);
 }
 
-static void
-exact_one_char(struct slre *r, int ch)
+static void exact_one_char(struct slre_pattern *r, int ch)
 {
 	emit(r, EXACT);
 	emit(r, r->data_size);
@@ -272,8 +268,7 @@
 	store_char_in_data(r, ch);
 }
 
-static void
-fixup_branch(struct slre *r, int fixup)
+static void fixup_branch(struct slre_pattern *r, int fixup)
 {
 	if (fixup > 0) {
 		emit(r, END);
@@ -281,8 +276,7 @@
 	}
 }
 
-static void
-compile(struct slre *r, const char **re)
+static void compile(struct slre_pattern *r, const char **re)
 {
 	int	op, esc, branch_start, last_op, fixup, cap_no, level;
 
@@ -372,8 +366,7 @@
 		}
 }
 
-int
-slre_compile(struct slre *r, const char *re)
+int slre_compile(struct slre_pattern *r, const char *re)
 {
 	r->err_str = NULL;
 	r->code_size = r->data_size = r->num_caps = r->anchored = 0;
@@ -397,11 +390,10 @@
 	return (r->err_str == NULL ? 1 : 0);
 }
 
-static int match(const struct slre *, int,
-		const char *, int, int *, struct cap *);
+static int match(const struct slre_pattern *, int,
+		const char *, int, int *, struct slre_capture *);
 
-static void
-loop_greedy(const struct slre *r, int pc, const char *s, int len, int *ofs)
+static void loop_greedy(const struct slre_pattern *r, int pc, const char *s, int len, int *ofs)
 {
 	int	saved_offset, matched_offset;
 
@@ -417,8 +409,7 @@
 	*ofs = matched_offset;
 }
 
-static void
-loop_non_greedy(const struct slre *r, int pc, const char *s,int len, int *ofs)
+static void loop_non_greedy(const struct slre_pattern *r, int pc, const char *s,int len, int *ofs)
 {
 	int	saved_offset = *ofs;
 
@@ -431,8 +422,7 @@
 	*ofs = saved_offset;
 }
 
-static int
-is_any_of(const unsigned char *p, int len, const char *s, int *ofs)
+static int is_any_of(const unsigned char *p, int len, const char *s, int *ofs)
 {
 	int	i, ch;
 
@@ -447,8 +437,7 @@
 	return (0);
 }
 
-static int
-is_any_but(const unsigned char *p, int len, const char *s, int *ofs)
+static int is_any_but(const unsigned char *p, int len, const char *s, int *ofs)
 {
 	int	i, ch;
 
@@ -462,12 +451,16 @@
 	return (1);
 }
 
-static int
-match(const struct slre *r, int pc, const char *s, int len,
-		int *ofs, struct cap *caps)
+static int match(const struct slre_pattern *r, int pc, const char *s, int len,
+		int *ofs, struct slre_capture *caps)
 {
 	int	n, saved_offset, res = 1;
 
+#ifdef USE_UTF8
+	int csize;
+	unsigned long uchar;
+#endif
+
 	while (res && r->code[pc] != END) {
 
 		assert(pc < r->code_size);
@@ -527,26 +520,50 @@
 			break;
 		case SPACE:
 			res = 0;
+#ifdef USE_UTF8
+			csize = helper_utf8_to_unicode_char(&uchar, ((unsigned char *)s) + *ofs, len - *ofs);
+			if (csize > 0 && helper_unicode_is_space(uchar)) {
+				(*ofs) += csize;
+				res = 1;
+			}
+#else
 			if (*ofs < len && isspace(((unsigned char *)s)[*ofs])) {
 				(*ofs)++;
 				res = 1;
 			}
+#endif
 			pc++;
 			break;
 		case NONSPACE:
 			res = 0;
+#ifdef USE_UTF8
+			csize = helper_utf8_to_unicode_char(&uchar, ((unsigned char *)s) + *ofs, len - *ofs);
+			if (csize > 0 && !helper_unicode_is_space(uchar)) {
+				(*ofs) += csize;
+				res = 1;
+			}
+#else
 			if (*ofs <len && !isspace(((unsigned char *)s)[*ofs])) {
 				(*ofs)++;
 				res = 1;
 			}
+#endif
 			pc++;
 			break;
 		case DIGIT:
 			res = 0;
+#ifdef USE_UTF8
+			csize = helper_utf8_to_unicode_char(&uchar, ((unsigned char *)s) + *ofs, len - *ofs);
+			if (csize > 0 && helper_unicode_is_digit(uchar)) {
+				(*ofs) += csize;
+				res = 1;
+			}
+#else
 			if (*ofs < len && isdigit(((unsigned char *)s)[*ofs])) {
 				(*ofs)++;
 				res = 1;
 			}
+#endif
 			pc++;
 			break;
 		case ANY:
@@ -603,9 +620,8 @@
 	return (res);
 }
 
-int
-slre_match(const struct slre *r, const char *buf, int len,
-		struct cap *caps)
+int slre_match(const struct slre_pattern *r, const char *buf, int len,
+		struct slre_capture *caps)
 {
 	int	i, ofs = 0, res = 0;
 
@@ -621,11 +637,11 @@
 	return (res);
 }
 
-#ifdef TEST
+#ifdef TEST_SLRE
 int main(int argc, char *argv[])
 {
-	struct slre	slre;
-	struct cap	caps[20];
+	struct slre_pattern	slre;
+	struct slre_capture	caps[20];
 	char		data[1 * 1024 * 1024];
 	FILE		*fp;
 	int		i, count, res, len;

Modified: software/gofind/slre.h
===================================================================
--- software/gofind/slre.h	2008-02-21 09:29:06 UTC (rev 5883)
+++ software/gofind/slre.h	2008-02-21 09:32:44 UTC (rev 5884)
@@ -8,14 +8,16 @@
  * this stuff is worth it, you can buy me a beer in return.
  */
 
+/* Webpage: http://slre.sourceforge.net/ */
+
 /*
  * This is a regular expression library that implements a subset of Perl RE.
  * Please refer to http://slre.sourceforge.net for detailed description.
  *
  * Usage example (parsing HTTP request):
  *
- * struct slre	slre;
- * struct cap	captures[4 + 1];  // Number of braket pairs + 1
+ * struct slre_pattern	slre;
+ * struct slre_capture	captures[4 + 1];  // Number of braket pairs + 1
  * ...
  *
  * slre_compile(&slre,"^(GET|POST) (\S+) HTTP/(\S+?)\r\n");
@@ -47,14 +49,22 @@
  */
 
 #ifndef SLRE_HEADER_DEFINED
-#define	SLRE_HEADER_DEFINED
+#define SLRE_HEADER_DEFINED
 
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
 /*
  * Compiled regular expression
  */
-struct slre {
+struct slre_pattern {
 	unsigned char	code[256];
+#ifdef USE_UTF8
+	unsigned long	data[256];
+#else
 	unsigned char	data[256];
+#endif
 	int		code_size;
 	int		data_size;
 	int		num_caps;	/* Number of bracket pairs	*/
@@ -65,7 +75,7 @@
 /*
  * Captured substring
  */
-struct cap {
+struct slre_capture {
 	const char	*ptr;		/* Pointer to the substring	*/
 	int		len;		/* Substring length		*/
 };
@@ -74,7 +84,7 @@
  * Compile regular expression. If success, 1 is returned.
  * If error, 0 is returned and slre.err_str points to the error message. 
  */
-int slre_compile(struct slre *, const char *re);
+int slre_compile(struct slre_pattern *, const char *re);
 
 /*
  * Return 1 if match, 0 if no match. 
@@ -86,7 +96,13 @@
  * hold all captures. The caller function must make sure it is! So, the
  * array_size = number_of_round_bracket_pairs + 1
  */
-int slre_match(const struct slre *, const char *buf, int buf_len,
-	struct cap *captured_substrings);
+int slre_match(const struct slre_pattern *, const char *buf, int buf_len,
+	struct slre_capture *captured_substrings);
 
+void slre_dump(const struct slre_pattern *r, FILE *fp);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* SLRE_HEADER_DEFINED */

Added: software/gofind/slre.txt
===================================================================
--- software/gofind/slre.txt	                        (rev 0)
+++ software/gofind/slre.txt	2008-02-21 09:32:44 UTC (rev 5884)
@@ -0,0 +1,88 @@
+SLRE - Super Light Regular Expression library
+
+SLRE is an ANSI C library that implements a tiny subset of Perl regular
+expressions. It is primarily targeted for developers who want to parse
+configuation files, where speed is unimportant. It is in single .c file, easily
+modifiable for custom needs. For example, if one wants to introduce a new
+metacharacter, '\i', that means 'IP address', it is easy to do so.
+
+Features
+
+    * Crossplatform - pure ANSI C
+    * Very simple API
+    * Light: about 5kB of code when compiled
+    * Uses no dynamic memory allocation
+    * Thread safe
+
+Supported RE Syntax
+
+      ^               Match beginning of a buffer
+      $               Match end of a buffer
+      ()              Grouping and substring capturing
+      [...]           Match any character from set
+      [^...]          Match any character but ones from set
+      \s              Match whitespace
+      \S              Match non-whitespace
+      \d              Match decimal digit
+      \r              Match carriage return
+      \n              Match newline
+      +               Match one or more times (greedy)
+      +?              Match one or more times (non-greedy)
+      *               Match zero or more times (greedy)
+      *?              Match zero or more times (non-greedy)
+      ?               Match zero or once
+      \xDD            Match byte with hex value 0xDD
+      \meta           Match one of the meta character: ^$().[*+?\
+
+API
+
+Two functions represent the API: one is used for compilations of the RE, the
+other for performing a match. Both functions return 0 on error, and 1 on
+success. If the round brackets are used in the RE, then matched substrings can
+be returned back to the caller in the 'struct slre_capture *' array. Array size must be
+enough to hold all matches: array_size = number_of_round_bracket_pairs + 1. The
+first element of the array will always hold the substring matched by the whole
+RE.
+
+/* Captured substring */
+struct slre_capture {
+        const char      *ptr;           /* Pointer to the substring     */
+        int             len;            /* Substring length             */
+};
+
+int slre_compile(struct slre_pattern *, const char *re);
+int slre_match(const struct slre_pattern *, const char *buf, int buf_len,
+        struct slre_capture *captured_substrings);
+
+Usage example
+
+This example shows how to parse HTTP request line:
+	struct slre_pattern slre;
+	struct slre_capture captures[4 + 1];
+
+	if (!slre_compile(&slre, "^(GET|POST) (\S+) HTTP/(\S+?)\r\n") {
+		printf("Error compiling RE: %s\n", slre.err_str);
+	} else if (!slre_match(&slre, buf, len, captures)) {
+		printf("Not a valid HTTP request\n" );
+	} else {
+		printf("Request line length: %d\n", captures[0].len);
+		printf("Method: %.*s\n", captures[1].len, captures[1].ptr);
+		printf("URI: %.*s\n", captures[2].len, captures[2].ptr);
+	}
+
+License
+
+/*
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * Sergey Lyubka wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return.
+ * ----------------------------------------------------------------------------
+ */
+ 
+Author
+
+
+Copyright © by Sergey Lyubka (valenok at gmail.com). Feel free to contact
+me if you want to comply with the license.

Modified: software/gofind/taghandler.cpp
===================================================================
--- software/gofind/taghandler.cpp	2008-02-21 09:29:06 UTC (rev 5883)
+++ software/gofind/taghandler.cpp	2008-02-21 09:32:44 UTC (rev 5884)
@@ -16,12 +16,9 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "common.h"
 #include "taghandler.h"
 
-#ifdef UNIT_TEST
-#include "CuTest.h"
-#endif
-
 #include <iostream>
 
 FilterTagHandler::FilterTagHandler() : current_position(0), current_flag(1)

Modified: software/gofind/utf8.c
===================================================================
--- software/gofind/utf8.c	2008-02-21 09:29:06 UTC (rev 5883)
+++ software/gofind/utf8.c	2008-02-21 09:32:44 UTC (rev 5884)
@@ -1,7 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 2 -*-
- *
+/* 
  * helper_utf8.c - Raptor UTF-8 and Unicode support
- *
+ * 
  * Copyright (C) 2002-2006, David Beckett http://purl.org/net/dajobe/
  * Copyright (C) 2002-2004, University of Bristol, UK http://www.bristol.ac.uk/
  * 
@@ -14,17 +13,15 @@
  * 
  * You may not use this file except in compliance with at least one of
  * the above three licenses.
- * 
- * See LICENSE.html or LICENSE.txt at the top of this package for the
- * complete terms and further detail along with the license texts for
- * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively.
- * 
- * 
  */
 
+#include "common.h"
+#include "utf8.h"
+
 #include <stdlib.h>
 #include <stdio.h>
 
+
 /**
  * helper_unicode_char_to_utf8:
  * @c: Unicode character
@@ -38,8 +35,7 @@
  * 
  * Return value: bytes encoded to output buffer or <0 on failure
  **/
-int
-helper_unicode_char_to_utf8(unsigned long c, unsigned char *output)
+int helper_unicode_char_to_utf8(unsigned long c, unsigned char *output)
 {
   int size=0;
   
@@ -108,10 +104,14 @@
  * If output is NULL, then will calculate the number of bytes that
  * will be used from the input buffer and not perform the conversion.
  * 
- * Return value: bytes used from input buffer or <0 on failure: -1 input buffer too short or length error, -2 overlong UTF-8 sequence, -3 illegal code positions, -4 code out of range U+0000 to U+10FFFF.  In cases -2, -3 and -4 the coded character is stored in the output.
+ * Return value: bytes used from input buffer or <0 on failure:
+ *  -1 input buffer too short or length error
+ *  -2 overlong UTF-8 sequence
+ *  -3 illegal code positions
+ *  -4 code out of range U+0000 to U+10FFFF.
+ *  In cases -2, -3 and -4 the coded character is stored in the output.
  */
-int
-helper_utf8_to_unicode_char(unsigned long *output,
+int helper_utf8_to_unicode_char(unsigned long *output,
                             const unsigned char *input, int length)
 {
   unsigned char in;
@@ -218,14 +218,6 @@
 }
 
 
-static int helper_unicode_is_letter(long c);
-static int helper_unicode_is_basechar(long c);
-static int helper_unicode_is_ideographic(long c);
-static int helper_unicode_is_combiningchar(long c);
-static int helper_unicode_is_digit(long c);
-static int helper_unicode_is_extender(long c);
-
-
 /**
  * helper_unicode_is_xml11_namestartchar:
  * @c: Unicode character to check
@@ -241,8 +233,7 @@
  *
  * Return value: non-0 if legal
  **/
-int
-helper_unicode_is_xml11_namestartchar(long c)
+int helper_unicode_is_xml11_namestartchar(long c)
 {
   return (((c >= 0x0041)  && (c <= 0x005A)) || /* [A-Z] */
           (c == 0x005F) ||                     /* '_' */
@@ -277,8 +268,7 @@
  *
  * Return value: non-0 if legal
  **/
-int
-helper_unicode_is_xml10_namestartchar(long c)
+int helper_unicode_is_xml10_namestartchar(long c)
 {
   return (helper_unicode_is_letter(c) ||
           (c == '_'));
@@ -286,24 +276,6 @@
 
 
 /**
- * helper_unicode_is_namestartchar:
- * @c: Unicode character to check
- *
- * Check if Unicode character is legal to start an XML Name
- * 
- * Return value: non-0 if the character is legal
- **/
-int
-helper_unicode_is_namestartchar(long c) {
-#ifdef helper_XML_1_1
-   return helper_unicode_is_xml11_namestartchar(c);
-#else
-   return helper_unicode_is_xml10_namestartchar(c);
-#endif
-}
-
-
-/**
  * helper_unicode_is_xml11_namechar:
  * @c: Unicode character
  * 
@@ -318,8 +290,7 @@
  * 
  * Return value: non-0 if legal
  **/
-int
-helper_unicode_is_xml11_namechar(long c)
+int helper_unicode_is_xml11_namechar(long c)
 {
   return (helper_unicode_is_xml11_namestartchar(c) ||
           (c == 0x002D) || /* '-' */
@@ -346,8 +317,7 @@
  *
  * Return value: non-0 if legal
  **/
-int
-helper_unicode_is_xml10_namechar(long c)
+int helper_unicode_is_xml10_namechar(long c)
 {
   return (helper_unicode_is_letter(c) ||
           helper_unicode_is_digit(c) ||
@@ -357,42 +327,21 @@
           helper_unicode_is_combiningchar(c) ||
           helper_unicode_is_extender(c));
 }
- 
 
-/**
- * helper_unicode_is_namechar:
- * @c: Unicode character to check
- *
- * Check if Unicode character is legal to continue an XML Name .
- * 
- * Return value: non-0 if the character is legal
- **/
-int
-helper_unicode_is_namechar(long c) 
-{
-#ifdef helper_XML_1_1
-   return helper_unicode_is_xml11_namechar(c);
-#else
-   return helper_unicode_is_xml10_namechar(c);
-#endif
-}
 
-
 /*
  * All this below was derived by machine-transforming the classes in Appendix B
  * of http://www.w3.org/TR/2000/REC-xml-20001006
  */
 
-static int
-helper_unicode_is_letter(long c)
+int helper_unicode_is_letter(long c)
 {
   return(helper_unicode_is_basechar(c) ||
          helper_unicode_is_ideographic(c));
 }
 
 
-static int
-helper_unicode_is_basechar(long c)
+int helper_unicode_is_basechar(long c)
 {
   /* http://www.w3.org/TR/2000/REC-xml-20001006#NT-BaseChar */
   return((c >= 0x0041 && c <= 0x005A ) ||
@@ -601,8 +550,7 @@
 }
 
    
-static int
-helper_unicode_is_ideographic(long c)
+int helper_unicode_is_ideographic(long c)
 {
   /* http://www.w3.org/TR/2000/REC-xml-20001006#NT-Ideographic */
   return((c >= 0x4E00 && c <= 0x9FA5 ) ||
@@ -611,8 +559,7 @@
 }
 
 
-static int
-helper_unicode_is_combiningchar(long c)
+int helper_unicode_is_combiningchar(long c)
 {
   /* http://www.w3.org/TR/2000/REC-xml-20001006#NT-CombiningChar */
   return((c >= 0x0300 && c <= 0x0345 ) ||
@@ -713,8 +660,7 @@
 }
 
 
-static int
-helper_unicode_is_digit(long c)
+int helper_unicode_is_digit(long c)
 {
   /* http://www.w3.org/TR/2000/REC-xml-20001006#NT-Digit */
   return((c >= 0x0030 && c <= 0x0039 ) ||
@@ -735,8 +681,7 @@
 }
 
 
-static int
-helper_unicode_is_extender(long c)
+int helper_unicode_is_extender(long c)
 {
   /* http://www.w3.org/TR/2000/REC-xml-20001006#NT-Extender */
   return((c == 0x00B7) ||
@@ -753,6 +698,17 @@
 }
 
 
+int helper_unicode_is_space(long c)
+{
+  return((c == 0x0020) || /* Space */
+         (c == 0x000C) || /* Page jump: \f */
+         (c == 0x000D) || /* Carriage return: \r */
+         (c == 0x000A) || /* Next line: \n */
+         (c == 0x0009) || /* Horizontal tab: \t */
+         (c == 0x000B) ); /* Vertical tab \v */
+}
+
+
 /**
  * helper_utf8_is_nfc:
  * @input: UTF-8 string
@@ -762,8 +718,7 @@
  * 
  * Return value: Non 0 if the string is NFC
  **/
-int
-helper_utf8_is_nfc(const unsigned char *input, size_t length) 
+int helper_utf8_is_nfc(const unsigned char *input, size_t length)
 {
   unsigned int i;
   int plain=1;
@@ -794,8 +749,7 @@
  * 
  * Return value: Non 0 if the string is UTF-8
  **/
-int
-helper_utf8_check(const unsigned char *string, size_t length)
+int helper_utf8_check(const unsigned char *string, size_t length)
 {
   while(length > 0) {
     unsigned long unichar=0;

Added: software/gofind/utf8.h
===================================================================
--- software/gofind/utf8.h	                        (rev 0)
+++ software/gofind/utf8.h	2008-02-21 09:32:44 UTC (rev 5884)
@@ -0,0 +1,50 @@
+/* 
+ * helper_utf8.c - Raptor UTF-8 and Unicode support
+ * 
+ * Copyright (C) 2002-2006, David Beckett http://purl.org/net/dajobe/
+ * Copyright (C) 2002-2004, University of Bristol, UK http://www.bristol.ac.uk/
+ * 
+ * This package is Free Software and part of Redland http://librdf.org/
+ * 
+ * It is licensed under the following three licenses as alternatives:
+ *   1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
+ *   2. GNU General Public License (GPL) V2 or any newer version
+ *   3. Apache License, V2.0 or any newer version
+ * 
+ * You may not use this file except in compliance with at least one of
+ * the above three licenses.
+ */
+
+#ifndef UTF8_HEADER_DEFINED
+#define UTF8_HEADER_DEFINED
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+int helper_unicode_char_to_utf8(unsigned long c, unsigned char *output);
+int helper_utf8_to_unicode_char(unsigned long *output,
+                            const unsigned char *input, int length);
+
+int helper_unicode_is_letter(long c);
+int helper_unicode_is_basechar(long c);
+int helper_unicode_is_ideographic(long c);
+int helper_unicode_is_combiningchar(long c);
+int helper_unicode_is_digit(long c);
+int helper_unicode_is_extender(long c);
+
+int helper_unicode_is_space(long c);
+
+int helper_unicode_is_xml11_namestartchar(long c);
+int helper_unicode_is_xml10_namestartchar(long c);
+int helper_unicode_is_xml11_namechar(long c);
+int helper_unicode_is_xml10_namechar(long c);
+
+int helper_utf8_is_nfc(const unsigned char *input, size_t length);
+int helper_utf8_check(const unsigned char *string, size_t length);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* UTF8_HEADER_DEFINED */




More information about the Pkg-games-commits mailing list