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 |
3803
|
35 #ifdef HAVE_UNISTD_H |
|
36 #ifdef HAVE_SYS_TYPES_H |
|
37 #include <sys/types.h> |
|
38 #endif |
|
39 #include <unistd.h> |
|
40 #endif |
|
41 |
3613
|
42 #include <stdlib.h> |
3803
|
43 #include <string.h> |
3706
|
44 #include <time.h> |
3613
|
45 |
|
46 void |
|
47 octave_qsort (void *base, size_t n, size_t size, |
|
48 int (*cmp) (const void *, const void *)) |
|
49 { |
|
50 qsort (base, n, size, cmp); |
|
51 } |
|
52 |
3706
|
53 char * |
|
54 oct_strptime (const char *buf, const char *format, struct tm *tm) |
|
55 { |
3786
|
56 return (char *) strptime (buf, format, tm); |
3706
|
57 } |
|
58 |
3803
|
59 #if ! defined (HAVE_GETHOSTNAME) && defined (HAVE_SYS_UTSNAME_H) |
3707
|
60 |
3803
|
61 #include <sys/utsname.h> |
|
62 |
|
63 int |
|
64 gethostname (char *name, int namelen) |
|
65 { |
|
66 int i; |
|
67 struct utsname ut; |
|
68 |
|
69 --namelen; |
|
70 |
|
71 uname (&ut); |
|
72 i = strlen (ut.nodename) + 1; |
|
73 strncpy (name, ut.nodename, i < namelen ? i : namelen); |
|
74 name[namelen] = '\0'; |
|
75 |
|
76 return 0; |
|
77 } |
|
78 |
|
79 #endif |
|
80 |
|
81 int |
|
82 octave_gethostname (char *name, int namelen) |
|
83 { |
|
84 return gethostname (name, namelen); |
|
85 } |
3707
|
86 |
3613
|
87 /* |
|
88 ;;; Local Variables: *** |
|
89 ;;; mode: C++ *** |
|
90 ;;; End: *** |
|
91 */ |