Mercurial > octave
annotate liboctave/lo-utils.h @ 10180:be952ce74023
bootstrap.conf fixes
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 21 Jan 2010 03:25:23 -0500 |
parents | 6bd86b6287b1 |
children | 4d433bd2d4dc |
rev | line source |
---|---|
1967 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
8920 | 4 2007, 2008 John W. Eaton |
1967 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1967 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1967 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_liboctave_utils_h) | |
25 #define octave_liboctave_utils_h 1 | |
26 | |
2926 | 27 #include <cstdio> |
28 | |
9469
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
29 #include <iostream> |
2926 | 30 #include <string> |
31 | |
4130 | 32 #include "oct-cmplx.h" |
5453 | 33 #include "syswait.h" |
4130 | 34 |
6108 | 35 extern OCTAVE_API octave_idx_type NINTbig (double x); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
36 extern OCTAVE_API octave_idx_type NINTbig (float x); |
6108 | 37 extern OCTAVE_API int NINT (double x); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
38 extern OCTAVE_API int NINT (float x); |
6108 | 39 extern OCTAVE_API double D_NINT (double x); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
40 extern OCTAVE_API float F_NINT (float x); |
1967 | 41 |
6108 | 42 extern OCTAVE_API char *strsave (const char *); |
2926 | 43 |
10180 | 44 extern OCTAVE_API void |
45 octave_putenv (const std::string&, const std::string&); | |
2926 | 46 |
6108 | 47 extern OCTAVE_API std::string octave_fgets (std::FILE *); |
48 extern OCTAVE_API std::string octave_fgetl (std::FILE *); | |
2926 | 49 |
6108 | 50 extern OCTAVE_API std::string octave_fgets (std::FILE *, bool& eof); |
51 extern OCTAVE_API std::string octave_fgetl (std::FILE *, bool& eof); | |
3970 | 52 |
6108 | 53 extern "C" OCTAVE_API int octave_gethostname (char *, int); |
3803 | 54 |
10175
d354be89b2c3
use link module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10174
diff
changeset
|
55 extern "C" OCTAVE_API int |
d354be89b2c3
use link module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10174
diff
changeset
|
56 octave_link (const char *old_name, const char *new_name); |
d354be89b2c3
use link module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10174
diff
changeset
|
57 |
10176
a0665fa8798c
use symlink module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10175
diff
changeset
|
58 extern "C" OCTAVE_API int |
a0665fa8798c
use symlink module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10175
diff
changeset
|
59 octave_symlink (const char *old_name, const char *new_name); |
a0665fa8798c
use symlink module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10175
diff
changeset
|
60 |
10177
cb3d926b4d9e
use readlink module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10176
diff
changeset
|
61 extern "C" OCTAVE_API int |
cb3d926b4d9e
use readlink module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10176
diff
changeset
|
62 octave_readlink (const char *name, char *buf, size_t size); |
cb3d926b4d9e
use readlink module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10176
diff
changeset
|
63 |
10180 | 64 extern "C" OCTAVE_API int |
65 octave_mkdir (const char *name, mode_t mode); | |
10172
96ed9db3345c
provide wrappers for mkdir and mkfifo
John W. Eaton <jwe@octave.org>
parents:
10171
diff
changeset
|
66 |
10180 | 67 extern "C" OCTAVE_API int |
68 octave_mkfifo (const char *name, mode_t mode); | |
10172
96ed9db3345c
provide wrappers for mkdir and mkfifo
John W. Eaton <jwe@octave.org>
parents:
10171
diff
changeset
|
69 |
10180 | 70 extern "C" OCTAVE_API void |
71 octave_qsort (void *base, size_t n, size_t size, | |
72 int (*cmp) (const void *, const void *)); | |
3613 | 73 |
10169
06bd6e57f889
use rmdir module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
74 extern "C" OCTAVE_API int octave_rmdir (const char *name); |
06bd6e57f889
use rmdir module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
75 |
10180 | 76 extern "C" OCTAVE_API int |
77 octave_rename (const char *from, const char *to); | |
78 | |
79 extern "C" OCTAVE_API char * | |
80 oct_strptime (const char *buf, const char *format, struct tm *tm); | |
10170
1dffc8b2fca7
use rename module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10169
diff
changeset
|
81 |
10180 | 82 extern "C" OCTAVE_API int |
83 octave_strcasecmp (const char *s1, const char *s2); | |
3706 | 84 |
10180 | 85 extern "C" OCTAVE_API int |
86 octave_strncasecmp (const char *s1, const char *s2, size_t n); | |
6111 | 87 |
10178
6bd86b6287b1
provide wrapper for tempnam
John W. Eaton <jwe@octave.org>
parents:
10177
diff
changeset
|
88 extern "C" OCTAVE_API char * |
6bd86b6287b1
provide wrapper for tempnam
John W. Eaton <jwe@octave.org>
parents:
10177
diff
changeset
|
89 octave_tempnam (const char *pdir, const char *ppfx); |
6bd86b6287b1
provide wrapper for tempnam
John W. Eaton <jwe@octave.org>
parents:
10177
diff
changeset
|
90 |
10173 | 91 extern "C" OCTAVE_API mode_t octave_umask (mode_t); |
92 | |
10174
eb64bf1c6107
use unlink module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10173
diff
changeset
|
93 extern "C" OCTAVE_API int octave_unlink (const char *name); |
eb64bf1c6107
use unlink module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10173
diff
changeset
|
94 |
9469
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
95 template <typename T> |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
96 T |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
97 octave_read_value (std::istream& is) |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
98 { |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
99 T retval; |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
100 is >> retval; |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
101 return retval; |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
102 } |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
103 |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
104 template <> OCTAVE_API double octave_read_value (std::istream& is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
105 template <> OCTAVE_API Complex octave_read_value (std::istream& is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
106 template <> OCTAVE_API float octave_read_value (std::istream& is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
107 template <> OCTAVE_API FloatComplex octave_read_value (std::istream& is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
108 |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
109 // The next four functions are provided for backward compatibility. |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
110 inline double |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
111 octave_read_double (std::istream& is) |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
112 { |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
113 return octave_read_value<double> (is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
114 } |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
115 |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
116 inline Complex |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
117 octave_read_complex (std::istream& is) |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
118 { |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
119 return octave_read_value<Complex> (is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
120 } |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
121 |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
122 inline float |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
123 octave_read_float (std::istream& is) |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
124 { |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
125 return octave_read_value<float> (is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
126 } |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
127 |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
128 inline FloatComplex |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
129 octave_read_float_complex (std::istream& is) |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
130 { |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
131 return octave_read_value<FloatComplex> (is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
132 } |
4130 | 133 |
10180 | 134 extern OCTAVE_API void |
135 octave_write_double (std::ostream& os, double dval); | |
136 | |
137 extern OCTAVE_API void | |
138 octave_write_complex (std::ostream& os, const Complex& cval); | |
4130 | 139 |
10180 | 140 extern OCTAVE_API void |
141 octave_write_float (std::ostream& os, float dval); | |
142 | |
143 extern OCTAVE_API void | |
144 octave_write_float_complex (std::ostream& os, const FloatComplex& cval); | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
145 |
5451 | 146 #ifdef HAVE_LOADLIBRARY_API |
147 #include <windows.h> | |
10180 | 148 extern "C" OCTAVE_API void * |
149 octave_w32_library_search (HINSTANCE handle, const char *name); | |
6108 | 150 #undef min |
151 #undef max | |
5451 | 152 #endif |
1967 | 153 #endif |
154 | |
10180 | 155 extern "C" OCTAVE_API pid_t |
156 octave_waitpid (pid_t pid, int *status, int options); |