chiark / gitweb /
Initial revision
[ssr] / StraySrc / Libraries / Steel / h / utils
1 /*
2  * utils
3  *
4  * Various miscellaneous (and largely non-WIMP) utility routines
5  *
6  * © 1991-1998 Straylight
7  */
8
9 /*----- Licensing note ----------------------------------------------------*
10  *
11  * This file is part of Straylight's Steel library.
12  *
13  * Steel is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2, or (at your option)
16  * any later version.
17  *
18  * Steel is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with Steel.  If not, write to the Free Software Foundation,
25  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26  */
27
28 #ifndef __utils_h
29 #define __utils_h
30
31 #ifndef __os_h
32 #include "os.h"
33 #endif
34
35 /*
36  * int utils_caselessCmp(const char *s1,const char *s2)
37  *
38  * Use
39  *  Caseless comparison between string 1 and string 2
40  *
41  * Parameters
42  *  const char *s1 == source string
43  *  const char *s2 == target string
44  *
45  * Returns
46  *  0 if the strings are equal, >0 if s1>s2, or <0 if s1<s2.
47  */
48
49 int utils_caselessCmp(const char *s1,const char *s2);
50
51 /*
52  * char *utils_ctermToNterm(char *s)
53  *
54  * Use
55  *  Changes a control-terminated string into a null-terminated string.
56  *
57  * Parameters
58  *  char *s == the string to change
59  *
60  * Returns
61  *  A pointer to the string.
62  */
63
64 char *utils_ctermToNterm(char *s);
65
66 /*
67  * char *utils_leafname(char *filename)
68  *
69  * Use
70  *  Returns the leafname of the file whose full pathname is given in
71  *  filename.
72  *
73  * Parameters
74  *  char *filename == pointer to full filename string
75  *
76  * Returns
77  *  Pointer to character after last '.' of string.
78  */
79
80 char *utils_leafname(char *filename);
81
82 /*
83  * os_error *utils_complain(os error *e,char *string)
84  *
85  * Use
86  *  If e is an error (i.e. not NULL) then the routine calls werr() with
87  *  parameters (string,e->errmess).  Ths string must contain a '%s' at some
88  *  point.
89  *
90  * Parameters
91  *  os_error *e == either NULL or a pointer to a standard system
92  *    error structure.
93  *  char *string == a string containing one %s, for which the error
94  *    message from the structure passed above will be substituted.
95  *
96  * Returns
97  *  The error pointer.
98  */
99
100 os_error *utils_complain(os_error *e,char *string);
101
102 /*
103  * char *utils_cvtSize(int size)
104  *
105  * Use
106  *  Converts a size in bytes into a string suitable to display the size to
107  *  a user.  It uses OS_ConvertFileSize to do he translation, although this
108  *  is not guaranteed for future versions.
109  *
110  * Parameters
111  *  int size == the size in bytes
112  *
113  * Returns
114  *  A pointer to the result (read-only)
115  */
116
117 char *utils_cvtSize(int size);
118
119 #endif