forked from dliganov/Chaotic-DAW
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAwful_utils_common.cpp
1323 lines (1197 loc) · 30 KB
/
Awful_utils_common.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
#include "awful.h"
#include "awful_audio.h"
#include "awful_instruments.h"
#include "awful_elements.h"
#include "awful_paramedit.h"
#include "awful_controls.h"
#include "awful_panels.h"
#include "awful_cursorandmouse.h"
#include "awful_utils_common.h"
#include "awful_preview.h"
extern float NoteToFreq(int note);
extern void PanConstantRule(float pan, float* volL, float* volR);
extern void PanLinearRule(float pan, float* volL, float* volR);
extern void CheckTempDrawareas();
extern void CheckButtonsRepaint();
extern void GetOriginalInstrumentAlias(const char* name, char* alias);
extern bool CheckMixcellLoop(Mixcell* mc, Mixcell* outmc);
extern Mixcell* GetMixcellFromFXString(DigitStr* dfxstr);
extern bool IsPianoKeyPressed(int pkeynum);
extern bool CheckPlaneCrossing(int x1, int y1, int x2, int y2, int a1, int b1, int a2, int b2);
extern void AuxCheck();
extern int Tick2X(float tick, Loc loc);
extern float X2Tick(int x, Loc loc);
extern int Line2Y(int line, Loc loc);
extern int Y2Line(int y, Loc loc);
extern int Gx(int xc, Loc loc);
extern int Gy(int yc, Loc loc);
extern void ToLowerCase(char* data);
extern void ToUpperCase(char* data);
extern void Get_FileName(char* source, char* dest);
extern char* GetOriginalPatternName();
extern void Num2String(long num, char* string);
extern void ParamNum2String(long num, char* string);
extern long ParamString2Num(char* string);
extern Symbol GetSymbolFromString(char* data);
extern AliasRecord* GetAliasRecordFromString(char* str);
extern Instrument* CheckStringForInstrumentAlias(char* string);
extern float CalcSampleFreqIncrement(Sample* sample, int semitones);
extern float Calc_SlideMultiplier(unsigned long frame_length, int semitones);
extern float CalcFreqRatio(int semitones);
extern long Tick2Frame(float tick);
extern float Tick2Second(float tick);
extern float Frame2Tick(unsigned long frame);
extern float Frame2Tick(double frame);
extern inline float Interpolate_Line(double x1, float y1, double x2, float y2, double x3);
extern int Calc_PixLength(long num_frames, long sample_rate, float tickwidth);
extern float Calc_PercentPan(float pan_percent);
extern inline float Div100(float percent);
extern void Vanish(Element* el);
extern void Vanish_CleanUp();
extern int RoundDouble(double val);
extern int RoundFloat(float val);
extern int MapKeyToNote(char character, bool relative);
extern CmdType MapCNum2CType(int com_num);
extern int MapCType2CNum(CmdType command);
extern float MapItem2Quant(MItemType itype);
extern void CopyImageSection(Image* img1, Image* img2, int x1, int y1, int x2, int y2, int w, int h);
extern Pattern* CheckStringForPatternName(char* string);
extern float GetVolOutput(float val);
extern float Second2Tick(float sec);
int MapKeyToNote(char character, bool relative)
{
int oct;
if(!relative)
{
oct = Octave;
}
else
{
oct = relOctave;
}
ToLowerCase(&character);
int note = -1000;
int base0 = oct * 12 - 12;
int base1 = oct * 12;
switch(character)
{
// Upper row:
case 0x71:
note = base1 + 0;
break;
case 0x32:
note = base1 + 1;
break;
case 0x77:
note = base1 + 2;
break;
case 0x33:
note = base1 + 3;
break;
case 0x65:
note = base1 + 4;
break;
case 0x72:
note = base1 + 5;
break;
case 0x35:
note = base1 + 6;
break;
case 0x74:
note = base1 + 7;
break;
case 0x36:
note = base1 + 8;
break;
case 0x79:
note = base1 + 9;
break;
case 0x37:
note = base1 + 10;
break;
case 0x75:
note = base1 + 11;
break;
case 0x69:
note = base1 + 12;
break;
case 0x39:
note = base1 + 13;
break;
case 0x6F:
note = base1 + 14;
break;
case 0x30:
note = base1 + 15;
break;
case 0x70:
note = base1 + 16;
break;
// Lower row:
case 0x7A:
note = base0 + 0;
break;
case 0x73:
note = base0 + 1;
break;
case 0x78:
note = base0 + 2;
break;
case 0x64:
note = base0 + 3;
break;
case 0x63:
note = base0 + 4;
break;
case 0x76:
note = base0 + 5;
break;
case 0x67:
note = base0 + 6;
break;
case 0x62:
note = base0 + 7;
break;
case 0x68:
note = base0 + 8;
break;
case 0x6E:
note = base0 + 9;
break;
case 0x6A:
note = base0 + 10;
break;
case 0x6D:
note = base0 + 11;
break;
case 0x2C:
note = base0 + 12;
break;
case 0x6C:
note = base0 + 13;
break;
case 0x2E:
note = base0 + 14;
break;
case 0x3B:
note = base0 + 15;
break;
}
return note;
}
CmdType MapCNum2CType(int com_num)
{
CmdType type;
switch(com_num)
{
case 0:
type = Cmd_Default;
break;
case 1:
type = Cmd_Vol;
break;
case 2:
type = Cmd_Pan;
break;
case 3:
type = Cmd_Mute;
break;
case 4:
type = Cmd_Solo;
break;
case 5:
type = Cmd_VolEnv;
break;
case 6:
type = Cmd_PanEnv;
break;
default:
break;
}
return type;
}
int MapCType2CNum(CmdType command)
{
int num = 0;
switch(command)
{
case Cmd_Default:
num = 0;
break;
case Cmd_Vol:
num = 1;
break;
case Cmd_Pan:
num = 2;
break;
case Cmd_Mute:
num = 3;
break;
case Cmd_Solo:
num = 4;
break;
case Cmd_VolEnv:
num = 5;
break;
case Cmd_PanEnv:
num = 6;
break;
case Cmd_LocVolEnv:
num = 5;
break;
case Cmd_LocPanEnv:
num = 6;
break;
default:
break;
}
return num;
}
float MapItem2Quant(MItemType itype)
{
switch(itype)
{
case MItem_Step:
return 1;
break;
case MItem_Step12:
return 0.5;
break;
case MItem_Step14:
return 0.25;
break;
case MItem_Step13:
return 1.0f/3.0f;
break;
case MItem_Step16:
return 1.0f/6.0f;
break;
case MItem_Beat:
return (float)ticks_per_beat;
break;
case MItem_Bar:
return float(ticks_per_beat*beats_per_bar);
break;
case MItem_None:
return -1.f;
break;
default:
return 1;
}
}
/*==================================================================================================
BRIEF: Converts tick into x-coordinate (app window relative).
PARAMETERS:
[IN]
tick - tick value
loc - grid location
[OUT]
N/A
OUTPUT: x-coordinate
==================================================================================================*/
int Tick2X(float tick, Loc loc)
{
if(loc == Loc_MainGrid)
{
//return ApproxFloat((tick - OffsTick)*tickWidth + GridX1);
return RoundFloat(tick*tickWidth) - RoundFloat(OffsTick*tickWidth) + GridX1;
}
else if(loc == Loc_SmallGrid)
{
//return ApproxFloat((tick - gAux->OffsTick)*gAux->tickWidth + GridXS1);
return RoundFloat(tick*aux_panel->tickWidth) - RoundFloat(aux_panel->OffsTick*aux_panel->tickWidth) + GridXS1;
}
else
{
return 0;
}
}
/*==================================================================================================
BRIEF: Converts x-coordinate (app window relative) into tick.
PARAMETERS:
[IN]
x - x-coordinate
loc - grid location
[OUT]
N/A
OUTPUT: tick value
==================================================================================================*/
float X2Tick(int x, Loc loc)
{
if(loc == Loc_MainGrid)
{
return ((float)x - GridX1)/tickWidth + OffsTick;
}
else if(loc == Loc_SmallGrid)
{
return ((float)x - GridXS1)/aux_panel->tickWidth + aux_panel->OffsTick;
}
else if(loc == Loc_StaticGrid)
{
return ((float)x - StX1)/st_tickWidth + st->tick_offset;
}
else
{
return 0;
}
}
/*==================================================================================================
BRIEF: Converts line into y-coordinate (app window relative).
PARAMETERS:
[IN]
line - line number
loc - grid location
[OUT]
N/A
OUTPUT: y-coordinate
==================================================================================================*/
int Line2Y(int line, Loc loc)
{
if(loc == Loc_MainGrid)
{
return ((line - OffsLine)*lineHeight + lineHeight + GridY1);
}
else if(loc == Loc_SmallGrid)
{
return ((line - aux_panel->OffsLine)*aux_panel->lineHeight + aux_panel->lineHeight + GridYS1);
}
else
{
return 0;
}
}
/*==================================================================================================
BRIEF: Converts y-coordinate (app window relative) into line.
PARAMETERS:
[IN]
y - y-coordinate
loc - grid location
[OUT]
N/A
OUTPUT: line number
==================================================================================================*/
int Y2Line(int y, Loc loc)
{
if(loc == Loc_MainGrid)
{
return (y - GridY1)/lineHeight + OffsLine;
}
else if(loc == Loc_SmallGrid)
{
return (y - GridYS1)/aux_panel->lineHeight + aux_panel->OffsLine;
}
else
{
return 0;
}
}
/*==================================================================================================
BRIEF: Converts x-coordinate relative to grid window into absolute grid x-coordinate.
PARAMETERS:
[IN]
xc - x-coordinate relative to grid window
loc - grid location
[OUT]
N/A
OUTPUT: absolute grid x-coordinate
==================================================================================================*/
int Gx(int xc, Loc loc)
{
if(loc == Loc_MainGrid)
{
return (int)(xc + OffsTick * tickWidth - GridX1);
}
else if(loc == Loc_SmallGrid)
{
return (int)(xc + aux_panel->OffsTick*aux_panel->tickWidth - GridXS1);
}
else if(loc == Loc_StaticGrid)
{
return (int)(xc + st->tick_offset * st_tickWidth - StX1);
}
else
{
return 0;
}
}
/*==================================================================================================
BRIEF: Converts y-coordinate relative to grid window into absolute grid y-coordinate.
PARAMETERS:
[IN]
yc - y-coordinate relative to grid window
loc - grid location
[OUT]
N/A
OUTPUT: absolute grid y-coordinate
==================================================================================================*/
int Gy(int yc, Loc loc)
{
if(loc == Loc_MainGrid)
{
return yc + OffsLine * lineHeight - GridY1;
}
else if(loc == Loc_SmallGrid)
{
return yc + aux_panel->OffsLine * aux_panel->lineHeight - GridYS1;
}
else
{
return 0;
}
}
//
////
///////////
////////////////////////// / / /
// Function ToLowerCase(char* data) - transforms all big letters into small ones
void ToLowerCase(char* data)
{
int ic, len, code;
len = strlen(data);
for(ic = 0; ic < len; ic++)
{
code = (short)data[ic];
if(code >= 0x41 && code <= 0x5A)
{
code += 0x20;
data[ic] = code;
}
}
}
//
////
///////////
////////////////////////// / / /
// Function ToUpperCase(char* data) - transforms all small letters into big ones
void ToUpperCase(char* data)
{
int ic, len, code;
len = strlen(data);
for(ic = 0; ic < len; ic++)
{
code = (short)data[ic];
if(code >= 0x61 && code <= 0x7A)
{
code -= 0x20;
data[ic] = code;
}
}
}
//
//////
//////////////////////
////////////
///////
/////
////
//
//
///
/////
////////
//////////
void Get_FileName(char* source, char* dest)
{
int ic, len, code;
len = strlen(source);
for(ic = 0; ic < len; ic++)
{
code = source[ic];
if((code >= 0x41 && code <= 0x5A)||
(code >= 0x61 && code <= 0x7A))
{
dest[ic] = code;
}
else
{
break;
}
}
dest[ic] = 0;
}
char* GetOriginalPatternName()
{
char* n = new char[5]; // TODO: overflow zone
memset(n, 0, 5);
//n[0] = 'p';
//n[1] = 't';
int index = 1;
Num2String(index, (char*)&n[0]);
Element* el = firstElem;
while(el != NULL)
{
if(el->IsPresent() && el->type == El_Pattern)
{
if(strcmp(n, ((Pattern*)el)->name->string) == 0)
{
index++;
Num2String(index, (char*)&(n[0]));
el = firstElem;
continue;
}
}
el = el->next;
}
return n;
}
Pattern* CheckStringForPatternName(char* string)
{
Element* el = firstElem;
while(el != NULL)
{
if(el->IsPresent() && el->type == El_Pattern)
{
if(strcmp(string, ((Pattern*)el)->name->string) == 0)
{
return (Pattern*)el;
}
}
el = el->next;
}
return NULL;
}
void Num2String(long num, char* string)
{
long count_digits = 100000;
long count_num;
short digit;
char char_digit;
char* p_string = string;
bool start = false;
count_num = num;
while(count_digits > 0)
{
digit = (short)(count_num / count_digits);
count_num = count_num % count_digits;
if((digit !=0)||(start == true))
{
char_digit = (char)(digit + 48);
*p_string = char_digit;
p_string++;
start = true;
}
count_digits /= 10;
}
if(start == false)
{
*p_string = (char)48; // zero
*p_string++;
}
*p_string = 0;
}
void ParamNum2String(long num, char* string)
{
long count_digits = 10;
long count_num;
short digit;
char char_digit;
char* p_string = string;
if(num == 100) // make dashed string "--" if 100
{
*p_string++ = 0x2D;
*p_string++ = 0x2D;
}
else if(num < 100)
{
count_num = num;
while(count_digits > 0)
{
digit = (short)(count_num / count_digits);
count_num = count_num % count_digits;
if(digit == 0)
{
*p_string = '0';
p_string++;
}
if(digit !=0)
{
char_digit = (char)(digit + 48);
*p_string = char_digit;
p_string++;
}
count_digits /= 10;
}
}
*p_string = 0;
}
long ParamString2Num(char* string)
{
long count_digits = 1;
int digit, nc;
int len = strlen(string);
long num = 0;
int dashcount = 0;
if(len != 0)
{
for(nc = len - 1; nc >= 0; nc--)
{
if(string[nc] == 0x2D)
{
dashcount++;
}
if((string[nc] >= 0x30)&&(string[nc] <= 0x39))
{
digit = string[nc] - 0x30;
num = num + digit * count_digits;
count_digits *= 10;
}
else if((string[nc] == 0x2D)||(string[nc] == 0x25))
{
count_digits *= 10;
}
}
if(dashcount == len)
{
num = 100; // 100 is a workaround for 2-digit number, likely to be changed to 10^len (len power of 10)
}
}
return(num);
}
float CalcSampleFreqIncrement(Sample* sample, int semitones)
{
float rate_inc = (float)((float)sample->sample_info.samplerate / (float)fSampleRate);
float note_mul = (float)(CalcFreqRatio(semitones));
return rate_inc*note_mul;
}
float Calc_SlideMultiplier(unsigned long frame_length, int semitones)
{
float r = CalcFreqRatio(semitones);
float sm = pow(r, (float)((double)1/(double)frame_length));
return sm;
}
float NoteToFreq(int note)
{
return 440.0f*CalcFreqRatio(note - 57);
}
////
//////////////////////////////////////////////
// Returns relative frequency multiplier between two notes
////////////////////////////////////////////////////////////
float CalcFreqRatio(int semitones)
{
int octave = abs(semitones / 12);
int note_oct = abs(semitones % 12);
float r = (float)freq_mul_table[note_oct]*(pow((float)2, octave));
if(semitones >= 0)
return r;
else
return (float)(1.0/r);
}
/////////////////////////////////////////////
// Certain frame, corresponding to certain tick. Depends on BPM.
inline long Tick2Frame(float tick)
{
return (unsigned long)(tick*frames_per_tick);
}
/////////////////////////////////////////////
// Certain frame, corresponding to certain tick. Depends on BPM.
float Tick2Second(float tick)
{
return Tick2Frame(tick)*one_divided_per_sample_rate;
}
/////////////////////////////////////////////
// Certain frame, corresponding to certain tick. Depends on BPM.
float Second2Tick(float sec)
{
return sec*fSampleRate*one_divided_per_frames_per_tick;
}
/////////////////////////////////////////////
// CTick, corresponding to certain frame. Depends on BPM.
float Frame2Tick(tframe frame)
{
return (float)(frame*one_divided_per_frames_per_tick);
}
float Frame2Tick(double frame)
{
return (float)(frame*one_divided_per_frames_per_tick);
}
///
///////////////////////////////////////
// Returns pixel length for a number of frames, depending on sample rate and current tick width
int Calc_PixLength(long num_frames, long sample_rate, float tickwidth)
{
float rate = (float)fSampleRate/sample_rate;
int l = RoundDouble(((double)num_frames/(double)fSampleRate)/seconds_in_tick*tickwidth * rate);
return l;
}
////////////////////////////////////////////////////
// Returns multiplier coefficients for left and right channels based on panning in percents.
float Calc_PercentPan(float pan_percent)
{
return pan_percent/50 - 1;
}
///////////////////////////
// Returns float edinitsa-based value
inline float Div100(float percent)
{
return(percent/100);
}
///////////////////////////////////////
// Returns linearly interpolated value between two values. Return value is y3 for given x3
// Interval is defined by [x1,x2] where x3 is any point on this interval
// y - is amplitude value of the signal being interpolated
INLINE float Interpolate_Line(double x1, float y1, double x2, float y2, double x3)
{
return (float)(y1 + (x3 - x1)*((y2 - y1)/(x2 - x1)));
}
void Vanish(Element* el)
{
if(el == M.active_elem)
{
M.active_elem = NULL;
}
if(el == C.curElem)
{
C.ExitToCurrentMode();
}
delList[delCount] = el;
delCount++;
}
// TODO: optimize adding/deleting
void Vanish_CleanUp()
{
Element* el;
while(delCount > 0)
{
delCount--;
el = delList[delCount];
DeleteElement(el, false, false);
}
}
int RoundDouble(double val)
{
int ival = abs((int)val);
if((fabs(val) - ival) >= 0.5)
ival++;
if(val > 0)
{
return ival;
}
else
{
return 0 - ival;
}
}
long RoundDoubleLong(double val)
{
long ival = c_abs((long)val);
if((c_abs(val) - ival) >= 0.5)
ival++;
if(val > 0)
{
return ival;
}
else
{
return 0 - ival;
}
}
int RoundFloat(float val)
{
int ival = abs((int)val);
if((fabs(val) - ival) >= 0.5)
ival++;
if(val > 0)
{
return ival;
}
else
{
return 0 - ival;
}
}
int RoundFloat1(float val)
{
int ival = abs((int)val);
if((fabs(val) - ival) > 0.5)
ival++;
if(val > 0)
{
return ival;
}
else
{
return 0 - ival;
}
}
Symbol GetSymbolFromString(char* data)
{
char* buffer;
int len;
Symbol s;
len = strlen(data);
buffer = (char*)malloc(len + 1);
memcpy(buffer, data, len);
buffer[len] = 0;
ToLowerCase(buffer);
if(strcmp(buffer, "#") == 0)
{
s = Symbol_Mute;
}
else if(strcmp(buffer, "^") == 0)
{
s = Symbol_Volume;
}
else if(strcmp(buffer, "*") == 0)
{
s = Symbol_Panning;
}
else if(strcmp(buffer, "/") == 0)
{
s = Symbol_Slider;
}
else if(strcmp(buffer, ">") == 0)
{
s = Symbol_Repeat;
}
else if(strcmp(buffer, "<") == 0)
{
s = Symbol_Reflect;
}
else if(strcmp(buffer, "~") == 0)
{
s = Symbol_Vibrate;
}
else if(strcmp(buffer, "=") == 0)
{
s = Symbol_Track;
}
else if(strcmp(buffer, "@") == 0)
{
s = Symbol_Local;
}
else if(strcmp(buffer, ".") == 0)
{
s = Symbol_Command;
}
else if(strcmp(buffer, "|") == 0)
{
s = Symbol_Break;
}
else if(strcmp(buffer, "%") == 0)
{
s = Symbol_Transpose;
}
else if(strcmp(buffer, "{") == 0)
{
s = Symbol_Bookmark;
}
else
{
s = SYMBOL_UNKNOWN;
}
free(buffer);
return s;
}
AliasRecord* GetAliasRecordFromString(char* str)
{
char* buffer;
int len;
len = strlen(str);
buffer = (char*)malloc(len + 1);
memcpy(buffer, str, len);
buffer[len] = 0;
ToLowerCase(buffer);
AliasRecord* ar = first_alias_record;
while(ar != NULL)
{
if(strcmp(buffer, ar->alias) == 0)
{
break;
}
ar = ar->next;
}
free(buffer);