void go_load(uint4 begin, uint4 end) { char *ptr; int len, fmt, keylength, keystate; uint4 iter, max_data_len, max_subsc_len, key_count, max_rec_size; mstr src, des; unsigned char *rec_buff, ch; boolean_t utf8_extract, format_error = FALSE, hasht_ignored = FALSE, hasht_gbl = FALSE; char *val_off; int val_len, val_off1, val_len1; boolean_t is_setextract; gvinit(); max_rec_size = DEFAULT_MAX_REC_SIZE; rec_buff = (unsigned char *)malloc(max_rec_size); fmt = MU_FMT_ZWR; /* by default, the extract format is ZWR (not GO) */ len = file_input_get(&ptr); if (mupip_error_occurred) { free(rec_buff); return; } if (len >= 0) { util_out_print("!AD", TRUE, len, ptr); utf8_extract = ((len >= STR_LIT_LEN(UTF8_NAME)) && (0 == MEMCMP_LIT(ptr + len - STR_LIT_LEN("UTF-8"), "UTF-8"))) ? TRUE : FALSE; if ((utf8_extract && !gtm_utf8_mode) || (!utf8_extract && gtm_utf8_mode)) { /* extract CHSET doesn't match $ZCHSET */ if (utf8_extract) gtm_putmsg(VARLSTCNT(4) ERR_LOADINVCHSET, 2, LEN_AND_LIT("UTF-8")); else gtm_putmsg(VARLSTCNT(4) ERR_LOADINVCHSET, 2, LEN_AND_LIT("M")); mupip_error_occurred = TRUE; free(rec_buff); return; } } else mupip_exit(ERR_LOADFILERR); len = file_input_get(&ptr); if (mupip_error_occurred) { free(rec_buff); return; } if (len >= 0) { util_out_print("!AD", TRUE, len, ptr); fmt = (0 == memcmp(ptr + len - STR_LIT_LEN("ZWR"), "ZWR", STR_LIT_LEN("ZWR"))) ? MU_FMT_ZWR : MU_FMT_GO; } else mupip_exit(ERR_LOADFILERR); if (begin < 3) begin = 3; for (iter = 3; iter < begin; iter++) { len = file_input_get(&ptr); if (len < 0) /* The IO device has signalled an end of file */ { gtm_putmsg(VARLSTCNT(3) ERR_LOADEOF, 1, begin); mupip_error_occurred = TRUE; } if (mupip_error_occurred) { util_out_print("Error reading record number: !UL\n", TRUE, iter); free(rec_buff); return; } } assert(iter == begin); util_out_print("Beginning LOAD at record number: !UL\n", TRUE, begin); max_data_len = 0; max_subsc_len = 0; key_count = 0; for (iter = begin - 1; ; ) { if (++iter > end) break; if (mu_ctrly_occurred) break; if (mu_ctrlc_occurred) { util_out_print("!AD:!_ Key cnt: !UL max subsc len: !UL max data len: !UL", TRUE, LEN_AND_LIT(gt_lit), key_count, max_subsc_len, max_data_len); util_out_print("Last LOAD record number: !UL", TRUE, key_count ? iter : 0); mu_gvis(); util_out_print(0, TRUE); mu_ctrlc_occurred = FALSE; } if (0 > (len = file_input_get(&ptr))) break; if (mupip_error_occurred) { mu_gvis(); break; } if ('\n' == *ptr) { if ('\n' == *(ptr+1)) break; ptr++; } if (0 == len) continue; if (MU_FMT_GO != fmt) { /* Determine if the ZWR has $extract format */ if ('$' == *ptr) { keylength = zwrkeyvallen(ptr, len, &val_off, &val_len, &val_off1, &val_len1); ptr = ptr + 4; /* Skip first 4 character '$','z','e','(' */ is_setextract = TRUE; } else { /* Determine the ZWR key length. -1 (SIZEOF(=)) is needed since ZWR allows '^x(1,2)='*/ keylength = zwrkeyvallen(ptr, len, &val_off, &val_len, NULL, NULL); is_setextract = FALSE; } ISSUE_TRIGDATAIGNORE_IF_NEEDED(keylength, ptr, hasht_gbl); if (hasht_gbl) { hasht_gbl = FALSE; continue; } go_call_db(GO_PUT_SUB, ptr, keylength, 0, 0); if (mupip_error_occurred) { mu_gvis(); util_out_print("Error loading record number: !UL\n", TRUE, iter); mupip_error_occurred = FALSE; continue; } assert(keylength < len - 1); if (max_subsc_len < (gv_currkey->end + 1)) max_subsc_len = gv_currkey->end + 1; src.len = val_len; src.addr = val_off; des.len = 0; if (src.len > max_rec_size) { max_rec_size = src.len; free(rec_buff); rec_buff = (unsigned char *)malloc(max_rec_size); } des.addr = (char *)rec_buff; if (FALSE == zwr2format(&src, &des)) { util_out_print("Format error in record number !8UL: !/!AD", TRUE, iter, src.len, src.addr); format_error = TRUE; continue; } if (max_data_len < des.len) max_data_len = des.len; (is_setextract) ? go_call_db(GO_SET_EXTRACT, des.addr, des.len, val_off1, val_len1) : go_call_db(GO_PUT_DATA, (char *)rec_buff, des.len, 0, 0); if (mupip_error_occurred) { mu_gvis(); util_out_print("Error loading record number: !UL\n", TRUE, iter); mupip_error_occurred = FALSE; continue; } key_count++; } else { ISSUE_TRIGDATAIGNORE_IF_NEEDED(len, ptr, hasht_gbl); if (hasht_gbl) { if (0 > (len = file_input_get(&ptr))) break; iter++; hasht_gbl = FALSE; continue; } go_call_db(GO_PUT_SUB, ptr, len, 0, 0); if (mupip_error_occurred) { mu_gvis(); util_out_print("Error loading record number: !UL\n", TRUE, iter); mupip_error_occurred = FALSE; continue; } if (max_subsc_len < (gv_currkey->end + 1)) max_subsc_len = gv_currkey->end + 1; if (++iter > end) { iter--; /* Decrement as didn't load key */ break; } if ((len = file_input_get(&ptr)) < 0) break; if (mupip_error_occurred) { mu_gvis(); util_out_print("Error loading record number: !UL\n", TRUE, iter); break; } stringpool.free = stringpool.base; if (max_data_len < len) max_data_len = len; go_call_db(GO_PUT_DATA, ptr, len, 0, 0); if (mupip_error_occurred) { mu_gvis(); util_out_print("Error loading record number: !UL\n", TRUE, iter); mupip_error_occurred = FALSE; continue; } key_count++; } } free(rec_buff); file_input_close(); if (mu_ctrly_occurred) { gtm_putmsg(VARLSTCNT(1) ERR_LOADCTRLY); mupip_exit(ERR_MUNOFINISH); } util_out_print("LOAD TOTAL!_!_Key Cnt: !UL Max Subsc Len: !UL Max Data Len: !UL",TRUE,key_count,max_subsc_len, max_data_len); util_out_print("Last LOAD record number: !UL\n", TRUE, key_count ? (iter - 1) : 0); if (format_error) mupip_exit(ERR_LOADFILERR); }
STATICFNDEF boolean_t process_delim(char *delim_str, uint4 *delim_len) { int char_count; mstr dst; int dst_len; char *dst_ptr; char dst_string[MAX_DELIM_LEN + 1]; uint4 len; char *ptr; char *ptr1; int q_len; char src_string[MAX_DELIM_LEN + 1]; mstr src; char *src_ptr; if (MAX_DELIM_LEN < *delim_len) { util_out_print_gtmio("Delimiter too long", FLUSH); return FALSE; } ptr = delim_str; len = *delim_len; src_ptr = src_string; dst_len = 0; /* If ", scan to end quote * If $, look for char --> c or zchar --> zch * If _, leave it */ while (0 < len) { switch (*ptr) { case '"': PROCESS_STRING(ptr, len, FALSE, src_ptr, dst_len, MAX_DELIM_LEN); break; case '$': UPDATE_DST(ptr, len, FALSE, src_ptr, dst_len, MAX_DELIM_LEN); if (0 == len) { util_out_print_gtmio("Invalid entry in delimiter", FLUSH); return FALSE; } if ((3 < len) && ('C' == lower_to_upper_table[*ptr]) && ('H' == lower_to_upper_table[*(ptr + 1)]) && ('A' == lower_to_upper_table[*(ptr + 2)]) && ('R' == lower_to_upper_table[*(ptr + 3)])) { if (MAX_DELIM_LEN < ++dst_len) { util_out_print_gtmio("Trigger definition too long", FLUSH); return FALSE; } *src_ptr++ = 'C'; ptr += 4; len -= 4; } else if ((4 < len) && ('Z' == lower_to_upper_table[*ptr]) && ('C' == lower_to_upper_table[*(ptr + 1)]) && ('H' == lower_to_upper_table[*(ptr + 2)]) && ('A' == lower_to_upper_table[*(ptr + 3)]) && ('R' == lower_to_upper_table[*(ptr + 4)])) { if (MAX_DELIM_LEN < (dst_len + 3)) { util_out_print_gtmio("Trigger definition too long", FLUSH); return FALSE; } MEMCPY_LIT(src_ptr, "ZCH"); src_ptr += 3; dst_len += 3; ptr += 5; len -= 5; } else { UPDATE_DST(ptr, len, FALSE, src_ptr, dst_len, MAX_DELIM_LEN); } break; default: UPDATE_DST(ptr, len, FALSE, src_ptr, dst_len, MAX_DELIM_LEN); break; } } *src_ptr = '\0'; src.addr = src_string; src.len = (mstr_len_t)(src_ptr - src_string); dst.addr = dst_string; dst.len = 0; if (!zwr2format(&src, &dst)) { util_out_print_gtmio("Invalid delimiter", FLUSH); return FALSE; } if (MAX_DELIM_LEN < dst.len) { util_out_print_gtmio("Delimiter too long", FLUSH); return FALSE; } memcpy(delim_str, dst_string, dst.len); *delim_len = dst.len; return TRUE; }
char *ext2jnl(char *ptr, jnl_record *rec) { unsigned char *pool_save; char *ret, ch; int keylength, keystate, len, i, reclen, temp_reclen; bool keepgoing; mstr src, des; jnl_record *temp_rec; muextract_type exttype; enum jnl_record_type rectype; jrec_suffix *suffix; ext_stop = ptr + strlen(ptr) + 1; temp_rec = rec; exttype = MUEXTRACT_TYPE(ptr); assert((exttype >= 0) && (exttype < MUEXT_MAX_TYPES)); switch(exttype) { case MUEXT_SET: if (in_tp) { if (0 == num_records) { num_records++; rec->prefix.jrec_type = JRT_TSET; } else rec->prefix.jrec_type = JRT_USET; } else rec->prefix.jrec_type = JRT_SET; break; case MUEXT_KILL: if (in_tp) { if (0 == num_records) { num_records++; rec->prefix.jrec_type = JRT_TKILL; } else rec->prefix.jrec_type = JRT_UKILL; } else rec->prefix.jrec_type = JRT_KILL; break; case MUEXT_ZKILL: if (in_tp) { if (0 == num_records) { num_records++; rec->prefix.jrec_type = JRT_TZKILL; } else rec->prefix.jrec_type = JRT_UZKILL; } else rec->prefix.jrec_type = JRT_ZKILL; break; case MUEXT_TSTART: in_tp = TRUE; num_records = 0; return (char *)rec; break; case MUEXT_TCOMMIT: rec->prefix.jrec_type = JRT_TCOM; in_tp = FALSE; break; case MUEXT_PINI: case MUEXT_PFIN: case MUEXT_EOF: case MUEXT_ZTSTART: case MUEXT_ZTCOMMIT: assert(FALSE); ext_stop = ptr; return (char *)rec; break; case MUEXT_NULL: rec->prefix.jrec_type = JRT_NULL; break; default: assert(FALSE); ext_stop = ptr; return (char *)rec; break; } rectype = rec->prefix.jrec_type; ptr = strtok(ptr, "\\"); /* get the rec-type field */ assert(NULL != ptr); ptr = strtok(NULL, "\\"); /* get the time field */ assert(NULL != ptr); ptr = strtok(NULL, "\\"); /* get the tn field */ assert(NULL != ptr); rec->prefix.tn = asc2i((uchar_ptr_t)ptr, strlen(ptr)); ptr = strtok(NULL, "\\"); /* get the pid field */ assert(NULL != ptr); ptr = strtok(NULL, "\\"); /* get the client pid field */ assert(NULL != ptr); ptr = strtok(NULL, "\\"); /* get the token or jnl_seqno */ assert(NULL != ptr); rec->jrec_null.jnl_seqno = asc2l((uchar_ptr_t)ptr, strlen(ptr)); if (MUEXT_NULL == exttype) { rec->jrec_null.prefix.forwptr = rec->jrec_null.suffix.backptr = NULL_RECLEN; rec->jrec_null.suffix.suffix_code = JNL_REC_SUFFIX_CODE; return ((char_ptr_t)rec) + NULL_RECLEN; } else if (MUEXT_TCOMMIT == exttype) { ptr = strtok(NULL, "\\"); /* get the participants */ ptr = strtok(NULL, "\\"); /* get the jnl_tid */ rec->jrec_tcom.jnl_tid[0] = 0; if (NULL != ptr) strcpy(rec->jrec_tcom.jnl_tid, ptr); num_records = 0; rec->jrec_tcom.prefix.forwptr = rec->jrec_tcom.suffix.backptr = TCOM_RECLEN; rec->jrec_tcom.suffix.suffix_code = JNL_REC_SUFFIX_CODE; return ((char_ptr_t)rec) + TCOM_RECLEN; } ptr = strtok(NULL, "\\"); /* get the key-value and data also */ assert(IS_SET_KILL_ZKILL(rectype)); assert(NULL != ptr); /* this part is lifted from go_load. later think of having a common routine */ len = strlen(ptr); keylength = 0; /* determine length of key */ keystate = 0; keepgoing = TRUE; while((keylength < len) && keepgoing) /* slightly different here from go_load since we can get kill records too */ { ch = *(ptr + keylength); keylength++; switch (keystate) { case 0: /* in global name */ if ('=' == ch) /* end of key */ { keylength--; keepgoing = FALSE; } else if ('(' == ch) /* start of subscripts */ keystate = 1; break; case 1: /* in subscripts area, but out of "..." or $C(...) */ switch (ch) { case ')': /* end of subscripts ==> end of key */ keepgoing = FALSE; break; case '"': /* step into "..." */ keystate = 2; break; case '$': /* step into $C(...) */ assert(('C' == *(ptr + keylength)) || ('c' == *(ptr + keylength))); assert('(' == *(ptr + keylength + 1)); keylength += 2; keystate = 3; break; } break; case 2: /* in "..." */ if ('"' == ch) { switch (*(ptr + keylength)) { case '"': /* "" */ keylength++; break; case '_': /* _$C(...) */ assert('$' == *(ptr + keylength + 1)); assert(('c' == *(ptr + keylength + 2)) || ('C' == *(ptr + keylength + 2))); assert('(' == *(ptr + keylength + 3)); keylength += 4; keystate = 3; break; default: /* step out of "..." */ keystate = 1; } } break; case 3: /* in $C(...) */ if (')' == ch) { if ('_' == *(ptr + keylength)) /* step into "..." */ { assert('"' == *(ptr + keylength + 1)); keylength += 2; keystate = 2; break; } else keystate = 1; /* step out of $C(...) */ } break; default: assert(FALSE); break; } } REPL_DPRINT2("ext2jnl source:KEY=DATA:%s\n", ptr); assert(keylength <= len); str2gvkey_nogvfunc(ptr, keylength, gv_currkey); rec->jrec_kill.mumps_node.length = gv_currkey->end; memcpy(rec->jrec_kill.mumps_node.text, gv_currkey->base, gv_currkey->end); temp_reclen = FIXED_UPD_RECLEN + rec->jrec_kill.mumps_node.length + sizeof(jnl_str_len_t); if (IS_KILL_ZKILL(rectype)) { temp_reclen += JREC_SUFFIX_SIZE; reclen = ROUND_UP2(temp_reclen, JNL_REC_START_BNDRY); memset((char_ptr_t)rec + temp_reclen - JREC_SUFFIX_SIZE, 0, reclen - temp_reclen); suffix = (jrec_suffix *)((char_ptr_t)rec + reclen - JREC_SUFFIX_SIZE); rec->prefix.forwptr = suffix->backptr = reclen; suffix->suffix_code = JNL_REC_SUFFIX_CODE; return (char_ptr_t)rec + reclen; } /* we have to get the data value now */ src.len = len - keylength - 1; src.addr = ptr + (keylength + 1); des.len = 0; des.addr = (char_ptr_t)rec + temp_reclen + sizeof(jnl_str_len_t); REPL_DPRINT3("ext2jnl JNL Format (before zwr2format): src : Len %d :: DATA:%s\n", src.len, src.addr); REPL_DPRINT3("ext2jnl JNL Format (before zwr2format): des : Len %d :: DATA:%s\n", des.len, des.addr); if (!zwr2format(&src, &des)) { assert(FALSE); return (char_ptr_t)rec; } REPL_DPRINT3("ext2jnl JNL Format : src : Len %d :: DATA:%s\n", src.len, src.addr); REPL_DPRINT3("ext2jnl JNL Format : des : Len %d :: DATA:%s\n", des.len, des.addr); PUT_MSTR_LEN((char_ptr_t)rec + temp_reclen, des.len); temp_reclen += sizeof(jnl_str_len_t) + des.len + JREC_SUFFIX_SIZE; reclen = ROUND_UP2(temp_reclen, JNL_REC_START_BNDRY); memset((char_ptr_t)rec + temp_reclen - JREC_SUFFIX_SIZE, 0, reclen - temp_reclen); suffix = (jrec_suffix *)((char_ptr_t)rec + reclen - JREC_SUFFIX_SIZE); rec->prefix.forwptr = suffix->backptr = reclen; suffix->suffix_code = JNL_REC_SUFFIX_CODE; return (char_ptr_t)rec + reclen; }
STATICFNDEF boolean_t process_dollar_char(char **src_ptr, int *src_len, boolean_t have_star, char **d_ptr, int *dst_len) { int char_count; char *char_ptr; int len; char *dst_ptr; char dst_string[MAX_DCHAR_LEN]; int lcl_dst_len; mstr m_dst; mstr m_src; char *ptr; int q_len; char *tmp_dst_ptr; tmp_dst_ptr = dst_ptr = *d_ptr; ptr = *src_ptr; len = *src_len; lcl_dst_len = *dst_len; assert('$' == *ptr); UPDATE_DST(ptr, len, have_star, dst_ptr, lcl_dst_len, MAX_GVSUBS_LEN); if (0 == len) return FALSE; switch (*ptr) { case 'c': case 'C': UPDATE_DST(ptr, len, have_star, dst_ptr, lcl_dst_len, MAX_GVSUBS_LEN); if ((0 < len) && ('(' == *ptr)) break; else if ((3 < len) && ('H' == lower_to_upper_table[*ptr]) && ('A' == lower_to_upper_table[*(ptr + 1)]) && ('R' == lower_to_upper_table[*(ptr + 2)]) && ('(' == *(ptr + 3))) { ptr += 3; len -= 3; break; } else return FALSE; break; case 'z': case 'Z': UPDATE_DST(ptr, len, have_star, dst_ptr, lcl_dst_len, MAX_GVSUBS_LEN); if ((2 < len) && ('C' == lower_to_upper_table[*ptr]) && ('H' == lower_to_upper_table[*(ptr + 1)]) && ('(' == *(ptr + 2))) { ptr += 2; len -= 2; } else if ((4 < len) && ('C' == lower_to_upper_table[*ptr]) && ('H' == lower_to_upper_table[*(ptr + 1)]) && ('A' == lower_to_upper_table[*(ptr + 2)]) && ('R' == lower_to_upper_table[*(ptr + 3)]) && ('(' == *(ptr + 4))) { ptr += 4; len -= 4; } else return FALSE; if (MAX_GVSUBS_LEN < lcl_dst_len + 2) { util_out_print_gtmio("Subscript too long", FLUSH); return FALSE; } MEMCPY_LIT(dst_ptr, "CH"); dst_ptr += 2; lcl_dst_len += 2; break; default: return FALSE; } assert('(' == *ptr); UPDATE_DST(ptr, len, have_star, dst_ptr, lcl_dst_len, MAX_GVSUBS_LEN); while ((0 < len) && (')' != *ptr)) { UPDATE_DST(ptr, len, have_star, dst_ptr, lcl_dst_len, MAX_GVSUBS_LEN); } q_len = 0; if (!have_star) { if (MAX_GVSUBS_LEN < ++lcl_dst_len) { util_out_print_gtmio("$[Z]CHAR expression too long", FLUSH); return FALSE; } *dst_ptr++ = *ptr++; *dst_ptr = '\0'; m_src.addr = tmp_dst_ptr; m_src.len = (mstr_len_t)(dst_ptr - tmp_dst_ptr); m_dst.addr = dst_string; m_dst.len = 0; if (!zwr2format(&m_src, &m_dst)) return FALSE; lcl_dst_len = *dst_len; /* Reset length because we're creating the final version now */ if (MAX_GVSUBS_LEN < ++lcl_dst_len) { util_out_print_gtmio("Subscript too long", FLUSH); return FALSE; } *tmp_dst_ptr++ = '"'; char_ptr = m_dst.addr; if (MAX_GVSUBS_LEN < (lcl_dst_len + m_dst.len)) { util_out_print_gtmio("Subscript too long", FLUSH); return FALSE; } for (char_count = 0; m_dst.len > char_count; char_count++) { if ('"' == *char_ptr) { if (MAX_GVSUBS_LEN < ++lcl_dst_len) { util_out_print_gtmio("Subscript too long", FLUSH); return FALSE; } *tmp_dst_ptr++ = '"'; q_len++; } *tmp_dst_ptr++ = *char_ptr++; lcl_dst_len++; } if (MAX_GVSUBS_LEN < ++lcl_dst_len) { util_out_print_gtmio("Subscript too long", FLUSH); return FALSE; } *tmp_dst_ptr++ = '"'; dst_ptr = tmp_dst_ptr; } else ptr++; assert(!have_star || ((dst_ptr == *d_ptr) && (lcl_dst_len == *dst_len))); *src_ptr = ptr; *src_len = len + 2 + q_len; /* Allow for the open and close quotes and any internal quotes */ *d_ptr = dst_ptr; *dst_len = lcl_dst_len; return TRUE; }
void go_load(int begin, int end) { char *ptr; int i, len, fmt, keylength, keystate; uint4 max_data_len, max_subsc_len, key_count, rec_count, max_rec_size; mstr src, des; unsigned char *rec_buff, ch; boolean_t format_error = FALSE, keepgoing; error_def(ERR_LOADFILERR); error_def(ERR_MUNOFINISH); error_def(ERR_LOADCTRLY); gvinit(); max_rec_size = DEFAULT_MAX_REC_SIZE; rec_buff = (unsigned char *)malloc(max_rec_size); if (!begin) { len = mu_load_get(&ptr); if (mupip_error_occurred) { free(rec_buff); return; } if (len >= 0) util_out_print("!AD", TRUE, len, ptr); else mupip_exit(ERR_LOADFILERR); len = mu_load_get(&ptr); if (mupip_error_occurred) { free(rec_buff); return; } if (len >= 0) { util_out_print("!AD", TRUE, len, ptr); fmt = (0 == memcmp(ptr + len - STR_LIT_LEN("ZWR"), "ZWR", STR_LIT_LEN("ZWR"))) ? MU_FMT_ZWR : MU_FMT_GO; } else mupip_exit(ERR_LOADFILERR); begin = 3; } else { for (i = 1; i < begin; i++) { len = mu_load_get(&ptr); if (mupip_error_occurred) { free(rec_buff); return; } if (len < 0) break; if (2 == i) /* the format flag appears only in the second record. */ fmt = (0 == memcmp(ptr + len - STR_LIT_LEN("ZWR"), "ZWR", STR_LIT_LEN("ZWR"))) ? MU_FMT_ZWR : MU_FMT_GO; } util_out_print("Beginning LOAD at #!UL\n", TRUE, begin); } max_data_len = 0; max_subsc_len = 0; key_count = 0; rec_count = 1; for (i = begin - 1 ; ;) { if (++i > end) break; if (mu_ctrly_occurred) break; if (mu_ctrlc_occurred) { util_out_print("!AD:!_ Key cnt: !UL max subsc len: !UL max data len: !UL", TRUE, LEN_AND_LIT(gt_lit), key_count, max_subsc_len, max_data_len); util_out_print("Last LOAD record number: !UL", TRUE, rec_count - 1); mu_gvis(); util_out_print(0, TRUE); mu_ctrlc_occurred = FALSE; } if ((len = mu_load_get(&ptr)) < 0) break; if (mupip_error_occurred) { mu_gvis(); break; } if ('\n' == *ptr) { if ('\n' == *(ptr+1)) break; ptr++; } stringpool.free = stringpool.base; rec_count++; if (0 == len) continue; if (MU_FMT_GO != fmt) { keylength = 0; /* determine length of key */ keystate = 0; keepgoing = TRUE; while((keylength < len - 1) && keepgoing) /* 1 == sizeof(=), since ZWR allows '^x(1,2)='*/ { ch = *(ptr + keylength); keylength++; switch (keystate) { case 0: /* in global name */ if ('=' == ch) /* end of key */ { keylength--; keepgoing = FALSE; } else if ('(' == ch) /* start of subscripts */ keystate = 1; break; case 1: /* in subscript area, but out of "..." or $C(...) */ switch (ch) { case ')': /* end of subscripts ==> end of key */ assert('=' == *(ptr + keylength)); keepgoing = FALSE; break; case '"': /* step into "..." */ keystate = 2; break; case '$': /* step into $C(...) */ assert(('C' == *(ptr + keylength)) || ('c' == *(ptr + keylength))); assert('(' == *(ptr + keylength + 1)); keylength += 2; keystate = 3; break; } break; case 2: /* in "..." */ if ('"' == ch) { switch (*(ptr + keylength)) { case '"': /* "" */ keylength++; break; case '_': /* _$C(...) */ assert('$' == *(ptr + keylength + 1)); assert(('c' == *(ptr + keylength + 2)) || ('C' == *(ptr + keylength + 2))); assert('(' == *(ptr + keylength + 3)); keylength += 4; keystate = 3; break; default: /* step out of "..." */ keystate = 1; } } break; case 3: /* in $C(...) */ if (')' == ch) { if ('_' == *(ptr + keylength)) /* step into "..." */ { assert('"' == *(ptr + keylength + 1)); keylength += 2; keystate = 2; break; } else keystate = 1; /* step out of $C(...) */ } break; default: assert(FALSE); break; } } assert(keylength < len - 1); go_call_db(GO_PUT_SUB, ptr, keylength); if (mupip_error_occurred) { mu_gvis(); mupip_error_occurred = FALSE; continue; } if (max_subsc_len < gv_currkey->end) max_subsc_len = gv_currkey->end; src.len = len - keylength - 1; src.addr = (char *)(ptr + keylength + 1); des.len = 0; if (src.len > max_rec_size) { max_rec_size = src.len; free(rec_buff); rec_buff = (unsigned char *)malloc(max_rec_size); } des.addr = (char *)rec_buff; if (FALSE == zwr2format(&src, &des)) { util_out_print("Format error in record !8UL: !/!AD", TRUE, rec_count + 1, src.len, src.addr); format_error = TRUE; continue; } if (max_data_len < des.len) max_data_len = des.len; stringpool.free = stringpool.base; go_call_db(GO_PUT_DATA, (char *)rec_buff, des.len); if (mupip_error_occurred) { mu_gvis(); mupip_error_occurred = FALSE; continue; } key_count++; } else { go_call_db(GO_PUT_SUB, ptr, len); if (mupip_error_occurred) { mu_gvis(); mupip_error_occurred = FALSE; continue; } if (max_subsc_len < gv_currkey->end) max_subsc_len = gv_currkey->end; if (++i > end) { i--; /* Decrement as didn't load key */ break; } if ((len = mu_load_get(&ptr)) < 0) break; if (mupip_error_occurred) { mu_gvis(); break; } rec_count++; stringpool.free = stringpool.base; if (max_data_len < len) max_data_len = len; go_call_db(GO_PUT_DATA, ptr, len); if (mupip_error_occurred) { mu_gvis(); mupip_error_occurred = FALSE; continue; } key_count++; } } free(rec_buff); mu_load_close(); if(mu_ctrly_occurred) { gtm_putmsg(VARLSTCNT(1) ERR_LOADCTRLY); mupip_exit(ERR_MUNOFINISH); } util_out_print("LOAD TOTAL!_!_Key Cnt: !UL Max Subsc Len: !UL Max Data Len: !UL",TRUE,key_count,max_subsc_len, max_data_len); util_out_print("Last LOAD record number: !UL\n",TRUE,i - 1); if (format_error) mupip_exit(ERR_LOADFILERR); }