-
Notifications
You must be signed in to change notification settings - Fork 0
/
famesupport.c
executable file
·654 lines (606 loc) · 21.9 KB
/
famesupport.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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
/****************************************************************************************
* PROJECT: FAME-FTPd
* FILE: famesupport.c
* PURPOSE: FAME-related functions like username/pw validation & File Management
* CREATED: 05-MAY-2003
* MODIFIED: 21-JAN-2004
* AUTHOR: Sascha 'SieGeL' Pfalz
****************************************************************************************/
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/locale.h>
#include <proto/utility.h>
#include <proto/fame.h>
#include <libraries/fame.h>
#include <fame/fame.h>
#include <sys/types.h>
#include <sys/syslog.h>
#include <sys/socket.h>
#include <sys/errno.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/wait.h>
#include <sys/errno.h>
#include <error.h>
#include <proto/socket.h>
#include <netinet/in.h>
#include <amitcp/socketbasetags.h>
#include <netdb.h>
#include "version.h"
#include "proto.h"
#include "ftp.h"
#include "struct_ex.h"
#include <stdlib.h>
#include <string.h>
static char uname[]="FAME-FTPd",udesc[]="FAME FTP Server";
/*************************************************************************************************
* Prototypes
*************************************************************************************************/
BOOL ValidateFameUser(char *username, char *password, struct FTP *ftp);
long RetrieveFAMEInfos(void);
static long ParseConferences(char *confaxs);
BOOL AddConference(struct FAMEConf *, long confnumber);
void FreeConferenceList(void);
BOOL AddFileToUList(char *fullname, long fsize, long cnum,struct FTP *ftp,char *tempname);
BOOL CheckForDoubles(char *fullname, long confnum);
long GetConfNumber(char *confname);
BOOL UpdateUserStats(long confnumber, struct FTP *ftp, ULONG bytes, long files);
BOOL CheckIfOnline(long unumcheck);
/*************************************************************************************************
* FUNCTION: RetrieveFAMEInfos()
* PURPOSE: Reads FAME infos like BBS Path, Sysop etc.
* REQUIREMENTS: FAME must be started!
* INPUT: -
* RETURN: 0 => OK | -1 => FAME not running
* NOTES: Must be called BEFORE ValidateFAMEUser(), else system crashes!
*************************************************************************************************/
long RetrieveFAMEInfos(void)
{
struct FAMESemaphore *MyFAMESemaphore;
FAMEMemSet(FameInfo,0,sizeof(struct FAMEInfos));
Forbid();
if(MyFAMESemaphore=(struct FAMESemaphore *)FindSemaphore("FAMESemaphore"))
{
ObtainSemaphore((struct SignalSemaphore *)MyFAMESemaphore);
FAMEStrCopy(MyFAMESemaphore->fsem_SVBBSName,FameInfo->BBSName,255);
FameInfo->FAMEVersion = MyFAMESemaphore->fsem_SVVersion;
FameInfo->FAMERevision = MyFAMESemaphore->fsem_SVRevision;
Permit();
ReleaseSemaphore((struct SignalSemaphore *)MyFAMESemaphore);
return(0);
}
else
{
Permit();
return(-1); // FAME not running !
}
}
/*************************************************************************************************
* FUNCTION: ValidateFAMEUser()
* PURPOSE: Checks if given user/password is valid/known to FAME and if given data are
* correct the conference list will be loaded and stored in memory.
* REQUIREMENTS: FAME must be started!
* INPUT: username => Name of user
* password => Password of user
* ftp => Master FTP struct
* RETURN: TRUE = User is valid and loaded | FALSE = User unknown/wrong PW
*************************************************************************************************/
BOOL ValidateFAMEUser(char *username, char *password,struct FTP *ftp)
{
struct FAMEConfigRequest *fcr;
struct FAMEUser *myuserdata;
struct FAMEConfAccess *mycfgaxs;
struct FAMESystem *mysystem;
struct FAMELevels *mylevel;
long myresult=0,rc2;
char errbuf[256],axs[22];
static char funcname[] = "ValidateFAMEUser";
long templevel = -1;
if(!*username)
{
DebugLog("LOGIN: No username given - login denied!");
return(FALSE);
}
fcr = AllocPooled(mem_pool,sizeof(struct FAMEConfigRequest));
if(!fcr)
{
fail(ERROR_NO_FREE_STORE,"%s: Unable to allocate fcr struct!",funcname);
usprintf(ftp->control,CRLF_NOSTRIP,ftperror);
return(FALSE);
}
FAMERequestReset(fcr);
fcr->fcr_CfgUserTask = FindTask(NULL);
fcr->fcr_CfgUserName = uname;
fcr->fcr_CfgUserDesc = udesc;
fcr->fcr_ConfigType = FCDD_User; // We want the FAME user.data
fcr->fcr_ConfigMode = FAMECFG_MODE_READ; // Nothing will be changed here!
fcr->fcr_SearchOffset = 0; // Search for the Username in user.data
fcr->fcr_SearchValue = username; // search for given Username
fcr->fcr_SearchType = FAMECFGVARTYPE_STRING; // We want string compare
fcr->fcr_SearchOperator = FAMECFGOP_EQUAL; // Username must match!
myuserdata = FAMEObtainConfig(fcr,&myresult);
if(myuserdata)
{
if(!Stricmp(password,myuserdata->Password))
{
myresult = FAMECFGRES_SUCCESS;
ftp->usernumber = myuserdata->UserNumber;
FAMEStrCopy(myuserdata->ConfAccess,axs,21);
}
else
{
myresult = FAMECFGRES_SEARCHNOTFOUND;
DebugLog("LOGIN: Unknown User %s - Login denied!",username);
}
}
/*
* We check now if the user is allowed to login by checking his state:
*/
if(myresult==FAMECFGRES_SUCCESS)
{
if(myuserdata->Deleted_Or_Not) // 0 means active, all others are forbidden
{
myresult = FAMECFGRES_SEARCHNOTFOUND;
}
else
{
templevel = myuserdata->Userlevel; // Save level for further checking
}
}
FAMEReleaseConfig( myuserdata, FAMECFG_MODE_READ, FindTask( NULL ));
if(myresult == FAMECFGRES_SEARCHNOTFOUND) return(FALSE);
if(myresult != FAMECFGRES_SUCCESS)
{
FAMEHandleConfigResults(errbuf,myresult,FCDD_User);
DebugLog("%s: %s (%ld)",funcname,errbuf,myresult);
usprintf(ftp->control,CRLF_NOSTRIP,ftperror);
return(FALSE);
}
/*
* Now we load the Level define for that user and check if he/she is allowed
* to upload files.
*/
FAMERequestReset(fcr);
fcr->fcr_CfgUserTask = FindTask(NULL);
fcr->fcr_CfgUserName = uname; // Tool name
fcr->fcr_CfgUserDesc = udesc; // Tool description
fcr->fcr_ConfigType = FCDD_Levels; // We want the level structure
fcr->fcr_ConfigMode = FAMECFG_MODE_READ; // Nothing will be changed here!
fcr->fcr_ConfigNum = templevel; // Load Level Data for current user
mylevel = FAMEObtainConfig(fcr,&myresult);
if(mylevel)
{
if(mylevel->Upload) ftp->UserFlags |= UF_UPLOAD; // Set UploadAllow Flag
}
else
{
FAMEHandleConfigResults(errbuf,myresult,FCDD_Levels);
DebugLog("%s: %s (%ld)",funcname,errbuf,myresult);
usprintf(ftp->control,CRLF_NOSTRIP,ftperror);
return(FALSE);
}
FAMEReleaseConfig(mylevel, FAMECFG_MODE_READ, FindTask( NULL ));
/*
* User/Password/Level access is known and valid, now request conference
* list for this user.
* First we need to know how many conferences exists for this BBS:
*/
FAMERequestReset(fcr);
fcr->fcr_CfgUserTask = FindTask(NULL);
fcr->fcr_CfgUserName = uname; // Tool name
fcr->fcr_CfgUserDesc = udesc; // Tool description
fcr->fcr_ConfigType = FCDD_System; // We want the system structure
fcr->fcr_ConfigMode = FAMECFG_MODE_READ; // Nothing will be changed here!
mysystem = FAMEObtainConfig(fcr,&myresult);
if(mysystem)
{
FameInfo->NodeCount = mysystem->NumberOfConfs;
FAMEStrCopy(mysystem->SysOpName,FameInfo->SysOp,31);
}
else
{
FAMEHandleConfigResults(errbuf,myresult,FCDD_System);
DebugLog("%s: %s (%ld)",funcname,errbuf,myresult);
usprintf(ftp->control,CRLF_NOSTRIP,ftperror);
return(FALSE);
}
FAMEReleaseConfig(mysystem, FAMECFG_MODE_READ, FindTask( NULL ));
/*
* Number of conferences is known. Build up the access list for this user:
*/
FAMERequestReset(fcr);
fcr->fcr_CfgUserTask = FindTask(NULL);
fcr->fcr_ConfigStr = axs; // The conference access from FAMEUser->ConfAccess
fcr->fcr_CfgUserName = uname; // Tool name
fcr->fcr_CfgUserDesc = udesc; // Tool description
fcr->fcr_ConfigType = FCDD_ConfAccess; // We want the conference access array
fcr->fcr_ConfigMode = FAMECFG_MODE_READ; // Nothing will be changed here!
mycfgaxs = FAMEObtainConfig(fcr,&myresult);
if(mycfgaxs)
{
rc2 = ParseConferences(mycfgaxs->ConfFlags);
if(rc2)
{
FAMEHandleConfigResults(errbuf,rc2,FCDD_Conf);
DebugLog("%s: %s (%ld)",funcname,errbuf,rc2);
FAMEReleaseConfig(mycfgaxs,FAMECFG_MODE_READ,FindTask(NULL));
usprintf(ftp->control,CRLF_NOSTRIP,ftperror);
return(FALSE);
}
}
else
{
FAMEHandleConfigResults(errbuf,myresult,FCDD_UserConf);
DebugLog("%s: %s (%ld)",funcname,errbuf,myresult);
usprintf(ftp->control,CRLF_NOSTRIP,ftperror);
return(FALSE);
}
FAMEReleaseConfig(mycfgaxs, FAMECFG_MODE_READ, FindTask( NULL ));
FreePooled(mem_pool,fcr,sizeof(struct FAMEConfigRequest));
return(TRUE);
}
/*************************************************************************************************
* FUNCTION: ParseConferences()
* PURPOSE: Reads FAME conference data
* REQUIREMENTS: Global list to hold the conference informations
* CALLED BY: ValidateFAMEUser()
* INPUT: XXX_X_XXX_ (ConfAccess array)
* RETURN: 0 => OK else Returncode indicates failure
*************************************************************************************************/
static long ParseConferences(char *confaxs)
{
struct FAMEConfigRequest *fcr2;
struct FAMEConf *fconf;
char *b = confaxs;
long confcnt = 0,res2 = 0;
fcr2 = AllocPooled(mem_pool,sizeof(struct FAMEConfigRequest));
if(!fcr2) return(-1);
while(*b && confcnt < FameInfo->NodeCount)
{
if(*b == 'X')
{
FAMERequestReset(fcr2);
fcr2->fcr_CfgUserTask = FindTask(NULL);
fcr2->fcr_CfgUserName = uname; // Tool name
fcr2->fcr_CfgUserDesc = udesc; // Tool description
fcr2->fcr_ConfigNum = confcnt+1; // Read data from this conference (cnfcount starts with 0!)
fcr2->fcr_ConfigType = FCDD_Conf; // We want the conference data
fcr2->fcr_ConfigMode = FAMECFG_MODE_READ; // Nothing will be changed here!
fconf = FAMEObtainConfig(fcr2,&res2);
if(fconf)
{
AddConference(fconf,confcnt+1);
}
else
{
FreePooled(mem_pool,fcr2,sizeof(struct FAMEConfigRequest));
return(res2);
}
FAMEReleaseConfig(fconf,FAMECFG_MODE_READ,FindTask(NULL));
}
*b++;
confcnt++;
}
FreePooled(mem_pool,fcr2,sizeof(struct FAMEConfigRequest));
return(0);
}
/*************************************************************************************************
* FUNCTION: AddConference()
* PURPOSE: Adds new conference to global list FConf
* REQUIREMENTS: Global list FConf
* INPUT: fc => Pointer to FAMEConf to add
* confnumber => Corrected Conference number
* RETURN: TRUE = Entry added | FALSE = Out of memory
*************************************************************************************************/
BOOL AddConference(struct FAMEConf *fc, long confnumber)
{
if(!fconf1)
{
if(!(fconf1=(struct FConf *)AllocPooled(mem_pool,sizeof(struct FConf)))) return(FALSE);
fconf2=fconf1;
}
else
{
if(!(fconf2->next=(struct FConf *)AllocPooled(mem_pool,sizeof(struct FConf)))) return(FALSE);
fconf2=fconf2->next;
}
fconf2->next=NULL;
FAMEStrCopy(fc->ConfName,fconf2->ConfName,31);
FAMEStrCopy(fc->ConfLocation,fconf2->ConfLocation,101);
FAMEStrCopy(fc->UploadPath,fconf2->ULPath,101);
FAMEStrCopy(fc->DownloadPath,fconf2->DLPath,101);
FAMEStrCopy(fc->AddUlPaths,fconf2->AddULPath,101);
FAMEStrCopy(fc->AddDlPaths,fconf2->AddDLPath,101);
fconf2->ConfNumber = confnumber;
ConvertSpaces(fconf2->ConfName);
return(TRUE);
}
/*************************************************************************************************
* FUNCTION: FreeConferenceList()
* PURPOSE: Adds new conference to global list FConf
* REQUIREMENTS: Global list FConf
* INPUT: -
* RETURN: -
*************************************************************************************************/
void FreeConferenceList(void)
{
struct FConf *h;
while(fconf1)
{
h=fconf1;
fconf1=fconf1->next;
FreePooled(mem_pool,h,sizeof(struct FConf));
}
fconf1=NULL;fconf2=NULL;
}
/*************************************************************************************************
* FUNCTION: CheckForDoubles()
* PURPOSE: Iterates through the filelist and searches for a given file already uploaded
* Also checks the dirs for the given fame conference if a file with that name
* already exists.
* REQUIREMENTS: FileUploads List must be initialized!
* INPUT: fullname => Full name of uploaded file
* confnum => Number of conference where we should check
* RETURN: TRUE = File already exists. FALSE = File cannot be found in list
*************************************************************************************************/
BOOL CheckForDoubles(char *fullname,long confnum)
{
struct FTPUploads *f1;
struct FConf *cdata=fconf1;
BOOL found=FALSE;
for(f1=(struct FTPUploads *)filelist.mlh_Head;f1!=(struct FTPUploads *)&filelist.mlh_Tail;f1=(struct FTPUploads *)f1->Node.mln_Succ)
{
if(!Stricmp(f1->FileName,FilePart(fullname)) && f1->ConfNum == confnum)
{
found=TRUE;
break;
}
}
if(found==TRUE) return(found);
// File was not found in session specific upload list, let's check now the other places:
while(cdata)
{
if(confnum == cdata->ConfNumber) break;
cdata=cdata->next;
}
if(!cdata)
{
DebugLog("Conf ptr. is ZERO???");
return(TRUE); // should not happen!
}
DebugLog("Location=%s\n1.ULPATH=%s\n1.DLPATH=%s\nn.ULPATH=%s\nn.DLPATH=%s",cdata->ConfLocation,cdata->ULPath,cdata->DLPath,cdata->AddULPath,cdata->AddDLPath);
return(found);
}
/*************************************************************************************************
* FUNCTION: AddFileToUList()
* PURPOSE: Adds new file to global upload list (using Exec() Lists) and copies the file
* to the conference playpen directory.
* REQUIREMENTS: FileUploads List must be initialized, and file must be uploaded without errors!
* INPUT: fullname => Full name to uploaded file
* fsize => Size of File
* cnum => Conference Number
* RETURN: -
*************************************************************************************************/
BOOL AddFileToUList(char *fullname, long fsize, long cnum, struct FTP *ftp, char *tempname)
{
struct FTPUploads *myul;
struct FConf *fc = fconf1;
char buf[256],playpen[256],partul[256],d[10],t[10];
BPTR fp;
BOOL retcode;
if(!(myul = AllocPooled(mem_pool,sizeof(struct FTPUploads))))
{
return(FALSE);
}
FAMEStrCopy(FilePart(fullname),myul->FileName,127);
myul->FileSize = fsize;
myul->ConfNum = cnum;
FormatStamp(NULL,myul->FileDate,myloc,TRUE);
AddTail((struct List *)&filelist, (struct Node *)myul);
while(fc)
{
if(fc->ConfNumber == cnum)
{
break;
}
fc=fc->next;
}
if(!fc)
{
RemTail((struct List *)&filelist);
return(FALSE);
}
FAMEStrCopy(fc->ConfLocation,playpen,255);
SPrintf(buf,"PlayPen/%s",myul->FileName);
AddPart(playpen,buf,255);
FAMEFillMem(buf,0,255);
FAMEStrCopy(fc->ConfLocation,partul,255);
SPrintf(buf,"LostCarrier/%s@%ld",myul->FileName,ftp->usernumber);
AddPart(partul,buf,255);
if(!(fp = Open(partul,MODE_NEWFILE)))
{
DebugLog("ERROR: Cannot open %s (IoErr()=%ld",playpen,IoErr());
RemTail((struct List *)&filelist);
return(FALSE);
}
FormatStamp(NULL,buf,NULL,FALSE);
FAMEStrMid(buf,d,1,8);
FAMEStrMid(buf,t,9,-1);
FPrintf(fp,"%s\n%lu\n%lu\n100\n%s\n%ld\n%s\n%s\n",myul->FileName,fsize,fsize,ftp->username,ftp->usernumber,d,t);
Close(fp);
retcode = FAMEDosMove(tempname,playpen,fconfig->FileBufferSize*1024,FDMF_KEEPDATA|FDMF_NODELETE);
if(retcode == FALSE) /* Error while copying, so cleanup uploaded files */
{
DebugLog("AddUL(): DosMove() %s -> %s failed (%ld)",tempname,playpen,IoErr());
DeleteFile(tempname);
DeleteFile(playpen);
DeleteFile(partul);
}
else
{
UpdateUserStats(cnum,ftp,fsize,1);
}
return(retcode);
}
/*************************************************************************************************
* FUNCTION: GetConfNumber()
* PURPOSE: Returns number of conference of given conf name
* INPUT: confname => Name of conference
* RETURN: Conf Number or 0 to indicate "conference not found"
*************************************************************************************************/
long GetConfNumber(char *confname)
{
struct FConf *fc = fconf1;
while(fc)
{
if(!Strnicmp(fc->ConfName,confname,strlen(fc->ConfName))) return(fc->ConfNumber);
fc = fc->next;
}
return(0);
}
/*************************************************************************************************
* FUNCTION: UpdateUserStats()
* PURPOSE: Updates FAME user.data with new uploaded bytes.
* INPUT: confnumber => Conference number
* ftp => Master FTP Structure
* bytes => Bytes to add
* files => Filecount to add
* RETURN: TRUE = Success, FALSE = Failure while updating
*************************************************************************************************/
BOOL UpdateUserStats(long confnumber, struct FTP *ftp, ULONG bytes, long files)
{
struct FAMEConfigRequest *fcr;
struct FAMEUser *myuserdata;
struct FAMEUserConf *myuserconf;
long myresult=0;
char errbuf[256];
static char funcname[] = "UpdateUserStats";
ULONG newbytes[2];
fcr = AllocPooled(mem_pool,sizeof(struct FAMEConfigRequest));
if(!fcr)
{
fail(ERROR_NO_FREE_STORE,"%s: Unable to allocate fcr struct!",funcname);
usprintf(ftp->control,CRLF_NOSTRIP,ftperror);
return(FALSE);
}
FAMERequestReset(fcr);
fcr->fcr_CfgUserTask = FindTask(NULL);
fcr->fcr_CfgUserName = uname;
fcr->fcr_CfgUserDesc = udesc;
fcr->fcr_ConfigType = FCDD_User; // We want the FAME user.data
fcr->fcr_ConfigMode = FAMECFG_MODE_MODIFY; // We have to update the datA
fcr->fcr_ConfigNum = ftp->usernumber; // Usernumber to load
myuserdata = FAMEObtainConfig(fcr,&myresult);
if(myresult != FAMECFGRES_SUCCESS)
{
FAMEHandleConfigResults(errbuf,myresult,FCDD_User);
DebugLog("%s: %s (%ld)",funcname,errbuf,myresult);
usprintf(ftp->control,CRLF_NOSTRIP,ftperror);
FAMEReleaseConfig( myuserdata, FAMECFG_MODE_MODIFY, FindTask( NULL ));
FreePooled(mem_pool,fcr,sizeof(struct FAMEConfigRequest));
return(FALSE);
}
newbytes[0] = myuserdata->BytesUpHi;
newbytes[1] = myuserdata->BytesUpload;
FAMEAdd64(0UL,bytes,&newbytes);
myresult = FAMELockConfig(myuserdata);
if(myresult == FAMECFGRES_SUCCESS)
{
myuserdata->Uploads+=files;
myuserdata->BytesUpHi = newbytes[0];
myuserdata->BytesUpload = newbytes[1];
FAMEUnLockConfig(myuserdata);
}
else DebugLog("LockConfig(user) Failed");
myresult = FAMESaveConfig(myuserdata,FAMECFG_MODE_MODIFY);
if(myresult != FAMECFGRES_SUCCESS)
{
DebugLog("Error writing back user.data: %ld",myresult);
}
FAMEReleaseConfig( myuserdata, FAMECFG_MODE_MODIFY, FindTask( NULL ));
/* Now update UserConf.data, too */
FAMERequestReset(fcr);
fcr->fcr_CfgUserTask = FindTask(NULL);
fcr->fcr_CfgUserName = uname;
fcr->fcr_CfgUserDesc = udesc;
fcr->fcr_ConfigType = FCDD_UserConf; // We want the FAME user.data
fcr->fcr_ConfigMode = FAMECFG_MODE_MODIFY; // We have to update the datA
fcr->fcr_ConfigNum = ftp->usernumber; // Usernumber
fcr->fcr_ConfigNum2 = confnumber; // Conference number
myuserconf = FAMEObtainConfig(fcr,&myresult);
if(myresult != FAMECFGRES_SUCCESS)
{
FAMEHandleConfigResults(errbuf,myresult,FCDD_UserConf);
DebugLog("%s: %s (%ld)",funcname,errbuf,myresult);
usprintf(ftp->control,CRLF_NOSTRIP,ftperror);
FAMEReleaseConfig( myuserconf, FAMECFG_MODE_MODIFY, FindTask( NULL ));
FreePooled(mem_pool,fcr,sizeof(struct FAMEConfigRequest));
return(FALSE);
}
newbytes[0] = myuserconf->BytesUpHi;
newbytes[1] = myuserconf->BytesUpload;
FAMEAdd64(0UL,bytes,&newbytes);
myresult = FAMELockConfig(myuserconf);
if(myresult == FAMECFGRES_SUCCESS)
{
myuserconf->Uploads+=files;
myuserconf->BytesUpHi = newbytes[0];
myuserconf->BytesUpload = newbytes[1];
FAMEUnLockConfig(myuserconf);
}
else DebugLog("LockConfig(conf) Failed");
myresult = FAMESaveConfig(myuserconf,FAMECFG_MODE_MODIFY);
if(myresult != FAMECFGRES_SUCCESS)
{
DebugLog("Error writing back userconf.data: %ld",myresult);
}
FAMEReleaseConfig( myuserconf, FAMECFG_MODE_MODIFY, FindTask( NULL ));
FreePooled(mem_pool,fcr,sizeof(struct FAMEConfigRequest));
return(TRUE);
}
/*************************************************************************************************
* FUNCTION: CheckIfOnline()
* PURPOSE: Tests if given User is currently online
* INPUT: unumcheck => Usernumber to check for
* RETURN: TRUE = User is online, FALSE = User is not online
*************************************************************************************************/
BOOL CheckIfOnline(long unumcheck)
{
struct FAMESemaphore *MyFAMESemaphore;
struct FAMEInfoList *MyFAMEInfoList;
BOOL isonline=FALSE;
long usernumber;
Forbid();
if(MyFAMESemaphore=(struct FAMESemaphore *)FindSemaphore("FAMESemaphore"))
{
ObtainSemaphore((struct SignalSemaphore *)MyFAMESemaphore);
Permit();
if(MyFAMESemaphore->fsem_FirstNode)
{
MyFAMEInfoList=MyFAMESemaphore->fsem_FirstNode;
do
{
if((MyFAMEInfoList->fili_SVNodeOnline) && (MyFAMEInfoList->fili_UserOnline==2))
{
Forbid();
usernumber = MyFAMEInfoList->fili_NodeRUser->UserNumber;
Permit();
if(usernumber == unumcheck)
{
isonline=TRUE;
break;
}
}
MyFAMEInfoList=MyFAMEInfoList->fili_Next;
}while(MyFAMEInfoList);
}
ReleaseSemaphore((struct SignalSemaphore *)MyFAMESemaphore);
}
else
{
Permit();
}
return(isonline);
}