Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int
- get_xml(char *dest, struct log_record *lrp, int wild_char)
- {
- EXEC SQL begin declare section;
- char auth_name[5];
- char type_code[5];
- char pri_tran_code[5];
- char sec_tran_code[5];
- char term_type[5];
- char buf[BUFF_SIZE];
- #ifdef INFORMIX
- loc_t xml;
- #endif
- #ifdef ORA_PROC
- char xml[BUFF_SIZE];
- #endif
- EXEC SQL end declare section;
- int no_code=0, i, found_xml;
- /*swx_printf(THIS, "wild_char(%d)\n", wild_char);*/
- cobtocstr(auth_name, p->tp_ch_name, 4);
- cobtocstr(type_code, lrp->type_code, 4);
- cobtocstr(pri_tran_code, lrp->pri_tran_code, 4);
- cobtocstr(sec_tran_code, lrp->sec_tran_code, 4);
- cobtocstr(term_type, lrp->term_type, 4);
- set_wild_char(auth_name, type_code, pri_tran_code,
- sec_tran_code, term_type, wild_char);
- /*swx_printf(THIS, "%d (%s) pri(%s) sec(%s) term(%s)\n",
- wild_char, auth_name, pri_tran_code, sec_tran_code, term_type);*/
- /*swx_printf(THIS, "%.4s\n", xml_keys[i].auth_name);*/
- found_xml=0;
- for (i=0; i<nbr_xml_keys; i++) {
- if (!memcmp(xml_keys[i].auth_name, auth_name, strlen(auth_name)) &&
- !memcmp(xml_keys[i].type_code, type_code, strlen(type_code)) &&
- !memcmp(xml_keys[i].pri_tran_code, pri_tran_code,
- strlen(pri_tran_code)) &&
- !memcmp(xml_keys[i].sec_tran_code, sec_tran_code,
- strlen(sec_tran_code)) &&
- !memcmp(xml_keys[i].term_type, term_type, strlen(term_type)) &&
- strlen(auth_name) &&
- strlen(type_code) &&
- strlen(pri_tran_code) &&
- strlen(sec_tran_code) &&
- strlen(term_type) )
- found_xml=1;
- }
- if (!found_xml && wild_char < MAX_LOOP) {
- /*doing a recursive search*/
- return get_xml(dest, lrp, ++wild_char);
- }
- else if (!found_xml) {
- swx_printf(THIS, "no xml_trans\n");
- return 0;
- }
- memset(buf, 0, BUFF_SIZE);
- #ifdef INFORMIX
- xml.loc_loctype = LOCMEMORY; /* set for in memory */
- xml.loc_buffer = (char *) &buf; /* set address of our buffer */
- xml.loc_bufsize = BUFF_SIZE; /* set our buffer size */
- #endif
- #ifdef ORA_PROC
- memset(buf, 0, BUFF_SIZE);
- #endif
- swx_printf(THIS, "use %d auth(%s) tc(%s) pri(%s) sec(%s) term(%s)\n",
- wild_char, auth_name, type_code,
- pri_tran_code, sec_tran_code, term_type);
- EXEC SQL select swx_xml into :xml
- from xml_trans
- where auth_name = :auth_name
- and type_code = :type_code
- and pri_tran_code = :pri_tran_code
- and sec_tran_code = :sec_tran_code
- and term_type = :term_type;
- if (sqlca.sqlcode) {
- swx_printf(THIS, "get_xml sqlcode=%d\n", sqlca.sqlcode);
- return 0;
- }
- #ifdef INFORMIX
- strcpy(dest, xml.loc_buffer);
- swx_printf(THIS, "# bytes or loc_size=%d\n", xml.loc_size);
- return xml.loc_size;
- #endif
- #ifdef ORA_PROC
- rtrim(xml);
- strcpy(dest, xml);
- swx_printf(THIS, "# bytes or loc_size=%d\n", strlen(xml));
- return strlen(xml);
- #endif
- }
Add Comment
Please, Sign In to add comment