forked from teamQPM/qpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
us_shell.prg
1073 lines (1005 loc) · 41.6 KB
/
us_shell.prg
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
/*
* QPM - QAC based Project Manager
*
* Copyright 2011-2021 Fernando Yurisich <[email protected]>
* https://teamqpm.github.io/
*
* Based on QAC - Project Manager for (x)Harbour
* Copyright 2006-2011 Carozo de Quilmes <[email protected]>
* http://www.CarozoDeQuilmes.com.ar
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/
#include "FuentesComunes\US_Env.h"
#include "fileio.ch"
#define VERSION "01.07"
#define CRLF hb_osNewLine()
MEMVAR CQPMDIR
MEMVAR bList
PROCEDURE MAIN( ... )
LOCAL aParams := hb_AParams()
LOCAL cTxtAux, cTxtAux2 := "", i, nCount, cWord
LOCAL cModuleNameAux, cLineaAux, cLineaAux2, bEncontroValido := .F.
LOCAL nPos, bObjLst := .F., bExpLst := .F., cObjExt := ".ObjLst", cExpExt := ".ExpLst"
LOCAL MemoObjLst := "", MemoExpLst := "EXPORTS"
LOCAL bDelete := .F., nZap, cFileStop := "", lStop := .F.
LOCAL bPellesDynamic, bBorlandDynamic, bMinGWDynamic
LOCAL cDLL_Name := "", nDLL_NameAux, cDLL_NameFunAux, cDLL_NameMemoAux
LOCAL cParam, cPar1, cPar2, cPar3, cPar4, j, vFun := {}
LOCAL nLineaBaseExport, vObjectsPelles := {}, vFuncionesPelles := {}, bFunList
PRIVATE cQPMDir := "", bList := .F.
cParam := ""
FOR i := 1 TO Len( aParams )
cParam += ( aParams[ i ] + " " )
NEXT i
cParam := AllTrim( cParam )
IF Upper( US_Word( cParam, 1 ) ) == "-VER" .or. Upper( US_Word( cParam, 1 ) ) == "-VERSION"
hb_MemoWrit( "US_Shell.version", VERSION )
RETURN
ENDIF
IF Upper( US_Word( cParam, 1 ) ) != "QPM"
__Run( "ECHO " + "US_Res 001E: Running Outside System" )
RETURN
ENDIF
cParam := US_WordDel( cParam, 1 )
IF Upper( SubStr( cParam, 1, 5 ) ) == "-LIST"
bList := .T.
cQPMDir := SubStr( US_Word( cParam, 1), 6 )
IF ! Right( cQPMDir, 1 ) == "\"
cQPMDir += "\"
ENDIF
cParam := AllTrim( SubStr( cParam, US_WordInd( cParam, 2 ) ) )
ENDIF
Say( "------------ " + "US_Shell.version " + VERSION )
IF ( nPos := US_WordPos( "-FILESTOP", US_Upper( cParam ) ) ) > 0
IF US_Words( cParam ) == nPos
Say( "US_Shell 001E: FILESTOP without file, USE: -FILESTOP cDisc:\cPath\cFileName.ext" )
RETURN
ENDIF
cFileStop := StrTran( US_Word( cParam, nPos + 1 ), "|", " " )
Say( "US_Shell 001I: FILESTOP: " + cFileStop )
cParam := US_WordDel( cParam, nPos + 1 )
cParam := US_WordDel( cParam, nPos )
ENDIF
cPar1 := Upper( US_Word( cParam, 1 ) )
DO CASE
CASE cPar1 == "CHECKRC"
Say( "US_Shell 100I: " + cPar1 )
IF US_Words( cParam ) < 2
Say( "US_Shell 101E: Invalid parameter count: " + cParam + CRLF )
Say( "No file to check!", .T. )
ELSE
Say( "US_Shell 101I: Processing: " + cParam )
cPar2 := US_Word( cParam, 2 )
Say( "US_Shell 102I: Option: " + cPar2 )
IF Upper( cPar2 ) == "NOTFILE"
cPar3 := StrTran( US_Word( cParam, 3 ), "|", " " )
Say( "US_Shell 103I: File: " + cPar3 )
IF ! File( cPar3 )
Say( "US_Shell 104I: File not found" + CRLF )
Say( "File not found!", .T. )
ELSE
Say( "US_Shell 105I: File found" )
Say( "US_Shell 106I: Size " + AllTrim( Str( US_FileSize( cPar3 ) ) ) + ' bytes' + CRLF )
ENDIF
ELSE
Say( "US_Shell 107E: Invalid parameter" + CRLF )
ENDIF
ENDIF
CASE cPar1 == "COPY" .OR. cPar1 == "COPYZAP"
Say( "US_Shell 200I: " + cPar1 )
IF US_Words( cParam ) < 3
Say( "US_Shell 201E: Invalid parameter count: " + cParam + CRLF )
Say( "No file to copy!", .T. )
ELSE
Say( "US_Shell 101I: Processing: " + cParam )
cPar2 := StrTran( US_Word( cParam, 2 ), "|", " " )
Say( "US_Shell 202I: File In: " + cPar2 )
IF ! File( cPar2 )
Say( "US_Shell 203E: File not found" + CRLF )
Say( "File not found!", .T. )
ELSE
cPar3 := StrTran( US_Word( cParam, 3 ), "|", " " )
Say( "US_Shell 203I: Folder Out: " + cPar3 )
IF ! US_IsDirectory( US_FileNameOnlyPath( cPar3 ) )
Say( "US_Shell 204E: Output folder not found: " + cPar3 + CRLF )
Say( "Output folder not found!", .T. )
ELSE
IF FileCopy( cPar2, cPar3 ) == US_FileSize( cPar2 )
IF cPar1 == "COPYZAP"
nZap := US_FileChar26Zap( cPar3 )
DO CASE
CASE nZap == -1
Say( "US_Shell 205I: OK" )
Say( "US_Shell 206W: Char x'1A' not removed" + CRLF )
CASE nZap == 1
Say( "US_Shell 205I: OK" )
Say( "US_Shell 207I: Char x'1A' removed" + CRLF )
OTHERWISE
Say( "US_Shell 205I: OK" + CRLF )
ENDCASE
ELSE
Say( "US_Shell 205I: OK" + CRLF )
ENDIF
ELSE
Say( "US_Shell 208E: ERROR" + CRLF )
Say( "Error copying file!", .T. )
ENDIF
ENDIF
ENDIF
ENDIF
CASE cPar1 == "MOVE" .OR. cPar1 == "MOVEZAP"
Say( "US_Shell 300I: " + cPar1 )
IF US_Words( cParam ) < 3
Say( "US_Shell 301E: Invalid parameter count: " + cParam + CRLF )
Say( "No file to move!", .T. )
ELSE
Say( "US_Shell 301I: Processing: " + cParam )
cPar2 := StrTran( US_Word( cParam, 2 ), "|", " " )
Say( "US_Shell 302I: File In: " + cPar2 )
IF ! File( cPar2 )
Say( "US_Shell 303E: File not found" + CRLF )
Say( "File not found!", .T. )
ELSE
cPar3 := StrTran( US_Word( cParam, 3 ), "|", " " )
Say( "US_Shell 303I: Folder Out: " + cPar3 )
IF ! US_IsDirectory( US_FileNameOnlyPath( cPar3 ) )
Say( "US_Shell 304E: Output folder not found: " + cPar3 + CRLF )
Say( "Output folder not found!", .T. )
ELSE
IF FileCopy( cPar2, cPar3 ) == US_FileSize( cPar2 )
IF FErase( cPar2 ) != -1
IF cPar1 == "MOVEZAP"
nZap := US_FileChar26Zap( cPar3 )
DO CASE
CASE nZap == -1
Say( "US_Shell 305I: OK" )
Say( "US_Shell 306W: Char x'1A' not removed" + CRLF )
CASE nZap == 1
Say( "US_Shell 305I: OK" )
Say( "US_Shell 307I: Char x'1A' removed" + CRLF )
OTHERWISE
Say( "US_Shell 305I: OK" + CRLF )
ENDCASE
ELSE
Say( "US_Shell 305I: OK" + CRLF )
ENDIF
hb_MemoWrit( cPar2 + ".MOVED.TXT", "File " + cPar2 + " has been moved to: " + cPar3 )
ELSE
Say( "US_Shell 308E: ERROR deleting" + CRLF )
Say( "Error deleting file!", .T. )
ENDIF
ELSE
Say( "US_Shell 309E: ERROR copying" + CRLF )
Say( "Error copying file!", .T. )
ENDIF
ENDIF
ENDIF
ENDIF
CASE cPar1 == "LIST_TXT"
Say( "US_Shell 400I: LIST_TXT" )
IF US_Words( cParam ) < 2
Say( "US_Shell 401E: Invalid parameter count: " + cParam + CRLF )
Say( "No file to list!", .T. )
ELSE
Say( "US_Shell 401I: Processing: " + cParam )
IF ( nPos := US_WordPos( "-DELETE", US_Upper( cParam ) ) ) > 0
cParam := US_WordDel( cParam, nPos )
bDelete := .T.
ENDIF
cPar2 := StrTran( US_Word( cParam, 2 ), "|", " " )
Say( "US_Shell 402I: File In: " + cPar2 )
IF ! File( cPar2 )
Say( "US_Shell 402E: File not found" + CRLF )
Say( "File not found!", .T. )
ELSE
cTxtAux := MemoRead( cPar2 )
FOR i := 1 TO MLCount( cTxtAux, 254 )
Say( MemoLine( cTxtAux, 254, i ) )
IF File( cFileStop )
lStop := .T.
Say( "User stop!", .T. )
Say( "US_Shell 402W: User Stop" + CRLF )
EXIT
ENDIF
NEXT i
IF ! lStop
Say( "End of list.", .T. )
Say( "US_Shell 403I: End of list" + CRLF )
ENDIF
IF bDelete
FErase( cPar2 )
ENDIF
ENDIF
ENDIF
CASE cPar1 == "ANALIZE_DLL"
Say( "US_Shell 500I: ANALIZE_DLL" )
IF US_Words( cParam ) < 2
Say( "US_Shell 501E: Invalid parameter count: " + cParam + CRLF )
Say( "No file to analize!", .T. )
ELSE
Say( "US_Shell 501I: Processing: " + cParam )
IF ( nPos := US_WordPos( "-DELETE", US_Upper( cParam ) ) ) > 0
cParam := US_WordDel( cParam, nPos )
bDelete := .T.
ENDIF
Say( "Analizing Definition File for Dynamic Library (DLL)", .T. )
cPar2 := StrTran( US_Word( cParam, 2 ), "|", " " )
Say( "US_Shell 502I: File In: " + cPar2 )
IF ! File( cPar2 )
Say( "US_Shell 502E: File not found" + CRLF )
Say( "File not found!", .T. )
ELSE
Say( "Functions exported: ", .T. )
Say( "US_Shell 503I: Functions exported: " )
cTxtAux := MemoRead( cPar2 )
nLineaBaseExport := MLCount( cTxtAux, 254 )
FOR i := 1 TO MLCount( cTxtAux, 254 )
IF AllTrim( MemoLine( cTxtAux, 254, i ) ) == "EXPORTS"
nLineaBaseExport := i + 1
ENDIF
IF File( cFileStop )
lStop := .T.
Say( "User stop!", .T. )
Say( "US_Shell 504W: User Stop" + CRLF )
EXIT
ENDIF
NEXT i
IF ! lStop
FOR i := nLineaBaseExport TO MLCount( cTxtAux, 254 )
cLineaAux := US_Word( MemoLine( cTxtAux, 254, i ), 1 )
Say( " " + PadL( AllTrim( Str( i - nLineaBaseExport + 1 ) ), 5 ) + ": " + cLineaAux, .T. )
Say( "US_Shell 505I: " + PadL( AllTrim( Str( i - nLineaBaseExport + 1 ) ), 5 ) + ": " + cLineaAux )
IF File( cFileStop )
lStop := .T.
Say( "User stop!", .T. )
Say( "US_Shell 506W: User Stop" )
EXIT
ENDIF
NEXT i
IF ! lStop
Say( "End of list.", .T. )
Say( "US_Shell 507I: End of list" + CRLF )
ENDIF
ENDIF
IF bDelete
FErase( cPar2 )
ENDIF
ENDIF
ENDIF
CASE cPar1 == "ANALIZE_LIB_PELLES"
Say( "US_Shell 600I: ANALIZE_LIB_PELLES" )
IF US_Words( cParam ) < 2
Say( "US_Shell 601E: Invalid parameter count: " + cParam + CRLF )
Say( "No file to analize!", .T. )
ELSE
Say( "US_Shell 601I: Processing: " + cParam )
IF ( nPos := US_WordPos( "-DELETE", US_Upper( cParam ) ) ) > 0
cParam := US_WordDel( cParam, nPos )
bDelete := .T.
ENDIF
IF ( nPos := US_WordPos( "-OBJLST", US_Upper( cParam ) ) ) > 0
cParam := US_WordDel( cParam, nPos )
bObjLst := .T.
ENDIF
IF ( nPos := US_WordPos( "-EXPLST", US_Upper( cParam ) ) ) > 0
cParam := US_WordDel( cParam, nPos )
bExpLst := .T.
ENDIF
Say( "Analizing Definition File for Pelles Static Library", .T. )
Say( "US_Shell 602I: ANALIZE_LIB_PELLES" )
cPar2 := StrTran( US_Word( cParam, 2 ), "|", " " )
Say( "File In: " + cPar2, .T. )
Say( "US_Shell 603I: File In: " + cPar2 )
IF ! File( cPar2 )
Say( "File not found!" )
Say( "US_Shell 604E: File not found" + CRLF )
ELSE
IF bObjLst
Say( "File Obj: " + cPar2 + cObjExt, .T. )
Say( "US_Shell 605I: File Obj: " + cPar2 + cObjExt )
ENDIF
IF bExpLst
Say( "File Ext: " + cPar2 + cExpExt, .T. )
Say( "US_Shell 606I: File Ext: " + cPar2 + cExpExt )
ENDIF
Say( "Function exported: ", .T. )
Say( "US_Shell 607E: Functions exported: " )
bPellesDynamic := .F.
cTxtAux := MemoRead( cPar2 )
FOR i := 1 TO MLCount( cTxtAux, 254 )
cLineaAux := MemoLine( cTxtAux, 254, i )
IF At( "Long name: ", cLineaAux ) == 1
AAdd( vObjectsPelles, US_FileNameOnlyName( SubStr( cLineaAux, 12 ) ) )
ENDIF
IF File( cFileStop )
lStop := .T.
Say( "User stop!", .T. )
Say( "US_Shell 506W: User Stop" + CRLF )
EXIT
ENDIF
NEXT i
IF ! lStop
IF Len( vObjectsPelles ) == 0
bPellesDynamic := .T.
cDLL_Name := StrTran( US_Word( SubStr( cTxtAux, RAt( "Member at offset", cTxtAux ) ), 5 ), "/", "" )
ENDIF
bFunList := .F.
FOR i := 1 TO MLCount( cTxtAux, 254 )
cLineaAux := MemoLine( cTxtAux, 254, i )
IF US_Word( cLineaAux, 2 ) == "global" .AND. ;
US_Word( cLineaAux, 3 ) == "symbols" .AND. ;
US_Words( cLineaAux ) == 3
bFunList := .T.
ENDIF
IF bFunList .AND. ;
US_Word( cLineaAux, 1 ) == "Member" .AND. ;
US_Word( cLineaAux, 2 ) == "at" .AND. ;
US_Word( cLineaAux, 3 ) == "offset"
EXIT
ENDIF
IF bFunList .AND. ;
US_Words( cLineaAux ) == 2
IF bPellesDynamic
AAdd( vFuncionesPelles, "DYNAMIC " + cDLL_Name + " " + US_Word( cLineaAux, 2 ) )
ELSE
AAdd( vFuncionesPelles, "STATIC " + vObjectsPelles[ Val( NToC( US_Word( cLineaAux, 1 ), 10 ) ) ] + " " + US_Word( cLineaAux, 2 ) )
ENDIF
ENDIF
IF File( cFileStop )
lStop := .T.
Say( "User stop!", .T. )
Say( "US_Shell 506W: User Stop" + CRLF )
EXIT
ENDIF
NEXT i
IF ! lStop
ASort( vFuncionesPelles, { |x, y| x < y } )
IF Len( vFuncionesPelles ) == 0
cTxtAux2 := 'No public symbols exist.'
ELSE
FOR i := 1 TO len( vFuncionesPelles )
cTxtAux2 := cTxtAux2 + vFuncionesPelles[i] + hb_osNewLine()
NEXT i
ENDIF
cTxtAux := cTxtAux2
IF AllTrim( MemoLine( cTxtAux, 254, 1 ) ) == 'No public symbols exist.'
Say( "US_Shell 608W: No public symbols found" + CRLF )
Say( "No public symbols found.", .T. )
ELSE
cModuleNameAux := "."
FOR i := 1 TO MLCount( cTxtAux, 254 )
cLineaAux := MemoLine( cTxtAux, 254, i )
IF US_Word( cLineaAux, 2 ) != cModuleNameAux
cModuleNameAux := US_Word( cLineaAux, 2 )
IF US_Word( cLineaAux, 1 ) == "DYNAMIC"
Say( "US_Shell 609I: Dynamic link import (IMPDEF) from " + cModuleNameAux )
Say( " Dynamic link import (IMPDEF) from " + cModuleNameAux, .T. )
ELSE
Say( "US_Shell 610I: Static Module " + cModuleNameAux )
Say( " Static Module " + cModuleNameAux, .T. )
IF bObjLst
MemoObjLst := MemoObjLst + iif( ! Empty( MemoObjLst ), hb_osNewLine(), "" ) + cModuleNameAux
ENDIF
ENDIF
ENDIF
IF ! Empty( cLineaAux )
cModuleNameAux := US_Word( cLineaAux, 2 )
AAdd( vFun, " " + SubStr( US_Word( cLineaAux, 3 ), 1 ) )
IF bExpLst
MemoExpLst := MemoExpLst + hb_osNewLine() + SubStr( US_Word( cLineaAux, 3 ), 1 )
ENDIF
ENDIF
IF File( cFileStop )
US_Shell_Listo( vFun )
lStop := .T.
Say( "User stop!", .T. )
Say( "US_Shell 611W: User Stop" + CRLF )
EXIT
ENDIF
NEXT i
IF ! lStop
US_Shell_Listo( vFun )
Say( "US_Shell 612I: End of list" + CRLF )
Say( "End of list.", .T. )
IF bObjLst
hb_MemoWrit( cPar2 + cObjExt, MemoObjLst )
ENDIF
IF bExpLst
hb_MemoWrit( cPar2 + cExpExt, MemoExpLst )
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
IF bDelete
FErase( cPar2 )
ENDIF
ENDIF
ENDIF
CASE cPar1 == "ANALIZE_LIB_BORLAND"
Say( "US_Shell 700I: ANALIZE_LIB_BORLAND" )
IF US_Words( cParam ) < 2
Say( "US_Shell 701E: Invalid parameter count: " + cParam + CRLF )
Say( "No file to analize!", .T. )
ELSE
Say( "US_Shell 701I: Processing: " + cParam )
IF ( nPos := US_WordPos( "-DELETE", US_Upper( cParam ) ) ) > 0
cParam := US_WordDel( cParam, nPos )
bDelete := .T.
ENDIF
IF ( nPos := US_WordPos( "-OBJLST", US_Upper( cParam ) ) ) > 0
cParam := US_WordDel( cParam, nPos )
bObjLst := .T.
ENDIF
IF ( nPos := US_WordPos( "-EXPLST", US_Upper( cParam ) ) ) > 0
cParam := US_WordDel( cParam, nPos )
bExpLst := .T.
ENDIF
Say( "Analizing Definition File for Borland Static Library", .T. )
Say( "US_Shell 702I: ANALIZE_LIB_BORLAND" )
cPar2 := StrTran( US_Word( cParam, 2 ), "|", " " )
Say( "File In: " + cPar2, .T. )
Say( "US_Shell 703I: File In: " + cPar2 )
IF ! File( cPar2 )
Say( "File not found!" )
Say( "US_Shell 704E: File not found" + CRLF )
ELSE
IF bObjLst
Say( "File Obj: " + cPar2 + cObjExt, .T. )
Say( "US_Shell 705I: File Obj: " + cPar2 + cObjExt )
ENDIF
IF bExpLst
Say( "File Ext: " + cPar2 + cExpExt, .T. )
Say( "US_Shell 706I: File Ext: " + cPar2 + cExpExt )
ENDIF
Say( "Functions exported: ", .T. )
Say( "US_Shell 707E: Functions exported: " )
cTxtAux := MemoRead( cPar2 )
IF AllTrim( MemoLine( cTxtAux, 254, 1 ) ) == 'No public symbols exist.'
Say( "US_Shell 708W: No public symbols found" + CRLF )
Say( "No public symbols found.", .T. )
ELSE
bBorlandDynamic := .F.
FOR i := 1 TO MLCount( cTxtAux, 254 )
cLineaAux := MemoLine( cTxtAux, 254, i )
IF US_Word( cLineaAux, 2 ) == "size" .AND. ;
US_Word( cLineaAux, 3 ) == "="
cModuleNameAux := US_Word( cLineaAux, 1 )
IF Val( US_Word( cLineaAux, 4 ) ) = 0
IF ! bBorlandDynamic
cDLL_NameFunAux := US_Word( cLineaAux, 1 )
cDLL_NameMemoAux := MemoRead( US_FileNameOnlyPathAndName( cPar2 ) )
cDLL_NameMemoAux := SubStr( cDLL_NameMemoAux, At( Chr( 14 ) + cDLL_NameFunAux + Chr( 12 ), cDLL_NameMemoAux ) )
cDLL_NameMemoAux := StrTran( cDLL_NameMemoAux, Chr( 12 ), " " )
cDLL_NameMemoAux := US_Word( cDLL_NameMemoAux, 2 )
cDLL_Name := SubStr( cDLL_NameMemoAux, 1, RAt( ".DLL", Upper( cDLL_NameMemoAux ) ) + 3 )
Say( "US_Shell 709I: Dynamic link import (IMPDEF) from " + cDLL_Name )
Say( " Dynamic link import (IMPDEF) from " + cDLL_Name, .T. )
bBorlandDynamic := .T.
ENDIF
ELSE
Say( "US_Shell 709I: Static Module " + cModuleNameAux )
Say( " Static Module " + cModuleNameAux, .T. )
IF bObjLst
MemoObjLst := MemoObjLst + iif( ! Empty( MemoObjLst ), hb_osNewLine(), "" ) + cModuleNameAux
ENDIF
ENDIF
ELSE
IF ! Empty( cLineaAux ) .AND. cLineaAux != "Publics by module"
AAdd( vFun, " " + SubStr( US_Word( cLineaAux, 1 ), 1 ) )
IF bExpLst
MemoExpLst := MemoExpLst + hb_osNewLine() + SubStr( US_Word( cLineaAux, 1 ), 1 )
ENDIF
IF US_Words( cLineaAux ) == 2
AAdd( vFun, " " + SubStr( US_Word( cLineaAux, 2 ), 1 ) )
IF bExpLst
MemoExpLst := MemoExpLst + hb_osNewLine() + SubStr( US_Word( cLineaAux, 2 ), 1 )
ENDIF
ENDIF
ENDIF
ENDIF
IF File( cFileStop )
US_Shell_Listo( vFun )
lStop := .T.
Say( "User stop!", .T. )
Say( "US_Shell 710W: User Stop" + CRLF )
EXIT
ENDIF
NEXT i
IF ! lStop
US_Shell_Listo( vFun )
Say( "US_Shell 711I: End of list" + CRLF )
Say( "End of list.", .T. )
IF bObjLst
hb_MemoWrit( cPar2 + cObjExt, MemoObjLst )
ENDIF
IF bExpLst
hb_MemoWrit( cPar2 + cExpExt, MemoExpLst )
ENDIF
ENDIF
ENDIF
IF bDelete
FErase( cPar2 )
ENDIF
ENDIF
ENDIF
CASE cPar1 == "ANALIZE_LIB_MINGW"
Say( "US_Shell 800I: ANALIZE_LIB_MINGW" )
IF US_Words( cParam ) < 2
Say( "US_Shell 801E: Invalid parameter count: " + cParam + CRLF )
Say( "No file to analize!", .T. )
ELSE
Say( "US_Shell 801I: Processing: " + cParam )
IF ( nPos := US_WordPos( "-DELETE", US_Upper( cParam ) ) ) > 0
cParam := US_WordDel( cParam, nPos )
bDelete := .T.
ENDIF
IF ( nPos := US_WordPos( "-OBJLST", US_Upper( cParam ) ) ) > 0
cParam := US_WordDel( cParam, nPos )
bObjLst := .T.
ENDIF
IF ( nPos := US_WordPos( "-EXPLST", US_Upper( cParam ) ) ) > 0
cParam := US_WordDel( cParam, nPos )
bExpLst := .T.
ENDIF
Say( "US_Shell 802I: Analizing Definition File for MinGW Static Library" )
cPar2 := StrTran( US_Word( cParam, 2 ), "|", " " )
Say( "File In: " + SubStr( cPar2, 1, Len( cPar2 ) - 4 ), .T. )
Say( "US_Shell 803I: File In: " + cPar2 )
IF ! File( cPar2 )
Say( "File not found!" )
Say( "US_Shell 804E: File not found" + CRLF )
ELSE
IF bObjLst
Say( "File Obj: " + cPar2 + cObjExt, .T. )
Say( "US_Shell 805I: File Obj: " + cPar2 + cObjExt )
ENDIF
IF bExpLst
Say( "File Ext: " + cPar2 + cExpExt, .T. )
Say( "US_Shell 806I: File Ext: " + cPar2 + cExpExt )
ENDIF
Say( "Functions exported: ", .T. )
Say( "US_Shell 807E: Functions exported: " )
cTxtAux := MemoRead( cPar2 )
bMinGWDynamic := .F.
nCount := MLCount( cTxtAux, 254 )
FOR i := 1 TO nCount
cLineaAux := MemoLine( cTxtAux, 254, i )
IF US_Word( cLineaAux, 1 ) == "SYMBOL" .AND. US_Word( cLineaAux, 2 ) == "TABLE:"
cLineaAux2 := MemoLine( cTxtAux, 254, i + 1 )
cModuleNameAux := US_Word( cLineaAux2, US_Words( cLineaAux2 ) )
// ignore first two files in import originated libraries
IF cModuleNameAux == "fake"
bEncontroValido := .F.
LOOP
ENDIF
// is a module originated by import
IF cModuleNameAux == ".text"
bEncontroValido := .F.
IF ! bMinGWDynamic
cDLL_Name := SubStr( cTxtAux, At( "Contents of section", cTxtAux ) )
nDLL_NameAux := RAt( " ", SubStr( cDLL_Name, 1, At( ".DLL.", Upper( cDLL_Name ) ) ) ) + 1
cDLL_Name := StrTran( US_Word( SubStr( cDLL_Name, nDLL_NameAux ), 1 ), "....", "" )
Say( " Dynamic link import (IMPDEF) from " + cDLL_Name )
bMinGWDynamic := .T.
ENDIF
AAdd( vFun, " " + US_Word( MemoLine( cTxtAux, 254, i + 8 ), US_Words( MemoLine( cTxtAux, 254, i + 8 ) ) ) )
ELSE
// standard module
bEncontroValido := .T.
cModuleNameAux := SubStr( cModuleNameAux, 1, RAt( ".", cModuleNameAux ) - 1 )
Say( " Static Module " + cModuleNameAux )
IF bObjLst
MemoObjLst := MemoObjLst + iif( ! Empty( MemoObjLst ), hb_osNewLine(), "" ) + cModuleNameAux
ENDIF
ENDIF
ELSE
// function in standard module
IF AllTrim( cLineaAux ) == "File" .AND. bEncontroValido
FOR j := i + 1 TO nCount
cLineaAux = MemoLine( cTxtAux, 254, j )
cWord := US_Word( cLineaAux, US_Words( cLineaAux ) )
IF Left( cWord, 1 ) == "."
i := j
EXIT
ENDIF
IF SubStr( cWord, 1, 7 ) == "_HB_FUN"
AAdd( vFun, " " + US_Word( cLineaAux, US_Words( cLineaAux ) ) )
IF bExpLst
MemoExpLst := MemoExpLst + hb_osNewLine() + US_Word( cLineaAux, US_Words( cLineaAux ) )
ENDIF
i := j
ENDIF
cWord := US_Word( cLineaAux, 1 )
IF Left( cWord, 1 ) # "[" .AND. cWord # "AUX"
i := j
EXIT
ENDIF
IF File( cFileStop )
EXIT
ENDIF
NEXT j
bEncontroValido := .F.
ENDIF
ENDIF
IF File( cFileStop )
US_Shell_Listo( vFun )
lStop := .T.
Say( "User stop!", .T. )
Say( "US_Shell 808W: User Stop" + CRLF )
EXIT
ENDIF
NEXT i
IF ! lStop
US_Shell_Listo( vFun )
Say( "US_Shell 809I: End of list" + CRLF )
Say( "End of list.", .T. )
IF bObjLst
hb_MemoWrit( cPar2 + cObjExt, MemoObjLst )
ENDIF
IF bExpLst
hb_MemoWrit( cPar2 + cExpExt, MemoExpLst )
ENDIF
ENDIF
IF bDelete
FErase( cPar2 )
ENDIF
ENDIF
ENDIF
CASE cPar1 == "DELETE"
Say( "US_Shell 900I: DELETE" )
IF US_Words( cParam ) < 2
Say( "US_Shell 901E: Invalid parameter count: " + cParam + CRLF )
Say( "No file to delete!", .T. )
ELSE
Say( "US_Shell 901I: Processing: " + cParam )
cPar2 := StrTran( US_Word( cParam, 2 ), "|", " " )
IF File( cPar2 )
IF FErase( cPar2 ) == -1
Say( "US_Shell 902E: ERROR" + CRLF )
Say( "Error deleting file!", .T. )
ELSE
Say( "US_Shell 902I: OK" + CRLF )
ENDIF
ELSE
Say( "US_Shell 903W: File not found" + CRLF )
ENDIF
ENDIF
CASE cPar1 == "CHANGE"
Say( "US_Shell 910I: CHANGE" )
IF US_Words( cParam ) != 4
Say( "US_Shell 911E: Invalid parameter count: " + cParam + CRLF )
ELSE
Say( "US_Shell 911I: Processing: " + cParam )
cPar2 := StrTran( US_Word( cParam, 2 ), "|", " " )
cPar3 := US_Word( cParam, 3 )
cPar4 := US_Word( cParam, 4 )
Say( " File: " + cPar2 )
Say( " Old String: " + if( cPar3 == "&", "(Character ampersand)", cPar3 ) )
Say( " New String: " + if( cPar4 == "&", "(Character ampersand)", cPar4 ) )
IF ! File( cPar2 )
Say( "US_Shell 912E: File not found" + CRLF )
Say( "File not found!", .T. )
ELSE
IF hb_MemoWrit( cPar2, StrTran( MemoRead( cPar2 ), cPar3, cPar4 ) )
Say( "US_Shell 913I: OK" + CRLF )
ELSE
Say( "US_Shell 913E: ERROR" + CRLF )
Say( "Error changing file!", .T. )
ENDIF
ENDIF
ENDIF
CASE cPar1 == "ECHO"
IF US_Words( cParam ) < 2
__Run( "@ECHO." )
ELSE
cPar2 := StrTran( US_Word( cParam, 2 ), "|", " " )
__Run( "@ECHO " + cPar2 )
ENDIF
OTHERWISE
Say( "US_Shell 002E: Invalid parameter: " + cParam + CRLF )
ENDCASE
Say( CRLF )
FErase( cFileStop )
RETURN
//========================================================================
FUNCTION US_Shell_Listo( vFun )
ASort( vFun, {|x, y| US_Word( x, 1 ) < US_Word( y, 1 ) } )
AEval( vFun, {|x| Say( x ), Say( x, .T. ) } )
RETURN NIL
//========================================================================
// FUNCION PARA EXTRAER UNA PALABRA DE UN ESTRING
//========================================================================
FUNCTION US_Word(ESTRING, POSICION)
LOCAL CONT
CONT := 1
IF Posicion == NIL
Posicion := 1
ENDIF
ESTRING := AllTrim( ESTRING )
DO WHILE .T.
IF At( " ", ESTRING ) != 0
IF CONT == POSICION
RETURN SubStr( ESTRING, 1, At( " ", ESTRING ) - 1 )
ELSE
ESTRING := AllTrim( SubStr( ESTRING, At( " ", ESTRING ) + 1 ) )
CONT ++
ENDIF
ELSE
IF POSICION == CONT
RETURN ESTRING
ELSE
EXIT
ENDIF
ENDIF
ENDDO
RETURN ""
//========================================================================
// FUNCION PARA ELIMINAR UNA PALABRA DE UN STRING
//========================================================================
FUNCTION US_WordDel( ESTRING, POSICION )
LOCAL cRet
IF POSICION > 0
cRet := AllTrim( SubStr( ESTRING, 1, US_WordInd( ESTRING, POSICION ) - 1 ) + ;
StrTran( SubStr( ESTRING, US_WordInd( ESTRING, POSICION ) ), US_Word( ESTRING, POSICION ), " ", 1, 1 ) )
ELSE
cRet := ESTRING
ENDIF
RETURN cRet
//========================================================================
// FUNCION PARA SABER LA POSICION DE LA PALABRA NUMERO ....
// ESTA FUNCION RETORNA EL BYTE DONDE EMPIEZA LA PALABRA
//========================================================================
FUNCTION US_WordInd( ESTRING, POSICION )
LOCAL CONT, ESTR, ESTR2
IF ESTRING == NIL
ESTRING := ""
ENDIF
IF US_Words( Estring ) < Posicion
RETURN ( Len( Estring ) + 1 )
ENDIF
CONT := 1
ESTR := ESTRING
ESTR2 := Rtrim( ESTRING )
ESTRING := AllTrim( ESTRING )
DO WHILE .T.
IF At( " ", ESTRING ) != 0
IF CONT == POSICION
RETURN ( Len( ESTR ) - ( Len( ESTRING ) + ( Len( ESTR ) - Len( ESTR2 ) ) ) + 1 )
ELSE
ESTRING := AllTrim( SubStr( ESTRING, At( " ", ESTRING ) + 1 ) )
CONT ++
ENDIF
ELSE
IF POSICION == CONT
RETURN ( Len( ESTR ) - ( Len( ESTRING ) + ( Len( ESTR ) - Len( ESTR2 ) ) ) + 1 )
ELSE
EXIT
ENDIF
ENDIF
ENDDO
RETURN 0
//========================================================================
// ESTA FUNCION TRANSFORMA EN MAYUSCULAS STRINGS, INCLUSO CON ACENTOS.
//========================================================================
FUNCTION US_Upper( STR )
IF ValType( STR ) == "N"
RETURN STR
ENDIF
RETURN Upper(StrTran(StrTran(StrTran(StrTran(StrTran(StrTran(StrTran(StrTran(StrTran(StrTran(StrTran(StrTran(StrTran(STR,"ü","U"),"ñ","N"),"Ñ","N"),"á","A"),"é","E"),"í","I"),"ó","O"),"ú","U"),"Á","A"),"É","E"),"Í","I"),"Ó","O"),"Ú","U"))
//========================================================================
// FUNCION PARA DETERMINAR EL NUMERO DE PALABRA DE UNA PALABRA EN UN ESTRING
// OJO, ES EL NUMERO DE PALABRA, NO EL BYTE DEL OFFSET
//========================================================================
FUNCTION US_WordPos( PAL, ESTRING )
LOCAL I
PAL := AllTrim( PAL )
ESTRING := AllTrim( ESTRING )
FOR I := 1 TO US_Words( ESTRING )
IF PAL == US_Word( ESTRING, I )
RETURN I
ENDIF
NEXT
RETURN 0
//========================================================================
// FUNCION PARA retornar un SubStr a partir de la posicion de una palabra
//========================================================================
FUNCTION US_WordSubStr( estring, pos )
IF Estring == NIL
Estring := ""
ENDIF
RETURN SubStr( estring, US_WordInd( estring, pos ) )
//========================================================================
// FUNCION PARA CONTAR LAS PALABRAS EN UN ESTRING
//========================================================================
FUNCTION US_Words( ESTRING )
LOCAL CONT := 0
IF Estring == NIL
Estring := ""
ENDIF
ESTRING := AllTrim( ESTRING )
DO WHILE .T.
IF At( " ", ESTRING) != 0
ESTRING := AllTrim( SubStr( ESTRING, At( " ", ESTRING ) + 1 ) )
CONT++
ELSE
IF Len( ESTRING ) > 0
RETURN ( CONT + 1 )
ELSE
EXIT
ENDIF
ENDIF
ENDDO
RETURN CONT
//========================================================================
FUNCTION US_VarToStr( X )
LOCAL T, StringAux := "", i
IF X == NIL
X := "*NIL*"
ENDIF
T = ValType( X )
DO CASE
CASE T = 'C'
RETURN X
CASE T = 'O'
RETURN "*OBJ*"
CASE T = 'U'
RETURN "*UND*"
CASE T = 'M'
RETURN X
CASE T = 'D'
StringAux := DToS( X )
RETURN StringAux
CASE T = 'N'
StringAux := US_StrCero( X )
RETURN StringAux
CASE T = 'L'
StringAux := iif( X, '.T.', '.F.' )
RETURN StringAux
CASE T = 'A'
FOR i := 1 TO Len( X ) - 1
StringAux := StringAux + US_VarToStr( X[ i ] ) + hb_osNewLine()
NEXT i
IF Len( X ) > 0
StringAux := StringAux + US_VarToStr( X[ Len( X ) ] )
ENDIF
RETURN StringAux
ENDCASE
RETURN ""
//========================================================================
FUNCTION US_StrCero( NUM, LONG, DEC )
LOCAL INDICIO
IF DEC == NIL
IF LONG == NIL
NUM := Str( NUM )
ELSE
NUM := Str( NUM, LONG )
ENDIF
ELSE
NUM := Str( NUM, LONG, DEC )
ENDIF
LONG := Len( NUM )
FOR INDICIO := 1 TO LONG
IF SubStr( NUM, INDICIO, 1 ) == " "
NUM := Stuff( NUM, INDICIO, 1, "0" )
ENDIF
NEXT
RETURN NUM
//========================================================================
FUNCTION US_FileChar26Zap( cFile )
LOCAL nHndIn, reto := -1, cAux := " ", cLinea := Space( 1024 ), nLeidosTotal, nLenFileOut, nLeidosLoop
LOCAL cFileOut := US_FileNameOnlyPathAndName( cFile ) + "_T" + AllTrim( STR( INT( SECONDS() ) ) ) + "." + US_FileNameOnlyExt( cFile )
LOCAL nHndOut
nHndIn := FOpen( cFile, FO_READWRITE )
FSeek( nHndIn, -1, 2 )
IF FRead( nHndIn, @cAux, 1 ) == 1
IF cAux == Chr( 26 )
FSeek( nHndIn, 0, 0 )
nLeidosTotal := 0
IF ( nHndOut := FCreate( cFileOut ) ) >= 0
nLenFileOut := US_FileSize( cFile ) - 1
DO WHILE ( nLeidosLoop := FRead( nHndIn, @cLinea, iif( ( nLenFileOut - nLeidosTotal ) > 1024, 1024, nLenFileOut - nLeidosTotal ) ) ) > 0
nLeidosTotal := nLeidosTotal + nLeidosLoop
IF FWrite( nHndOut, cLinea, nLeidosLoop ) != nLeidosLoop
FClose( nHndIn )
FClose( nHndOut )
RETURN -1
ENDIF
ENDDO
FClose( nHndOut )
ELSE
FClose( nHndIn )
RETURN -1
ENDIF
reto := 1
ELSE
reto := 0
ENDIF
ENDIF
FClose( nHndIn )
IF reto == 1
FErase( cFile )
FRename( cFileOut, cFile )
ENDIF
RETURN Reto
//========================================================================
FUNCTION US_FileNameOnlyExt( arc )
arc := SubStr( arc, RAt( DEF_SLASH, arc ) + 1 )
IF US_IsDirectory( arc )
RETURN ""
ENDIF
IF RAt( ".", arc ) == 0
RETURN ""
ENDIF
RETURN SubStr( arc, RAt( ".", arc ) + 1 )
//========================================================================
FUNCTION US_FileNameOnlyName( arc )
LOCAL barra, punto, reto