1 --- firebird-1.0.0.796/porting/pyxis/save.c.orig Thu Jan 1 01:00:00 1970
2 +++ firebird-1.0.0.796/porting/pyxis/save.c Wed Dec 4 23:34:54 2002
4 +/*********** Preprocessed module -- do not edit ***************/
5 +/*********** Preprocessed module -- do not edit ***************/
6 +/*********** Preprocessed module -- do not edit ***************/
7 +/*********** Preprocessed module -- do not edit ***************/
8 +/*********** Preprocessed module -- do not edit ***************/
9 +/***************** gpre version LI-T6.2.796 Firebird 1.0 **********************/
11 + * PROGRAM: PYXIS Form Package
13 + * DESCRIPTION: Form dump/load code.
15 + * The contents of this file are subject to the Interbase Public
16 + * License Version 1.0 (the "License"); you may not use this file
17 + * except in compliance with the License. You may obtain a copy
18 + * of the License at http://www.Inprise.com/IPL.html
20 + * Software distributed under the License is distributed on an
21 + * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
22 + * or implied. See the License for the specific language governing
23 + * rights and limitations under the License.
25 + * The Original Code was created by Inprise Corporation
26 + * and its predecessors. Portions created by Inprise Corporation are
27 + * Copyright (C) Inprise Corporation.
29 + * All Rights Reserved.
30 + * Contributor(s): ______________________________________.
33 +#include "../jrd/gds.h"
34 +#include "../pyxis/pyxis.h"
37 +#define PYXIS_RELATION "PYXIS$FORMS"
40 +extern PIC PICSTR_analyze();
41 +extern OBJ PYXIS_create_object(), PYXIS_clone(), PYXIS_get_attribute_value();
42 +extern ATT PYXIS_get_attribute(), PYXIS_put_attribute(),
43 + PYXIS_find_object();
46 + DB = STATIC "yachts.lnk";*/
47 +/**** GDS Preprocessor Definitions ****/
48 +#ifndef _JRD_IBASE_H_
53 + isc_blob_null = {0,0}; /* initializer for blobs */
54 +static long *gds__null = 0; /* dummy status vector */
56 + DB = 0; /* database handle */
59 + gds__trans = 0; /* default transaction handle */
61 + isc_status [20], /* status vector */
62 + isc_status2 [20]; /* status vector */
64 + isc_array_length, /* array return size */
65 + SQLCODE; /* SQL status code */
67 + isc_tpb_0 [4] = {1,9,2,6};
73 + 4,2,4,0,2,0,9,0,40,32,0,12,0,15,'J',11,'P','Y','X','I','S','$',
74 + 'F','O','R','M','S',0,2,1,25,0,0,0,23,0,10,'P','Y','X','I','S',
75 + '$','F','O','R','M',1,25,0,1,0,23,0,15,'P','Y','X','I','S','$',
76 + 'F','O','R','M','_','N','A','M','E',-1,-1,'L'
77 + }; /* end of blr string for request isc_1 */
83 + 4,2,4,3,1,0,7,0,4,2,1,0,9,0,4,1,2,0,9,0,7,0,4,0,1,0,40,32,0,
84 + 12,0,2,7,'C',1,'J',11,'P','Y','X','I','S','$','F','O','R','M',
85 + 'S',0,'G',47,23,0,15,'P','Y','X','I','S','$','F','O','R','M',
86 + '_','N','A','M','E',25,0,0,0,-1,2,14,1,2,1,23,0,10,'P','Y','X',
87 + 'I','S','$','F','O','R','M',25,1,0,0,1,21,8,0,1,0,0,0,25,1,1,
88 + 0,-1,17,0,9,13,12,3,18,0,12,2,10,0,1,2,1,25,2,0,0,23,1,10,'P',
89 + 'Y','X','I','S','$','F','O','R','M',-1,-1,-1,14,1,1,21,8,0,0,
90 + 0,0,0,25,1,1,0,-1,-1,'L'
91 + }; /* end of blr string for request isc_8 */
97 + 4,2,4,0,2,0,40,32,0,7,0,2,7,'C',1,'J',13,'R','D','B','$','R',
98 + 'E','L','A','T','I','O','N','S',0,'G',47,23,0,15,'R','D','B',
99 + '$','S','Y','S','T','E','M','_','F','L','A','G',21,8,0,0,0,0,
100 + 0,'F',1,'H',23,0,17,'R','D','B','$','R','E','L','A','T','I',
101 + 'O','N','_','N','A','M','E',-1,14,0,2,1,23,0,17,'R','D','B',
102 + '$','R','E','L','A','T','I','O','N','_','N','A','M','E',25,0,
103 + 0,0,1,21,8,0,1,0,0,0,25,0,1,0,-1,14,0,1,21,8,0,0,0,0,0,25,0,
105 + }; /* end of blr string for request isc_21 */
111 + 4,2,4,1,8,0,40,32,0,7,0,40,126,0,40,126,0,7,0,7,0,7,0,7,0,4,
112 + 0,1,0,40,32,0,12,0,2,7,'C',2,'J',19,'R','D','B','$','R','E',
113 + 'L','A','T','I','O','N','_','F','I','E','L','D','S',0,'J',10,
114 + 'R','D','B','$','F','I','E','L','D','S',1,'G',58,47,23,0,17,
115 + 'R','D','B','$','R','E','L','A','T','I','O','N','_','N','A',
116 + 'M','E',25,0,0,0,47,23,0,16,'R','D','B','$','F','I','E','L',
117 + 'D','_','S','O','U','R','C','E',23,1,14,'R','D','B','$','F',
118 + 'I','E','L','D','_','N','A','M','E','F',1,'H',23,0,18,'R','D',
119 + 'B','$','F','I','E','L','D','_','P','O','S','I','T','I','O',
120 + 'N',-1,14,1,2,1,23,0,14,'R','D','B','$','F','I','E','L','D',
121 + '_','N','A','M','E',25,1,0,0,1,21,8,0,1,0,0,0,25,1,1,0,1,23,
122 + 1,15,'R','D','B','$','E','D','I','T','_','S','T','R','I','N',
123 + 'G',25,1,2,0,1,23,0,15,'R','D','B','$','E','D','I','T','_','S',
124 + 'T','R','I','N','G',25,1,3,0,1,23,1,18,'R','D','B','$','S','E',
125 + 'G','M','E','N','T','_','L','E','N','G','T','H',25,1,4,0,1,23,
126 + 1,14,'R','D','B','$','F','I','E','L','D','_','T','Y','P','E',
127 + 25,1,5,0,1,23,1,16,'R','D','B','$','F','I','E','L','D','_','L',
128 + 'E','N','G','T','H',25,1,6,0,1,23,1,15,'R','D','B','$','F','I',
129 + 'E','L','D','_','S','C','A','L','E',25,1,7,0,-1,14,1,1,21,8,
130 + 0,0,0,0,0,25,1,1,0,-1,-1,'L'
131 + }; /* end of blr string for request isc_25 */
137 + 4,2,4,1,2,0,9,0,7,0,4,0,1,0,40,32,0,12,0,2,7,'C',1,'J',11,'P',
138 + 'Y','X','I','S','$','F','O','R','M','S',0,'G',47,23,0,15,'P',
139 + 'Y','X','I','S','$','F','O','R','M','_','N','A','M','E',25,0,
140 + 0,0,-1,14,1,2,1,23,0,10,'P','Y','X','I','S','$','F','O','R',
141 + 'M',25,1,0,0,1,21,8,0,1,0,0,0,25,1,1,0,-1,14,1,1,21,8,0,0,0,
142 + 0,0,25,1,1,0,-1,-1,'L'
143 + }; /* end of blr string for request isc_37 */
149 + 4,2,4,0,2,0,40,32,0,7,0,2,7,'C',1,'J',11,'P','Y','X','I','S',
150 + '$','F','O','R','M','S',0,'F',1,'H',23,0,15,'P','Y','X','I',
151 + 'S','$','F','O','R','M','_','N','A','M','E',-1,14,0,2,1,23,0,
152 + 15,'P','Y','X','I','S','$','F','O','R','M','_','N','A','M','E',
153 + 25,0,0,0,1,21,8,0,1,0,0,0,25,0,1,0,-1,14,0,1,21,8,0,0,0,0,0,
155 + }; /* end of blr string for request isc_46 */
161 + 4,2,4,3,1,0,7,0,4,2,1,0,7,0,4,1,1,0,7,0,4,0,1,0,40,32,0,12,0,
162 + 2,7,'C',1,'J',11,'P','Y','X','I','S','$','F','O','R','M','S',
163 + 0,'G',47,23,0,15,'P','Y','X','I','S','$','F','O','R','M','_',
164 + 'N','A','M','E',25,0,0,0,-1,2,14,1,2,1,21,8,0,1,0,0,0,25,1,0,
165 + 0,-1,17,0,9,13,12,3,18,0,12,2,5,0,-1,-1,14,1,1,21,8,0,0,0,0,
166 + 0,25,1,0,0,-1,-1,'L'
167 + }; /* end of blr string for request isc_50 */
173 + 4,2,4,0,1,0,7,0,2,7,'C',1,'J',13,'R','D','B','$','R','E','L',
174 + 'A','T','I','O','N','S',0,'G',47,23,0,17,'R','D','B','$','R',
175 + 'E','L','A','T','I','O','N','_','N','A','M','E',21,14,11,0,'P',
176 + 'Y','X','I','S','$','F','O','R','M','S',-1,14,0,2,1,21,8,0,1,
177 + 0,0,0,25,0,0,0,-1,14,0,1,21,8,0,0,0,0,0,25,0,0,0,-1,-1,'L'
178 + }; /* end of blr string for request isc_59 */
181 +#define gds__blob_null isc_blob_null /* compatibility symbols */
182 +#define gds__status isc_status
183 +#define gds__status2 isc_status2
184 +#define gds__array_length isc_array_length
185 +#define gds__count isc_count
186 +#define gds__slack isc_slack
187 +#define gds__utility isc_utility /* end of compatibility symbols */
189 +#ifndef isc_version4
190 + Generate a compile-time error.
191 + Picking up a V3 include file after preprocessing with V4 GPRE.
194 +/**** end of GPRE definitions ****/
197 +static SCHAR ddl [] =
199 +#include "../pyxis/form_ddl.h"
202 +static ATT_N special_attributes [] =
221 + att_updatable_flag,
223 + att_reverse_for_update,
228 +PYXIS_define_forms_relation (dbb)
232 + short isc_61; /* isc_utility */
234 +/**************************************
236 + * P Y X I S _ d e f i n e _ f o r m s _ r e l a t i o n
238 + **************************************
240 + * Functional description
241 + * Check for existence of PYXIS$FORMS relation. If it doesn't
242 + * exist, create it.
244 + **************************************/
245 +SLONG *transaction, *handle, success;
246 +STATUS status_vector [20];
249 +transaction = handle = NULL;
252 +/*START_TRANSACTION transaction READ_WRITE;*/
254 +isc_start_transaction ((long*) 0L, &transaction, (short) 1, &DB, (short) 4, isc_tpb_0);
257 +/*FOR (REQUEST_HANDLE handle TRANSACTION_HANDLE transaction)
258 + X IN RDB$RELATIONS WITH X.RDB$RELATION_NAME EQ "PYXIS$FORMS"*/
261 + isc_compile_request ((long*) 0L, &DB, &handle, (short) sizeof (isc_59), (char ISC_FAR *) isc_59);
262 +isc_start_request ((long*) 0L, &handle, &transaction, (short) 0);
265 + isc_receive ((long*) 0L, &handle, (short) 0, (short) 2, &isc_60, (short) 0);
266 + if (!isc_60.isc_61) break;
272 +gds__release_request (status_vector, GDS_REF (handle));
274 +if (!success && gds__ddl (status_vector,
276 + GDS_REF (transaction),
280 + gds__print_status (status_vector);
282 + /*ROLLBACK transaction;*/
284 + isc_rollback_transaction ((long*) 0L, &transaction);
289 +/*COMMIT transaction;*/
291 +isc_commit_transaction ((long*) 0L, &transaction);
297 +OBJ PYXIS_delete_form (dbb, transaction, form_name)
298 + SLONG **dbb, **transaction;
302 + short isc_58; /* isc_utility */
305 + short isc_56; /* isc_utility */
308 + short isc_54; /* isc_utility */
311 + char isc_52 [32]; /* PYXIS$FORM_NAME */
313 +/**************************************
315 + * P Y X I S _ d e l e t e _ f o r m
317 + **************************************
319 + * Functional description
320 + * Delete a form from a database.
322 + **************************************/
326 +gds__trans = *transaction;
329 +/*FOR (REQUEST_HANDLE handle)
330 + X IN PYXIS$FORMS WITH X.PYXIS$FORM_NAME EQ form_name*/
333 + isc_compile_request ((long*) 0L, &DB, &handle, (short) sizeof (isc_50), (char ISC_FAR *) isc_50);
334 +isc_vtov (form_name, isc_51.isc_52, 32);
335 +isc_start_and_send ((long*) 0L, &handle, &gds__trans, (short) 0, (short) 32, &isc_51, (short) 0);
338 + isc_receive ((long*) 0L, &handle, (short) 1, (short) 2, &isc_53, (short) 0);
339 + if (!isc_53.isc_54) break;
341 + isc_send ((long*) 0L, &handle, (short) 2, (short) 2, &isc_55, (short) 0);
343 + isc_send ((long*) 0L, &handle, (short) 3, (short) 2, &isc_57, (short) 0);
347 +gds__release_request (gds__status, GDS_REF (handle));
352 +PYXIS_dump (object, ptr)
356 +/**************************************
358 + * P Y X I S _ d u m p
360 + **************************************
362 + * Functional description
363 + * Dump an object into linear form. Assume space is large
366 + **************************************/
368 +ATT_N *attr_ptr, name;
374 +/* Start by handling ordinary attributes */
376 +for (attribute = object->obj_attributes; attribute;
377 + attribute = attribute->att_next)
379 + if (attribute->att_type == attype_other)
381 + sprintf (p, "%d", attribute->att_name);
383 + switch (attribute->att_type)
385 + case attype_string:
386 + c = (attribute == object->obj_display_attribute) ? 'D' : 'S';
387 + sprintf (p, "%c`%s`", c, attribute->att_value);
391 + case attype_numeric:
392 + sprintf (p, "N%d.", attribute->att_value);
396 + case attype_object:
398 + PYXIS_dump (attribute->att_value, &p);
402 + BUGCHECK ("DUMP:Unknown attribute type");
406 +/* Next, handle special attributes */
408 +for (attr_ptr = special_attributes; *attr_ptr != att_any; attr_ptr++)
409 + if (value = GET_VALUE (object, *attr_ptr))
411 + sprintf (p, "%dN%d.", *attr_ptr, value);
421 +PYXIS_dump_length (object)
424 +/**************************************
426 + * P Y X I S _ d u m p _ l e n g t h
428 + **************************************
430 + * Functional description
431 + * Compute length of object when dumped.
433 + **************************************/
443 +for (attribute = object->obj_attributes; attribute;
444 + attribute = attribute->att_next)
446 + if (attribute->att_type == attype_other)
448 + sprintf (buffer, "%d", attribute->att_name);
449 + length += strlen (buffer);
450 + switch (attribute->att_type)
452 + case attype_string:
453 + length += strlen (attribute->att_value) + 3;
456 + case attype_numeric:
457 + sprintf (buffer, "N%d.", attribute->att_value);
458 + length += strlen (buffer);
461 + case attype_object:
462 + length += 1 + PYXIS_dump_length (attribute->att_value);
466 + BUGCHECK ("Unknown attribute type");
470 +/* Next, handle special attributes */
472 +for (attr_ptr = special_attributes; *attr_ptr != att_any; attr_ptr++)
473 + if (value = GET_VALUE (object, *attr_ptr))
475 + sprintf (buffer, "%dN%d.", *attr_ptr, value);
476 + length += strlen (buffer);
482 +PYXIS_field_defaults (field)
485 +/**************************************
487 + * P Y X I S _ f i e l d _ d e f a u l t s
489 + **************************************
491 + * Functional description
492 + * Supply defaults for missing field characteristics.
494 + **************************************/
497 +USHORT length, display_length;
498 +TEXT *p, buffer [256], c, *edit_string;
503 +PYXIS_delete_named_attribute (field, att_inactive);
505 +desc.dsc_length = desc.dsc_dtype = desc.dsc_scale = 0;
507 +/* If we have a picture string, analyze it */
509 +if (edit_string = GET_STRING (field, att_edit_string))
511 + picture = PICSTR_analyze (edit_string, NULL);
512 + switch (picture->pic_type)
516 + desc.dsc_dtype = dtype_text;
517 + desc.dsc_length = picture->pic_length;
521 + desc.dsc_dtype = dtype_long;
522 + desc.dsc_scale = -picture->pic_fractions;
526 + desc.dsc_dtype = dtype_text;
531 + desc.dsc_dtype = dtype_double; /* No path to this stmt. */
536 +/* Pick up data type info, if supplied directly */
538 +if (GET_ATTRIBUTE (field, att_dtype))
539 + desc.dsc_dtype = GET_VALUE (field, att_dtype);
541 +if (GET_ATTRIBUTE (field, att_length))
542 + desc.dsc_length = GET_VALUE (field, att_length);
544 +if (GET_ATTRIBUTE (field, att_scale))
545 + desc.dsc_scale = GET_VALUE (field, att_scale);
547 +/* Cleanup datatype info, as appropriate */
549 +switch (desc.dsc_dtype)
551 + case dtype_varying:
553 + desc.dsc_length += 2;
558 + desc.dsc_length = 2;
562 + desc.dsc_length = 4;
566 + desc.dsc_length = 4;
571 + case dtype_d_float:
573 + desc.dsc_length = 8;
576 + case dtype_timestamp:
577 + desc.dsc_length = 8;
580 + case dtype_sql_date:
581 + desc.dsc_length = 4;
584 + case dtype_sql_time:
585 + desc.dsc_length = 4;
589 + if (!(display_length = GET_VALUE (field, att_segment_length)))
590 + display_length = 40;
591 + REPLACE_ATTRIBUTE (field, att_width, attype_numeric, display_length + 2);
592 + REPLACE_ATTRIBUTE (field, att_height, attype_numeric, 6);
593 + if (!GET_VALUE (field, att_prototype))
596 + prototype = PYXIS_create_object (NULL_PTR, 0);
597 + REPLACE_ATTRIBUTE (prototype, att_width, attype_numeric, display_length);
598 + REPLACE_ATTRIBUTE (prototype, att_reverse_for_update, attype_numeric, TRUE);
599 + REPLACE_ATTRIBUTE (field, att_prototype, attype_object, prototype);
605 + desc.dsc_dtype = dtype_text;
606 + desc.dsc_scale = 0;
607 + if (!desc.dsc_length &&
608 + !(desc.dsc_length = GET_VALUE (field, att_width)))
609 + desc.dsc_length = 10;
613 +REPLACE_ATTRIBUTE (field, att_dtype, attype_numeric, desc.dsc_dtype);
614 +REPLACE_ATTRIBUTE (field, att_length, attype_numeric, desc.dsc_length);
616 + REPLACE_ATTRIBUTE (field, att_scale, attype_numeric, desc.dsc_scale);
620 + edit_string = (TEXT*) PICSTR_default_edit_string (&desc, buffer);
621 + REPLACE_ATTRIBUTE (field, att_edit_string, attype_string, edit_string);
622 + picture = PICSTR_analyze (edit_string, NULL);
625 +REPLACE_ATTRIBUTE (field, att_width, attype_numeric, picture->pic_length);
627 +if (!(attribute = GET_ATTRIBUTE (field, att_fill_string)))
629 + switch (picture->pic_type)
631 + case pic_alpha : c = 'X'; break;
632 + case pic_numeric: c = '9'; break;
633 + case pic_date : c = 'D'; break;
634 + case pic_float : c = 'F'; break;
635 + case pic_text : c = 'T'; break;
638 + /* Make up fill string, possibly laboriously */
640 + display_length = picture->pic_length;
643 + if (display_length < 255)
647 + string = (STR) ALLOCDV (type_str, display_length);
648 + p = string->str_data;
651 + do *p++ = c; while (--display_length);
656 + attribute = PUT_ATTRIBUTE (field, att_fill_string, attype_string, string->str_data);
657 + PYXIS_release (string);
660 + attribute = PUT_ATTRIBUTE (field, att_fill_string, attype_string, buffer);
663 +PYXIS_set_display_attribute (field, attribute);
665 +if (picture->pic_type == pic_numeric || picture->pic_type == pic_float)
666 + REPLACE_ATTRIBUTE (field, att_insert_right, attype_numeric, TRUE);
671 +OBJ PYXIS_forms (dbb, transaction)
672 + SLONG **dbb, **transaction;
675 + char isc_48 [32]; /* PYXIS$FORM_NAME */
676 + short isc_49; /* isc_utility */
678 +/**************************************
680 + * P Y X I S _ f o r m s
682 + **************************************
684 + * Functional description
685 + * Get menu all of forms, etc.
687 + **************************************/
692 +gds__trans = *transaction;
693 +menu = PYXIS_create_object (NULL_PTR, 0);
696 +/*FOR (REQUEST_HANDLE handle)
697 + X IN PYXIS$FORMS SORTED BY X.PYXIS$FORM_NAME*/
700 + isc_compile_request ((long*) 0L, &DB, &handle, (short) sizeof (isc_46), (char ISC_FAR *) isc_46);
701 +isc_start_request ((long*) 0L, &handle, &gds__trans, (short) 0);
704 + isc_receive ((long*) 0L, &handle, (short) 0, (short) 34, &isc_47, (short) 0);
705 + if (!isc_47.isc_49) break;
706 + zap_string (/*X.PYXIS$FORM_NAME*/
708 + PYXIS_create_entree (menu, /*X.PYXIS$FORM_NAME*/
709 + isc_47.isc_48, 0, NULL_PTR);
714 +gds__release_request (gds__status, GDS_REF (handle));
719 +OBJ PYXIS_load (ptr)
722 +/**************************************
724 + * P Y X I S _ l o a d
726 + **************************************
728 + * Functional description
729 + * Load an object from linear representation.
731 + **************************************/
735 +SLONG value, name, n, negate, buf_size;
736 +TEXT *p, c, verb, *s, *string, *new_buf, *buf_end, buffer[1024];
739 +object = PYXIS_create_object (NULL_PTR, 0);
744 + while (*p >= '0' && *p <= '9')
745 + name = name * 10 + *p++ - '0';
746 + switch (verb = *p++)
752 + buf_size = sizeof(buffer);
753 + buf_end = string + buf_size;
760 + new_buf = (TEXT*) gds__alloc (2 * buf_size);
761 + memcpy (new_buf, string, buf_size);
762 + if (string != buffer)
763 + gds__free (string);
765 + s = string + buf_size;
766 + buf_size = 2 * buf_size;
767 + buf_end = string + buf_size;
771 + attribute = PUT_ATTRIBUTE (object, name, attype_string, string);
773 + PYXIS_set_display_attribute (object, attribute);
775 + if (string != buffer)
776 + gds__free (string);
780 + type = attype_numeric;
781 + negate = ((*p == '-') ? (++p, TRUE) : (FALSE));
783 + while ((c = *p++) != '.')
784 + n = n * 10 + c - '0';
787 + PUT_ATTRIBUTE (object, name, attype_numeric, n);
791 + PUT_ATTRIBUTE (object, name, attype_object, PYXIS_load (&p));
799 + BUGCHECK ("Bad form definition");
804 +OBJ PYXIS_load_form (status_vector, dbb, transaction,
805 + form_handle, form_name_length, form_name)
806 + int *status_vector;
807 + SLONG **dbb, **transaction;
809 + USHORT *form_name_length;
813 + ISC_QUAD isc_41; /* PYXIS$FORM */
814 + short isc_42; /* isc_utility */
817 + char isc_39 [32]; /* PYXIS$FORM_NAME */
819 + isc_blob_handle isc_43; /* blob handle */
820 + char isc_44 [80]; /* blob segment */
821 + unsigned short isc_45; /* segment length */
822 +/**************************************
824 + * P Y X I S _ l o a d _ f o r m
826 + **************************************
828 + * Functional description
829 + * Load a form from a database.
830 + * If the form doesn't exist, return NULL.
832 + **************************************/
833 +USHORT buf_len, out_size, length;
834 +TEXT *ptr, buffer [4096], *buff, *p;
836 +SLONG temp_vector [20], handle, seg_count, max_seg;
840 +gds__trans = *transaction;
841 +*form_handle = NULL;
845 +/* Unless name is zero terminated, copy and terminate form name */
847 +if (form_name_length && (length = *form_name_length))
849 + for (p = buffer; length; --length)
850 + *p++ = *form_name++;
852 + form_name = buffer;
856 +buf_len = sizeof (buffer);
860 +/*FOR (REQUEST_HANDLE handle)
861 + X IN PYXIS$FORMS WITH X.PYXIS$FORM_NAME EQ form_name*/
864 + isc_compile_request (isc_status, &DB, &handle, (short) sizeof (isc_37), (char ISC_FAR *) isc_37);
866 +isc_vtov (form_name, isc_38.isc_39, 32);
868 + isc_start_and_send (isc_status, &handle, &gds__trans, (short) 0, (short) 32, &isc_38, (short) 0);
869 +if (!isc_status [1]) {
872 + isc_receive (isc_status, &handle, (short) 1, (short) 10, &isc_40, (short) 0);
873 + if (!isc_40.isc_42 || isc_status [1]) break;
874 + /*OPEN_BLOB B IN X.PYXIS$FORM*/
877 + isc_open_blob2 (isc_status, &DB, &gds__trans, &isc_43, &isc_40.isc_41, (short) 0, (char*) 0);
880 + if (isc_status [1])
887 + if (gds__blob_size (&/*B*/
888 + isc_43, &size, &seg_count, &max_seg))
889 + if (size > sizeof (buffer))
890 + buff = ptr = (TEXT *) gds__alloc (size + 2);
894 + buf_len = MIN (buf_len, size);
895 + if (code = gds__get_segment (gds__status,
898 + GDS_REF (out_size),
904 + /* segment and segstr_eof codes are benign;
905 + otherwise, we have an internal error */
907 + if (code == gds__segstr_eof)
909 + if (code != gds__segment)
910 + BUGCHECK ("Unable to load form");
918 + isc_close_blob ((long*) 0L, &isc_43);
922 + *form_handle = PYXIS_load (&buff);
928 + if (isc_status [1])
934 +gds__release_request (temp_vector, GDS_REF (handle));
936 +/* If something failed and there isn't a status vector,
939 +if (!status_vector && !*form_handle)
941 + if (gds__status [1])
942 + gds__print_status (gds__status);
945 + sprintf (buffer, "form %s not found\n", form_name);
946 + gds__put_error (buffer);
954 +/* Copy status vector */
957 + MOVP_fast (gds__status, status_vector, 20 * sizeof (STATUS));
959 +return (OBJ) gds__status [1];
962 +OBJ PYXIS_relation_fields (dbb, transaction, relation_name)
963 + SLONG **dbb, **transaction;
964 + TEXT *relation_name;
967 + char isc_29 [32]; /* RDB$FIELD_NAME */
968 + short isc_30; /* isc_utility */
969 + char isc_31 [126]; /* RDB$EDIT_STRING */
970 + char isc_32 [126]; /* RDB$EDIT_STRING */
971 + short isc_33; /* RDB$SEGMENT_LENGTH */
972 + short isc_34; /* RDB$FIELD_TYPE */
973 + short isc_35; /* RDB$FIELD_LENGTH */
974 + short isc_36; /* RDB$FIELD_SCALE */
977 + char isc_27 [32]; /* RDB$RELATION_NAME */
979 +/**************************************
981 + * P Y X I S _ r e l a t i o n _ f i e l d s
983 + **************************************
985 + * Functional description
986 + * Create an object containing fields for relation. This is
987 + * NOT formatted as a form.
989 + **************************************/
992 +USHORT length, display_length, segment_length;
993 +TEXT *p, c, *edit_string;
998 +gds__trans = *transaction;
999 +form = PYXIS_create_object (NULL_PTR, 0);
1002 +/*FOR (REQUEST_HANDLE handle)
1003 + RFR IN RDB$RELATION_FIELDS CROSS FLD IN RDB$FIELDS WITH
1004 + RFR.RDB$RELATION_NAME EQ relation_name AND
1005 + RFR.RDB$FIELD_SOURCE EQ FLD.RDB$FIELD_NAME
1006 + SORTED BY RFR.RDB$FIELD_POSITION*/
1009 + isc_compile_request ((long*) 0L, &DB, &handle, (short) sizeof (isc_25), (char ISC_FAR *) isc_25);
1010 +isc_vtov (relation_name, isc_26.isc_27, 32);
1011 +isc_start_and_send ((long*) 0L, &handle, &gds__trans, (short) 0, (short) 32, &isc_26, (short) 0);
1014 + isc_receive ((long*) 0L, &handle, (short) 1, (short) 294, &isc_28, (short) 0);
1015 + if (!isc_28.isc_30) break;
1017 + /* Create field itself */
1019 + zap_string (/*RFR.RDB$FIELD_NAME*/
1021 + field = PYXIS_create_object (/*RFR.RDB$FIELD_NAME*/
1022 + isc_28.isc_29, att_field_name);
1024 + desc.dsc_scale = /*FLD.RDB$FIELD_SCALE*/
1026 + desc.dsc_length = /*FLD.RDB$FIELD_LENGTH*/
1028 + switch (/*FLD.RDB$FIELD_TYPE*/
1032 + desc.dsc_dtype = dtype_text;
1036 + desc.dsc_dtype = dtype_varying;
1037 + desc.dsc_length += 2;
1041 + desc.dsc_dtype = dtype_short;
1042 + desc.dsc_length = 2;
1046 + desc.dsc_dtype = dtype_long;
1047 + desc.dsc_length = 4;
1051 + desc.dsc_dtype = dtype_real;
1052 + desc.dsc_length = 4;
1059 + desc.dsc_dtype = dtype_double;
1060 + desc.dsc_length = 8;
1065 + desc.dsc_dtype = dtype_d_float;
1066 + desc.dsc_length = 8;
1070 + case blr_timestamp:
1071 + desc.dsc_dtype = dtype_timestamp;
1072 + desc.dsc_length = 8;
1075 + case blr_sql_date:
1076 + desc.dsc_dtype = dtype_sql_date;
1077 + desc.dsc_length = 4;
1080 + case blr_sql_time:
1081 + desc.dsc_dtype = dtype_sql_time;
1082 + desc.dsc_length = 4;
1086 + desc.dsc_dtype = dtype_blob;
1087 + desc.dsc_length = 8;
1088 + if (segment_length = /*FLD.RDB$SEGMENT_LENGTH*/
1090 + PUT_ATTRIBUTE (field, att_segment_length, attype_numeric, segment_length);
1094 + PYXIS_put_attribute (field, att_dtype, attype_numeric, desc.dsc_dtype);
1095 + PYXIS_put_attribute (field, att_length, attype_numeric, desc.dsc_length);
1096 + if (desc.dsc_scale)
1097 + PYXIS_put_attribute (field, att_scale, attype_numeric, desc.dsc_scale);
1099 + if (desc.dsc_dtype != dtype_blob)
1101 + edit_string = /*RFR.RDB$EDIT_STRING*/
1103 + if (!*edit_string || *edit_string == ' ')
1104 + edit_string = /*FLD.RDB$EDIT_STRING*/
1106 + if (*edit_string && *edit_string != ' ')
1107 + PUT_ATTRIBUTE (field, att_edit_string, attype_string, edit_string);
1109 + PUT_ATTRIBUTE (field, att_inactive, attype_numeric, TRUE);
1110 + PYXIS_create_entree (form, /*RFR.RDB$FIELD_NAME*/
1111 + isc_28.isc_29, attype_object, field);
1116 +gds__release_request (gds__status, GDS_REF (handle));
1122 +OBJ PYXIS_relation_form (window, fields)
1126 +/**************************************
1128 + * P Y X I S _ r e l a t i o n _ f o r m
1130 + **************************************
1132 + * Functional description
1133 + * Create a form from the fields of a relation.
1135 + **************************************/
1137 +OBJ form, field, label;
1140 +form = PYXIS_create_object (NULL_PTR, 0);
1142 +for (attribute = NULL;
1143 + attribute = PYXIS_find_object (fields, attribute, att_entree, TRUE);)
1144 + if (field = GET_OBJECT ((OBJ)attribute->att_value, att_entree_value))
1146 + field = PYXIS_clone (field);
1147 + if (GET_VALUE (field, att_dtype) != dtype_blob &&
1148 + GET_VALUE (field, att_datatype) != blr_blob)
1149 + REPLACE_ATTRIBUTE (field, att_reverse_for_update, attype_numeric, TRUE);
1150 + PYXIS_field_defaults (field);
1151 + name = GET_STRING (field, att_field_name);
1152 + label = PYXIS_create_object (name, att_literal_string);
1153 + PUT_ATTRIBUTE (form, att_label, attype_object, label);
1154 + PUT_ATTRIBUTE (form, att_field, attype_object, field);
1157 +PYXIS_format_form (form, window->win_width, window->win_height);
1162 +OBJ PYXIS_relations (dbb, transaction)
1163 + SLONG **dbb, **transaction;
1166 + char isc_23 [32]; /* RDB$RELATION_NAME */
1167 + short isc_24; /* isc_utility */
1169 +/**************************************
1171 + * P Y X I S _ r e l a t i o n s
1173 + **************************************
1175 + * Functional description
1176 + * Get menu all of relations, etc.
1178 + **************************************/
1183 +gds__trans = *transaction;
1184 +menu = PYXIS_create_object (NULL_PTR, 0);
1187 +/*FOR (REQUEST_HANDLE handle)
1188 + X IN RDB$RELATIONS WITH X.RDB$SYSTEM_FLAG == 0 SORTED BY X.RDB$RELATION_NAME*/
1191 + isc_compile_request ((long*) 0L, &DB, &handle, (short) sizeof (isc_21), (char ISC_FAR *) isc_21);
1192 +isc_start_request ((long*) 0L, &handle, &gds__trans, (short) 0);
1195 + isc_receive ((long*) 0L, &handle, (short) 0, (short) 34, &isc_22, (short) 0);
1196 + if (!isc_22.isc_24) break;
1197 + zap_string (/*X.RDB$RELATION_NAME*/
1199 + PYXIS_create_entree (menu, /*X.RDB$RELATION_NAME*/
1200 + isc_22.isc_23, 0, NULL_PTR);
1205 +gds__release_request (gds__status, GDS_REF (handle));
1211 +PYXIS_store_form (dbb, transaction, form_name, form)
1212 + SLONG **dbb, **transaction;
1217 + ISC_QUAD isc_3; /* PYXIS$FORM */
1218 + char isc_4 [32]; /* PYXIS$FORM_NAME */
1220 + isc_blob_handle isc_5; /* blob handle */
1221 + char isc_6 [80]; /* blob segment */
1222 + unsigned short isc_7; /* segment length */
1224 + short isc_17; /* isc_utility */
1227 + ISC_QUAD isc_15; /* PYXIS$FORM */
1230 + ISC_QUAD isc_12; /* PYXIS$FORM */
1231 + short isc_13; /* isc_utility */
1234 + char isc_10 [32]; /* PYXIS$FORM_NAME */
1236 + isc_blob_handle isc_18; /* blob handle */
1237 + char isc_19 [80]; /* blob segment */
1238 + unsigned short isc_20; /* segment length */
1239 +/**************************************
1241 + * P Y X I S _ s t o r e _ f o r m
1243 + **************************************
1245 + * Functional description
1246 + * Store a form in a database. If the form already exists, replace it.
1248 + **************************************/
1250 +TEXT *ptr, buffer [4096], *buff, *p;
1255 +gds__trans = *transaction;
1258 +seg_len = sizeof (buffer);
1260 +/* If local buffer is big enough use it; otherwise allocate buffer big enough */
1262 +size = PYXIS_dump_length (form);
1265 +if (size > sizeof (buffer))
1266 + buff = ptr = (TEXT*) gds__alloc (size);
1268 +/* Linearize the form */
1271 +PYXIS_dump (form, &p);
1274 +/* If form exists, modify it */
1276 +/*FOR (REQUEST_HANDLE handle)
1277 + X IN PYXIS$FORMS WITH X.PYXIS$FORM_NAME EQ form_name*/
1280 + isc_compile_request ((long*) 0L, &DB, &handle, (short) sizeof (isc_8), (char ISC_FAR *) isc_8);
1282 +isc_vtov (form_name, isc_9.isc_10, 32);
1283 +isc_start_and_send ((long*) 0L, &handle, &gds__trans, (short) 0, (short) 32, &isc_9, (short) 0);
1286 + isc_receive ((long*) 0L, &handle, (short) 1, (short) 10, &isc_11, (short) 0);
1287 + if (!isc_11.isc_13) break;
1288 + /*MODIFY X USING*/
1290 + /*CREATE_BLOB B IN X.PYXIS$FORM;*/
1292 + isc_create_blob2 ((long*) 0L, &DB, &gds__trans, &isc_18, &isc_11.isc_12, (short) 0, (char*) 0);
1296 + seg_len = MIN (seg_len, size);
1297 + if (gds__put_segment (gds__status,
1306 + if (gds__status[1])
1307 + gds__print_status (gds__status);
1310 + isc_close_blob ((long*) 0L, &isc_18);
1313 + isc_14.isc_15 = isc_11.isc_12;
1314 + isc_send ((long*) 0L, &handle, (short) 2, (short) 8, &isc_14, (short) 0);
1318 + gds__release_request (gds__status, GDS_REF (handle));
1319 + return SUCCESS; /* gpre generates a gds__send call after this which
1320 + can never be reached; but it's ok */
1322 + isc_send ((long*) 0L, &handle, (short) 3, (short) 2, &isc_16, (short) 0);
1326 +gds__release_request (gds__status, GDS_REF (handle));
1328 +/* Form doesn't exist -- store a new record */
1330 +/*STORE (REQUEST_HANDLE handle)
1331 + X IN PYXIS$FORMS*/
1335 + isc_compile_request ((long*) 0L, &DB, &handle, (short) sizeof (isc_1), (char ISC_FAR *) isc_1);
1337 +isc_2.isc_3 = isc_blob_null;
1338 + strcpy (/*X.PYXIS$FORM_NAME*/
1339 + isc_2.isc_4, form_name);
1340 + /*CREATE_BLOB B IN X.PYXIS$FORM;*/
1342 + isc_create_blob2 ((long*) 0L, &DB, &gds__trans, &isc_5, &isc_2.isc_3, (short) 0, (char*) 0);
1346 + seg_len = MIN (seg_len, size);
1347 + if (gds__put_segment (gds__status,
1356 + if (gds__status[1])
1357 + gds__print_status (gds__status);
1360 + isc_close_blob ((long*) 0L, &isc_5);
1364 +isc_start_and_send ((long*) 0L, &handle, &gds__trans, (short) 0, (short) 40, &isc_2, (short) 0);
1367 +gds__release_request (gds__status, GDS_REF (handle));
1373 +static zap_string (string)
1376 +/**************************************
1378 + * z a p _ s t r i n g
1380 + **************************************
1382 + * Functional description
1383 + * Zap trailing blanks in a string.
1385 + **************************************/
1387 +while (*string && *string != ' ')