4 * Various miscellaneous (and largely non-WIMP) utility routines
6 * © 1993-1998 Straylight
9 /*----- Licensing note ----------------------------------------------------*
11 * This file is part of Straylight's Steel library.
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)
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.
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.
40 * int utils_caselessCmp(const char *s1,const char *s2)
43 * Caseless comparison between string 1 and string 2
46 * const char *s1 == source string
47 * const char *s2 == target string
50 * 0 if the strings are equal, >0 if s1>s2, or <0 if s1<s2.
53 int utils_caselessCmp(const char *s1,const char *s2)
55 if (wimpt_getVersion()>=300)
56 return (_swi(Territory_Collate, _inr(0,3)+_return(0), -1,s1,s2,3));
61 while (*s1!='\0' || *s2!='\0')
73 * char *utils_ctermToNterm(char *s)
76 * Changes a control-terminated string into a null-terminated string.
79 * char *s == the string to change
82 * A pointer to the string.
85 char *utils_ctermToNterm(char *s)
89 /* blank loop - all in for statement */;
95 * char *utils_leafname(char *filename)
98 * Returns the leafname of the file whose full pathname is given in
102 * char *filename == pointer to full filename string
105 * Pointer to character after last '.' of string.
108 char *utils_leafname(char *filename)
113 if (*(filename++)=='.')
120 * os_error *utils_complain(os error *e,char *string)
123 * If e is an error (i.e. not NULL) then the routine calls werr() with
124 * parameters (string,e->errmess). Ths string must contain a '%s' at some
128 * os_error *e == either NULL or a pointer to a standard system
130 * char *string == a string containing one %s, for which the error
131 * message from the structure passed above will be substituted.
137 os_error *utils_complain(os_error *e,char *string)
140 werr(FALSE,string,e->errmess);
145 * char *utils_cvtSize(int size)
148 * Converts a size in bytes into a string suitable to display the size to
149 * a user. It uses OS_ConvertFileSize to do he translation, although this
150 * is not guaranteed for future versions.
153 * int size == the size in bytes
156 * A pointer to the result (read-only)
159 char *utils_cvtSize(int size)
161 char *buff=buffer_find();
162 _swix(XOS_ConvertFileSize,_inr(0,2),size,buff,16);