2 * $Id: util.c,v 1.1 2004/11/14 07:26:26 paulus Exp $
4 * Copyright (C) 1995,1996,1997 Lars Fenneberg
6 * Copyright 1992 Livingston Enterprises, Inc.
8 * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
9 * and Merit Network, Inc. All Rights Reserved
11 * See the file COPYRIGHT for the respective terms and conditions.
12 * If the file is missing contact me at lf@elemental.net
13 * and I'll send you a copy.
18 #include <radiusclient.h>
23 * Purpose: Turns printable string into correct tm struct entries.
27 static const char * months[] =
29 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
30 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
33 void rc_str2tm (char *valstr, struct tm *tm)
38 for (i = 0; i < 12; i++)
40 if (strncmp (months[i], valstr, 3) == 0)
48 tm->tm_mday = atoi (&valstr[4]);
51 tm->tm_year = atoi (&valstr[7]) - 1900;
54 void rc_mdelay(int msecs)
58 tv.tv_sec = (int) msecs / 1000;
59 tv.tv_usec = (msecs % 1000) * 1000;
61 select(0,(fd_set *)NULL,(fd_set *)NULL,(fd_set *)NULL, &tv);
67 * Purpose: generate a quite unique string
69 * Remarks: not that unique at all...
77 static unsigned short int cnt = 0;
78 sprintf (buf, "%08lX%04X%02hX",
79 (unsigned long int) time (NULL),
80 (unsigned int) getpid (),