home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PCBOARD
/
PCBM102.ZIP
/
SOURCES.ZIP
/
SYSTEM.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-22
|
3KB
|
100 lines
/*
┌────────────────────────────────────────────────────────────────────────┐
│ │
│ ▒▒▒▒▒▒▄ ▒▒▒▒▒▒▄ ▒▒▒▒▒▒▒▄ ▒▒▒▒▒▒▒▒▄ ▒▒▒▒▒▒▄ ▒▒▄ ▒▒▄ ▒▒▒▒▒▒▄ │
│ ▒▒█▀▒▒█ ▒▒█▀▀▀▀ ▒▒█▀▒▒█ ▒▒█▒▒█▒▒█ ▒▒█▀▒▒█ ▒▒█ ▒▒█▀ ▒▒█▀▀▀▀ │
│ ▒▒▒▒▒▒█ ▒▒█ ▒▒▒▒▒█▀ ▒▒█▒▒█▒▒█ ▒▒█ ▒▒█ ▒▒█ ▒▒█▀ ▒▒▒▒▄ │
│ ▒▒█▀▀▀▀ ▒▒█ ▒▒█▀▒▒█ ▒▒█ ▀▀▒▒█ ▒▒█ ▒▒█ ▒▒█▒▒█▀ ▒▒█▀▀ │
│ ▒▒█ ▒▒▒▒▒▒▄ ▒▒▒▒▒▒▒█ ▒▒█ ▒▒█ ▒▒▒▒▒▒█ ▒▒▒█▀ ▒▒▒▒▒▒▄ │
│ ▀▀ ▀▀▀▀▀▀ ▀▀▀▀▀▀▀ ▀▀ ▀▀ ▀▀▀▀▀▀ ▀▀▀ ▀▀▀▀▀▀ │
│ │
│ Module : SYSTEM.C │
│ │
│ Fonction : Gestion bas niveau diverses fonctions spécifiques │
│ au système ou à la machine. │
│ │
└────────────────────────────────────────────────────────────────────────┘
*/
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "pcbmove.h"
#include "strings.h"
#include "system.h"
/* ------------------------------------------------------------------------
* FRTIME : retourne un pointeur sur une chaine statique contenant
* la date en ascii et en Francais.
*
* SFRTIME : Idem mais plus court. (sans system.c)
*/
char *frtime( long t )
{
struct tm *tm;
tm = localtime( &t );
sprintf(tampon,"%s %02d %s %d , %02d H %02d mn %02d s",
_days_[tm->tm_wday], tm->tm_mday,
_months_[tm->tm_mon],tm->tm_year + 1900,
tm->tm_hour, tm->tm_min, tm->tm_sec );
return (tampon);
}
/* ------------------------------------------------------------------------ */
char *sfrtime( long t )
{
struct tm *tm;
tm = localtime ( &t );
sprintf(tampon,"%02d %s %02d %02d:%02d",
tm->tm_mday,
_months_[tm->tm_mon],tm->tm_year ,
tm->tm_hour, tm->tm_min );
return (tampon);
}
/*-------------------------------------------------------------------------*/
/*
Calcul du crc:extrait de la documentation de Chuck Forsberg
Figure 8. Example of CRC Calculation written in C
This function calculates the CRC used by the XMODEM/CRC Protocol
The first argument is a pointer to the message block.
The second argument is the number of bytes in the message block.
The function returns an integer which contains the CRC.
The low order 16 bits are the coefficients of the CRC.
*/
int calcrc(char *ptr, int count)
{
int crc, i;
crc = 0;
while(--count >= 0)
{
crc = crc ^ (int)*ptr++ << 8;
for(i = 0; i < 8; ++i)
if(crc & 0x8000)
crc = crc << 1 ^ 0x1021;
else
crc = crc << 1;
}
return (crc & 0xFFFF);
}
/*--------------------------------------------------------------------------*/