2001-05-23 15:26:42 +02:00
|
|
|
//____________________________________________________________
|
|
|
|
//
|
|
|
|
// PROGRAM: Language Preprocessor
|
|
|
|
// MODULE: form.cpp
|
|
|
|
// DESCRIPTION: Form manager stuff
|
|
|
|
//
|
|
|
|
// The contents of this file are subject to the Interbase Public
|
|
|
|
// License Version 1.0 (the "License"); you may not use this file
|
|
|
|
// except in compliance with the License. You may obtain a copy
|
|
|
|
// of the License at http://www.Inprise.com/IPL.html
|
|
|
|
//
|
|
|
|
// Software distributed under the License is distributed on an
|
|
|
|
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
|
|
|
|
// or implied. See the License for the specific language governing
|
|
|
|
// rights and limitations under the License.
|
|
|
|
//
|
|
|
|
// The Original Code was created by Inprise Corporation
|
|
|
|
// and its predecessors. Portions created by Inprise Corporation are
|
|
|
|
// Copyright (C) Inprise Corporation.
|
|
|
|
//
|
|
|
|
// All Rights Reserved.
|
|
|
|
// Contributor(s): ______________________________________.
|
2002-11-17 01:04:19 +01:00
|
|
|
// $Id: form.cpp,v 1.6 2002-11-17 00:04:18 hippoman Exp $
|
2001-05-23 15:26:42 +02:00
|
|
|
// Revision 1.2 2000/11/27 09:26:13 fsg
|
|
|
|
// Fixed bugs in gpre to handle PYXIS forms
|
|
|
|
// and allow edit.e and fred.e to go through
|
|
|
|
// gpre without errors (and correct result).
|
|
|
|
//
|
|
|
|
// This is a partial fix until all
|
|
|
|
// PYXIS datatypes are adjusted in frm_trn.c
|
|
|
|
//
|
|
|
|
// removed some compiler warnings too
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//____________________________________________________________
|
|
|
|
//
|
2002-11-17 01:04:19 +01:00
|
|
|
// $Id: form.cpp,v 1.6 2002-11-17 00:04:18 hippoman Exp $
|
2001-05-23 15:26:42 +02:00
|
|
|
//
|
|
|
|
|
2001-07-30 01:43:24 +02:00
|
|
|
#include "firebird.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
#include "../gpre/gpre.h"
|
|
|
|
#include "../gpre/form.h"
|
|
|
|
#include "../pyxis/phase1.h"
|
|
|
|
#include "../gpre/form_proto.h"
|
|
|
|
#include "../gpre/form__proto.h"
|
|
|
|
#include "../gpre/hsh_proto.h"
|
|
|
|
#include "../gpre/msc_proto.h"
|
|
|
|
|
|
|
|
typedef int *HANDLE;
|
|
|
|
|
2001-07-12 07:46:06 +02:00
|
|
|
extern "C" HANDLE PYXIS_find_field(HANDLE , TEXT *);
|
|
|
|
extern "C" HANDLE PYXIS_get_attribute_value(HANDLE , ATT_N );
|
|
|
|
extern int pyxis__load_form(STATUS *, SLONG *, SLONG *, SLONG *, SSHORT *,
|
|
|
|
SCHAR *);
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
extern USHORT sw_cstring;
|
|
|
|
|
|
|
|
#define GET_VALUE PYXIS_get_attribute_value
|
|
|
|
|
|
|
|
|
|
|
|
//____________________________________________________________
|
|
|
|
//
|
|
|
|
// Lookup field in form.
|
|
|
|
//
|
|
|
|
|
|
|
|
FLD FORM_lookup_field( FORM form, HANDLE object, char *string)
|
|
|
|
{
|
|
|
|
SYM symbol;
|
|
|
|
FLD field;
|
|
|
|
UCHAR name[32], *p;
|
|
|
|
HANDLE handle;
|
|
|
|
USHORT l;
|
|
|
|
|
|
|
|
for (p = name; (*p = UPPER(*string)); string++, p++);
|
|
|
|
|
|
|
|
// See if we already know about field
|
|
|
|
|
|
|
|
for (field = form->form_fields; field; field = field->fld_next) {
|
|
|
|
symbol = field->fld_symbol;
|
2001-07-12 07:46:06 +02:00
|
|
|
if (!strcmp((char*)name, symbol->sym_string))
|
2001-05-23 15:26:42 +02:00
|
|
|
return field;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Haven't seen it before -- look it up on form
|
|
|
|
|
2001-07-12 07:46:06 +02:00
|
|
|
if (!(handle = PYXIS_find_field(object, (TEXT*) name)))
|
2001-05-23 15:26:42 +02:00
|
|
|
return NULL;
|
|
|
|
// Make field block and decrypt data type
|
|
|
|
|
|
|
|
field = (FLD) ALLOC(sizeof(struct fld));
|
|
|
|
field->fld_next = form->form_fields;
|
|
|
|
form->form_fields = field;
|
|
|
|
field->fld_handle = handle;
|
2001-07-12 07:46:06 +02:00
|
|
|
field->fld_prototype = (int*) GET_VALUE(handle, att_prototype);
|
2001-05-23 15:26:42 +02:00
|
|
|
field->fld_dtype = FORM_TRN_dtype((USHORT) GET_VALUE(handle, att_dtype));
|
|
|
|
field->fld_length = (int) GET_VALUE(handle, att_length);
|
|
|
|
field->fld_scale = (int) GET_VALUE(handle, att_scale);
|
|
|
|
|
|
|
|
if (field->fld_dtype == dtype_varying) {
|
|
|
|
field->fld_dtype = dtype_text;
|
|
|
|
field->fld_flags |= FLD_text;
|
|
|
|
field->fld_length -= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sw_cstring &&
|
|
|
|
(field->fld_dtype == dtype_text ||
|
|
|
|
field->fld_dtype == dtype_varying)) {
|
|
|
|
field->fld_dtype = dtype_cstring;
|
|
|
|
++field->fld_length;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make up symbol block
|
|
|
|
|
|
|
|
l = p - name;
|
2001-07-12 07:46:06 +02:00
|
|
|
field->fld_symbol = symbol = MSC_symbol(SYM_form_field, (TEXT*) name, l, 0);
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
return field;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//____________________________________________________________
|
|
|
|
//
|
|
|
|
// Lookup form. This may be an instance already in
|
|
|
|
// use.
|
|
|
|
//
|
|
|
|
|
|
|
|
FORM FORM_lookup_form(DBB dbb, UCHAR * string)
|
|
|
|
{
|
|
|
|
SYM symbol;
|
|
|
|
FORM form;
|
|
|
|
USHORT l;
|
2002-10-24 11:01:44 +02:00
|
|
|
STATUS status[ISC_STATUS_LENGTH];
|
2001-05-23 15:26:42 +02:00
|
|
|
UCHAR name[32], *p;
|
|
|
|
|
|
|
|
if (!dbb)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (p = name; (*p = UPPER(*string)); string++, p++);
|
|
|
|
|
|
|
|
// See if we already know about form
|
|
|
|
|
|
|
|
l = p - name;
|
|
|
|
|
2001-07-12 07:46:06 +02:00
|
|
|
for (symbol = HSH_lookup((SCHAR*) name); symbol; symbol = symbol->sym_homonym)
|
2001-05-23 15:26:42 +02:00
|
|
|
if (symbol->sym_type == SYM_form &&
|
|
|
|
(form = (FORM) symbol->sym_object) && form->form_dbb == dbb)
|
|
|
|
return form;
|
|
|
|
|
|
|
|
// Load form
|
|
|
|
|
|
|
|
form = (FORM) ALLOC(sizeof(struct form));
|
|
|
|
pyxis__load_form(status,
|
2001-07-12 07:46:06 +02:00
|
|
|
(SLONG*)&dbb->dbb_handle, (SLONG*)&dbb->dbb_transaction,
|
|
|
|
(SLONG*)&form->form_object, 0, (SCHAR*)name);
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
if (!form->form_object)
|
|
|
|
return NULL;
|
|
|
|
// *PYXIS_print(form->form_object,0);
|
|
|
|
form->form_dbb = dbb;
|
|
|
|
form->form_next = dbb->dbb_forms;
|
|
|
|
dbb->dbb_forms = form;
|
|
|
|
|
|
|
|
// Make up form block, etc
|
|
|
|
|
2002-11-17 01:04:19 +01:00
|
|
|
form->form_name = symbol = MSC_symbol(SYM_form, (TEXT*) name, l, (GPRE_CTX) form);
|
2001-05-23 15:26:42 +02:00
|
|
|
HSH_insert(symbol);
|
|
|
|
|
|
|
|
return form;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//____________________________________________________________
|
|
|
|
//
|
|
|
|
// Lookup sub-form of a given form.
|
|
|
|
//
|
|
|
|
|
|
|
|
FORM FORM_lookup_subform(FORM parent, FLD field)
|
|
|
|
{
|
|
|
|
FORM form;
|
|
|
|
|
|
|
|
// Allocate form block
|
|
|
|
|
|
|
|
form = (FORM) ALLOC(sizeof(struct form));
|
|
|
|
form->form_dbb = parent->form_dbb;
|
|
|
|
form->form_field = field;
|
|
|
|
form->form_name = field->fld_symbol;
|
|
|
|
|
|
|
|
if (!
|
|
|
|
(form->form_object =
|
|
|
|
PYXIS_get_attribute_value(field->fld_handle,
|
|
|
|
att_prototype))) return NULL;
|
|
|
|
|
|
|
|
field->fld_dtype = dtype_short;
|
|
|
|
field->fld_length = sizeof(SSHORT);
|
|
|
|
field->fld_flags |= FLD_repeating;
|
|
|
|
|
|
|
|
return form;
|
|
|
|
}
|