-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathACP.e
4439 lines (3857 loc) · 127 KB
/
ACP.e
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
-> ACP v5
OPT LARGE,OSVERSION=37
MODULE 'workbench/startup',
'exec/ports',
'exec/nodes',
'exec/memory',
'exec/lists',
'exec/semaphores',
'exec/io',
'exec/lists',
'dos/datetime',
'dos/dos',
'dos/dosextens',
'commodities',
'libraries/commodities',
'dos/dostags',
'intuition/screens',
'gadtools',
'graphics/rastport',
'graphics/text',
'diskfont',
'libraries/gadtools',
'intuition/intuition',
'intuition/iobsolete',
'amigalib/io',
'amigalib/ports',
'amigalib/lists',
'workbench/workbench',
'asl',
'libraries/asl',
'wb',
'socket',
'net/netdb',
'net/in',
'net/socket',
'icon'
MODULE '*axcommon',
'*jsonParser',
'*jsonCreate',
'*stringlist',
'*acpversion'
ENUM ERR_NONE,ERR_ALREADY_RUNNING,ERR_STARTUP, ERR_VALIDATE,ERR_NO_DISKFONT,ERR_FDS_RANGE
CONST AX_SETUP_TOOL='BBS:Utils/axSetupTool'
CONST LISTENQ=100
CONST EINTR=4
CONST MAX_LINE=255
CONST FIONBIO=$8004667e
CONST EWOULDBLOCK=35
#ifndef EVO_3_5_0
CONST TAG_END=0
#endif
CONST NODECONFIG=1
CONST RUNMCP=2
CONST LAST_CALLERS=0
CONST LAST_UPLOADS=1
CONST LAST_DOWNLOADS=2
CONST SYSTEM_STATS=3
CONST SESSION_STATS=4
CONST CHAT_ENTER=5
CONST CHAT_EXIT=4
CONST CHAT_IDLE=3
CONST CHAT_TEXT=2
CONST CHAT_NONE=1
CONST CHAT_NTXT=6
CONST WLEF=0
CONST WTOP=0
CONST WWID=640
CONST WHEI=88
CONST GAD_SYSOPLOGIN=0
CONST GAD_INSTANTLOGIN=1
CONST GAD_AESHELL=2
CONST GAD_TOGGLECHAT=3
CONST GAD_EXITNODE=4
CONST GAD_LOCALLOGIN=5
CONST GAD_RESERVENODE=6
CONST GAD_ACCOUNTS=7
CONST GAD_INITMODEM=8
CONST GAD_NODEOFFHOOK=9
CONST GAD_MCP=10
CONST GAD_NODECONFIG=11
CONST GAD_NODECHAT=12
CONST GAD_SAVEWIN=13
CONST GAD_NRAMS=14
CONST GAD_FLIP=15
CONST GAD_CONTROL=16
CONST GAD_ACTION=17
CONST GAD_USER=18
CONST GAD_LOCATION=19
CONST GAD_BAUD=20
CONST GAD_TOPS=21
CONST GAD_TOPSBOX=22
CONST GAD_SHORT=23
CONST GAD_NODES=24
CONST ALL_GADS=GAD_NODES+MAX_NODES
CONST GLEF_0=5
CONST GTOP_0=24
CONST GWID_0=55
CONST GHEI_0=11
CONST GLEF_ACTION=435
CONST GTOP_ACTION=12
CONST GWID_ACTION=128
CONST GHEI_ACTION=11
CONST GLEF_USER=67
CONST GTOP_USER=12
CONST GWID_USER=183
CONST GHEI_USER=11
CONST GLEF_LOCATION=251
CONST GTOP_LOCATION=12
CONST GWID_LOCATION=183
CONST GHEI_LOCATION=11
CONST GLEF_BAUD=563
CONST GTOP_BAUD=12
CONST GWID_BAUD=70
CONST GHEI_BAUD=11
CONST GLEF_EXITNODE=4
CONST GTOP_EXITNODE=78 ->188
CONST GWID_EXITNODE=109
CONST GHEI_EXITNODE=10
CONST GLEF_NODEOFFHOOK=114
CONST GTOP_NODEOFFHOOK=78 ->188
CONST GWID_NODEOFFHOOK=109
CONST GHEI_NODEOFFHOOK=10
CONST GLEF_INSTANTLOGIN=4
CONST GTOP_INSTANTLOGIN=48 ->158
CONST GWID_INSTANTLOGIN=109
CONST GHEI_INSTANTLOGIN=10
CONST GLEF_AESHELL=4
CONST GTOP_AESHELL=58 ->168
CONST GWID_AESHELL=109
CONST GHEI_AESHELL=10
CONST GLEF_TOGGLECHAT=4
CONST GTOP_TOGGLECHAT=68 ->178
CONST GWID_TOGGLECHAT=109
CONST GHEI_TOGGLECHAT=10
CONST GLEF_SYSOPLOGIN=4
CONST GTOP_SYSOPLOGIN=38 ->148
CONST GWID_SYSOPLOGIN=109
CONST GHEI_SYSOPLOGIN=10
CONST GLEF_NRAMS=224
CONST GTOP_NRAMS=78 ->188
CONST GWID_NRAMS=109
CONST GHEI_NRAMS=10
CONST GLEF_RESERVENODE=114
CONST GTOP_RESERVENODE=48 ->158
CONST GWID_RESERVENODE=109
CONST GHEI_RESERVENODE=10
CONST GLEF_ACCOUNTS=114
CONST GTOP_ACCOUNTS=58 ->168
CONST GWID_ACCOUNTS=109
CONST GHEI_ACCOUNTS=10
CONST GLEF_INITMODEM=114
CONST GTOP_INITMODEM=68 ->178
CONST GWID_INITMODEM=109
CONST GHEI_INITMODEM=10
CONST GLEF_LOCALLOGIN=114
CONST GTOP_LOCALLOGIN=38 ->148
CONST GWID_LOCALLOGIN=109
CONST GHEI_LOCALLOGIN=10
CONST GLEF_MCP=224
CONST GTOP_MCP=38 ->148
CONST GWID_MCP=109
CONST GHEI_MCP=10
CONST GLEF_NODECONFIG=224
CONST GTOP_NODECONFIG=48 ->158
CONST GWID_NODECONFIG=109
CONST GHEI_NODECONFIG=10
CONST GLEF_NODECHAT=224
CONST GTOP_NODECHAT=58 ->168
CONST GWID_NODECHAT=109
CONST GHEI_NODECHAT=10
CONST GLEF_SAVEWIN=224
CONST GTOP_SAVEWIN=68 ->178
CONST GWID_SAVEWIN=109
CONST GHEI_SAVEWIN=10
CONST GLEF_FLIP=4
CONST GTOP_FLIP=27 ->137
CONST GWID_FLIP=14
CONST GHEI_FLIP=10
CONST GLEF_CONTROL=19
CONST GTOP_CONTROL=27 ->137
CONST GWID_CONTROL=314
CONST GHEI_CONTROL=10
CONST GLEF_TOPS=335
CONST GTOP_TOPS=26 ->136
CONST GWID_TOPS=300
CONST GHEI_TOPS=11
CONST GLEF_SHORT=10
CONST GTOP_SHORT=12
CONST GWID_SHORT=37
CONST GHEI_SHORT=9
CONST BLEF_0=66
CONST BTOP_0=24
CONST BWID_0=569
CONST BHEI_0=110
CONST BLEF_TOPSBOX=335
CONST BTOP_TOPSBOX=38 ->148
CONST BWID_TOPSBOX=300
CONST BHEI_TOPSBOX=50
OBJECT itemsList
PRIVATE lastUsers[5]:ARRAY OF LONG ->array[6,44]
PRIVATE lastUserDates[5]:ARRAY OF LONG
num:INT
ENDOBJECT
OBJECT user
user[50]:ARRAY OF CHAR
location[50]:ARRAY OF CHAR
action[50]:ARRAY OF CHAR
baud[10]:ARRAY OF CHAR
active:INT
actionVal:INT
ENDOBJECT
OBJECT pstr
s1:INT
s2:INT
ns:INT
ne:INT
ENDOBJECT
OBJECT button
text[100]:ARRAY OF CHAR
command[100]:ARRAY OF CHAR
type:CHAR
ENDOBJECT
OBJECT screenPref
left:INT
top:INT
width:INT
height:INT
nodes:INT
->WORD Zoom[5];
ENDOBJECT
OBJECT connectionItem
ipAddr: LONG
connectionTime: LONG
blocked: CHAR
blockExpiry: LONG
ENDOBJECT
DEF ngAry[ALL_GADS]:ARRAY OF LONG
DEF signals=NIL
DEF mybbslocation[40]:STRING
DEF mp=NIL:PTR TO mp
DEF acpError=FALSE
DEF nport=NIL:PTR TO mp
DEF dim:PTR TO INT /*** Dimensions of ZIP window default ***/
DEF zim:PTR TO INT
/* main function to test gadgets */
DEF masterSig /*** storage for our ports address ***/
DEF scr:PTR TO screen /*** Pointer to our screen ***/
DEF eWin:PTR TO window
DEF gadgets: PTR TO gadget
DEF startNode[MAX_NODES]:ARRAY OF LONG /*** Node startup scripts ***/
DEF nodeIdle[MAX_NODES]:ARRAY OF CHAR
DEF startUp=FALSE/*** Set startup scripts to none ***/
DEF zipOn=FALSE/*** Turn ZIPPED window off ***/
DEF notDone=1
DEF shuttingDown=0
DEF down[MAX_NODES]:ARRAY OF CHAR
DEF activeNodes[MAX_NODES]:ARRAY OF CHAR
DEF publicName[200]:STRING
DEF pens[9]:ARRAY OF INT
DEF myVerStr[255]:STRING
DEF myBuildStr[255]:STRING
DEF myappport=NIL:PTR TO mp
DEF doMultiCom
DEF quietNode[MAX_NODES]:ARRAY OF INT
DEF telnetNode[MAX_NODES]:ARRAY OF INT
DEF ftpNode[MAX_NODES]:ARRAY OF INT
DEF bbsStack
DEF startTime:datestamp
DEF startCalls
DEF ulCount=0,dlCount=0
DEF nodes[MAX_NODES]:ARRAY OF INT
DEF suspend[MAX_NODES]:ARRAY OF INT
DEF showAbout=0
DEF edgeX,edgeY
DEF width=0,height=0
DEF theight=0
DEF drawPen = 1
DEF chat[MAX_NODES]:ARRAY OF INT /*** Default color for nonchat ***/
DEF tChat[MAX_NODES]:ARRAY OF INT
DEF activeNodeCount=0
DEF colourSpecs
DEF amigaSpecs
DEF colours
DEF dosCheckTime=60
DEF dosCheckTrigger=5
DEF dosBanTime=60
DEF menuSelect=FALSE
DEF masterPort[100]:STRING
DEF cmds[MAX_NODES]:ARRAY OF LONG
DEF sopts[MAX_NODES]:ARRAY OF LONG
DEF msg:PTR TO acpMessage
DEF cpymsg:PTR TO acpMessage
DEF portName[255]:STRING
DEF acpData:PTR TO acpData
DEF lastUsers=NIL: PTR TO itemsList
DEF lastUploads=NIL: PTR TO itemsList
DEF lastDownloads=NIL: PTR TO itemsList
DEF ndUser[MAX_NODES]: ARRAY OF LONG
DEF ndUploads[MAX_NODES]: ARRAY OF LONG
DEF ndDownloads[MAX_NODES]: ARRAY OF LONG
DEF bbsPath[41]:STRING
DEF buttons[20]:ARRAY OF button
DEF users[MAX_NODES]:ARRAY OF user
DEF eWinMenu: PTR TO newmenu
DEF control=0
DEF short=0
DEF bm[20]:ARRAY OF INT
DEF button=FALSE
DEF buttonID=-1 /**** Nutton to be processed when Node Button is selected*/
DEF shortUp=FALSE
DEF setOriText[15]:ARRAY OF LONG ->char[15][100]/** Original Text for 15 control buttons **/
DEF semiNodes=NIL:PTR TO multiPort
DEF singleNode=NIL:PTR TO singlePort
DEF multiName[8]:STRING
DEF singleName[8]:STRING
DEF eGList=NIL:PTR TO gadget
DEF visInfo=NIL
DEF pref:screenPref
DEF eWinM=NIL:PTR TO menu
DEF dobj=NIL:PTR TO diskobject
DEF appicon=NIL:PTR TO appicon
DEF dir_info:PTR TO fileinfoblock
DEF pdir
DEF tags:PTR TO LONG
DEF topOption=0
DEF topOffset=0
DEF shorten=0
DEF maxMenus=0
DEF menuset=0
DEF fontName[255]:STRING
DEF defaultfontattr: textattr
DEF fontHandle=NIL
DEF version[200]:STRING
DEF translators=NIL: PTR TO translator
DEF minNode=NIL: PTR TO mln
DEF lockedNodes=-1
DEF persistState=FALSE
DEF shellMode=FALSE
DEF commodityEnabled=TRUE
DEF broker=NIL, broker_mp=NIL:PTR TO mp, cxsigflag=0
DEF starting=TRUE
/* some global variables used to replace the statics from the C version
they are prefixed with the procdure name to prevent any name clashes
*/
DEF initGadsagain=FALSE
DEF setTheGadsj=0
DEF setTheGadsSet=FALSE
DEF do_appiconi=0
DEF do_appiconj=0
DEF maddItemi=0
DEF startupCompleteScript[255]:STRING
DEF telnetPort=-1
DEF ftpPort=-1
DEF fds=0:PTR TO LONG
PROC init() OF itemsList ->constructor
self.lastUsers[0]:=String(36)
self.lastUsers[1]:=String(36)
self.lastUsers[2]:=String(36)
self.lastUsers[3]:=String(36)
self.lastUsers[4]:=String(36)
self.lastUserDates[0]:=String(20)
self.lastUserDates[1]:=String(20)
self.lastUserDates[2]:=String(20)
self.lastUserDates[3]:=String(20)
self.lastUserDates[4]:=String(20)
self.num:=0
ENDPROC
PROC end() OF itemsList -> destructor
DisposeLink(self.lastUsers[0])
DisposeLink(self.lastUsers[1])
DisposeLink(self.lastUsers[2])
DisposeLink(self.lastUsers[3])
DisposeLink(self.lastUsers[4])
DisposeLink(self.lastUserDates[0])
DisposeLink(self.lastUserDates[1])
DisposeLink(self.lastUserDates[2])
DisposeLink(self.lastUserDates[3])
DisposeLink(self.lastUserDates[4])
ENDPROC
PROC getItem(num) OF itemsList IS self.lastUsers[num]
PROC getItemDate(num) OF itemsList IS self.lastUserDates[num]
PROC getDisplayText(num,outText:PTR TO CHAR) OF itemsList
IF EstrLen(self.lastUserDates[num])>0
StringF(outText,'\s [\s]',self.lastUsers[num],self.lastUserDates[num])
ELSE
StrCopy(outText,self.lastUsers[num])
ENDIF
ENDPROC
PROC add(name:PTR TO CHAR, dateStr:PTR TO CHAR) OF itemsList
DEF i=0
IF((self.num>0) AND (self.num<6))
IF(StrCmp(self.lastUsers[self.num-1],name))
-> StrCopy(self.lastUsers[self.num-1],name)
StrCopy(self.lastUserDates[self.num-1],dateStr)
RETURN
ENDIF
ENDIF
IF(self.num=5)
WHILE(i<4)
StrCopy(self.lastUsers[i],self.lastUsers[i+1])
StrCopy(self.lastUserDates[i],self.lastUserDates[i+1])
i++
ENDWHILE
self.num:=4;
ENDIF
StrCopy(self.lastUsers[self.num],name)
StrCopy(self.lastUserDates[self.num],dateStr)
self.num:=self.num+1
ENDPROC
PROC checkPathSlash(path)
DEF c
c:=path[StrLen(path)-1]
IF (c<>":") AND (c<>"/")
StrAdd(path,'/')
ENDIF
ENDPROC
PROC getSystemDate(outDateStr:PTR TO CHAR)
DEF dt : datetime
DEF datestr[255]:STRING
DEF timestr[255]:STRING
DateStamp(dt.stamp)
dt.format:=FORMAT_DOS
dt.flags:=0
dt.strday:=NIL
dt.strdate:=datestr
dt.strtime:=timestr
IF DateToStr(dt)
StringF(outDateStr,'\s[6] \s[5]',datestr,timestr)
ENDIF
ENDPROC
->returns system time as a long
PROC getSystemTime()
DEF currDate: datestamp
DEF startds:PTR TO datestamp
startds:=DateStamp(currDate)
ENDPROC Mul(Mul(startds.days,1440),60)+(startds.minute*60)+(startds.tick/50)
PROC formatLongDateTime(dt:PTR TO datetime,outDateStr)
DEF datestr[10]:STRING
DEF daystr[10]:STRING
DEF timestr[10]:STRING
DEF dateVal
dt.format:=FORMAT_DOS
dt.flags:=0
dt.strday:=0
dt.strdate:=datestr
dt.strtime:=timestr
IF DateToStr(dt)
StringF(outDateStr,'\s[7]\d\s \s',datestr,IF dt.stamp.days>=8035 THEN 20 ELSE 19,datestr+7,timestr)
RETURN TRUE
ENDIF
ENDPROC FALSE
PROC trimStr(src:PTR TO CHAR, dest:PTR TO CHAR)
DEF i
StrCopy(dest,TrimStr(src))
i:=StrLen(dest)-1
WHILE (i>=0)
IF dest[i]<>" "
i:=-1
ELSE
SetStr(dest,i)
i--
ENDIF
ENDWHILE
ENDPROC
PROC myrequest(s:PTR TO CHAR)
DEF myES:PTR TO LONG
myES:=NEW [20,0,'ACP Notification',s,'Continue']:LONG
EasyRequestArgs(NIL,myES,NIL,NIL)
END myES[5]
ENDPROC
PROC menunum(n) IS ((n) AND $1F)
PROC itemnum(n) IS (Shr((n),5) AND $3F)
PROC subnum(n) IS (Shr((n),11) AND $1F)
->/* ***** Free the Gadlist and return ***** */
PROC freeGads()
IF eGList THEN FreeGadgets(eGList)
IF (visInfo) THEN FreeVisualInfo(visInfo)
visInfo:=NIL
eGList:=NIL
ENDPROC
PROC waitSocketLib()
DEF n=0,id=0
IF socketbase=NIL THEN socketbase:=OpenLibrary('bsdsocket.library', 2)
WHILE (socketbase=NIL) AND (n<60)
Delay(50)
n++
socketbase:=OpenLibrary('bsdsocket.library', 2)
ENDWHILE
IF socketbase
n:=0
id:=GetHostId()
WHILE(id=0) AND (n<60)
Delay(50)
n++
id:=GetHostId()
ENDWHILE
ENDIF
ENDPROC
PROC openListenSocket(port)
DEF server_s
DEF servaddr=0:PTR TO sockaddr_in
->DEF tempStr[255]:STRING
IF((server_s:=Socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
->StringF(tempStr,'/X Telnet: Error creating listening socket. (\d)\b\n',Errno())
->aePuts(tempStr)
RETURN -1
ENDIF
servaddr:=NEW servaddr
servaddr.sin_len:=SIZEOF sockaddr_in
servaddr.sin_family:=AF_INET
servaddr.sin_port:=port
servaddr.sin_addr:=INADDR_ANY
SetSockOpt(server_s, SOL_SOCKET, SO_REUSEADDR, [1]:LONG, SIZEOF LONG)
IF(Bind(server_s, servaddr, SIZEOF sockaddr_in) < 0)
->StringF(tempStr,'/X Telnet: Error calling bind() for port \d, error=\d\b\n',port,Errno());
->aePuts(tempStr)
CloseSocket(server_s)
END servaddr
RETURN -1
ENDIF
IF(Listen(server_s, LISTENQ) < 0)
->StringF(tempStr,'/X Telnet: Error calling listen() for port \d, error=\d\b\n',port,Errno());
->aePuts(tempStr)
CloseSocket(server_s)
END servaddr
RETURN -1
ENDIF
IoctlSocket(server_s,FIONBIO,[1])
END servaddr
ENDPROC server_s
->*******************************************************************
-> OpenMaster - This function opens a port for the nodes to interact
->********************************************************************
PROC openMaster()
mp:=createPort(portName,0)
myappport:=CreateMsgPort()
ENDPROC
->*******************************************************************
-> ShutDownMaster - This function removes our Master port insuring
-> that there is no pending messages first
->*******************************************************************
PROC shutDownMaster()
IF mp
WHILE(cpymsg:=GetMsg((mp)))
CopyMem(cpymsg,msg,SIZEOF acpMessage)
ReplyMsg(cpymsg)
ENDWHILE
deletePort(mp)
mp:=0
ENDIF
IF myappport
DeleteMsgPort(myappport)
myappport:=0
ENDIF
ENDPROC
->*********************************************************************
-> ClearUsers - initialize all the User storage
->*********************************************************************
PROC clearUsers()
DEF i
FOR i:=0 TO MAX_NODES-1
AstrCopy(users[i].user,'')
AstrCopy(users[i].location,'')
AstrCopy(users[i].action,'')
AstrCopy(users[i].baud,' ')
users[i].active:=0
ENDFOR
ENDPROC
PROC printMyText(rport:PTR TO rastport,text:PTR TO CHAR, x, y)
DEF t:PTR TO intuitext
t:=[3,0,RP_JAM2,0,0,NIL,NIL,NIL]:intuitext
t.itext:=text
PrintIText(rport,t,x,y-6)
ENDPROC
PROC initNgAry()
DEF i
DEF nodetext:PTR TO CHAR
ngAry[0]:=[GLEF_SYSOPLOGIN,topOffset+(theight*11)+GTOP_SYSOPLOGIN,GWID_SYSOPLOGIN,GHEI_SYSOPLOGIN,'Sysop Login',NIL,GAD_SYSOPLOGIN,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[1]:=[GLEF_INSTANTLOGIN,topOffset+(theight*11)+GTOP_INSTANTLOGIN,GWID_INSTANTLOGIN,GHEI_INSTANTLOGIN,'Instant Login',NIL,GAD_INSTANTLOGIN,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
IF shellMode
ngAry[2]:=[GLEF_AESHELL, topOffset+(theight*11)+GTOP_AESHELL, GWID_AESHELL, GHEI_AESHELL,'AEShell',NIL,GAD_AESHELL,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ELSE
ngAry[2]:=[GLEF_AESHELL, topOffset+(theight*11)+GTOP_AESHELL, GWID_AESHELL, GHEI_AESHELL,'Config',NIL,GAD_AESHELL,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ENDIF
ngAry[3]:=[GLEF_TOGGLECHAT, topOffset+(theight*11)+GTOP_TOGGLECHAT, GWID_TOGGLECHAT, GHEI_TOGGLECHAT,'Toggle Chat',NIL,GAD_TOGGLECHAT,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[4]:=[GLEF_EXITNODE, topOffset+(theight*11)+GTOP_EXITNODE, GWID_EXITNODE, GHEI_EXITNODE,'Exit Node',NIL,GAD_EXITNODE,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[5]:=[GLEF_LOCALLOGIN, topOffset+(theight*11)+GTOP_LOCALLOGIN, GWID_LOCALLOGIN, GHEI_LOCALLOGIN,'Local Login',NIL,GAD_LOCALLOGIN,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[6]:=[GLEF_RESERVENODE, topOffset+(theight*11)+GTOP_RESERVENODE, GWID_RESERVENODE, GHEI_RESERVENODE,'Reserve Node',NIL,GAD_RESERVENODE,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[7]:=[GLEF_ACCOUNTS, topOffset+(theight*11)+GTOP_ACCOUNTS, GWID_ACCOUNTS, GHEI_ACCOUNTS,'Accounts',NIL,GAD_ACCOUNTS,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[8]:=[GLEF_INITMODEM, topOffset+(theight*11)+GTOP_INITMODEM, GWID_INITMODEM, GHEI_INITMODEM,'Init Modem',NIL,GAD_INITMODEM,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[9]:=[GLEF_NODEOFFHOOK, topOffset+(theight*11)+GTOP_NODEOFFHOOK, GWID_NODEOFFHOOK, GHEI_NODEOFFHOOK,'Node(offhook)',NIL,GAD_NODEOFFHOOK,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[10]:=[GLEF_MCP, topOffset+(theight*11)+GTOP_MCP, GWID_MCP, GHEI_MCP,'Quiet Node',NIL,GAD_MCP,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[11]:=[GLEF_NODECONFIG, topOffset+(theight*11)+GTOP_NODECONFIG, GWID_NODECONFIG, GHEI_NODECONFIG,'Config Node',NIL,GAD_NODECONFIG,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[12]:=[GLEF_NODECHAT, topOffset+(theight*11)+GTOP_NODECHAT, GWID_NODECHAT, GHEI_NODECHAT,'Node Chat',NIL,GAD_NODECHAT,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[13]:=[GLEF_SAVEWIN, topOffset+(theight*11)+GTOP_SAVEWIN, GWID_SAVEWIN, GHEI_SAVEWIN,'Save Win',NIL,GAD_SAVEWIN,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[14]:=[GLEF_NRAMS, topOffset+(theight*11)+GTOP_NRAMS, GWID_NRAMS, GHEI_NRAMS,'Set NRAMS',NIL,GAD_NRAMS,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[15]:=[GLEF_FLIP, topOffset+(theight*11)+GTOP_FLIP, GWID_FLIP, GHEI_FLIP,'X',NIL,GAD_FLIP,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[16]:=[GLEF_CONTROL, topOffset+(theight*11)+GTOP_CONTROL, GWID_CONTROL, GHEI_CONTROL,'Ami Express Master Control',NIL,GAD_CONTROL,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[17]:=[GLEF_ACTION, topOffset+GTOP_ACTION, GWID_ACTION, GHEI_ACTION,'Action',NIL,GAD_ACTION,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[18]:=[GLEF_USER, topOffset+GTOP_USER, GWID_USER, GHEI_USER,'User',NIL,GAD_USER,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[19]:=[GLEF_LOCATION, topOffset+GTOP_LOCATION, GWID_LOCATION, GHEI_LOCATION,'Location',NIL,GAD_LOCATION,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[20]:=[GLEF_BAUD, topOffset+GTOP_BAUD, GWID_BAUD, GHEI_BAUD,'Baud/CPS',NIL,GAD_BAUD,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[21]:=[GLEF_TOPS, topOffset+(theight*11)+GTOP_TOPS, GWID_TOPS, GHEI_TOPS,NIL,NIL,GAD_TOPS,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[22]:=[BLEF_TOPSBOX, topOffset+(theight*11)+BTOP_TOPSBOX, BWID_TOPSBOX, BHEI_TOPSBOX,NIL,NIL,GAD_TOPSBOX,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ngAry[23]:=[GLEF_SHORT, topOffset+GTOP_SHORT, GWID_SHORT, GHEI_SHORT,'/X',NIL,GAD_SHORT,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
FOR i:=0 TO MAX_NODES-1
nodetext:=String(2) ->note we dont retain a pointer to these so we rely on E's own cleanup to free them on exit
StringF(nodetext,'\d',i)
ngAry[24+i]:=NEW [GLEF_0, topOffset+GTOP_0+(GHEI_0*i), GWID_0, GHEI_0,nodetext,NIL,i+GAD_NODES,PLACETEXT_IN OR NG_HIGHLABEL,NIL,NIL]:newgadget
ENDFOR
ENDPROC
PROC initCycles()
lastUsers:=NEW lastUsers.init()
lastUploads:=NEW lastUploads.init()
lastDownloads:=NEW lastDownloads.init()
initNdCycles()
ENDPROC
PROC initNdCycles()
DEF x
DEF list:PTR TO itemsList
FOR x:=0 TO MAX_NODES-1
ndUser[x]:=NEW list.init()
ndUploads[x]:=NEW list.init()
ndDownloads[x]:=NEW list.init()
ENDFOR
ENDPROC
PROC tLock(str:PTR TO CHAR)
DEF lock
IF(lock:=Lock(str,ACCESS_READ))
UnLock(lock)
RETURN 1
ENDIF
ENDPROC 0
PROC free_pdir()
IF ( pdir )
UnLock(pdir)
pdir:=NIL
ENDIF
ENDPROC
PROC getToolTypes(filename:PTR TO CHAR)
DEF dobj: PTR TO diskobject,fn[255]:STRING,isCfg
DEF toolTypes:PTR TO LONG
DEF fh,fileBuf,off,lineCount
DEF i,len
dobj:=GetDiskObject(filename)
isCfg:=FALSE
IF(dobj=NIL)
StringF(fn,'\s.txt',filename)
IF (len:=FileLength(fn))=-1
StringF(fn,'\s.cfg',filename)
IF (len:=FileLength(fn))=-1
StrCopy(fn,'')
ENDIF
ENDIF
IF StrLen(fn)>0
dobj:=GetDefDiskObject(WBPROJECT)
IF dobj<>NIL
fileBuf:=New(len+1) ->allow an extra char in case file does not end in LF
fh:=Open(fn,MODE_OLDFILE)
IF fh<>0
off:=0
lineCount:=0
WHILE(ReadStr(fh,fn)<>-1) OR (StrLen(fn)>0)
len:=0
WHILE (fn[len]<>0) AND (fn[len]<>";")
len++
ENDWHILE
->trim trailing space
WHILE (fn[len-1]<=32) AND (len>0)
len--
EXIT len=0 ->this is just here to prevent the fn2[len-1] causing a buffer underrun in the absence of short circuit evaluation
ENDWHILE
SetStr(fn,len)
AstrCopy(fileBuf+off,fn,len+1)
lineCount++
off:=off+len+1
ENDWHILE
toolTypes:=List(lineCount+1)
off:=0
FOR i:=1 TO lineCount
ListAdd(toolTypes,[fileBuf+off])
off:=off+StrLen(fileBuf+off)+1
ENDFOR
ListAdd(toolTypes,[NIL])
dobj.tooltypes:=toolTypes
isCfg:=TRUE
Close(fh)
ELSE
Dispose(fileBuf)
FreeDiskObject(dobj)
dobj:=NIL
ENDIF
ENDIF
ENDIF
ENDIF
ENDPROC dobj,isCfg
PROC freeToolTypes(dobj:PTR TO diskobject,isCfg)
DEF mem
IF dobj
IF isCfg
mem:=dobj.tooltypes[0] -> release the file buffer (first string pointer points to start of buffer)
Dispose(mem)
END dobj.tooltypes ->our tooltypes is a list that needs to be freed
ENDIF
FreeDiskObject(dobj)
ENDIF
ENDPROC
PROC getFileName(path:PTR TO CHAR,buf:PTR TO CHAR)
DEF returnval=0
IF ((dir_info:=AllocDosObject(DOS_FIB,NIL)) = NIL)
Delay(300)
RETURN 0
ENDIF
IF ((pdir:=Lock(path,ACCESS_READ)))=FALSE
FreeDosObject(DOS_FIB,dir_info)
free_pdir()
RETURN 0
ENDIF
IF(Examine(pdir, dir_info))=FALSE
FreeDosObject(DOS_FIB,dir_info)
free_pdir()
RETURN 0
ENDIF
IF(ExNext(pdir,dir_info))
IF(dir_info.direntrytype < 0)
returnval:=1
AstrCopy(buf,dir_info.filename)
ENDIF
ENDIF
free_pdir()
FreeDosObject(DOS_FIB,dir_info)
ENDPROC returnval
PROC findFirst(path: PTR TO CHAR,buf: PTR TO CHAR)
DEF returnval=0
IF ((dir_info:=(AllocDosObject(DOS_FIB,NIL)))=NIL)
Delay(300)
RETURN 0
ENDIF
IF((pdir:=(Lock(path,ACCESS_READ)))=FALSE)
findClose()
UnLock(pdir)
FreeDosObject(DOS_FIB,dir_info)
RETURN 0
ENDIF
IF(Examine(pdir,dir_info))=FALSE
findClose()
RETURN 0
ENDIF
IF(ExNext(pdir,dir_info))
IF(dir_info.direntrytype < 0 )
returnval:=1
StrCopy(buf,dir_info.filename)
ENDIF
ENDIF
ENDPROC returnval
PROC findNext(buf: PTR TO CHAR)
DEF returnval=0
IF(ExNext(pdir,dir_info))
IF(dir_info.direntrytype < 0 )
returnval:=1
StrCopy(buf,dir_info.filename)
ENDIF
ENDIF
ENDPROC returnval
PROC findClose()
IF pdir<>NIL THEN UnLock(pdir)
IF dir_info<>NIL THEN FreeDosObject(DOS_FIB,dir_info)
pdir:=NIL
dir_info:=NIL
ENDPROC
EXPORT PROC readIntFromFile(filename: PTR TO CHAR)
DEF fh
DEF v[100]:STRING
IF((fh:=Open(filename,MODE_OLDFILE)))<>0
ReadStr(fh,v)
Close(fh)
RETURN Val(v)
ENDIF
ENDPROC -1
/* ***** Do BevelBorders ***** */
PROC drawborders()
/* *** Stats *** */
DrawBevelBoxA(eWin.rport, BLEF_0, topOffset+BTOP_0, BWID_0, theight*11,[GT_VISUALINFO, visInfo,TAG_END])
ENDPROC
PROC getNodeTextColour(node)
DEF c
c:=chat[node]
IF(quietNode[node]) THEN c:=3
ENDPROC c
->//*********************************************************************
->// CallNode - This function opens a port to a nodes AEServer and tries
->// to send a msg to the node and waits on a reply
->//*********************************************************************
PROC callNode(node,code,data=1)
DEF response[100]:STRING
StringF(response,'AmiExpress_Node.\d',node)
IF(FindPort(response))=FALSE
IF(StrLen(startNode[node])>0)
->ActiveNodeCount +=1; Down[node]=FALSE;
IF(startProcess(startNode[node],bbsStack))
activeNodeCount++
activeNodes[node]:=TRUE
down[node]:=FALSE
ENDIF
->Execute(StartNode[node],NULL,NULL);
RETURN
ENDIF
ENDIF
IF(register(node))
sendMessage(code,data)
ENDIF
ENDPROC
PROC putToPort(message)
PutMsg(nport,message)
ENDPROC 1
PROC sendMessage(nl,data=1)
DEF jhmsg: PTR TO jhMessage
jhmsg:=AllocMem(SIZEOF jhMessage,MEMF_PUBLIC OR MEMF_CLEAR)
jhmsg.msg.ln.type:=NT_FREEMSG
jhmsg.msg.length:=SIZEOF jhMessage
jhmsg.msg.replyport:=0
jhmsg.command:=nl
jhmsg.data:=data ->READIT