/
ParseText.cpp
1128 lines (1001 loc) · 31.1 KB
/
ParseText.cpp
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ParseText.cpp
Copyright (C) David C. J. Matthews 2004, 2008 dm at prolingua.co.uk
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.
Or, point your browser to http://www.gnu.org/copyleft/gpl.html
*/
/*
Parser for the textual form of MHEG5.
This is very basic and is only there to enable some test programs to be run.
*/
#include "ParseText.h"
#include "ParseNode.h"
#include "BaseClasses.h"
#include "ASN1Codes.h"
#include "Root.h"
#include "Groups.h"
#include <ctype.h>
#include "Ingredients.h" // For GetEventType
#include "Text.h" // For GetJustification etc
#include "Engine.h"
#include "Logging.h"
#ifndef WIN32
#define stricmp strcasecmp
#endif
MHParseText::MHParseText(QByteArray &program)
: m_lineCount(1), m_nType(PTNull),
m_ch(0), m_nTag(0),
m_nInt(0), m_fBool(false),
m_String((unsigned char *)malloc(100)),
m_nStringLength(0), m_p(0)
{
}
MHParseText::~MHParseText()
{
free(m_String);
}
// Get the next character.
void MHParseText::GetNextChar()
{
if ((int)m_p >= m_data.size())
{
m_ch = EOF;
}
else
{
m_ch = m_data[m_p++];
}
}
// Maximum length of a tag (i.e. a symbol beginning with a colon). Actually the longest is around 22 chars.
#define MAX_TAG_LENGTH 30
const char *rchTagNames[] =
{
":Application",
":Scene",
":StdID",
":StdVersion",
":ObjectInfo",
":OnStartUp",
":OnCloseDown",
":OrigGCPriority",
":Items",
":ResidentPrg",
":RemotePrg",
":InterchgPrg",
":Palette",
":Font", // Occurs twice.
":CursorShape",
":BooleanVar",
":IntegerVar",
":OStringVar",
":ObjectRefVar",
":ContentRefVar",
":Link",
":Stream",
":Bitmap",
":LineArt",
":DynamicLineArt",
":Rectangle",
":Hotspot",
":SwitchButton",
":PushButton",
":Text",
":EntryField",
":HyperText",
":Slider",
":TokenGroup",
":ListGroup",
":OnSpawnCloseDown",
":OnRestart",
"", // Default attributes - encoded as a group in binary
":CharacterSet",
":BackgroundColour",
":TextCHook",
":TextColour",
":Font",
":FontAttributes",
":InterchgPrgCHook",
":StreamCHook",
":BitmapCHook",
":LineArtCHook",
":ButtonRefColour",
":HighlightRefColour",
":SliderRefColour",
":InputEventReg",
":SceneCS",
":AspectRatio",
":MovingCursor",
":NextScenes",
":InitiallyActive",
":CHook",
":OrigContent",
":Shared",
":ContentSize",
":CCPriority",
"" , // Link condition - always replaced by EventSource, EventType and EventData
":LinkEffect",
":Name",
":InitiallyAvailable",
":ProgramConnectionTag",
":OrigValue",
":ObjectRef",
":ContentRef",
":MovementTable",
":TokenGroupItems",
":NoTokenActionSlots",
":Positions",
":WrapAround",
":MultipleSelection",
":OrigBoxSize",
":OrigPosition",
":OrigPaletteRef",
":Tiling",
":OrigTransparency",
":BBBox",
":OrigLineWidth",
":OrigLineStyle",
":OrigRefLineColour",
":OrigRefFillColour",
":OrigFont",
":HJustification",
":VJustification",
":LineOrientation",
":StartCorner",
":TextWrapping",
":Multiplex",
":Storage",
":Looping",
":Audio",
":Video",
":RTGraphics",
":ComponentTag",
":OrigVolume",
":Termination",
":EngineResp",
":Orientation",
":MaxValue",
":MinValue",
":InitialValue",
":InitialPortion",
":StepSize",
":SliderStyle",
":InputType",
":CharList",
":ObscuredInput",
":MaxLength",
":OrigLabel",
":ButtonStyle",
":Activate",
":Add",
":AddItem",
":Append",
":BringToFront",
":Call",
":CallActionSlot",
":Clear",
":Clone",
":CloseConnection",
":Deactivate",
":DelItem",
":Deselect",
":DeselectItem",
":Divide",
":DrawArc",
":DrawLine",
":DrawOval",
":DrawPolygon",
":DrawPolyline",
":DrawRectangle",
":DrawSector",
":Fork",
":GetAvailabilityStatus",
":GetBoxSize",
":GetCellItem",
":GetCursorPosition",
":GetEngineSupport",
":GetEntryPoint",
":GetFillColour",
":GetFirstItem",
":GetHighlightStatus",
":GetInteractionStatus",
":GetItemStatus",
":GetLabel",
":GetLastAnchorFired",
":GetLineColour",
":GetLineStyle",
":GetLineWidth",
":GetListItem",
":GetListSize",
":GetOverwriteMode",
":GetPortion",
":GetPosition",
":GetRunningStatus",
":GetSelectionStatus",
":GetSliderValue",
":GetTextContent",
":GetTextData",
":GetTokenPosition",
":GetVolume",
":Launch",
":LockScreen",
":Modulo",
":Move",
":MoveTo",
":Multiply",
":OpenConnection",
":Preload",
":PutBefore",
":PutBehind",
":Quit",
":ReadPersistent",
":Run",
":ScaleBitmap",
":ScaleVideo",
":ScrollItems",
":Select",
":SelectItem",
":SendEvent",
":SendToBack",
":SetBoxSize",
":SetCachePriority",
":SetCounterEndPosition",
":SetCounterPosition",
":SetCounterTrigger",
":SetCursorPosition",
":SetCursorShape",
":SetData",
":SetEntryPoint",
":SetFillColour",
":SetFirstItem",
":SetFontRef",
":SetHighlightStatus",
":SetInteractionStatus",
":SetLabel",
":SetLineColour",
":SetLineStyle",
":SetLineWidth",
":SetOverwriteMode",
":SetPaletteRef",
":SetPortion",
":SetPosition",
":SetSliderValue",
":SetSpeed",
":SetTimer",
":SetTransparency",
":SetVariable",
":SetVolume",
":Spawn",
":Step",
":Stop",
":StorePersistent",
":Subtract",
":TestVariable",
":Toggle",
":ToggleItem",
":TransitionTo",
":Unload",
":UnlockScreen",
":GBoolean",
":GInteger",
":GOctetString",
":GObjectRef",
":GContentRef",
":NewColourIndex",
":NewAbsoluteColour",
":NewFontName",
":NewFontRef",
":NewContentSize",
":NewCCPriority",
":IndirectRef",
/* UK MHEG */
":SetBackgroundColour",
":SetCellPosition",
":SetInputRegister",
":SetTextColour",
":SetFontAttributes",
":SetVideoDecodeOffset",
":GetVideoDecodeOffset",
":GetFocusPosition",
":SetFocusPosition",
":SetBitmapDecodeOffset",
":GetBitmapDecodeOffset",
":SetSliderParameters",
/* Pseudo-operations. These are encoded as LinkCondition in binary. */
":EventSource",
":EventType",
":EventData",
":ActionSlots"
};
// Some example programs use these colour names
static struct
{
const char *name;
unsigned char r, g, b, t;
} colourTable[] =
{
{ "black", 0, 0, 0, 0 },
{ "transparent", 0, 0, 0, 255 },
{ "gray"/*sic*/, 128, 128, 128, 0 },
{ "darkgray"/*sic*/, 192, 192, 192, 0 },
{ "red", 255, 0, 0, 0 },
{ "darkred", 128, 0, 0, 0 },
{ "blue", 0, 0, 255, 0 },
{ "darkblue", 0, 0, 128, 0 },
{ "green", 0, 255, 0, 0 },
{ "darkgreen", 0, 128, 0, 0 },
{ "yellow", 255, 255, 0, 0 },
{ "cyan", 0, 255, 255, 0 },
{ "magenta", 255, 0, 255, 0 }
};
// Search for a tag and return it if it exists. Returns -1 if it isn't found.
static int FindTag(const char *p)
{
for (int i = 0; i < (int)(sizeof(rchTagNames) / sizeof(rchTagNames[0])); i++)
{
if (stricmp(p, rchTagNames[i]) == 0)
{
return i;
}
}
return -1;
}
// Ditto for the enumerated types
#define MAX_ENUM 30
void MHParseText::Error(const char *str)
{
MHERROR(QString("%1- at line %2\n").arg(str).arg(m_lineCount));
}
// Lexical analysis. Get the next symbol.
void MHParseText::NextSym()
{
while (1)
{
switch (m_ch)
{
case '\n':
m_lineCount++; // And drop to next
case ' ':
case '\r':
case '\t':
case '\f':
// Skip white space.
GetNextChar();
continue;
case '/':
{
// Comment.
GetNextChar();
if (m_ch != '/')
{
Error("Malformed comment");
}
do
{
GetNextChar();
}
while (m_ch != '\n' && m_ch != '\f' && m_ch != '\r');
continue; // Next symbol
}
case ':': // Start of a tag
{
m_nType = PTTag;
char buff[MAX_TAG_LENGTH+1];
char *p = buff;
do
{
*p++ = m_ch;
GetNextChar();
if (p == buff + MAX_TAG_LENGTH)
{
break;
}
}
while ((m_ch >= 'a' && m_ch <= 'z') || (m_ch >= 'A' && m_ch <= 'Z'));
*p = 0;
// Look it up and return it if it's found.
m_nTag = FindTag(buff);
if (m_nTag >= 0)
{
return;
}
// Unrecognised tag.
Error("Unrecognised tag");
}
case '"': // Start of a string
{
m_nType = PTString;
// MHEG strings can include NULLs. For the moment we pass back the length and also
// null-terminate the strings.
m_nStringLength = 0;
while (1)
{
GetNextChar();
if (m_ch == '"')
{
break; // Finished the string.
}
if (m_ch == '\\')
{
GetNextChar(); // Escape character. Include the next char in the string.
}
if (m_ch == '\n' || m_ch == '\r')
{
Error("Unterminated string");
}
// We grow the buffer to the largest string in the input.
unsigned char *str = (unsigned char *)realloc(m_String, m_nStringLength + 2);
if (str == NULL)
{
Error("Insufficient memory");
}
m_String = str;
m_String[m_nStringLength++] = m_ch;
}
GetNextChar(); // Skip the closing quote
m_String[m_nStringLength] = 0;
return;
}
case '\'': // Start of a string using quoted printable
{
m_nType = PTString;
m_nStringLength = 0;
// Quotable printable strings contain escape sequences beginning with the
// escape character '='. The strings can span lines but each line must
// end with an equal sign.
while (1)
{
GetNextChar();
if (m_ch == '\'')
{
break;
}
if (m_ch == '\n')
{
Error("Unterminated string");
}
if (m_ch == '=') // Special code in quoted-printable.
{
// Should be followed by two hex digits or by white space and a newline.
GetNextChar();
if (m_ch == ' ' || m_ch == '\t' || m_ch == '\r' || m_ch == '\n')
{
// White space. Remove everything up to the newline.
while (m_ch != '\n')
{
if (!(m_ch == ' ' || m_ch == '\t' || m_ch == '\r'))
{
Error("Malformed quoted printable string");
}
GetNextChar();
}
continue; // continue with the first character on the next line
}
else
{
int byte = 0;
if (m_ch >= '0' && m_ch <= '9')
{
byte = m_ch - '0';
}
else if (m_ch >= 'A' && m_ch <= 'F')
{
byte = m_ch - 'A' + 10;
}
else if (m_ch >= 'a' && m_ch <= 'f')
{
byte = m_ch - 'a' + 10;
}
else
{
Error("Malformed quoted printable string");
}
byte *= 16;
GetNextChar();
if (m_ch >= '0' && m_ch <= '9')
{
byte += m_ch - '0';
}
else if (m_ch >= 'A' && m_ch <= 'F')
{
byte += m_ch - 'A' + 10;
}
else if (m_ch >= 'a' && m_ch <= 'f')
{
byte += m_ch - 'a' + 10;
}
else
{
Error("Malformed quoted printable string");
}
m_ch = byte; // Put this into the string.
}
}
// We grow the buffer to the largest string in the input.
unsigned char *str = (unsigned char *)realloc(m_String, m_nStringLength + 2);
if (str == NULL)
{
Error("Insufficient memory");
}
m_String = str;
m_String[m_nStringLength++] = m_ch;
}
GetNextChar(); // Skip the closing quote
m_String[m_nStringLength] = 0;
return;
}
case '`': // Start of a string using base 64
// These can, presumably span lines.
MHERROR("Base 64 string is not implemented");
break;
case '#': // Start of 3-byte hex constant.
MHERROR("3-byte hex constant is not implemented");
break;
case '-':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
{
m_nType = PTInt;
bool negative = m_ch == '-';
if (negative)
{
GetNextChar();
if (m_ch < '0' || m_ch > '9')
{
Error("Expected digit after '-'");
}
}
// Start of a number. Hex can be represented as 0xn.
// Strictly speaking hex values cannot be preceded by a minus sign.
m_nInt = m_ch - '0';
GetNextChar();
if (m_nInt == 0 && (m_ch == 'x' || m_ch == 'X'))
{
MHERROR("Hex constant is not implemented");
}
while (m_ch >= '0' && m_ch <= '9')
{
m_nInt = m_nInt * 10 + m_ch - '0';
// TODO: What about overflow?
GetNextChar();
}
if (negative)
{
m_nInt = -m_nInt;
}
return;
}
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
case 'h':
case 'i':
case 'j':
case 'k':
case 'l':
case 'm':
case 'n':
case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
case 'u':
case 'v':
case 'w':
case 'x':
case 'y':
case 'z':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
{
// Start of an enumerated type.
m_nType = PTEnum;
char buff[MAX_ENUM+1];
char *p = buff;
do
{
*p++ = m_ch;
GetNextChar();
if (p == buff + MAX_ENUM)
{
break;
}
}
while ((m_ch >= 'a' && m_ch <= 'z') || (m_ch >= 'A' && m_ch <= 'Z') || m_ch == '-');
*p = '\0';
if (stricmp(buff, "NULL") == 0)
{
m_nType = PTNull;
return;
}
if (stricmp(buff, "true") == 0)
{
m_nType = PTBool;
m_fBool = true;
return;
}
if (stricmp(buff, "false") == 0)
{
m_nType = PTBool;
m_fBool = false;
return;
}
// Look up the tag in all the tables. Fortunately all the enumerations
// are distinct so we don't need to know the context.
m_nInt = MHLink::GetEventType(buff);
if (m_nInt > 0)
{
return;
}
m_nInt = MHText::GetJustification(buff);
if (m_nInt > 0)
{
return;
}
m_nInt = MHText::GetLineOrientation(buff);
if (m_nInt > 0)
{
return;
}
m_nInt = MHText::GetStartCorner(buff);
if (m_nInt > 0)
{
return;
}
m_nInt = MHSlider::GetOrientation(buff);
if (m_nInt > 0)
{
return;
}
m_nInt = MHSlider::GetStyle(buff);
if (m_nInt > 0)
{
return;
}
// Check the colour table. If it's there generate a string containing the colour info.
for (int i = 0; i < (int)(sizeof(colourTable) / sizeof(colourTable[0])); i++)
{
if (stricmp(buff, colourTable[i].name) == 0)
{
m_nType = PTString;
unsigned char *str = (unsigned char *)realloc(m_String, 4 + 1);
if (str == NULL)
{
Error("Insufficient memory");
}
m_String = str;
m_String[0] = colourTable[i].r;
m_String[1] = colourTable[i].g;
m_String[2] = colourTable[i].b;
m_String[3] = colourTable[i].t;
m_nStringLength = 4;
m_String[m_nStringLength] = 0;
return;
}
}
Error("Unrecognised enumeration");
break;
}
case '{': // Start of a "section".
// The standard indicates that open brace followed by a tag should be written
// as a single word. We'll be more lenient and allow spaces or comments between them.
m_nType = PTStartSection;
GetNextChar();
return;
case '}': // End of a "section".
m_nType = PTEndSection;
GetNextChar();
return;
case '(': // Start of a sequence.
m_nType = PTStartSeq;
GetNextChar();
return;
case ')': // End of a sequence.
m_nType = PTEndSeq;
GetNextChar();
return;
case EOF:
m_nType = PTEOF;
return;
default:
Error("Unknown character");
GetNextChar();
}
}
}
MHParseNode *MHParseText::DoParse()
{
MHParseNode *pRes = NULL;
try
{
switch (m_nType)
{
case PTStartSection: // Open curly bracket
{
NextSym();
// Should be followed by a tag.
if (m_nType != PTTag)
{
Error("Expected ':' after '{'");
}
MHPTagged *pTag = new MHPTagged(m_nTag);
pRes = pTag;
NextSym();
while (m_nType != PTEndSection)
{
pTag->AddArg(DoParse());
}
NextSym(); // Remove the close curly bracket.
break;
}
case PTTag: // Tag on its own.
{
int nTag = m_nTag;
MHPTagged *pTag = new MHPTagged(nTag);
pRes = pTag;
NextSym();
switch (nTag)
{
case C_ITEMS:
case C_LINK_EFFECT:
case C_ACTIVATE:
case C_ADD:
case C_ADD_ITEM:
case C_APPEND:
case C_BRING_TO_FRONT:
case C_CALL:
case C_CALL_ACTION_SLOT:
case C_CLEAR:
case C_CLONE:
case C_CLOSE_CONNECTION:
case C_DEACTIVATE:
case C_DEL_ITEM:
case C_DESELECT:
case C_DESELECT_ITEM:
case C_DIVIDE:
case C_DRAW_ARC:
case C_DRAW_LINE:
case C_DRAW_OVAL:
case C_DRAW_POLYGON:
case C_DRAW_POLYLINE:
case C_DRAW_RECTANGLE:
case C_DRAW_SECTOR:
case C_FORK:
case C_GET_AVAILABILITY_STATUS:
case C_GET_BOX_SIZE:
case C_GET_CELL_ITEM:
case C_GET_CURSOR_POSITION:
case C_GET_ENGINE_SUPPORT:
case C_GET_ENTRY_POINT:
case C_GET_FILL_COLOUR:
case C_GET_FIRST_ITEM:
case C_GET_HIGHLIGHT_STATUS:
case C_GET_INTERACTION_STATUS:
case C_GET_ITEM_STATUS:
case C_GET_LABEL:
case C_GET_LAST_ANCHOR_FIRED:
case C_GET_LINE_COLOUR:
case C_GET_LINE_STYLE:
case C_GET_LINE_WIDTH:
case C_GET_LIST_ITEM:
case C_GET_LIST_SIZE:
case C_GET_OVERWRITE_MODE:
case C_GET_PORTION:
case C_GET_POSITION:
case C_GET_RUNNING_STATUS:
case C_GET_SELECTION_STATUS:
case C_GET_SLIDER_VALUE:
case C_GET_TEXT_CONTENT:
case C_GET_TEXT_DATA:
case C_GET_TOKEN_POSITION:
case C_GET_VOLUME:
case C_LAUNCH:
case C_LOCK_SCREEN:
case C_MODULO:
case C_MOVE:
case C_MOVE_TO:
case C_MULTIPLY:
case C_OPEN_CONNECTION:
case C_PRELOAD:
case C_PUT_BEFORE:
case C_PUT_BEHIND:
case C_QUIT:
case C_READ_PERSISTENT:
case C_RUN:
case C_SCALE_BITMAP:
case C_SCALE_VIDEO:
case C_SCROLL_ITEMS:
case C_SELECT:
case C_SELECT_ITEM:
case C_SEND_EVENT:
case C_SEND_TO_BACK:
case C_SET_BOX_SIZE:
case C_SET_CACHE_PRIORITY:
case C_SET_COUNTER_END_POSITION:
case C_SET_COUNTER_POSITION:
case C_SET_COUNTER_TRIGGER:
case C_SET_CURSOR_POSITION:
case C_SET_CURSOR_SHAPE:
case C_SET_DATA:
case C_SET_ENTRY_POINT:
case C_SET_FILL_COLOUR:
case C_SET_FIRST_ITEM:
case C_SET_FONT_REF:
case C_SET_HIGHLIGHT_STATUS:
case C_SET_INTERACTION_STATUS:
case C_SET_LABEL:
case C_SET_LINE_COLOUR:
case C_SET_LINE_STYLE:
case C_SET_LINE_WIDTH:
case C_SET_OVERWRITE_MODE:
case C_SET_PALETTE_REF:
case C_SET_PORTION:
case C_SET_POSITION:
case C_SET_SLIDER_VALUE:
case C_SET_SPEED:
case C_SET_TIMER:
case C_SET_TRANSPARENCY:
case C_SET_VARIABLE:
case C_SET_VOLUME:
case C_SPAWN:
case C_STEP:
case C_STOP:
case C_STORE_PERSISTENT:
case C_SUBTRACT:
case C_TEST_VARIABLE:
case C_TOGGLE: