| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#ifndef __COMMON_H__ |
| 27 |
#define __COMMON_H__ |
| 28 |
|
| 29 |
#include <stdio.h> |
| 30 |
#include <stdlib.h> |
| 31 |
#include <stdint.h> |
| 32 |
#include <string.h> |
| 33 |
#include <assert.h> |
| 34 |
#include <ctype.h> |
| 35 |
#include <wctype.h> |
| 36 |
#include <time.h> |
| 37 |
#include <math.h> |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
#ifdef _WIN32 |
| 42 |
#include <direct.h> |
| 43 |
#include <shlobj.h> |
| 44 |
#include <windows.h> |
| 45 |
#define _USE_MATH_DEFINES |
| 46 |
#include <math.h> |
| 47 |
#define DIR_SEP_STR "\\" |
| 48 |
#define DIR_SEP_CHAR '\\' |
| 49 |
#define STRCASECMP _stricmp |
| 50 |
#else |
| 51 |
#define DIR_SEP_STR "/" |
| 52 |
#define DIR_SEP_CHAR '/' |
| 53 |
#define STRCASECMP strcasecmp |
| 54 |
#endif |
| 55 |
|
| 56 |
#define RELEASE "20200708" |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
#define NGTYPE 13 // number of different grid types |
| 61 |
#define MAXNDIR 3 // maximum number of directions |
| 62 |
#define MXSZ 63 // max grid size X and Y |
| 63 |
#define MXCL 250 // max number of cells in light; must be >=MXSZ*2; allow more for VL:s |
| 64 |
#define MXCT 31 // max contents in one cell per direction |
| 65 |
#define MXMUX MXCT // maximum degree of multiplexing |
| 66 |
#define NMSG 2 // number of messages passed to treatment code |
| 67 |
#define MXLE 250 // max entries in a light before tags added |
| 68 |
#define MXFL 255 // max entries in a word that filler can cope with: light plus tags, >=MXLE+NMSG; <256 to allow poscnt[] not to overflow |
| 69 |
#define MXLT (MAXNDIR*MXSZ*MXSZ+NVL) // max number of lights (conservative estimate) |
| 70 |
#define NVL (MXSZ*4) // max number of virtual lights |
| 71 |
#define MAXNMK (MAXNDIR*2) // max number of corner marks |
| 72 |
#define MXMK 30 // max length of mark string |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
#define NLEM 5 // number of light entry methods |
| 79 |
#define NATREAT 12 // number of treatments |
| 80 |
#define TREAT_PLUGIN 9 |
| 81 |
|
| 82 |
#define UNDOS 50 |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
#define STRSTARTS(s,t) (!strncmp((s),(t),strlen(t))) |
| 87 |
|
| 88 |
#define MEMBLK 100000 // unit of memory allocation |
| 89 |
|
| 90 |
struct memblk { |
| 91 |
struct memblk*next; |
| 92 |
int ct; |
| 93 |
char s[MEMBLK]; |
| 94 |
}; |
| 95 |
|
| 96 |
#define PI (M_PI) |
| 97 |
#define ODD(x) ((x)&1) |
| 98 |
#define EVEN(x) (!((x)&1)) |
| 99 |
#define FREEX(p) if(p) {free(p);p=0;} |
| 100 |
#define SLEN 1000 // maximum length for filenames, strings etc.; Windows has MAX_PATH around 260; should be >>MXFL |
| 101 |
#define LEMDESCLEN 20 // maximum length of entry method description |
| 102 |
|
| 103 |
#define MX(a,b) ((a)>(b)?(a):(b)) |
| 104 |
|
| 105 |
extern int debug; |
| 106 |
#define DEB_F0 if(debug&0x00000001) // filler: start and stop |
| 107 |
#define DEB_F1 if(debug&0x00000002) // filler: basics |
| 108 |
#define DEB_F2 if(debug&0x00000004) // more detail |
| 109 |
#define DEB_F3 if(debug&0x00000008) // spreads and jumbles |
| 110 |
#define DEB_GU if(debug&0x00000010) // general GUI |
| 111 |
#define DEB_RF if(debug&0x00000020) // refresh, events |
| 112 |
#define DEB_DI if(debug&0x00000040) // dictionaries |
| 113 |
#define DEB_DV if(debug&0x00000080) // dictionaries, verbose |
| 114 |
#define DEB_AL if(debug&0x00000100) // alphabets |
| 115 |
#define DEB_FL if(debug&0x00000200) // feasible list building |
| 116 |
#define DEB_TR if(debug&0x00000400) // treatments and plug-ins |
| 117 |
#define DEB_GR if(debug&0x00000800) // grid operations, save, load |
| 118 |
#define DEB_BS if(debug&0x00001000) // buildstructs |
| 119 |
#define DEB_DE if(debug&0x00002000) // decks |
| 120 |
#define DEB_EX if(debug&0x00004000) // export |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
typedef unsigned int uchar; |
| 126 |
#define MAXUCHAR 0x30000 // maximum Unicode character accepted: first three planes only |
| 127 |
#define MAXEQUIV 100 // maximum equivalent unicode charaacters mapping to given internal code |
| 128 |
#define MAXICC 61 // internal character codes from 1..MAXICC-1 are allowed for normal characters; 0 reserved for 0-termination; code MAXICC used for "dash" in treatments (to mean "no treatment") |
| 129 |
#define ICC_DASH MAXICC // internal character code for dash |
| 130 |
|
| 131 |
#define TOUUPPER(c) g_unichar_toupper(c) |
| 132 |
#define TOULOWER(c) g_unichar_tolower(c) |
| 133 |
#define ISUUPPER(c) g_unichar_isupper(c) |
| 134 |
#define ISULOWER(c) g_unichar_islower(c) |
| 135 |
#define ISUDIGIT(c) g_unichar_isdigit(c) |
| 136 |
#define ISUALPHA(c) g_unichar_isalpha(c) |
| 137 |
#define ISUPRINT(c) g_unichar_isprint(c) |
| 138 |
#define ISUGRAPH(c) g_unichar_isgraph(c) |
| 139 |
|
| 140 |
struct alphaentry { |
| 141 |
char*rep; |
| 142 |
char*eqv; |
| 143 |
int vow; |
| 144 |
int con; |
| 145 |
int seq; |
| 146 |
}; |
| 147 |
|
| 148 |
#define ICCTOABM(x) (1ULL<<((x)-1)) |
| 149 |
typedef unsigned long long int ABM; |
| 150 |
#define ABM_NRM ((1ULL<<(MAXICC-1))-1) // normal characters |
| 151 |
#define ABM_DASH (1ULL<<(ICC_DASH-1)) |
| 152 |
#define ABM_ALL (ABM_NRM|ABM_DASH) // normal characters plus dash |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
struct sprop { |
| 162 |
unsigned int bgcol; |
| 163 |
unsigned int fgcol; |
| 164 |
unsigned int mkcol; |
| 165 |
unsigned char ten; |
| 166 |
unsigned char spor; |
| 167 |
unsigned char fstyle; |
| 168 |
unsigned char dech; |
| 169 |
char mk[MAXNMK][MXMK+1]; |
| 170 |
}; |
| 171 |
|
| 172 |
|
| 173 |
#define EM_FWD 1 |
| 174 |
#define EM_REV 2 |
| 175 |
#define EM_CYC 4 |
| 176 |
#define EM_RCY 8 |
| 177 |
#define EM_JUM 16 |
| 178 |
#define EM_ALL 31 |
| 179 |
#define EM_SPR 32 // for internal use only |
| 180 |
|
| 181 |
struct lprop { |
| 182 |
unsigned int dmask; |
| 183 |
unsigned int emask; |
| 184 |
unsigned char ten; |
| 185 |
unsigned char lpor; |
| 186 |
unsigned char dnran; |
| 187 |
unsigned char mux; |
| 188 |
}; |
| 189 |
|
| 190 |
struct jdata { |
| 191 |
int nuf; |
| 192 |
unsigned char ufhist[MAXICC+1]; |
| 193 |
unsigned char poscnt[MAXICC+1]; |
| 194 |
}; |
| 195 |
|
| 196 |
struct sdata { |
| 197 |
ABM flbm[MXFL]; |
| 198 |
double ct[MXFL][MXFL]; |
| 199 |
double ctd[MXFL]; |
| 200 |
}; |
| 201 |
|
| 202 |
struct word { |
| 203 |
int nent; |
| 204 |
int wlen; |
| 205 |
int jlen; |
| 206 |
int gx0,gy0; |
| 207 |
int ldir; |
| 208 |
int*flist; |
| 209 |
int flistlen; |
| 210 |
struct jdata*jdata; |
| 211 |
ABM*jflbm; |
| 212 |
struct sdata*sdata; |
| 213 |
int commitdep; |
| 214 |
struct entry*e[MXFL]; |
| 215 |
struct lprop*lp; |
| 216 |
unsigned char upd; |
| 217 |
int fe; |
| 218 |
int goi[MXLE]; |
| 219 |
}; |
| 220 |
struct entry { |
| 221 |
ABM flbm; |
| 222 |
ABM flbmh; |
| 223 |
int gx,gy; |
| 224 |
int checking; |
| 225 |
double score[MAXICC+1]; |
| 226 |
double crux; |
| 227 |
unsigned char sel; |
| 228 |
unsigned char upd; |
| 229 |
}; |
| 230 |
struct square { |
| 231 |
|
| 232 |
unsigned int bars; |
| 233 |
unsigned int merge; |
| 234 |
unsigned char fl; |
| 235 |
unsigned char dsel; |
| 236 |
int ctlen[MAXNDIR]; |
| 237 |
ABM ctbm[MAXNDIR][MXCT]; |
| 238 |
struct sprop sp; |
| 239 |
struct lprop lp[MAXNDIR]; |
| 240 |
|
| 241 |
struct entry*ents[MAXNDIR][MXCT]; |
| 242 |
struct word*w[MAXNDIR][MXMUX]; |
| 243 |
unsigned int vflags[MAXNDIR]; |
| 244 |
int number; |
| 245 |
int goi; |
| 246 |
}; |
| 247 |
struct vl { |
| 248 |
int l; |
| 249 |
int x[MXCL],y[MXCL]; |
| 250 |
struct lprop lp; |
| 251 |
unsigned char sel; |
| 252 |
struct word*w; |
| 253 |
}; |
| 254 |
|
| 255 |
extern struct word*words; |
| 256 |
extern struct entry*entries; |
| 257 |
extern struct entry*treatmsge0[NMSG][MXFL]; |
| 258 |
extern struct square gsq[MXSZ][MXSZ]; |
| 259 |
extern struct vl vls[NVL]; |
| 260 |
extern int nc,nw,nw0,ntw,ne,ne0,ns,nvl; |
| 261 |
|
| 262 |
extern int cwperm[MAXICC]; |
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
struct answer { |
| 267 |
int ahlink; |
| 268 |
unsigned int dmask; |
| 269 |
unsigned int cfdmask; |
| 270 |
|
| 271 |
double score; |
| 272 |
char*cf; |
| 273 |
struct answer*acf; |
| 274 |
char*ul; |
| 275 |
char banned; |
| 276 |
}; |
| 277 |
|
| 278 |
struct light { |
| 279 |
int hashslink; |
| 280 |
int hashaeslink; |
| 281 |
int ans; |
| 282 |
int em; |
| 283 |
char*s; |
| 284 |
int uniq; |
| 285 |
int tagged; |
| 286 |
ABM lbm; |
| 287 |
unsigned char hist[MAXICC+1]; |
| 288 |
}; |
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
extern int*llist; |
| 293 |
extern int*llistp; |
| 294 |
extern int llistn; |
| 295 |
extern int llistwlen; |
| 296 |
extern unsigned int llistdm; |
| 297 |
extern int llistem; |
| 298 |
|
| 299 |
extern int ifamode; |
| 300 |
extern volatile int abort_flag; |
| 301 |
|
| 302 |
extern struct answer**ansp; |
| 303 |
extern struct light*lts; |
| 304 |
|
| 305 |
extern int atotal; |
| 306 |
extern int ultotal; |
| 307 |
|
| 308 |
extern char tpifname[SLEN]; |
| 309 |
extern int treatmode; |
| 310 |
extern int treatorder[NMSG]; |
| 311 |
extern char treatmsg[NMSG][MXLT*8+1]; |
| 312 |
extern ABM treatcstr[NMSG][MXFL]; |
| 313 |
extern int tambaw; |
| 314 |
|
| 315 |
extern uchar treatmsgU [NMSG][MXLT+1]; |
| 316 |
extern char treatmsgICC [NMSG][MXLT+1]; |
| 317 |
extern char treatmsgICCAZ [NMSG][MXLT+1]; |
| 318 |
extern char treatmsgICCAZ09[NMSG][MXLT+1]; |
| 319 |
extern uchar treatmsgUAZ [NMSG][MXLT+1]; |
| 320 |
extern uchar treatmsgUAZ09 [NMSG][MXLT+1]; |
| 321 |
|
| 322 |
extern char treatmsgAZ [NMSG][MXLT+1]; |
| 323 |
extern char treatmsgAZ09 [NMSG][MXLT+1]; |
| 324 |
|
| 325 |
extern char msgword[NMSG][MXFL+1]; |
| 326 |
|
| 327 |
extern int clueorderindex; |
| 328 |
extern int gridorderindex[MXLE]; |
| 329 |
extern int checking[MXLE]; |
| 330 |
extern int lightx; |
| 331 |
extern int lighty; |
| 332 |
extern int lightdir; |
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
#define NLOOKUP 6 |
| 337 |
#define NPREFS (14+NLOOKUP*2) |
| 338 |
extern int prefdata[NPREFS]; |
| 339 |
extern char prefstring[NPREFS][SLEN+1]; |
| 340 |
#define clickblock (prefdata[0]) |
| 341 |
#define clickbar (prefdata[1]) |
| 342 |
#define shownums (prefdata[2]) |
| 343 |
#define mincheck (prefdata[3]) |
| 344 |
#define maxcheck (prefdata[4]) |
| 345 |
#define afunique (prefdata[5]) |
| 346 |
#define afrandom (prefdata[6]) |
| 347 |
#define eptsq (prefdata[7]) |
| 348 |
#define hpxsq (prefdata[8]) |
| 349 |
#define lnis (prefdata[9]) |
| 350 |
#define lookupname(i) (prefstring[10+(i)]) |
| 351 |
#define lookup(i) (prefstring[10+NLOOKUP+(i)]) |
| 352 |
#define startup_dict1 (prefstring[10+NLOOKUP*2]) |
| 353 |
#define startup_ff1 (prefstring[10+NLOOKUP*2+1]) |
| 354 |
#define startup_af1 (prefstring[10+NLOOKUP*2+2]) |
| 355 |
#define startup_al (prefdata[10+NLOOKUP*2+3]) |
| 356 |
|
| 357 |
#endif |