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 181
|
/*
* 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 "modules.h"
#include "variable.h"
#include "ags.h"
static void ExchangeString(void) {
/*
文字列(target)中の一部(pat)を別の文字列(patr)で置き換える
*/
int target = getCaliValue();
int pat = getCaliValue();
int patr = getCaliValue();
svar_replaceAll(target, pat, patr);
TRACE("ShString.ExchangeString: %d,%d,%d:", target, pat, patr);
}
static void SetNum16String(void) { /* 1 */
int p1 = getCaliValue();
int p2 = getCaliValue();
TRACE_UNIMPLEMENTED("ShString.SetNum16String: %d,%d:", p1, p2);
}
static void SetNum16HalfString(void) { /* 2 */
int p1 = getCaliValue();
int p2 = getCaliValue();
TRACE_UNIMPLEMENTED("ShString.SetNum16HalfString: %d,%d:", p1, p2);
}
static void SetNum32String(void) { /* 3 */
int p1 = getCaliValue();
int p2 = getCaliValue();
TRACE_UNIMPLEMENTED("ShString.SetNum32String: %d,%d:", p1, p2);
}
static void SetNum32HalfString(void) { /* 4 */
int p1 = getCaliValue();
int p2 = getCaliValue();
TRACE_UNIMPLEMENTED("ShString.SetNum32HalfString: %d,%d:", p1, p2);
}
static void GetArrayString(void) { /* 5 */
int p1 = getCaliValue();
int p2 = getCaliValue();
int p3 = getCaliValue();
TRACE_UNIMPLEMENTED("ShString.GetArrayString: %d,%d,%d:", p1, p2, p3);
}
static void SetWindowTitle(void) { /* 6 */
int strno = getCaliValue();
int p2 = getCaliValue(); /* ISys3xSystem */
char *title_utf8 = toUTF8(svar_get(strno));
ags_setWindowTitle(title_utf8);
free(title_utf8);
TRACE("ShString.SetWindowTitle: %d,%d:", strno, p2);
}
static 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++) {
if (st + i != src)
svar_set(st + i, svar_get(src));
}
TRACE("ShString.FillString: %d,%d,%d,%d:", st, cnt, src, p4);
}
static void SetStringNum16(void) {
/*
文字列を数値に変換
大文字、小文字、混在可
p1: 変換元文字列番号
p2: 変換された数値を格納する変数
*/
int st = getCaliValue();
int *var = getCaliVariable();
const char *str = svar_get(st);
char _dst[100];
char *dst = _dst;
TRACE("ShString.SetStringNum16: %d,%p:", 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);
}
static void SetStringNum32(void) {
int p1 = getCaliValue();
int *p2 = getCaliVariable();
TRACE_UNIMPLEMENTED("ShString.SetStringNum32: %d,%p:", p1, p2);
}
static const ModuleFunc functions[] = {
{"ExchangeString", ExchangeString},
{"FillString", FillString},
{"GetArrayString", GetArrayString},
{"SetNum16HalfString", SetNum16HalfString},
{"SetNum16String", SetNum16String},
{"SetNum32HalfString", SetNum32HalfString},
{"SetNum32String", SetNum32String},
{"SetStringNum16", SetStringNum16},
{"SetStringNum32", SetStringNum32},
{"SetWindowTitle", SetWindowTitle},
};
const Module module_ShString = {"ShString", functions, sizeof(functions) / sizeof(ModuleFunc)};
|