mirror of
				https://github.com/davidgiven/fluxengine.git
				synced 2025-10-24 11:11:02 -07:00 
			
		
		
		
	Compare commits
	
		
			12 Commits
		
	
	
		
			fluxengine
			...
			FluxEngine
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | a06d8ff05a | ||
|  | c91ca1b730 | ||
|  | 3b6ea24df5 | ||
|  | b0e905fdd0 | ||
|  | 34a858346e | ||
|  | 499cb4f720 | ||
|  | 3960b1e4d7 | ||
|  | adb1e9ba00 | ||
|  | 7752fd9f2c | ||
|  | 5db81e681f | ||
|  | 6ef969fd7e | ||
|  | 98dece78c6 | 
| @@ -1,5 +1,6 @@ | ||||
| version: '{branch}.{build}' | ||||
| clone_depth: 1 | ||||
| skip_tags: true | ||||
|  | ||||
| environment: | ||||
|   MSYSTEM: MINGW32 | ||||
| @@ -10,22 +11,29 @@ init: | ||||
| install: | ||||
|   - set PATH=c:\msys64\mingw32\bin;c:\msys64\usr\bin;c:\msys64\bin;%PATH% | ||||
|   - echo %PATH% | ||||
|   - pacman -S --noconfirm --needed make ninja mingw-w64-i686-libusb mingw-w64-i686-sqlite3 mingw-w64-i686-zlib mingw-w64-i686-gcc | ||||
|   - pacman -S --noconfirm --needed make ninja mingw-w64-i686-libusb mingw-w64-i686-sqlite3 mingw-w64-i686-zlib mingw-w64-i686-gcc zip | ||||
|  | ||||
| build_script: | ||||
|   - make | ||||
|   - zip -9 fluxengine.zip fluxengine.exe brother120tool.exe cwftoflux.exe | ||||
|  | ||||
| artifacts: | ||||
|   - path: fluxengine.exe | ||||
|     name: fluxengine.exe | ||||
|   - path: fluxengine.zip | ||||
|     name: fluxengine.zip | ||||
|  | ||||
| deploy: | ||||
|   release: fluxengine-windows-client-v$(appveyor_build_version) | ||||
|   description: FluxEngine Windows client | ||||
|   release: FluxEngine Windows client version $(APPVEYOR_BUILD_NUMBER) | ||||
|   description: > | ||||
|     This is an automatically built version of the FluxEngine Windows client | ||||
|     which is generated whenever a significant checkin has happened. It's had | ||||
|     no testing whatsoever. | ||||
|  | ||||
|     To use, download it, put it somewhere, and then run it from a cmd window | ||||
|     or other command line shell. | ||||
|   provider: GitHub | ||||
|   auth_token: | ||||
|     secure: dfJjj7fWCoDUz+Ni11OcNPB/U3TNJFwNA2AsL++ChFjniUsZLlC6SDWHiL/t4FZo | ||||
|   artifact: fluxengine.exe | ||||
|   artifact: fluxengine.zip | ||||
|   draft: false | ||||
|   prerelease: false | ||||
|   on: | ||||
|   | ||||
| @@ -11,11 +11,13 @@ matrix: | ||||
|             compiler: gcc | ||||
|             env: CXX=g++-8 | ||||
|             script: | ||||
|               - make | ||||
|             - make | ||||
|         - | ||||
|             os: osx | ||||
|             osx_image: xcode10.2 | ||||
|             compiler: clang | ||||
|             env: | ||||
|             - HOMEBREW_NO_INSTALL_CLEANUP=1 | ||||
|  | ||||
| addons: | ||||
|     apt: | ||||
|   | ||||
							
								
								
									
										12
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								Makefile
									
									
									
									
									
								
							| @@ -1,19 +1,23 @@ | ||||
| PACKAGES = zlib sqlite3 libusb-1.0 | ||||
|  | ||||
| export CFLAGS = -O3 -g --std=c++14 \ | ||||
| 	-ffunction-sections -fdata-sections | ||||
| export LDFLAGS = -O3 | ||||
|  | ||||
| ifeq ($(OS), Windows_NT) | ||||
| export CXX = /mingw32/bin/g++ | ||||
| export AR = /mingw32/bin/ar rcs | ||||
| export STRIP = /mingw32/bin/strip | ||||
| export CFLAGS = -O3 -g --std=c++14 -I/mingw32/include/libusb-1.0 | ||||
| export LDFLAGS = -O3 | ||||
| export CFLAGS += -I/mingw32/include/libusb-1.0 | ||||
| export LDFLAGS += | ||||
| export LIBS = -static -lz -lsqlite3 -lusb-1.0 | ||||
| export EXTENSION = .exe | ||||
| else | ||||
| export CXX = g++ | ||||
| export AR = ar rcs | ||||
| export STRIP = strip | ||||
| export CFLAGS = -Og -g --std=c++14 $(shell pkg-config --cflags $(PACKAGES)) | ||||
| export LDFLAGS = -Og | ||||
| export CFLAGS += $(shell pkg-config --cflags $(PACKAGES)) | ||||
| export LDFLAGS += | ||||
| export LIBS = $(shell pkg-config --libs $(PACKAGES)) | ||||
| export EXTENSION = | ||||
| endif | ||||
|   | ||||
| @@ -188,3 +188,8 @@ maintained by Victor Zverovich (`vitaut <https://github.com/vitaut>`) and | ||||
| Jonathan Müller (`foonathan <https://github.com/foonathan>`) with | ||||
| contributions from many other people. It is licensed under the terms of the | ||||
| BSD license. Please see the contents of the directory for the full text. | ||||
|  | ||||
| As an exception, `dep/fnmatchemu` contains parts of the OpenBSD C library | ||||
| code, Todd Miller and William A. Rowe (and probably others). It is licensed | ||||
| under the terms of the 3-clause BSD license. Please see the contents of the | ||||
| directory for the full text. It's been lightly modified by me. | ||||
|   | ||||
							
								
								
									
										29
									
								
								dep/emu/charclass.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								dep/emu/charclass.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | ||||
| /* | ||||
|  * Public domain, 2008, Todd C. Miller <Todd.Miller@courtesan.com> | ||||
|  * | ||||
|  * $OpenBSD: charclass.h,v 1.1 2008/10/01 23:04:13 millert Exp $ | ||||
|  */ | ||||
|  | ||||
| /* | ||||
|  * POSIX character class support for fnmatch() and glob(). | ||||
|  */ | ||||
| static struct cclass { | ||||
| 	const char *name; | ||||
| 	int (*isctype)(int); | ||||
| } cclasses[] = { | ||||
| 	{ "alnum",	isalnum }, | ||||
| 	{ "alpha",	isalpha }, | ||||
| 	{ "blank",	isblank }, | ||||
| 	{ "cntrl",	iscntrl }, | ||||
| 	{ "digit",	isdigit }, | ||||
| 	{ "graph",	isgraph }, | ||||
| 	{ "lower",	islower }, | ||||
| 	{ "print",	isprint }, | ||||
| 	{ "punct",	ispunct }, | ||||
| 	{ "space",	isspace }, | ||||
| 	{ "upper",	isupper }, | ||||
| 	{ "xdigit",	isxdigit }, | ||||
| 	{ NULL,		NULL } | ||||
| }; | ||||
|  | ||||
| #define NCCLASSES	(sizeof(cclasses) / sizeof(cclasses[0]) - 1) | ||||
							
								
								
									
										481
									
								
								dep/emu/fnmatch.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										481
									
								
								dep/emu/fnmatch.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,481 @@ | ||||
| /*  | ||||
|  * This has been lightly tweaked by me, David Given, to change the exported name | ||||
|  * so that it doesn't conflict with the real fnmatch (if any). | ||||
|  */ | ||||
|  | ||||
| /*	$OpenBSD: fnmatch.c,v 1.16 2011/12/06 11:47:46 stsp Exp $	*/ | ||||
|  | ||||
| /* Copyright (c) 2011, VMware, Inc. | ||||
|  * All rights reserved. | ||||
|  *  | ||||
|  * Redistribution and use in source and binary forms, with or without | ||||
|  * modification, are permitted provided that the following conditions are met: | ||||
|  *     * Redistributions of source code must retain the above copyright | ||||
|  *       notice, this list of conditions and the following disclaimer. | ||||
|  *     * Redistributions in binary form must reproduce the above copyright | ||||
|  *       notice, this list of conditions and the following disclaimer in the | ||||
|  *       documentation and/or other materials provided with the distribution. | ||||
|  *     * Neither the name of the VMware, Inc. nor the names of its contributors | ||||
|  *       may be used to endorse or promote products derived from this software | ||||
|  *       without specific prior written permission. | ||||
|  *  | ||||
|  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||||
|  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
|  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
|  * ARE DISCLAIMED. IN NO EVENT SHALL VMWARE, INC. OR CONTRIBUTORS BE LIABLE FOR | ||||
|  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||||
|  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||||
|  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||||
|  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
|  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||||
|  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  */ | ||||
|  | ||||
| /* | ||||
|  * Copyright (c) 2008 Todd C. Miller <millert@openbsd.org> | ||||
|  * | ||||
|  * Permission to use, copy, modify, and distribute this software for any | ||||
|  * purpose with or without fee is hereby granted, provided that the above | ||||
|  * copyright notice and this permission notice appear in all copies. | ||||
|  * | ||||
|  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||||
|  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||||
|  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||||
|  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||||
|  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||||
|  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||||
|  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
|  */ | ||||
|  | ||||
| /* Authored by William A. Rowe Jr. <wrowe; apache.org, vmware.com>, April 2011 | ||||
|  * | ||||
|  * Derived from The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008 | ||||
|  * as described in; | ||||
|  *   http://pubs.opengroup.org/onlinepubs/9699919799/functions/fnmatch.html | ||||
|  * | ||||
|  * Filename pattern matches defined in section 2.13, "Pattern Matching Notation" | ||||
|  * from chapter 2. "Shell Command Language" | ||||
|  *   http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13 | ||||
|  * where; 1. A bracket expression starting with an unquoted <circumflex> '^'  | ||||
|  * character CONTINUES to specify a non-matching list; 2. an explicit <period> '.'  | ||||
|  * in a bracket expression matching list, e.g. "[.abc]" does NOT match a leading  | ||||
|  * <period> in a filename; 3. a <left-square-bracket> '[' which does not introduce | ||||
|  * a valid bracket expression is treated as an ordinary character; 4. a differing | ||||
|  * number of consecutive slashes within pattern and string will NOT match; | ||||
|  * 5. a trailing '\' in FNM_ESCAPE mode is treated as an ordinary '\' character. | ||||
|  * | ||||
|  * Bracket expansion defined in section 9.3.5, "RE Bracket Expression", | ||||
|  * from chapter 9, "Regular Expressions" | ||||
|  *   http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03_05 | ||||
|  * with no support for collating symbols, equivalence class expressions or  | ||||
|  * character class expressions.  A partial range expression with a leading  | ||||
|  * hyphen following a valid range expression will match only the ordinary | ||||
|  * <hyphen> and the ending character (e.g. "[a-m-z]" will match characters  | ||||
|  * 'a' through 'm', a <hyphen> '-', or a 'z'). | ||||
|  * | ||||
|  * Supports BSD extensions FNM_LEADING_DIR to match pattern to the end of one | ||||
|  * path segment of string, and FNM_CASEFOLD to ignore alpha case. | ||||
|  * | ||||
|  * NOTE: Only POSIX/C single byte locales are correctly supported at this time. | ||||
|  * Notably, non-POSIX locales with FNM_CASEFOLD produce undefined results, | ||||
|  * particularly in ranges of mixed case (e.g. "[A-z]") or spanning alpha and | ||||
|  * nonalpha characters within a range. | ||||
|  * | ||||
|  * XXX comments below indicate porting required for multi-byte character sets | ||||
|  * and non-POSIX locale collation orders; requires mbr* APIs to track shift | ||||
|  * state of pattern and string (rewinding pattern and string repeatedly). | ||||
|  * | ||||
|  * Certain parts of the code assume 0x00-0x3F are unique with any MBCS (e.g. | ||||
|  * UTF-8, SHIFT-JIS, etc).  Any implementation allowing '\' as an alternate | ||||
|  * path delimiter must be aware that 0x5C is NOT unique within SHIFT-JIS. | ||||
|  */ | ||||
|  | ||||
| #include "fnmatch.h" | ||||
| #include <string.h> | ||||
| #include <ctype.h> | ||||
| #include <limits.h> | ||||
|  | ||||
| #include "charclass.h" | ||||
|  | ||||
| #define	RANGE_MATCH	1 | ||||
| #define	RANGE_NOMATCH	0 | ||||
| #define	RANGE_ERROR	(-1) | ||||
|  | ||||
| static int | ||||
| classmatch(const char *pattern, char test, int foldcase, const char **ep) | ||||
| { | ||||
| 	struct cclass *cc; | ||||
| 	const char *colon; | ||||
| 	size_t len; | ||||
| 	int rval = RANGE_NOMATCH; | ||||
| 	const char * const mismatch = pattern; | ||||
|  | ||||
| 	if (*pattern != '[' || pattern[1] != ':') { | ||||
| 		*ep = mismatch; | ||||
| 		return(RANGE_ERROR); | ||||
| 	} | ||||
|  | ||||
| 	pattern += 2; | ||||
|  | ||||
| 	if ((colon = strchr(pattern, ':')) == NULL || colon[1] != ']') { | ||||
| 		*ep = mismatch; | ||||
| 		return(RANGE_ERROR); | ||||
| 	} | ||||
| 	*ep = colon + 2; | ||||
| 	len = (size_t)(colon - pattern); | ||||
|  | ||||
| 	if (foldcase && strncmp(pattern, "upper:]", 7) == 0) | ||||
| 		pattern = "lower:]"; | ||||
| 	for (cc = cclasses; cc->name != NULL; cc++) { | ||||
| 		if (!strncmp(pattern, cc->name, len) && cc->name[len] == '\0') { | ||||
| 			if (cc->isctype((unsigned char)test)) | ||||
| 				rval = RANGE_MATCH; | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
| 	if (cc->name == NULL) { | ||||
| 		/* invalid character class, treat as normal text */ | ||||
| 		*ep = mismatch; | ||||
| 		rval = RANGE_ERROR; | ||||
| 	} | ||||
| 	return(rval); | ||||
| } | ||||
|  | ||||
| /* Most MBCS/collation/case issues handled here.  Wildcard '*' is not handled. | ||||
|  * EOS '\0' and the FNM_PATHNAME '/' delimiters are not advanced over,  | ||||
|  * however the "\/" sequence is advanced to '/'. | ||||
|  * | ||||
|  * Both pattern and string are **char to support pointer increment of arbitrary | ||||
|  * multibyte characters for the given locale, in a later iteration of this code | ||||
|  */ | ||||
| static int fnmatch_ch(const char **pattern, const char **string, int flags) | ||||
| { | ||||
|     const char * const mismatch = *pattern; | ||||
|     const int nocase = !!(flags & FNM_CASEFOLD); | ||||
|     const int escape = !(flags & FNM_NOESCAPE); | ||||
|     const int slash = !!(flags & FNM_PATHNAME); | ||||
|     int result = FNM_NOMATCH; | ||||
|     const char *startch; | ||||
|     int negate; | ||||
|  | ||||
|     if (**pattern == '[') | ||||
|     { | ||||
|         ++*pattern; | ||||
|  | ||||
|         /* Handle negation, either leading ! or ^ operators (never both) */ | ||||
|         negate = ((**pattern == '!') || (**pattern == '^')); | ||||
|         if (negate) | ||||
|             ++*pattern; | ||||
|  | ||||
|         /* ']' is an ordinary character at the start of the range pattern */ | ||||
|         if (**pattern == ']') | ||||
|             goto leadingclosebrace; | ||||
|  | ||||
|         while (**pattern) | ||||
|         { | ||||
|             if (**pattern == ']') { | ||||
|                 ++*pattern; | ||||
|                 /* XXX: Fix for MBCS character width */ | ||||
|                 ++*string; | ||||
|                 return (result ^ negate); | ||||
|             } | ||||
|  | ||||
|             if (escape && (**pattern == '\\')) { | ||||
|                 ++*pattern; | ||||
|  | ||||
|                 /* Patterns must be terminated with ']', not EOS */ | ||||
|                 if (!**pattern) | ||||
|                     break; | ||||
|             } | ||||
|  | ||||
|             /* Patterns must be terminated with ']' not '/' */ | ||||
|             if (slash && (**pattern == '/')) | ||||
|                 break; | ||||
|  | ||||
|             /* Match character classes. */ | ||||
|             if (classmatch(*pattern, **string, nocase, pattern) | ||||
|                 == RANGE_MATCH) { | ||||
|                 result = 0; | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
| leadingclosebrace: | ||||
|             /* Look at only well-formed range patterns;  | ||||
|              * "x-]" is not allowed unless escaped ("x-\]") | ||||
|              * XXX: Fix for locale/MBCS character width | ||||
|              */ | ||||
|             if (((*pattern)[1] == '-') && ((*pattern)[2] != ']')) | ||||
|             { | ||||
|                 startch = *pattern; | ||||
|                 *pattern += (escape && ((*pattern)[2] == '\\')) ? 3 : 2; | ||||
|  | ||||
|                 /* NOT a properly balanced [expr] pattern, EOS terminated  | ||||
|                  * or ranges containing a slash in FNM_PATHNAME mode pattern | ||||
|                  * fall out to to the rewind and test '[' literal code path | ||||
|                  */ | ||||
|                 if (!**pattern || (slash && (**pattern == '/'))) | ||||
|                     break; | ||||
|  | ||||
|                 /* XXX: handle locale/MBCS comparison, advance by MBCS char width */ | ||||
|                 if ((**string >= *startch) && (**string <= **pattern)) | ||||
|                     result = 0; | ||||
|                 else if (nocase && (isupper(**string) || isupper(*startch) | ||||
|                                                       || isupper(**pattern)) | ||||
|                             && (tolower(**string) >= tolower(*startch))  | ||||
|                             && (tolower(**string) <= tolower(**pattern))) | ||||
|                     result = 0; | ||||
|  | ||||
|                 ++*pattern; | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
|             /* XXX: handle locale/MBCS comparison, advance by MBCS char width */ | ||||
|             if ((**string == **pattern)) | ||||
|                 result = 0; | ||||
|             else if (nocase && (isupper(**string) || isupper(**pattern)) | ||||
|                             && (tolower(**string) == tolower(**pattern))) | ||||
|                 result = 0; | ||||
|  | ||||
|             ++*pattern; | ||||
|         } | ||||
|  | ||||
|         /* NOT a properly balanced [expr] pattern; Rewind | ||||
|          * and reset result to test '[' literal | ||||
|          */ | ||||
|         *pattern = mismatch; | ||||
|         result = FNM_NOMATCH; | ||||
|     } | ||||
|     else if (**pattern == '?') { | ||||
|         /* Optimize '?' match before unescaping **pattern */ | ||||
|         if (!**string || (slash && (**string == '/'))) | ||||
|             return FNM_NOMATCH; | ||||
|         result = 0; | ||||
|         goto fnmatch_ch_success; | ||||
|     } | ||||
|     else if (escape && (**pattern == '\\') && (*pattern)[1]) { | ||||
|         ++*pattern; | ||||
|     } | ||||
|  | ||||
|     /* XXX: handle locale/MBCS comparison, advance by the MBCS char width */ | ||||
|     if (**string == **pattern) | ||||
|         result = 0; | ||||
|     else if (nocase && (isupper(**string) || isupper(**pattern)) | ||||
|                     && (tolower(**string) == tolower(**pattern))) | ||||
|         result = 0; | ||||
|  | ||||
|     /* Refuse to advance over trailing slash or nulls | ||||
|      */ | ||||
|     if (!**string || !**pattern || (slash && ((**string == '/') || (**pattern == '/')))) | ||||
|         return result; | ||||
|  | ||||
| fnmatch_ch_success: | ||||
|     ++*pattern; | ||||
|     ++*string; | ||||
|     return result; | ||||
| } | ||||
|  | ||||
|  | ||||
| int fnmatch(const char *pattern, const char *string, int flags) | ||||
| { | ||||
|     static const char dummystring[2] = {' ', 0}; | ||||
|     const int escape = !(flags & FNM_NOESCAPE); | ||||
|     const int slash = !!(flags & FNM_PATHNAME); | ||||
|     const char *strendseg; | ||||
|     const char *dummyptr; | ||||
|     const char *matchptr; | ||||
|     int wild; | ||||
|     /* For '*' wild processing only; surpress 'used before initialization' | ||||
|      * warnings with dummy initialization values; | ||||
|      */ | ||||
|     const char *strstartseg = NULL; | ||||
|     const char *mismatch = NULL; | ||||
|     int matchlen = 0; | ||||
|  | ||||
|     if (strnlen(pattern, PATH_MAX) == PATH_MAX || | ||||
|         strnlen(string, PATH_MAX) == PATH_MAX) | ||||
|             return (FNM_NOMATCH); | ||||
|  | ||||
|     if (*pattern == '*') | ||||
|         goto firstsegment; | ||||
|  | ||||
|     while (*pattern && *string) | ||||
|     { | ||||
|         /* Pre-decode "\/" which has no special significance, and | ||||
|          * match balanced slashes, starting a new segment pattern | ||||
|          */ | ||||
|         if (slash && escape && (*pattern == '\\') && (pattern[1] == '/')) | ||||
|             ++pattern; | ||||
|         if (slash && (*pattern == '/') && (*string == '/')) { | ||||
|             ++pattern; | ||||
|             ++string; | ||||
|         }             | ||||
|  | ||||
| firstsegment: | ||||
|         /* At the beginning of each segment, validate leading period behavior. | ||||
|          */ | ||||
|         if ((flags & FNM_PERIOD) && (*string == '.')) | ||||
|         { | ||||
|             if (*pattern == '.') | ||||
|                 ++pattern; | ||||
|             else if (escape && (*pattern == '\\') && (pattern[1] == '.')) | ||||
|                 pattern += 2; | ||||
|             else | ||||
|                 return FNM_NOMATCH; | ||||
|             ++string; | ||||
|         } | ||||
|  | ||||
|         /* Determine the end of string segment | ||||
|          * | ||||
|          * Presumes '/' character is unique, not composite in any MBCS encoding | ||||
|          */ | ||||
|         if (slash) { | ||||
|             strendseg = strchr(string, '/'); | ||||
|             if (!strendseg) | ||||
|                 strendseg = strchr(string, '\0'); | ||||
|         } | ||||
|         else { | ||||
|             strendseg = strchr(string, '\0'); | ||||
|         } | ||||
|  | ||||
|         /* Allow pattern '*' to be consumed even with no remaining string to match | ||||
|          */ | ||||
|         while (*pattern) | ||||
|         { | ||||
|             if ((string > strendseg) | ||||
|                 || ((string == strendseg) && (*pattern != '*'))) | ||||
|                 break; | ||||
|  | ||||
|             if (slash && ((*pattern == '/') | ||||
|                            || (escape && (*pattern == '\\') | ||||
|                                       && (pattern[1] == '/')))) | ||||
|                 break; | ||||
|  | ||||
|             /* Reduce groups of '*' and '?' to n '?' matches | ||||
|              * followed by one '*' test for simplicity | ||||
|              */ | ||||
|             for (wild = 0; ((*pattern == '*') || (*pattern == '?')); ++pattern) | ||||
|             { | ||||
|                 if (*pattern == '*') { | ||||
|                     wild = 1; | ||||
|                 } | ||||
|                 else if (string < strendseg) {  /* && (*pattern == '?') */ | ||||
|                     /* XXX: Advance 1 char for MBCS locale */ | ||||
|                     ++string; | ||||
|                 } | ||||
|                 else {  /* (string >= strendseg) && (*pattern == '?') */ | ||||
|                     return FNM_NOMATCH; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             if (wild) | ||||
|             { | ||||
|                 strstartseg = string; | ||||
|                 mismatch = pattern; | ||||
|  | ||||
|                 /* Count fixed (non '*') char matches remaining in pattern | ||||
|                  * excluding '/' (or "\/") and '*' | ||||
|                  */ | ||||
|                 for (matchptr = pattern, matchlen = 0; 1; ++matchlen) | ||||
|                 { | ||||
|                     if ((*matchptr == '\0')  | ||||
|                         || (slash && ((*matchptr == '/') | ||||
|                                       || (escape && (*matchptr == '\\') | ||||
|                                                  && (matchptr[1] == '/'))))) | ||||
|                     { | ||||
|                         /* Compare precisely this many trailing string chars, | ||||
|                          * the resulting match needs no wildcard loop | ||||
|                          */ | ||||
|                         /* XXX: Adjust for MBCS */ | ||||
|                         if (string + matchlen > strendseg) | ||||
|                             return FNM_NOMATCH; | ||||
|  | ||||
|                         string = strendseg - matchlen; | ||||
|                         wild = 0; | ||||
|                         break; | ||||
|                     } | ||||
|  | ||||
|                     if (*matchptr == '*') | ||||
|                     { | ||||
|                         /* Ensure at least this many trailing string chars remain | ||||
|                          * for the first comparison | ||||
|                          */ | ||||
|                         /* XXX: Adjust for MBCS */ | ||||
|                         if (string + matchlen > strendseg) | ||||
|                             return FNM_NOMATCH; | ||||
|  | ||||
|                         /* Begin first wild comparison at the current position */ | ||||
|                         break; | ||||
|                     } | ||||
|  | ||||
|                     /* Skip forward in pattern by a single character match | ||||
|                      * Use a dummy fnmatch_ch() test to count one "[range]" escape | ||||
|                      */  | ||||
|                     /* XXX: Adjust for MBCS */ | ||||
|                     if (escape && (*matchptr == '\\') && matchptr[1]) { | ||||
|                         matchptr += 2; | ||||
|                     } | ||||
|                     else if (*matchptr == '[') { | ||||
|                         dummyptr = dummystring; | ||||
|                         fnmatch_ch(&matchptr, &dummyptr, flags); | ||||
|                     } | ||||
|                     else { | ||||
|                         ++matchptr; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             /* Incrementally match string against the pattern | ||||
|              */ | ||||
|             while (*pattern && (string < strendseg)) | ||||
|             { | ||||
|                 /* Success; begin a new wild pattern search | ||||
|                  */ | ||||
|                 if (*pattern == '*') | ||||
|                     break; | ||||
|  | ||||
|                 if (slash && ((*string == '/') | ||||
|                               || (*pattern == '/') | ||||
|                               || (escape && (*pattern == '\\') | ||||
|                                          && (pattern[1] == '/')))) | ||||
|                     break; | ||||
|  | ||||
|                 /* Compare ch's (the pattern is advanced over "\/" to the '/', | ||||
|                  * but slashes will mismatch, and are not consumed) | ||||
|                  */ | ||||
|                 if (!fnmatch_ch(&pattern, &string, flags)) | ||||
|                     continue; | ||||
|  | ||||
|                 /* Failed to match, loop against next char offset of string segment  | ||||
|                  * until not enough string chars remain to match the fixed pattern | ||||
|                  */ | ||||
|                 if (wild) { | ||||
|                     /* XXX: Advance 1 char for MBCS locale */ | ||||
|                     string = ++strstartseg; | ||||
|                     if (string + matchlen > strendseg) | ||||
|                         return FNM_NOMATCH; | ||||
|  | ||||
|                     pattern = mismatch; | ||||
|                     continue; | ||||
|                 } | ||||
|                 else | ||||
|                     return FNM_NOMATCH; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (*string && !(slash && (*string == '/'))) | ||||
|             return FNM_NOMATCH; | ||||
|  | ||||
|         if (*pattern && !(slash && ((*pattern == '/') | ||||
|                                     || (escape && (*pattern == '\\') | ||||
|                                                && (pattern[1] == '/'))))) | ||||
|             return FNM_NOMATCH; | ||||
|     } | ||||
|  | ||||
|     /* Where both pattern and string are at EOS, declare success | ||||
|      */ | ||||
|     if (!*string && !*pattern) | ||||
|         return 0; | ||||
|  | ||||
|     /* pattern didn't match to the end of string */ | ||||
|     return FNM_NOMATCH; | ||||
| } | ||||
							
								
								
									
										21
									
								
								dep/emu/fnmatch.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								dep/emu/fnmatch.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| #ifndef FNMATCH_H | ||||
| #define FNMATCH_H | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| #endif | ||||
|  | ||||
| #define	FNM_NOMATCH	1	/* Match failed. */ | ||||
|  | ||||
| #define	FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ | ||||
| #define	FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ | ||||
| #define	FNM_PERIOD   0x04 /* Period must be matched by period. */ | ||||
| #define FNM_CASEFOLD 0x08 /* Fold cases */ | ||||
|  | ||||
| extern int fnmatch(const char *pattern, const char *string, int flags); | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
|  | ||||
| #endif | ||||
| @@ -139,6 +139,11 @@ the port and proceed normally. | ||||
|  | ||||
| ## Building the client | ||||
|  | ||||
| **Before you read this:** If you're on Windows, good news! You can download a | ||||
| *precompiled version of the FluxEngine client [from the GitHub releases | ||||
| *page](https://github.com/davidgiven/fluxengine/releases/latest). Simply unzip | ||||
| *it somewhere and run it from a `cmd` window (or other shell). | ||||
|  | ||||
| The client software is where the intelligence, such as it is, is. It's pretty | ||||
| generic libusb stuff and should build and run on Windows, Linux and OSX as | ||||
| well, although on Windows it'll need MSYS2 and mingw32. You'll need to | ||||
|   | ||||
							
								
								
									
										32
									
								
								mkninja.sh
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								mkninja.sh
									
									
									
									
									
								
							| @@ -48,7 +48,7 @@ buildlibrary() { | ||||
|     objs= | ||||
|     for src in "$@"; do | ||||
|         local obj | ||||
|         obj="$OBJDIR/${src%%.cc}.o" | ||||
|         obj="$OBJDIR/${src%%.c*}.o" | ||||
|         objs="$objs $obj" | ||||
|  | ||||
|         echo build $obj : cxx $src | ||||
| @@ -83,8 +83,10 @@ buildprogram() { | ||||
|         objs="$objs $OBJDIR/$src" | ||||
|     done | ||||
|  | ||||
|     echo build $prog : link $objs | ||||
|     echo build $prog-debug$EXTENSION : link $objs | ||||
|     echo "    flags=$flags" | ||||
|  | ||||
|     echo build $prog$EXTENSION : strip $prog-debug$EXTENSION | ||||
| } | ||||
|  | ||||
| runtest() { | ||||
| @@ -95,12 +97,12 @@ runtest() { | ||||
|     buildlibrary lib$prog.a \ | ||||
|         "$@" | ||||
|  | ||||
|     buildprogram $OBJDIR/$prog$EXTENSION \ | ||||
|     buildprogram $OBJDIR/$prog \ | ||||
|         lib$prog.a \ | ||||
|         libbackend.a \ | ||||
|         libfmt.a | ||||
|  | ||||
|     echo build $OBJDIR/$prog.stamp : test $OBJDIR/$prog$EXTENSION | ||||
|     echo build $OBJDIR/$prog.stamp : test $OBJDIR/$prog-debug$EXTENSION | ||||
| } | ||||
|  | ||||
| buildlibrary libfmt.a \ | ||||
| @@ -176,12 +178,30 @@ buildlibrary libfrontend.a \ | ||||
|     src/fe-writetestpattern.cc \ | ||||
|     src/fluxengine.cc \ | ||||
|  | ||||
| buildprogram fluxengine-debug$EXTENSION \ | ||||
| buildprogram fluxengine \ | ||||
|     libfrontend.a \ | ||||
|     libbackend.a \ | ||||
|     libfmt.a \ | ||||
|  | ||||
| echo "build fluxengine$EXTENSION : strip fluxengine-debug$EXTENSION" | ||||
| buildlibrary libbrother120tool.a \ | ||||
|     -Idep/emu \ | ||||
|     tools/brother120tool.cc \ | ||||
|  | ||||
| buildlibrary libemu.a \ | ||||
|     dep/emu/fnmatch.c | ||||
|  | ||||
| buildprogram brother120tool \ | ||||
|     libbrother120tool.a \ | ||||
|     libemu.a \ | ||||
|     libfmt.a \ | ||||
|  | ||||
| buildlibrary libcwftoflux.a \ | ||||
|     tools/cwftoflux.cc \ | ||||
|  | ||||
| buildprogram cwftoflux \ | ||||
|     libcwftoflux.a \ | ||||
|     libbackend.a \ | ||||
|     libfmt.a \ | ||||
|  | ||||
| runtest dataspec-test       tests/dataspec.cc | ||||
| runtest flags-test          tests/flags.cc | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| #include "globals.h" | ||||
| #include "fmt/format.h" | ||||
| #include <fstream> | ||||
| #include <fnmatch.h> | ||||
| #include "fnmatch.h" | ||||
|  | ||||
| /* Theoretical maximum number of sectors. */ | ||||
| static const int SECTOR_COUNT = 640; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user