File: ShString.c

package info (click to toggle)
xsystem35 1.7.3-pre5-7
  • links: PTS
  • area: main
  • in suites: buster
  • size: 7,332 kB
  • sloc: ansic: 51,002; sh: 12,048; asm: 863; makefile: 410; xml: 281; perl: 142
file content (180 lines) | stat: -rw-r--r-- 4,300 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
 * ShString.c  ʸ module
 *
 *   ˤˤ祢ꥹ(̤)
 *   簭
 *
 * Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
 *               1998-                           <masaki-c@is.aist-nara.ac.jp>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
*/
/* $Id: ShString.c,v 1.6 2004/10/31 04:18:03 chikama Exp $ */

#include "config.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "portab.h"
#include "nact.h"
#include "system.h"
#include "xsystem35.h"
#include "variable.h"
#include "ags.h"

void ExchangeString(void) {
	/*
	  ʸ(target)ΰ(pat)̤ʸ(patr)֤
	*/
	int target = getCaliValue();
	int pat    = getCaliValue();
	int patr   = getCaliValue();
	char *start = v_str(target -1);
	char *next;
	char dst[STRVAR_LEN] = "";
	
	DEBUG_COMMAND("ShString.ExchangeString: %d,%d,%d:\n", target, pat, patr);
	
	if (v_strlen(target -1) == 0 || v_strlen(pat -1) == 0) {
		return;
	}
	
	while(TRUE) {
		next = strstr(start, v_str(pat -1));
		if (next == NULL) break;
		strncat(dst, start, (size_t)(next - start));
		strncat(dst, v_str(patr -1), sizeof(dst) - strlen(dst));
		start = next + v_strlen(pat -1);
	}
	
	strncat(dst, start, sizeof(dst) - strlen(dst));
	v_strcpy(target -1, dst);
}

void SetNum16String(void) { /* 1 */
	int p1 = getCaliValue();
	int p2 = getCaliValue();

	DEBUG_COMMAND_YET("ShString.SetNum16String: %d,%d:\n", p1, p2);
}

void SetNum16HalfString(void) { /* 2 */
	int p1 = getCaliValue();
	int p2 = getCaliValue();

	DEBUG_COMMAND_YET("ShString.SetNum16HalfString: %d,%d:\n", p1, p2);
}

void SetNum32String(void) { /* 3 */
	int p1 = getCaliValue();
	int p2 = getCaliValue();

	DEBUG_COMMAND_YET("ShString.SetNum32String: %d,%d:\n", p1, p2);
}

void SetNum32HalfString(void) { /* 4 */
	int p1 = getCaliValue();
	int p2 = getCaliValue();

	DEBUG_COMMAND_YET("ShString.SetNum32HalfString: %d,%d:\n", p1, p2);
}

void GetArrayString(void) { /* 5 */
	int p1 = getCaliValue();
	int p2 = getCaliValue();
	int p3 = getCaliValue();

	DEBUG_COMMAND_YET("ShString.GetArrayString: %d,%d,%d:\n", p1, p2, p3);
}

void SetWindowTitle(void) { /* 6 */
	int strno = getCaliValue();
	int p2    = getCaliValue(); /* ISys3xSystem */ 
	
	ags_setWindowTitle(v_str(strno - 1));
	
	DEBUG_COMMAND("ShString.SetWindowTitle: %d,%d:\n", strno, p2);
}

void FillString() {
	/*
	  ֹʸ¾ʸ˥ԡ
	  
	  st:  ԡʸκǽֹ
	  cnt: ԡʸο
	  src: ԡʸֹ
	*/
	int st  = getCaliValue();
	int cnt = getCaliValue();
	int src = getCaliValue();
	int p4 = getCaliValue(); /* ISys3xStringTable */
	int i;
	
	for (i = 0; i < cnt; i++) {
		v_strcpy(st -1, v_str(src));
	}
	
	DEBUG_COMMAND("ShString.FillString: %d,%d,%d,%d:\n", st, cnt, src, p4);
}

void SetStringNum16(void) {
	/*
	  ʸͤѴ
	    ʸʸ߲
	  
	  p1: Ѵʸֹ
	  p2: Ѵ줿ͤǼѿ
	*/
	int st = getCaliValue();
	int *var = getCaliVariable();
	char *str = v_str(st -1);
	char _dst[100];
	char *dst = _dst;
	
	DEBUG_COMMAND("ShString.SetStringNum16: %d,%p:\n", st, var);
	
	
	while(*str) {
		if (*str >= '0' && *str <= '9') {
			*dst = *str;
			dst++; str++;
		} else if ((unsigned char)*str == 0x82) {
			str++;
			if (*str >= '0' && *str <= '9') { 
				*dst = *str;
				dst++; str++;
			} else {
				*var = 0;
				return;
			}
		} else {
			*var = 0;
			return;
		}
	}
	*dst = '\0';
	
	*var = atoi(_dst);
}

void SetStringNum32(void) {
	int p1 = getCaliValue();
	int *p2 = getCaliVariable();
	
	DEBUG_COMMAND_YET("ShString.SetStringNum32: %d,%p:\n", p1, p2);
}