-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfunctions.c
86 lines (84 loc) · 2.29 KB
/
functions.c
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
86
/************************
* String functions
*/
CLIPS *prependString(char *buffer, CLIPS *clips)
{
char newText[strlen(clips->buffer) + strlen(buffer) + 1];
strcpy(newText, buffer);
strcat(newText, clips->buffer);
return al_clips( LITERAL, 0, 0, newText, strlen(newText)+1);
}
CLIPS *appendString(CLIPS *clips,char *buffer)
{
char newText[strlen(clips->buffer) + strlen(buffer) + 1];
strcpy(newText, clips->buffer);
strcat(newText, buffer);
return al_clips( LITERAL, 0, 0, newText, strlen(newText)+1);
}
CLIPS *append2Strings(CLIPS *clips,char *buffer,char *buffer2)
{
char newText[strlen(clips->buffer) + strlen(buffer) + strlen(buffer2) + 1];
strcpy(newText, clips->buffer);
strcat(newText, buffer);
strcat(newText, buffer2);
return al_clips( LITERAL, 0, 0, newText, strlen(newText)+1);
}
CLIPS *prepend2Strings(char *buffer1, char *buffer2, CLIPS *clips)
{
char newText[strlen(clips->buffer) + strlen(buffer1) + strlen(buffer2) + 1];
strcpy(newText, buffer1);
strcat(newText, buffer2);
strcat(newText, clips->buffer);
return al_clips( LITERAL, 0, 0, newText, strlen(newText)+1);
}
CLIPS *prepend3Strings(char *buffer1, char *buffer2, char *buffer3, CLIPS *clips)
{
char newText[strlen(clips->buffer) + strlen(buffer1) + strlen(buffer2)+ strlen(buffer3) + 1];
strcpy(newText, buffer1);
strcat(newText, buffer2);
strcat(newText, buffer3);
strcat(newText, clips->buffer);
return al_clips( LITERAL, 0, 0, newText, strlen(newText)+1);
}
/*******************
* Language Functions
*/
CLIPS *createModifier(int token)
{
char newText[strlen(tokens[token % TYPEDEF])+1];
strcpy(newText,tokens[token % TYPEDEF]);
int i;
for(i = 0; newText[ i ]; i++)
newText[i] = tolower(newText[ i ]);
return al_clips(token,0,0,newText,strlen(newText)+1);
}
CLIPS *createLeftBracket() {
return al_clips( LITERAL, 0, 0, "{", 2);
}
CLIPS *createRightBracket() {
return al_clips( LITERAL, 0, 0, "}", 2);
}
CLIPS *createEquals()
{
return al_clips(LITERAL,0,0,"=",2);
}
CLIPS *createSemicolon()
{
return al_clips(LITERAL,0,0,";",2);
}
CLIPS *createFromString(char *c)
{
return al_clips(LITERAL,0,0,c,strlen(c)+1);
}
CLIPS *createFromStringWithToken(char *c,int token)
{
return al_clips(token,0,0,c,strlen(c)+1);
}
void maskClips(CLIPS *clips,int mask)
{
while(clips)
{
clips->mask |= mask;
clips = clips->next;
}
}