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 |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
3613
|
21 |
|
22 */ |
|
23 |
3803
|
24 /* |
|
25 |
|
26 The function gethostname was adapted from a similar function from GNU |
|
27 Bash, the Bourne Again SHell, copyright (C) 1987, 1989, 1991 Free |
|
28 Software Foundation, Inc. |
|
29 |
|
30 */ |
|
31 |
3613
|
32 #ifdef HAVE_CONFIG_H |
|
33 #include <config.h> |
|
34 #endif |
|
35 |
4290
|
36 /* This gives us a better chance of finding a prototype for strptime |
|
37 on some systems. */ |
|
38 |
|
39 #if ! defined (_XOPEN_SOURCE) |
|
40 #define _XOPEN_SOURCE |
|
41 #endif |
|
42 |
3803
|
43 #ifdef HAVE_UNISTD_H |
|
44 #ifdef HAVE_SYS_TYPES_H |
|
45 #include <sys/types.h> |
|
46 #endif |
|
47 #include <unistd.h> |
|
48 #endif |
|
49 |
3613
|
50 #include <stdlib.h> |
3803
|
51 #include <string.h> |
3706
|
52 #include <time.h> |
3613
|
53 |
5453
|
54 #include "syswait.h" |
|
55 |
6108
|
56 OCTAVE_API void |
3613
|
57 octave_qsort (void *base, size_t n, size_t size, |
|
58 int (*cmp) (const void *, const void *)) |
|
59 { |
|
60 qsort (base, n, size, cmp); |
|
61 } |
|
62 |
6108
|
63 OCTAVE_API char * |
3706
|
64 oct_strptime (const char *buf, const char *format, struct tm *tm) |
|
65 { |
3786
|
66 return (char *) strptime (buf, format, tm); |
3706
|
67 } |
|
68 |
4093
|
69 #if defined (__WIN32__) && ! defined (_POSIX_VERSION) |
|
70 |
|
71 #include <winsock.h> |
|
72 |
|
73 #elif ! defined (HAVE_GETHOSTNAME) && defined (HAVE_SYS_UTSNAME_H) |
3707
|
74 |
3803
|
75 #include <sys/utsname.h> |
|
76 |
|
77 int |
|
78 gethostname (char *name, int namelen) |
|
79 { |
|
80 int i; |
|
81 struct utsname ut; |
|
82 |
|
83 --namelen; |
|
84 |
|
85 uname (&ut); |
|
86 i = strlen (ut.nodename) + 1; |
|
87 strncpy (name, ut.nodename, i < namelen ? i : namelen); |
|
88 name[namelen] = '\0'; |
|
89 |
|
90 return 0; |
|
91 } |
|
92 |
|
93 #endif |
|
94 |
6108
|
95 OCTAVE_API int |
6111
|
96 octave_strcasecmp (const char *s1, const char *s2) |
|
97 { |
|
98 return strcasecmp (s1, s2); |
|
99 } |
|
100 |
|
101 OCTAVE_API int |
|
102 octave_strncasecmp (const char *s1, const char *s2, size_t n) |
|
103 { |
|
104 return strncasecmp (s1, s2, n); |
|
105 } |
|
106 |
|
107 OCTAVE_API int |
3803
|
108 octave_gethostname (char *name, int namelen) |
|
109 { |
|
110 return gethostname (name, namelen); |
|
111 } |
3707
|
112 |
5451
|
113 #ifdef HAVE_LOADLIBRARY_API |
|
114 #include <windows.h> |
|
115 |
|
116 /* Need this since in C++ can't cast from int(*)() to void* */ |
6108
|
117 OCTAVE_API void * |
5453
|
118 octave_w32_library_search (HINSTANCE handle, const char * name) |
5451
|
119 { |
|
120 return (GetProcAddress (handle, name)); |
|
121 } |
|
122 #endif |
|
123 |
6108
|
124 OCTAVE_API pid_t |
5453
|
125 octave_waitpid (pid_t pid, int *status, int options) |
|
126 { |
|
127 return WAITPID (pid, status, options); |
|
128 } |
|
129 |
3613
|
130 /* |
|
131 ;;; Local Variables: *** |
|
132 ;;; mode: C++ *** |
|
133 ;;; End: *** |
|
134 */ |