Mercurial > hg > octave-lyh
annotate liboctave/lo-cutils.c @ 10169:06bd6e57f889
use rmdir module from gnulib
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 21 Jan 2010 01:49:36 -0500 |
parents | 4c0cdbe0acca |
children | 1dffc8b2fca7 |
rev | line source |
---|---|
3613 | 1 /* |
2 | |
7017 | 3 Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006, 2007 John W. Eaton |
3613 | 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
3613 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
3613 | 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 |
5453 | 53 #include "syswait.h" |
54 | |
6108 | 55 OCTAVE_API void |
3613 | 56 octave_qsort (void *base, size_t n, size_t size, |
57 int (*cmp) (const void *, const void *)) | |
58 { | |
59 qsort (base, n, size, cmp); | |
60 } | |
61 | |
6108 | 62 OCTAVE_API char * |
3706 | 63 oct_strptime (const char *buf, const char *format, struct tm *tm) |
64 { | |
3786 | 65 return (char *) strptime (buf, format, tm); |
3706 | 66 } |
67 | |
4093 | 68 #if defined (__WIN32__) && ! defined (_POSIX_VERSION) |
69 | |
70 #include <winsock.h> | |
71 | |
72 #elif ! defined (HAVE_GETHOSTNAME) && defined (HAVE_SYS_UTSNAME_H) | |
3707 | 73 |
3803 | 74 #include <sys/utsname.h> |
75 | |
76 int | |
77 gethostname (char *name, int namelen) | |
78 { | |
79 int i; | |
80 struct utsname ut; | |
81 | |
82 --namelen; | |
83 | |
84 uname (&ut); | |
85 i = strlen (ut.nodename) + 1; | |
86 strncpy (name, ut.nodename, i < namelen ? i : namelen); | |
87 name[namelen] = '\0'; | |
88 | |
89 return 0; | |
90 } | |
91 | |
92 #endif | |
93 | |
6108 | 94 OCTAVE_API int |
10169
06bd6e57f889
use rmdir module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
95 octave_rmdir (const char *name) |
06bd6e57f889
use rmdir module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
96 { |
06bd6e57f889
use rmdir module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
97 return rmdir (name); |
06bd6e57f889
use rmdir module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
98 } |
06bd6e57f889
use rmdir module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
99 |
06bd6e57f889
use rmdir module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
100 OCTAVE_API int |
6111 | 101 octave_strcasecmp (const char *s1, const char *s2) |
102 { | |
103 return strcasecmp (s1, s2); | |
104 } | |
105 | |
106 OCTAVE_API int | |
107 octave_strncasecmp (const char *s1, const char *s2, size_t n) | |
108 { | |
109 return strncasecmp (s1, s2, n); | |
110 } | |
111 | |
112 OCTAVE_API int | |
3803 | 113 octave_gethostname (char *name, int namelen) |
114 { | |
115 return gethostname (name, namelen); | |
116 } | |
3707 | 117 |
5451 | 118 #ifdef HAVE_LOADLIBRARY_API |
119 #include <windows.h> | |
120 | |
121 /* Need this since in C++ can't cast from int(*)() to void* */ | |
6108 | 122 OCTAVE_API void * |
5453 | 123 octave_w32_library_search (HINSTANCE handle, const char * name) |
5451 | 124 { |
125 return (GetProcAddress (handle, name)); | |
126 } | |
127 #endif | |
128 | |
6108 | 129 OCTAVE_API pid_t |
5453 | 130 octave_waitpid (pid_t pid, int *status, int options) |
131 { | |
132 return WAITPID (pid, status, options); | |
133 } |