1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "ags/shared/ac/common.h"
24 #include "ags/engine/ac/global_string.h"
25 #include "ags/engine/ac/global_translation.h"
26 #include "ags/engine/ac/runtime_defines.h"
27 #include "ags/engine/ac/string.h"
28 #include "ags/shared/util/string_compat.h"
29 #include "ags/globals.h"
30
31 namespace AGS3 {
32
StrGetCharAt(const char * strin,int posn)33 int StrGetCharAt(const char *strin, int posn) {
34 if ((posn < 0) || (posn >= (int)strlen(strin)))
35 return 0;
36 return strin[posn];
37 }
38
StrSetCharAt(char * strin,int posn,int nchar)39 void StrSetCharAt(char *strin, int posn, int nchar) {
40 if ((posn < 0) || (posn > (int)strlen(strin)) || (posn >= MAX_MAXSTRLEN))
41 quit("!StrSetCharAt: tried to write past end of string");
42
43 if (posn == (int)strlen(strin))
44 strin[posn + 1] = 0;
45 strin[posn] = nchar;
46 }
47
_sc_strcat(char * s1,const char * s2)48 void _sc_strcat(char *s1, const char *s2) {
49 // make sure they don't try to append a char to the string
50 VALIDATE_STRING(s2);
51 check_strlen(s1);
52 int mosttocopy = (_G(MAXSTRLEN) - strlen(s1)) - 1;
53 // int numbf=_GP(game).iface[4].numbuttons;
54 my_strncpy(&s1[strlen(s1)], s2, mosttocopy);
55 }
56
_sc_strlower(char * desbuf)57 void _sc_strlower(char *desbuf) {
58 VALIDATE_STRING(desbuf);
59 check_strlen(desbuf);
60 ags_strlwr(desbuf);
61 }
62
_sc_strupper(char * desbuf)63 void _sc_strupper(char *desbuf) {
64 VALIDATE_STRING(desbuf);
65 check_strlen(desbuf);
66 ags_strupr(desbuf);
67 }
68
69 /*int _sc_strcmp (char *s1, char *s2) {
70 return strcmp (get_translation (s1), get_translation(s2));
71 }
72
73 int _sc_stricmp (char *s1, char *s2) {
74 return ags_stricmp (get_translation (s1), get_translation(s2));
75 }*/
76
_sc_strcpy(char * destt,const char * text)77 void _sc_strcpy(char *destt, const char *text) {
78 VALIDATE_STRING(destt);
79 check_strlen(destt);
80 my_strncpy(destt, text, _G(MAXSTRLEN) - 1);
81 }
82
83 } // namespace AGS3
84