TBSTRUCT * IItstart(const char *tabname, const char *formname) { TBSTRUCT *tb; /* table field to return */ char *bufptr; /* pointer to table buffer */ char buf[MAXFRSNAME+1]; /* check that general I/O frame is set, and update IIfrmio */ if (IIfsetio(formname) == 0) { return (NULL); } /* valid I/O frame */ if (IIfrmio == NULL) { IIFDerror(RTFRACT, 0, NULL); return (NULL); } /* table field name must be given */ if ((bufptr=IIstrconv(II_CONV, tabname, buf, (i4)MAXFRSNAME)) == NULL) { IIFDerror(TBNONE, 0); return (NULL); } /* is table field within the given frame */ if ((tb = (TBSTRUCT *) IItfind(IIfrmio, bufptr)) == NULL) { IIFDerror(TBBAD, 2, (char *) bufptr, IIfrmio->fdfrmnm); return (NULL); } return (tb); }
i4 IIFRtoact(i4 timeout, i4 intr_val) { i4 *tovptr; if (IIissubmu()) /* ## submenu */ { tovptr = &IIFRtovTmOutVal; } else /* ## display or ## display submenu */ { tovptr = &(IIstkfrm->tmout_val); } if (*tovptr == 0) { /* Set the activate timeout value. */ *tovptr = intr_val; } else { /* Already an activate timeout block for this context. */ IIFDerror(RTDBTACT, 0, NULL); } return(TRUE); }
/*{ ** Name: RTrcdecode - Decode display attribute data utility routine. ** ** Description: ** This is a utility routine used by RTsetrow() and RTsetrc() to ** support setting/resetting display attributes for a ROW or ** ROW_COLUMN. These are RTI internal use only features. Restrictions ** of the current implementation are that the clearing out a display ** attribute clears all display attributes and setting display attributes ** is not additive. That is, setting a display attribute for a row and ** row_column will wipe any previous settings. A final caution ** is that these settings are very temporary (no place to store ** the settings) and will disappear when switching between displays ** of forms. Display attributes that are recognized: ** - normal (clear out) display attribute. ** - reverse video. ** - blinking. ** - underlining. ** - display intensity change. ** ** ** Inputs: ** frsflg Display attribute operation to decode. ** data A 0/1 indicator for setting/resetting the display attribute. ** ** Outputs: ** flag Pointer to integer where decoded information is placed. ** ** Returns: ** TRUE If decoding was successful. ** FALSE If an unknown operation or bad "data" was passed in. ** Exceptions: ** None. ** ** Side Effects: ** None. ** ** History: ** 08/30/85 (dkh) - Initial version. ** 02/13/87 (dkh) - Added procedure header. */ i4 RTrcdecode(i4 frsflg, i4 *flag, i4 data) { i4 onoff; if (data == 0 || data == 1) { onoff = data; } else { IIFDerror(SIDANOFF, 0); return(FALSE); } switch(frsflg) { case frsNORMAL: if (onoff) { *flag = 0; } else { return(FALSE); } break; case frsRVVID: if (onoff) { *flag = fdRVVID; } break; case frsBLINK: if (onoff) { *flag = fdBLINK; } break; case frsUNLN: if (onoff) { *flag = fdUNLN; } break; case frsINTENS: if (onoff) { *flag = fdCHGINT; } break; default: return(FALSE); } return(TRUE); }
i4 IIgetfldio(i2 *ind, i4 variable, i4 type, i4 len, PTR data, char *name) { char *namestr; char fbuf[MAXFRSNAME+1]; DB_EMBEDDED_DATA edv; DB_DATA_VALUE *dbvptr; DB_DATA_VALUE oper_dbv; DB_DATA_VALUE dbvcop; i4 oper; ADF_CB *cb; bool errflag = FALSE; i4 getop = 0; i4 (*oldproc)(); bool disp_msgs = TRUE; /* Check field name for validity */ namestr = IIstrconv(II_CONV, name, fbuf, (i4)MAXFRSNAME); if (namestr == NULL) { IIFDerror(RTRFFL, 2, IIfrmio->fdfrmnm, ERx("")); return(FALSE); } /* Set up an EDV to describe the caller's parameters. */ edv.ed_type = type; edv.ed_length = len; edv.ed_data = (PTR) data; edv.ed_null = ind; cb = FEadfcb(); if (IIfrscb->frs_globs->enabled & GETMSGS_OFF) { disp_msgs = FALSE; oldproc = IIseterr(IIFRgmoGetmsgsOff); } /* ** If getting an 'oper', not a value, special processing required. ** Operators are not returned from FRAME as DBV's, so we must build ** one so we can follow the normal path and convert to the final EDV. */ getop = IIgetoper( (i4) 0 ); if ( getop ) { oper_dbv.db_datatype = DB_INT_TYPE; oper_dbv.db_length = sizeof(i4); oper_dbv.db_prec = 0; oper_dbv.db_data = (PTR) &oper; /* ** Make sure the frame is in Query mode, else return NOOP. */ if (IIfrmio->fdrunmd != fdrtQRY) oper = fdNOP; else FDqryop( IIfrmio->fdrunfrm, namestr, (i4 *) oper_dbv.db_data ); dbvptr = &oper_dbv; } else if (IIfrmio->fdrunmd == fdrtQRY) { /* ** If in query mode, we must use a different routine ** to retrieve the data portion of the field. This ** routine also strips off the operator. */ if (!FDqryfld(IIfrmio->fdrunfrm, namestr, &dbvptr)) errflag = TRUE; } else { IIfrscb->frs_event->eval_aggs = TRUE; /* ** Get data portion of the field */ if (!FDgetfld(IIfrmio->fdrunfrm, namestr, &dbvptr)) errflag = TRUE; IIfrscb->frs_event->eval_aggs = FALSE; } /* ** If "errflag" is set at this point, then it was not ** possible to get the DB_DATA_VALUE pointer for a field. ** ** Trim trailing blanks on character-type fields */ if ( errflag == FALSE && ( IIftrim( dbvptr, &dbvcop ) != OK ) ) errflag = TRUE; /* ** Convert the DBV containing the field's value to an EDV */ if ( errflag == FALSE && ( adh_dbcvtev( cb, &dbvcop, &edv ) != OK ) ) { if (cb->adf_errcb.ad_errcode == E_AD1012_NULL_TO_NONNULL) { IIFDerror(RTRNLNNL, 2, IIfrmio->fdfrmnm, namestr); } else { IIFDerror(RTGFERR, 2, IIfrmio->fdfrmnm, namestr); } errflag = TRUE; } if (!disp_msgs) _VOID_ IIseterr(oldproc); if ( errflag == TRUE ) return (FALSE); else return (TRUE); }
/*{ ** Name: IIgetquery - Get query spec for field and process it. ** ** Description: ** Given a field in a form, get the query specification for that ** field and process it by calling FDrngchk(). If the field ** is a table field, then process the passed in column for the ** current row. The current row is defined by the row that ** is currently being unloaded in an "unloadtable" loop. ** ** DML compatibility level is passed in and we assume that we will ** be building the query, not just simply doing a validation ** check. Fields are assumed to be not display only. The ** DB_DATA_VALUE that is passed to FDrngchk() must be READ ** ONLY to FDrngchk() and FDrngchk() must copy the value ** if it wants to use it later on. ** ** The current code is designed not to work with range query ** buffers at the moment and only allows ONE qualification ** per field. When the switch to use range query ** buffers is made, the code below (as well as some code in ** FT) must be changed to call FTgetdisp(). Also, the use ** of an "unloadtable" loop is invalid at this point and ** another mechanism must be used to unload the range query ** buffers for a table field. ** ** Yes, the code below is looking at the forms structures ** but it is only until we go to range query buffers. ** ** Inputs: ** form {char *} Name of form containing field. ** field {char *} Name of field on which to operate. ** column {char *} Name of column if field is a table field. ** tblname {char *} Name of database table to pass to FDrngchk(). ** dml_level {nat} DML compatibility level passed to 'FDrngchk()': ** UI_DML_QUEL ** UI_DML_SQL ** UI_DML_GTWSQL ** att {char *} Name of attribute in database table to pass ** to FDrngchk(). ** prefix {char *} Special information to be passed ** to FDrngchk(). ** func {STATUS (*)()} Function reference to pass ** to FDrngchk(). ** data {PTR} Parameter to be passed to "func" by FDrnghck(). ** ** Returns: ** {STATUS} OK If everything worked. ** FAIL If something went wrong. ** ** History: ** 06/09/87 (dkh) - Initial version. ** 08/25/88 (jhw) - Fixed Jup bug #3161. Allow DISPONLY fields to ** be qualified. ** 3/21/91 (elein) (b35574) Add FALSE parameter to call to ** fmt_multi. TRUE is used internally for boxed ** messages only. They need to have control ** characters suppressed. */ STATUS IIgetquery (char *form, char *field, char *column, char *tblname, i4 dml_level, char *attr, char *prefix, STATUS (*func)(), PTR data ) { RUNFRM *runf; FIELD *fld; DB_DATA_VALUE *dispdbv; FLDVAL *val; STATUS stat; bool nonseq; DB_DATA_VALUE ldbv; TBLFLD *tbl; FLDCOL *col; DB_TEXT_STRING *text; DB_TEXT_STRING *otext; ADF_CB *ladfcb; FMT *cfmt; i4 oper; char *opchar; i4 qrycnt; DB_DATA_VALUE valdbv; i4 rows = 0; i4 columns = 0; bool reversed; i4 len; i4 cursize; i4 i; u_char *c; u_char *end; /* ** Do various checks on existence of form, field, etc. ** Return FAIL if something is missing. Assume that ** we are being called from 'C', so no need to call ** IIstrconv(). */ runf = ( form == NULL || *form == EOS ) ? IIstkfrm : RTfindfrm(form); if ( runf == NULL ) { return FAIL; } /* ** Find field in the form, return FAIL if field does not exist. ** (Allow DISPONLY fields to be qualified, however.) */ if ( (fld = FDfndfld(runf->fdrunfrm, field, &nonseq)) == NULL ) { IIFDerror( GFFLNF, 1, field ); return FAIL; } ladfcb = FEadfcb(); if ( (stat = FDfmtget(runf->fdrunfrm, field, column, 0, &cfmt)) != OK ) { return(stat); } if ( cfmt == NULL ) { return FAIL; } _VOID_ fmt_isreversed(ladfcb, cfmt, &reversed); if (qtag == 0) { qtag = FEgettag(); } if (fld->fltag == FREGULAR) { /* ** Just point to the simple field's display ** buffer. It should be good. */ val = FDgetval(fld); dispdbv = val->fvdsdbv; if (reversed) { /* ** Find out information for formatting. */ if (fmt_size(ladfcb, cfmt, val->fvdbv, &rows, &columns) != OK) { return(FAIL); } MEcopy((PTR) val->fvdsdbv, (u_i2) sizeof(DB_DATA_VALUE), (PTR) &valdbv); if ((valdbv.db_data = FEreqmem(qtag, (u_i4)valdbv.db_length, TRUE, &stat)) == NULL) { FEfree(qtag); return(FAIL); } text = (DB_TEXT_STRING *) valdbv.db_data; otext = (DB_TEXT_STRING *) val->fvdsdbv->db_data; cursize = text->db_t_count = otext->db_t_count; MEcopy((PTR)otext->db_t_text, (u_i2)cursize, (PTR)text->db_t_text); c = text->db_t_text; len = rows * columns; if (len > cursize) { MEfill((u_i2)(len - cursize), (unsigned char)' ', (PTR)(c + cursize)); text->db_t_count = len; } for (i = 0; i < rows; i++) { f_revrsbuf(columns, (bool)TRUE, c); c += columns; } /* ** Need to trim trailing blanks at this point. ** Don't need to use CM routines here, since Kanji ** and reverse don't work together. */ end = text->db_t_text; c = end + text->db_t_count - 1; while ( c >= end && *c-- == ' ' ) { --(text->db_t_count); } dispdbv = &valdbv; } } else { /* a table field */ FMT scrfmt; /* for scrolling columns */ tbl = fld->fld_var.fltblfld; /* ** Need to get value and query operator from ** dataset and then convert into a LONG_TEXT ** struct for display. First, check for ** existence of column. */ if ((col = FDfndcol(tbl, column)) == NULL) { return(FAIL); } /* ** Allocate local copies of column value and display ** buffers. */ val = tbl->tfwins + col->flhdr.fhseq; /* + ( 0 * tbl->tfcols ) */ MEcopy((PTR) val->fvdbv, (u_i2) sizeof(DB_DATA_VALUE), (PTR) &valdbv); MEcopy((PTR) val->fvdsdbv, (u_i2) sizeof(DB_DATA_VALUE), (PTR) &ldbv); if ( (valdbv.db_data = FEreqmem(qtag, (u_i4)valdbv.db_length, TRUE, &stat)) == NULL || (ldbv.db_data = FEreqmem(qtag, (u_i4)ldbv.db_length, TRUE, &stat)) == NULL ) { FEfree(qtag); return FAIL; } if (IITBcieColIsEmpty(column)) { text = (DB_TEXT_STRING *) ldbv.db_data; text->db_t_count = 0; } else { /* ** Get value for column from current row. ** Note that this is a direct call to internal routine ** and changes made must be done carefully. */ if ( !IItcogetio((i2 *) NULL, TRUE, DB_DBV_TYPE, 0, &valdbv, column) ) { FEfree(qtag); return(FAIL); } /* ** Now get query operator. */ IIgetoper(1); if ( !IItcogetio((i2 *) NULL, TRUE, DB_INT_TYPE, sizeof(oper), &oper, column) ) { FEfree(qtag); return(FAIL); } /* ** Format value. */ /* ** If it's a scrolling column, make a format for all the ** data, not just the fraction that can be displayed ** at once. */ if ((col->flhdr.fhd2flags & fdSCRLFD) != 0) { STRUCT_ASSIGN_MACRO(*cfmt, scrfmt); scrfmt.fmt_width = ldbv.db_length - 2; cfmt = &scrfmt; } /* ** Find out information for formatting. */ if (fmt_size(ladfcb, cfmt, &valdbv, &rows, &columns) != OK) { FEfree(qtag); return(FAIL); } /* ** Just format output if single line output. */ if (rows == 1) { if (fmt_format(ladfcb, cfmt, &valdbv, &ldbv, TRUE) != OK) { FEfree(qtag); return(FAIL); } } else { reg u_char *dsptr; DB_TEXT_STRING *ftext; PTR buffer; DB_DATA_VALUE wksp; i4 length = 0; wksp.db_datatype = DB_LTXT_TYPE; wksp.db_prec = 0; wksp.db_length = DB_CNTSIZE + columns; if ( (wksp.db_data = FEreqmem(qtag, (u_i4)wksp.db_length, TRUE, &stat)) == NULL ) { FEfree(qtag); return(FAIL); } fmt_workspace(ladfcb, cfmt, &valdbv, &length); if ( (buffer = FEreqmem(qtag, (u_i4)length, TRUE, &stat)) == NULL ) { FEfree(qtag); return(FAIL); } /* ** Do multi-line output. */ IIfmt_init(ladfcb, cfmt, &valdbv, buffer); text = (DB_TEXT_STRING *) ldbv.db_data; text->db_t_count = 0; dsptr = text->db_t_text; ftext = (DB_TEXT_STRING *) wksp.db_data; for (;;) { reg i4 j; reg u_char *fptr; i4 fcount; bool more = FALSE; if (fmt_multi(ladfcb, cfmt, &valdbv, buffer, &wksp,&more,TRUE, FALSE) != OK) { FEfree(qtag); return(FAIL); } if (!more) { break; } /* ** put into fields display buffer. */ fcount = ftext->db_t_count; fptr = ftext->db_t_text; for (j = 0; j < fcount; j++) { *dsptr++ = *fptr++; } text->db_t_count += fcount; } } text = (DB_TEXT_STRING *) ldbv.db_data; if (reversed) { c = text->db_t_text; cursize = text->db_t_count; len = rows * columns; if (len > cursize) { MEfill((u_i2)(len - cursize), (unsigned char)' ', (PTR)(c + cursize)); text->db_t_count = len; } for (i = 0; i < rows; i++) { f_revrsbuf(columns, (bool)TRUE, c); c += columns; } } /* ** Need to trim trailing blanks at this point. */ end = text->db_t_text; c = end + text->db_t_count - 1; while ( c >= end && *c-- == ' ' ) { --(text->db_t_count); } /* ** Insert query operators up front. */ if ( oper != fdNOP && oper != fdEQ && (qrycnt = STlength(opchar = iiugOpRep(oper))) > 0 ) { reg u_char *dsptr; reg u_char *head; reg i4 j; reg i4 cnt; head = text->db_t_text + text->db_t_count - 1; dsptr = head + qrycnt; cnt = text->db_t_count; for (j = 0; j < cnt; j++) { *dsptr-- = *head--; } text->db_t_text[0] = opchar[0]; if (qrycnt == 2) { text->db_t_text[1] = opchar[1]; } text->db_t_count += qrycnt; } } dispdbv = &ldbv; } stat = FDrngchk(runf->fdrunfrm, field, column, dispdbv, (bool) TRUE, tblname, attr, (bool) TRUE, dml_level, prefix, func, data); if (qtag != 0) { FEfree(qtag); } return stat; }