-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathFeature.cpp
More file actions
85 lines (67 loc) · 1.89 KB
/
Feature.cpp
File metadata and controls
85 lines (67 loc) · 1.89 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "stdafx.h"
#include "data.h"
#include "chess.h"
#include "Resource.h"
#include "pregen.h"
void
ParseAttribs(COLORREF *color, int *effects, TCHAR* argValue){
TCHAR *e = argValue;
int eff = 0;
while (*e) {
if (*e == 'b') eff |= CFE_BOLD;
else if (*e == 'i') eff |= CFE_ITALIC;
else if (*e == 'u') eff |= CFE_UNDERLINE;
else if (*e == 's') eff |= CFE_STRIKEOUT;
else if (*e == '#' || isdigit(*e)) break;
e++;
}
*effects = eff;
*color = ParseColorName(e);
}
int
BoolFeature(char **p,char *name,int *loc,ChessProgramState *cps){
TCHAR buf[MSG_SIZ];
int len = (int)strlen(name);
int val;
if (strncmp((*p), name, len) == 0 && (*p)[len] == '=') {
(*p) += len + 1;
sscanf_s(*p, "%d", &val);
*loc = (val != 0);
while (**p && **p != ' ') (*p)++;
swprintf_s(buf,MSG_SIZ, L"accepted %hs\n", name);
SendToProgram(buf, cps);
return TRUE;
}
return FALSE;
}
int
IntFeature(char **p,char *name,int *loc,ChessProgramState *cps){
TCHAR buf[MSG_SIZ];
int len = (int)strlen(name);
if (strncmp((*p), name, len) == 0 && (*p)[len] == '=') {
(*p) += len + 1;
sscanf_s(*p, "%d", loc);
while (**p && **p != ' ') (*p)++;
swprintf_s(buf,MSG_SIZ, L"accepted %hs\n", name);
SendToProgram(buf, cps);
return TRUE;
}
return FALSE;
}
void
FeatureDone(ChessProgramState *cps,int val){
//DelayedEventCallback cb = GetDelayedEvent();
//if ((cb == InitBackEnd3 && cps == &DIS.first) ||
// (cb == TwoMachinesEventIfReady && cps == &DIS.second)) {
// CancelDelayedEvent();
// ScheduleDelayedEvent(cb, val ? 1 : 3600000);
//}
//cps->UCCI_initDone = val;
}
VOID //有参数错误时,显示并退出
ExitArgError(TCHAR *msg, TCHAR *badArg){
TCHAR buf[MSG_SIZ];
StringCbPrintf(buf,MSG_SIZ,_T("%s %s"), msg, badArg);
LogOut(buf);
exit(2);
}