int64_t ObSqlReadParam::get_basic_param_serialize_size(void) const { int64_t total_size = 0; ObObj obj; // consistency obj.set_int(get_is_read_consistency()); total_size += obj.get_serialize_size(); // result cached obj.set_int(get_is_result_cached()); total_size += obj.get_serialize_size(); // data version obj.set_int(get_data_version()); total_size += obj.get_serialize_size(); // table id obj.set_int(table_id_); total_size += obj.get_serialize_size(); // renamed table id obj.set_int(renamed_table_id_); total_size += obj.get_serialize_size(); // only_static_data obj.set_bool(only_static_data_); total_size += obj.get_serialize_size(); return total_size; }
////////////////////// SERIALIZATION /////////////////////// int ObSqlReadParam::serialize_basic_param(char * buf, const int64_t buf_len, int64_t & pos) const { ObObj obj; int ret = OB_SUCCESS; // read consistency if (ret == OB_SUCCESS) { obj.set_int(get_is_read_consistency()); if (OB_SUCCESS != (ret = obj.serialize(buf, buf_len, pos))) { TBSYS_LOG(WARN, "fail to serialize basic param. buf=%p, buf_len=%ld, pos=%ld, ret=%d", buf, buf_len, pos, ret); } } // result cached if (ret == OB_SUCCESS) { obj.set_int(get_is_result_cached()); if (OB_SUCCESS != (ret = obj.serialize(buf, buf_len, pos))) { TBSYS_LOG(WARN, "fail to serialize basic param. buf=%p, buf_len=%ld, pos=%ld, ret=%d", buf, buf_len, pos, ret); } } // data version if (ret == OB_SUCCESS) { obj.set_int(get_data_version()); if (OB_SUCCESS != (ret = obj.serialize(buf, buf_len, pos))) { TBSYS_LOG(WARN, "fail to serialize basic param. buf=%p, buf_len=%ld, pos=%ld, ret=%d", buf, buf_len, pos, ret); } } // table id if (OB_SUCCESS == ret) { if (OB_INVALID_ID != table_id_) { obj.set_int(table_id_); if (OB_SUCCESS != (ret = obj.serialize(buf, buf_len, pos))) { TBSYS_LOG(WARN, "fail to serialize table id = %lu", table_id_); } } else { TBSYS_LOG(WARN, "Invalid table_id_. table_id_=%ld", table_id_); ret = OB_INVALID_ARGUMENT; } } // renamed table id if (OB_SUCCESS == ret) { if (OB_INVALID_ID != renamed_table_id_) { obj.set_int(renamed_table_id_); if (OB_SUCCESS != (ret = obj.serialize(buf, buf_len, pos))) { TBSYS_LOG(WARN, "fail to serialize renamed table id = %lu", renamed_table_id_); } } else { TBSYS_LOG(WARN, "Invalid renamed_table_id_. renamed_table_id_=%ld", renamed_table_id_); ret = OB_INVALID_ARGUMENT; } } if (OB_SUCCESS == ret) { obj.set_bool(only_static_data_); if (OB_SUCCESS != (ret = obj.serialize(buf, buf_len, pos))) { TBSYS_LOG(WARN, "fail to serialize bool:ret[%d]", ret); } } return ret; }
int main(int argc, char **argv) { int cnt; char index[10], *target = NULL, *date = NULL, *view = NULL, *uname, *loc; Props *p = NULL; CSA_entry_handle *list; CSA_session_handle c_handle; CSA_return_code stat; CSA_calendar_user csa_user; int version; #ifdef FNS char buf[256]; #endif init_time(); setlocale(LC_ALL, ""); _DtEnvControl(DT_ENV_SET); /* set up environment variables */ DT_catd = catopen(DTCM_CAT, NL_CAT_LOCALE); cm_tty_load_props(&p); cm_args(argc,argv); /* parse command line */ target = (cm_strlen(cm_target)) ? cm_target : cm_get_credentials(); #ifdef FNS dtfns_init(); if (cmfns_use_fns(p)) { cmfns_lookup_calendar(target, buf, sizeof(buf)); target = buf; } #endif if (cm_strlen(cm_date)) date = cm_date; if (cm_strlen(cm_view)) view = cm_view; uname = cm_target2name(target); loc = cm_target2location(target); csa_user.user_name = target; csa_user.user_type = 0; csa_user.calendar_user_extensions = NULL; csa_user.calendar_address = target; stat = csa_logon(NULL, &csa_user, NULL, NULL, NULL, &c_handle, NULL); if (stat != CSA_SUCCESS) { char *format = strdup(catgets(DT_catd, 1, 188, "\nCould not open calendar %s\n")); fprintf(stderr, format, target ? target : catgets(DT_catd, 1, 189, "UNKNOWN")); free(format); free(uname); free(loc); exit(1); } version = get_data_version(c_handle); while (!cm_index) { if ((cnt = cm_tty_lookup(DT_catd, c_handle, version, date, view, &list, p)) <= 0) { csa_logoff(c_handle, NULL); free(uname); free(loc); exit(0); } fprintf(stdout, catgets(DT_catd, 1, 190, "Item to delete (number)? ")); fgets(index, 9, stdin); fprintf(stdout,"\n\n"); if (*index < '0' || *index > '9') { csa_free(list); break; } cm_index = atoi(index); if (cnt >= cm_index) cm_tty_delete(DT_catd, c_handle, version, cm_index - 1, list); memset(index, '\0', 10); csa_free(list); cm_index = 0; } csa_logoff(c_handle, NULL); props_clean_up(p); free(p); free(uname); free(loc); return 0; }
void main(int argc, char **argv) { int cnt, status = 0; char *date = NULL, *view = NULL, *target = NULL, *start = NULL, *end = NULL, *repeat = NULL, *numrepeat = NULL, *what = NULL, *uname, *loc; Props *p = NULL; CSA_entry_handle *list; CSA_session_handle c_handle; CSA_return_code stat; CSA_calendar_user csa_user; DisplayType dt; int version; char date_str[256]; #ifdef FNS char buf[256]; #endif init_time(); _DtEnvControl(DT_ENV_SET); /* set up environment variables */ setlocale(LC_ALL, ""); DT_catd = catopen(DTCM_CAT, NL_CAT_LOCALE); cm_tty_load_props(&p); dt = get_int_prop(p, CP_DEFAULTDISP); #ifdef FNS dtfns_init(); #endif if (argc > 1) { cm_args(argc,argv); /* parse command line */ if (cm_strlen(cm_target)) target = cm_target; else target = cm_get_credentials(); #ifdef FNS if (cmfns_use_fns(p)) { cmfns_lookup_calendar(target, buf, sizeof(buf)); target = buf; } #endif uname = cm_target2name(target); loc = cm_target2location(target); csa_user.user_name = target; csa_user.user_type = 0; csa_user.calendar_user_extensions = NULL; csa_user.calendar_address = target; stat = csa_logon(NULL, &csa_user, NULL, NULL, NULL, &c_handle, NULL); if (stat != CSA_SUCCESS) { char *format = cm_strdup(catgets(DT_catd, 1, 206, "\nCould not open calendar %s\n")); fprintf(stderr, format, target ? target : catgets(DT_catd, 1, 209, "UNKNOWN")); free(format); free(uname); free(loc); exit(1); } version = get_data_version(c_handle); if (!cm_date[0]) format_tick(now(), get_int_prop(p, CP_DATEORDERING), get_int_prop(p, CP_DATESEPARATOR), cm_date); if (cm_strlen(cm_date)) date = cm_date; if (cm_strlen(cm_view)) view = cm_view; if (cm_strlen(cm_start)) start = cm_start; if (!cm_end[0] && cm_start[0]) { format_time((int)cm_getdate(cm_start, NULL) + hrsec, dt, cm_end); } if (cm_strlen(cm_end)) end = cm_end; if (cm_strlen(cm_repeatstr)) repeat = cm_repeatstr; if (cm_strlen(cm_for)) numrepeat = cm_for; if (cm_strlen(cm_what)) what = cm_what; if (!cm_appt_file[0]) status = cm_tty_insert(DT_catd, c_handle, version, date, start, end, repeat, numrepeat, what, NULL, p); else status = cm_tty_insert(DT_catd, c_handle, version, date, start, end, repeat, numrepeat, what, cm_appt_file, p); } else { prompt_for_insert(p); if (cm_strlen(cm_target)) target = cm_target; uname = cm_target2name(target); loc = cm_target2location(target); csa_user.user_name = target; csa_user.user_type = 0; csa_user.calendar_user_extensions = NULL; csa_user.calendar_address = target; stat = csa_logon(NULL, &csa_user, NULL, NULL, NULL, &c_handle, NULL); if (stat !=CSA_SUCCESS) { char *format = cm_strdup(catgets(DT_catd, 1, 206, "\nCould not open calendar %s\n")); fprintf(stderr, format, target ? target : catgets(DT_catd, 1, 209, "UNKNOWN")); free(format); free(uname); free(loc); exit(1); } version = get_data_version(c_handle); if (cm_strlen(cm_date)) date = cm_date; if (cm_strlen(cm_view)) view = cm_view; if (cm_strlen(cm_start)) start = cm_start; if (cm_strlen(cm_end)) end = cm_end; if (cm_strlen(cm_repeatstr)) repeat = cm_repeatstr; if (cm_strlen(cm_for)) numrepeat = cm_for; if (cm_strlen(cm_what)) what = cm_what; status = cm_tty_insert(DT_catd, c_handle, version, date, start, end, repeat, numrepeat, what, NULL, p); } if ((cnt = cm_tty_lookup(DT_catd, c_handle, version, date, view, &list, p)) > 0) csa_free(list); csa_logoff(c_handle, NULL); props_clean_up(p); free(p); free(uname); free(loc); exit(status); }
int main(int argc, char **argv) { int cnt; char *target = NULL, *date = NULL, *view = NULL, *uname, *loc; Props *p = NULL; CSA_session_handle c_handle; CSA_entry_handle *list; CSA_return_code stat; CSA_calendar_user csa_user; int version; #ifdef FNS char buf[256]; #endif init_time(); _DtEnvControl(DT_ENV_SET); /* set up environment variables */ setlocale(LC_ALL, ""); DT_catd = catopen(DTCM_CAT, NL_CAT_LOCALE); cm_tty_load_props(&p); cm_args(argc,argv); /* parse command line */ target = (cm_strlen(cm_target)) ? cm_target : cm_get_credentials(); #ifdef FNS dtfns_init(); if (cmfns_use_fns(p)) { cmfns_lookup_calendar(target, buf, sizeof(buf)); target = buf; } #endif uname = cm_target2name(target); loc = cm_target2location(target); csa_user.user_name = target; csa_user.user_type = 0; csa_user.calendar_user_extensions = NULL; csa_user.calendar_address = target; stat = csa_logon(NULL, &csa_user, NULL, NULL, NULL, &c_handle, NULL); if (stat != CSA_SUCCESS) { char *format = cm_strdup(catgets(DT_catd, 1, 208, "\nCould not open calendar \"%s\"\n")); fprintf(stderr, format, target ? target : catgets(DT_catd, 1, 209, "UNKNOWN")); free(format); free(uname); free(loc); exit(1); } version = get_data_version(c_handle); if (cm_strlen(cm_date)) date = cm_date; if (cm_strlen(cm_view)) view = cm_view; if ((cnt = cm_tty_lookup(DT_catd, c_handle, version, date, view, &list, p)) > 0) csa_free(list); csa_logoff(c_handle, NULL); props_clean_up(p); free(p); free(uname); free(loc); return 0; }