4 * Copyright (c) 2014 project bchan
6 * This software is provided 'as-is', without any express or implied
7 * warranty. In no event will the authors be held liable for any damages
8 * arising from the use of this software.
10 * Permission is granted to anyone to use this software for any purpose,
11 * including commercial applications, and to alter it and redistribute it
12 * freely, subject to the following restrictions:
14 * 1. The origin of this software must not be misrepresented; you must not
15 * claim that you wrote the original software. If you use this software
16 * in a product, an acknowledgment in the product documentation would be
17 * appreciated but is not required.
19 * 2. Altered source versions must be plainly marked as such, and must not be
20 * misrepresented as being the original software.
22 * 3. This notice may not be removed or altered from any source
27 #include "tadsegment.h"
33 EXPORT W tadsegment_getvariable(tadsegment *segment, UB *segid, UW *seglen, UB **segdata)
38 if (segment->type != TADSEGMENT_TYPE_VARIABLE) {
42 ch = (TC*)segment->value.variable.raw;
46 if (seg->len == 0xffff) {
48 *segdata = ((UB*)seg) + 8;
51 *segdata = ((UB*)seg) + 4;
57 EXPORT Bool tadsegment_isvalid(tadsegment *segment)
61 switch (segment->type) {
62 case TADSEGMENT_TYPE_VARIABLE:
63 seg = (LTADSEG*)segment->value.variable.raw;
64 if (seg->len == 0xffff) {
65 if (segment->value.variable.rawlen != (seg->llen + 8)) {
69 if (segment->value.variable.rawlen != (seg->len + 4)) {
74 case TADSEGMENT_TYPE_CHARACTOR:
75 if ((segment->value.ch & 0xFF00) == 0xFE00) {
79 case TADSEGMENT_TYPE_LANGCODE: