Category : C Source Code
Archive   : GHSTSCPT.ZIP
Filename : GSMISC.C

 
Output of file : GSMISC.C contained in archive : GHSTSCPT.ZIP
/* Copyright (C) 1989 Aladdin Enterprises. All rights reserved.
Distributed by Free Software Foundation, Inc.

This file is part of Ghostscript.

Ghostscript is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
to anyone for the consequences of using it or for whether it serves any
particular purpose or works at all, unless he says so in writing. Refer
to the Ghostscript General Public License for full details.

Everyone is granted permission to copy, modify and redistribute
Ghostscript, but only under the conditions described in the Ghostscript
General Public License. A copy of this license is supposed to have been
given to you along with Ghostscript so you can know your rights and
responsibilities. It should be in a file named COPYING. Among other
things, the copyright notice and this notice must be preserved on all
copies. */

/* gsmisc.c */
/* Miscellaneous utilities for GhostScript library */
#include "gx.h"
#include "malloc_.h"

/* Debugging flags */
#ifdef gs_DEBUG
char gs_debug[128];
#endif

/* Versions of malloc and free compatible with GhostScript's */
/* model of memory management. */
char *
gs_malloc(uint size)
{ return malloc(size);
}
void
gs_free(char *ptr, uint size)
{ free(ptr);
}

/* Read the current date (in days since Jan. 1, 1980) */
/* and time (in milliseconds since midnight). */
/****** WARNING: this routine is OS dependent. ******/
void
gs_get_clock(long *pdt)
{
#ifdef __MSDOS__
#define interrupt /* non-ANSI! */
#include
struct date osdate;
struct time ostime;
long idate, itime;
static int mstart[12] =
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
getdate(&osdate);
gettime(&ostime);
idate = (long)osdate.da_year * 365 +
osdate.da_year / 4 + 1 + /* account for leap years */
mstart[osdate.da_mon - 1] + /* month is 1-origin */
osdate.da_day - 1; /* day of month is 1-origin */
if ( osdate.da_mon <= 2 && osdate.da_year % 4 == 0 ) /* Jan. or Feb. of leap year */
idate--;
pdt[0] = idate;
itime = ostime.ti_hour;
itime = itime * 60 + ostime.ti_min;
itime = itime * 60 + ostime.ti_sec;
itime = itime * 100 + ostime.ti_hund;
itime = itime * 10; /* milliseconds */
pdt[1] = itime;
#else /* Unix */
long clock();
pdt[0] = 0;
pdt[1] = clock();
#endif
}


  3 Responses to “Category : C Source Code
Archive   : GHSTSCPT.ZIP
Filename : GSMISC.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/