Guest User

Untitled

a guest
Feb 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. int
  2. get_xml(char *dest, struct log_record *lrp, int wild_char)
  3. {
  4. EXEC SQL begin declare section;
  5. char auth_name[5];
  6. char type_code[5];
  7. char pri_tran_code[5];
  8. char sec_tran_code[5];
  9. char term_type[5];
  10. char buf[BUFF_SIZE];
  11. #ifdef INFORMIX
  12. loc_t xml;
  13. #endif
  14. #ifdef ORA_PROC
  15. char xml[BUFF_SIZE];
  16. #endif
  17. EXEC SQL end declare section;
  18. int no_code=0, i, found_xml;
  19.  
  20. /*swx_printf(THIS, "wild_char(%d)\n", wild_char);*/
  21. cobtocstr(auth_name, p->tp_ch_name, 4);
  22. cobtocstr(type_code, lrp->type_code, 4);
  23. cobtocstr(pri_tran_code, lrp->pri_tran_code, 4);
  24. cobtocstr(sec_tran_code, lrp->sec_tran_code, 4);
  25. cobtocstr(term_type, lrp->term_type, 4);
  26.  
  27. set_wild_char(auth_name, type_code, pri_tran_code,
  28. sec_tran_code, term_type, wild_char);
  29. /*swx_printf(THIS, "%d (%s) pri(%s) sec(%s) term(%s)\n",
  30. wild_char, auth_name, pri_tran_code, sec_tran_code, term_type);*/
  31. /*swx_printf(THIS, "%.4s\n", xml_keys[i].auth_name);*/
  32.  
  33. found_xml=0;
  34. for (i=0; i<nbr_xml_keys; i++) {
  35. if (!memcmp(xml_keys[i].auth_name, auth_name, strlen(auth_name)) &&
  36. !memcmp(xml_keys[i].type_code, type_code, strlen(type_code)) &&
  37. !memcmp(xml_keys[i].pri_tran_code, pri_tran_code,
  38. strlen(pri_tran_code)) &&
  39. !memcmp(xml_keys[i].sec_tran_code, sec_tran_code,
  40. strlen(sec_tran_code)) &&
  41. !memcmp(xml_keys[i].term_type, term_type, strlen(term_type)) &&
  42. strlen(auth_name) &&
  43. strlen(type_code) &&
  44. strlen(pri_tran_code) &&
  45. strlen(sec_tran_code) &&
  46. strlen(term_type) )
  47. found_xml=1;
  48. }
  49. if (!found_xml && wild_char < MAX_LOOP) {
  50. /*doing a recursive search*/
  51. return get_xml(dest, lrp, ++wild_char);
  52. }
  53. else if (!found_xml) {
  54. swx_printf(THIS, "no xml_trans\n");
  55. return 0;
  56. }
  57.  
  58. memset(buf, 0, BUFF_SIZE);
  59. #ifdef INFORMIX
  60. xml.loc_loctype = LOCMEMORY; /* set for in memory */
  61. xml.loc_buffer = (char *) &buf; /* set address of our buffer */
  62. xml.loc_bufsize = BUFF_SIZE; /* set our buffer size */
  63. #endif
  64. #ifdef ORA_PROC
  65. memset(buf, 0, BUFF_SIZE);
  66. #endif
  67.  
  68. swx_printf(THIS, "use %d auth(%s) tc(%s) pri(%s) sec(%s) term(%s)\n",
  69. wild_char, auth_name, type_code,
  70. pri_tran_code, sec_tran_code, term_type);
  71. EXEC SQL select swx_xml into :xml
  72. from xml_trans
  73. where auth_name = :auth_name
  74. and type_code = :type_code
  75. and pri_tran_code = :pri_tran_code
  76. and sec_tran_code = :sec_tran_code
  77. and term_type = :term_type;
  78.  
  79. if (sqlca.sqlcode) {
  80. swx_printf(THIS, "get_xml sqlcode=%d\n", sqlca.sqlcode);
  81. return 0;
  82. }
  83.  
  84. #ifdef INFORMIX
  85. strcpy(dest, xml.loc_buffer);
  86. swx_printf(THIS, "# bytes or loc_size=%d\n", xml.loc_size);
  87. return xml.loc_size;
  88. #endif
  89. #ifdef ORA_PROC
  90. rtrim(xml);
  91. strcpy(dest, xml);
  92. swx_printf(THIS, "# bytes or loc_size=%d\n", strlen(xml));
  93. return strlen(xml);
  94. #endif
  95. }
Add Comment
Please, Sign In to add comment