home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Elysian Archive
/
AmigaElysianArchive.iso
/
comm
/
term23_2.lha
/
Source_Code
/
termSource
/
termCall.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-18
|
3KB
|
170 lines
/*
** $Id: termCall.c,v 1.3 92/08/15 20:13:42 olsen Sta Locker: olsen $
** $Revision: 1.3 $
** $Date: 92/08/15 20:13:42 $
**
** NComm-compatible log file maintenance routines
**
** Copyright © 1990-1992 by Olaf `Olsen' Barthel & MXM
** All Rights Reserved
*/
#include "termGlobal.h"
/* Some local variables. */
STATIC BPTR CallFile;
STATIC struct timeval CallTime;
/* CallDate():
*
* Add the current date and time to the logfile.
*/
STATIC VOID
CallDate()
{
/* Days of the week. */
STATIC STRPTR CallDays[7] =
{
"Sun","Mon","Tue","Wed","Thu","Fri","Sat"
};
/* Months of the year. */
STATIC STRPTR CallMonths[12] =
{
"Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
};
struct DateStamp __aligned Date;
struct ClockData ClockData;
/* Obtain current date. */
DateStamp(&Date);
/* Convert time and date. */
Amiga2Date((Date . ds_Days * 86400) + (Date . ds_Minute * 60) + (Date . ds_Tick / TICKS_PER_SECOND),&ClockData);
/* Add the date line. */
FPrintf(CallFile,"%s %s %2ld %02ld:%02ld:%02ld %ld\n",CallDays[ClockData . wday - 1],CallMonths[ClockData . month - 1],ClockData . mday,ClockData . hour,ClockData . min,ClockData . sec,ClockData . year);
}
/* MakeCall(struct PhoneEntry *Entry):
*
* Register a new phone call.
*/
VOID
MakeCall(STRPTR Name,STRPTR Number)
{
/* End previous entry. */
if(CallFile)
StopCall(FALSE);
if(Config . NCommLog)
{
STRPTR File;
strcpy(SharedBuffer,Config . LogFile);
if(File = PathPart(SharedBuffer))
*File = 0;
if(AddPart(SharedBuffer,"term-call.log",256))
{
/* Open logfile for writing. */
if(CallFile = Open(SharedBuffer,MODE_READWRITE))
{
/* Seek to the end of it (append). */
if(Seek(CallFile,0,OFFSET_END) != -1)
{
/* Get current system time. */
TimeRequest -> tr_node . io_Command = TR_GETSYSTIME;
DoIO(TimeRequest);
/* Remember the starting time, we will need
* it later.
*/
CallTime = TimeRequest -> tr_time;
/* Add the title line. */
FPrintf(CallFile,"%s (%s)\n--------------------------------\nLogin: ",Name,Number);
/* Make the line complete. */
CallDate();
}
else
{
Close(CallFile);
CallFile = NULL;
}
}
}
}
}
/* StopCall(BYTE Finish):
*
* End the current phone call.
*/
VOID
StopCall(BYTE Finish)
{
/* Is a call currently being made? */
if(CallFile)
{
struct timeval StopTime;
/* Get current system time. */
TimeRequest -> tr_node . io_Command = TR_GETSYSTIME;
DoIO(TimeRequest);
/* Remember it. */
StopTime = TimeRequest -> tr_time;
/* Subtract the starting time from it. */
SubTime(&StopTime,&CallTime);
/* Add the info line. */
if(Finish)
FPrintf(CallFile,"*** term exited before logout: ");
else
FPrintf(CallFile,"Logout: ");
/* Make the line complete. */
CallDate();
/* Add the online time. */
FPrintf(CallFile,"Time online: %02ld:%02ld:%02ld\n\n",(StopTime . tv_secs % 86400) / 3600,(StopTime . tv_secs % 3600) / 60,StopTime . tv_secs % 60);
/* Finis... */
Close(CallFile);
CallFile = NULL;
}
}