3613
|
1 /* |
|
2 |
|
3 Copyright (C) 2000 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
3803
|
23 /* |
|
24 |
|
25 The function gethostname was adapted from a similar function from GNU |
|
26 Bash, the Bourne Again SHell, copyright (C) 1987, 1989, 1991 Free |
|
27 Software Foundation, Inc. |
|
28 |
|
29 */ |
|
30 |
3613
|
31 #ifdef HAVE_CONFIG_H |
|
32 #include <config.h> |
|
33 #endif |
|
34 |
4290
|
35 /* This gives us a better chance of finding a prototype for strptime |
|
36 on some systems. */ |
|
37 |
|
38 #if ! defined (_XOPEN_SOURCE) |
|
39 #define _XOPEN_SOURCE |
|
40 #endif |
|
41 |
3803
|
42 #ifdef HAVE_UNISTD_H |
|
43 #ifdef HAVE_SYS_TYPES_H |
|
44 #include <sys/types.h> |
|
45 #endif |
|
46 #include <unistd.h> |
|
47 #endif |
|
48 |
3613
|
49 #include <stdlib.h> |
3803
|
50 #include <string.h> |
3706
|
51 #include <time.h> |
3613
|
52 |
|
53 void |
|
54 octave_qsort (void *base, size_t n, size_t size, |
|
55 int (*cmp) (const void *, const void *)) |
|
56 { |
|
57 qsort (base, n, size, cmp); |
|
58 } |
|
59 |
3706
|
60 char * |
|
61 oct_strptime (const char *buf, const char *format, struct tm *tm) |
|
62 { |
3786
|
63 return (char *) strptime (buf, format, tm); |
3706
|
64 } |
|
65 |
4093
|
66 #if defined (__WIN32__) && ! defined (_POSIX_VERSION) |
|
67 |
|
68 #include <winsock.h> |
|
69 |
|
70 #elif ! defined (HAVE_GETHOSTNAME) && defined (HAVE_SYS_UTSNAME_H) |
3707
|
71 |
3803
|
72 #include <sys/utsname.h> |
|
73 |
|
74 int |
|
75 gethostname (char *name, int namelen) |
|
76 { |
|
77 int i; |
|
78 struct utsname ut; |
|
79 |
|
80 --namelen; |
|
81 |
|
82 uname (&ut); |
|
83 i = strlen (ut.nodename) + 1; |
|
84 strncpy (name, ut.nodename, i < namelen ? i : namelen); |
|
85 name[namelen] = '\0'; |
|
86 |
|
87 return 0; |
|
88 } |
|
89 |
|
90 #endif |
|
91 |
|
92 int |
|
93 octave_gethostname (char *name, int namelen) |
|
94 { |
|
95 return gethostname (name, namelen); |
|
96 } |
3707
|
97 |
3613
|
98 /* |
|
99 ;;; Local Variables: *** |
|
100 ;;; mode: C++ *** |
|
101 ;;; End: *** |
|
102 */ |