|
|
1.1 root 1: # include <ingres.h>
2: # undef MAXNAME
3: # include "../equel/constants.h"
4: # include "IIglobals.h"
5: # include <sccs.h>
6:
7: SCCSID(@(#)IIw_left.c 7.2 10/27/81)
8:
9: /*
10: ** IIw_left -- writes down a "tupret's" target list.
11: **
12: ** Parameters:
13: ** string -- a char * to a string containing everything
14: ** inside the equivalent "retrieve" statement,
15: ** but instead of result domain names, the string
16: ** should have '%<ingres_type>', where <ingres_type>
17: ** is the ingres type of the resulting C variable.
18: ** To escape a '%' use 2 ("%%").
19: ** 'String' is left unchanged after the call.
20: ** argv -- a vector of pointers to the
21: ** corresponding C variables.
22: **
23: ** Usage:
24: ** argv [0] = &double_var;
25: ** argv [1] = &int_var;
26: ** IIw_left("%f8 = i.double, %i2=i.ifield", argv);
27: **
28: ** Required by:
29: ** parametrized retrieves without a target relation
30: **
31: ** Requires:
32: ** Uses the ret_sym array IIretsym, and the old equel
33: ** method for doing tuprets. NOTE that this does not
34: ** allow dynamic (before each tuple) resolution of
35: ** the result C variables as does the new tupret method.
36: **
37: ** Error numbers:
38: ** 1003 -- 1 parameter, the erroneous string.
39: ** "Bad format for a domain in a param retrieve
40: ** without a result relation"
41: */
42:
43:
44: IIw_left(string, argv)
45: char *string;
46: char **argv;
47: {
48: register char *b_st, *e_st;
49: register char **av;
50: int type;
51: char *IIitos();
52:
53: if (IIdebug)
54: printf("ent IIw_left : string \"%s\"\n",
55: string);
56: av = argv;
57: for (b_st = e_st = string; *e_st; )
58: {
59: if (*e_st != '%')
60: {
61: e_st++;
62: continue;
63: }
64:
65: /* provide escape method */
66: if (e_st [1] == '%')
67: {
68: e_st [1] = '\0';
69: IIwrite(b_st);
70: /* leave string intact */
71: e_st [1] = '%';
72: b_st = e_st = &e_st [2];
73: continue;
74: }
75: *e_st = '\0';
76: IIwrite(b_st);
77: *e_st++ = '%';
78: IIwrite(" RET_VAR ");
79:
80: switch (*e_st)
81: {
82:
83: case 'f' :
84: switch (*++e_st)
85: {
86:
87: case '8' :
88: type = opDOUBLE;
89: break;
90:
91: case '4' :
92: type = opFLOAT;
93: break;
94:
95: default :
96: goto error_label;
97: }
98: break;
99:
100: case 'i' :
101: switch (*++e_st)
102: {
103:
104: case '4' :
105: type = opLONG;
106: break;
107:
108: case '2' :
109: type = opSHORT;
110: break;
111:
112: default :
113: goto error_label;
114: }
115: break;
116:
117: case 'c' :
118: type = opSTRING;
119: break;
120: }
121: IIretrieve(*av++, type);
122: b_st = ++e_st;
123: }
124: IIwrite(b_st);
125: return;
126:
127:
128: error_label :
129: IIerror(1003, 1, &string);
130: IIerrflag = 1003;
131: /* make sure that part already written down will
132: * cause an error, and ignore that error
133: */
134: IIwrite(",");
135: IIo_print = IIprint_err;
136: IIprint_err = IIno_err;
137: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.