missing-ansi.c 2.43 KB
Newer Older
Linus Tolke's avatar
Linus Tolke committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * $Id: missing-ansi.c,v 0.4 1991/09/15 10:30:58 linus Exp $
 * Copyright (C) 1991  Lysator Academic Computer Association.
 *
 * This file is part of the LysKOM server.
 * 
 * LysKOM is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 1, or (at your option) 
 * any later version.
 * 
 * LysKOM is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with LysKOM; see the file COPYING.  If not, write to
 * Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
 * or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
 * MA 02139, USA.
 *
 * Please mail bug reports to bug-lyskom@lysator.liu.se. 
 */
Per Cederqvist's avatar
Per Cederqvist committed
25
26
27
28
29
30
/*
 * Some missing functions that are needed.
 *
 * Written by ceder.
 */

Linus Tolke's avatar
Linus Tolke committed
31
static char *rcsid = "$Id: missing-ansi.c,v 0.4 1991/09/15 10:30:58 linus Exp $";
Per Cederqvist's avatar
Per Cederqvist committed
32
33


Per Cederqvist's avatar
Per Cederqvist committed
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
#include <string.h>
#include <time.h>

#if defined(__sequent__) && !defined(DEBUG_MALLOC)

void *
memcpy (void * s1, const void * s2, size_t n)
{
    extern bcopy(const char *b1, char *b2, unsigned int length);

    /* bcopy takes the parameters the other way round. */
    
    bcopy(s2, s1, n);
    return s1;			/* Since ANSI says so */
}

#endif

#if defined(__sequent__) || defined(__sun__)

extern double
difftime(time_t t1, time_t t2)
{
    return (double) t1 - (double) t2;
}

#endif

#ifdef __sequent__

/*
 * This version in NOT 100 % ANSI-conformant, but it is enough to run LysKOM
 * (I hope) /ceder
 */

extern time_t
mktime (const struct tm  * temeptr )
{
    int nyears;
    int nleaps;
    int ndays;

    nyears = temeptr->tm_year - 70;
    nleaps = (nyears+2) / 4;

    ndays = 365 * nyears + nleaps + temeptr->tm_yday;
    
    return (time_t) ( temeptr->tm_sec
		     + 60 * ( temeptr->tm_min
			     + 60 * ( temeptr->tm_hour 
				     + 24 * ndays )));
}

#endif


90
#if defined(__sequent__) || defined(__sun__)
Per Cederqvist's avatar
Per Cederqvist committed
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <errno.h>
#include <stdio.h>

extern char *sys_errlist[];
extern int sys_nerr;

const char *strerror(int eno)
{
  static char buf[200];

  
  if (eno < 0 || eno >= sys_nerr)
  {
    sprintf(buf, "error #%d", eno);
    return buf;
  }
  else
    return sys_errlist[eno];
}
#endif