static SessionData * NewSessionData(void) { SessionData *data; ENTER_FUNC; data = New(SessionData); memclear(data,sizeof(SessionData)); data->type = SESSION_TYPE_TERM; data->status = SESSION_STATUS_NORMAL; data->hdr = New(MessageHeader); memclear(data->hdr,sizeof(MessageHeader)); data->hdr->command = APL_COMMAND_LINK; data->apsid = -1; data->spadata = NewNameHash(); data->scrpool = NewNameHash(); gettimeofday(&(data->create_time), NULL); gettimeofday(&(data->access_time), NULL); timerclear(&(data->process_time)); timerclear(&(data->total_process_time)); data->apidata = New(APIData); data->apidata->status = WFC_API_OK; data->apidata->rec = NewLBS(); data->sysdbval = RecParseValueMem(SYSDBVAL_DEF,NULL); InitializeValue(data->sysdbval); data->count = 0; data->w.sp = 0; LEAVE_FUNC; return (data); }
extern SessionCtrl* NewSessionCtrl( SessionCtrlType type) { SessionCtrl *ctrl; ctrl = g_new0(SessionCtrl,1); ctrl->type = type; ctrl->waitq = NewQueue(); ctrl->sysdbval = RecParseValueMem(SYSDBVAL_DEF,NULL); InitializeValue(ctrl->sysdbval); ctrl->sysdbvals = RecParseValueMem(SYSDBVALS_DEF,NULL); InitializeValue(ctrl->sysdbvals); return ctrl; }
static ValueStruct * SELECTALL( DBG_Struct *dbg, DBCOMM_CTRL *ctrl, RecordStruct *rec, ValueStruct *args) { ValueStruct *ret; PacketClass rc; ENTER_FUNC; ret = NULL; ctrl->rc = MCP_BAD_OTHER; if ( rec->type != RECORD_DB ) { ctrl->rc = MCP_BAD_ARG; } else { if (sysdbvals == NULL) { sysdbvals = RecParseValueMem(SYSDBVALS_DEF,NULL); InitializeValue(sysdbvals); } rc = SYSDB_GetDataAll(NBCONN(dbg),&numData, sysdbvals); if (rc == SESSION_CONTROL_OK) { hasData = TRUE; idx = 0; ctrl->rc = MCP_OK; } else { hasData = FALSE; ctrl->rc = MCP_BAD_OTHER; } } LEAVE_FUNC; return ret; }
static VALUE recval_clear(VALUE self) { value_struct_data *data; Data_Get_Struct(self, value_struct_data, data); InitializeValue(data->value); return Qnil; }
extern void InitTerm(void) { ENTER_FUNC; RecParserInit(); if (ThisEnv->linkrec != NULL) { InitializeValue(ThisEnv->linkrec->value); } LEAVE_FUNC; }
extern void InitSystem( char *name) { char *user = NULL; char *term = NULL; ENTER_FUNC; InitData(BD_Name); if ( ( ThisBD = GetBD(BD_Name) ) == NULL ) { Error("BD file not found."); } if ( ThisBD->home != NULL ) { chdir(ThisBD->home); } ThisLD = NULL; ThisDBD = NULL; InitiateBatchHandler(); ThisDB = ThisBD->db; DB_Table = ThisBD->DB_Table; TextSize = ThisBD->textsize; if ( ThisEnv->mcprec != NULL ) { InitializeValue(ThisEnv->mcprec->value); } SetValueString(GetItemLongName(ThisEnv->mcprec->value,"dc.module"),name,NULL); if ((user = getenv("MONTSUQIUSER")) != NULL) { SetValueString(GetItemLongName(ThisEnv->mcprec->value,"dc.user"),user,NULL); } if ((term = getenv("MONTSUQITERM")) != NULL) { SetValueString(GetItemLongName(ThisEnv->mcprec->value,"dc.term"),term,NULL); } if ( ( Bind = g_hash_table_lookup(ThisBD->BatchTable,name) ) == NULL ) { Error("%s application is not in BD.",name); } InitDB_Process(AppName); ReadyHandlerDB(Bind->handler); LEAVE_FUNC; }
CKnights::CKnights() { m_pMain = (CEbenezerDlg*)AfxGetApp()->GetMainWnd(); InitializeValue(); }
int main(int argc, char *argv[]) { ValueStruct *value, *v; size_t size; char *buf; RecParserInit(); value = RecParseValueMem(recdef, NULL); InitializeValue(value); v = GetRecordItem(value, "command"); SetValueString(v, "a\"a\\a/a\ba\fa\na\ra\ta", NULL); v = GetItemLongName(value, "record1[0].col1"); SetValueString(v, "bbbb", NULL); v = GetItemLongName(value, "record1[0].record2.col21"); SetValueString(v, "cccc", NULL); v = GetItemLongName(value, "int1"); SetValueInteger(v, 10); v = GetItemLongName(value, "int2"); SetValueInteger(v, 20); v = GetItemLongName(value, "double1"); SetValueFloat(v, -3.2); fprintf(stderr, "\n---- JSON_PackValue\n"); size = JSON_SizeValue(NULL, value); fprintf(stderr, "size:%ld\n", size); buf = malloc(size + 1); memset(buf, 0, size + 1); JSON_PackValue(NULL, buf, value); fprintf(stderr, "[%s]\nsize:%ld\n", buf, strlen(buf)); fprintf(stderr, "\n---- JSON_UnPackValue 1\n"); JSON_UnPackValue(NULL, buf, value); DumpValueStruct(value); free(buf); fprintf(stderr, "\n---- JSON_UnPackValue 2\n"); JSON_UnPackValue(NULL, "{\"int1\":1000,\"int2\":2000}", value); DumpValueStruct(value); /* ommit */ fprintf(stderr, "\n-------------------\n"); fprintf(stderr, "ommit\n"); fprintf(stderr, "-------------------\n\n"); InitializeValue(value); v = GetRecordItem(value, "command"); SetValueString(v, "a\"a\\a/a\ba\fa\na\ra\ta", NULL); v = GetItemLongName(value, "record1[0].col1"); SetValueString(v, "bbbb", NULL); v = GetItemLongName(value, "record1[0].record2.col21"); SetValueString(v, "cccc", NULL); v = GetItemLongName(value, "int1"); SetValueInteger(v, 10); v = GetItemLongName(value, "int2"); SetValueInteger(v, 20); v = GetItemLongName(value, "record3[1].record4[1].vc41"); SetValueString(v, "vc41", NULL); fprintf(stderr, "\n---- JSON_PackValueOmmit\n"); size = JSON_SizeValueOmmit(NULL, value); fprintf(stderr, "size:%ld\n", size); buf = malloc(size + 1); memset(buf, 0, size + 1); JSON_PackValueOmmit(NULL, buf, value); fprintf(stderr, "size:%ld [%s]\n", strlen(buf), buf); free(buf); fprintf(stderr, "\n---- JSON_UnPackValueOmmit\n"); JSON_UnPackValueOmmit(NULL, "{\"int1\":1000,\"int2\":2000}", value); DumpValueStruct(value); fprintf(stderr, "\n---- JSON_UnPackValueOmmit 2\n"); JSON_UnPackValueOmmit( NULL, "{\"int1\":1234,\"int2\":5678,\"bool1\":false,\"double1\":3.141592}", value); DumpValueStruct(value); fprintf(stderr, "\n---- JSON_UnPackValueOmmit 3\n"); JSON_UnPackValueOmmit( NULL, "{\"int1\":1000,\"command\":\"moge\",\"record1\":[{\"col1\":\"muge\"," "\"record2\":{\"col21\":\"gage\"}},{},{\"col2\":\"nuge\"}],\"record3\":[{" "},{\"record4\":[{},{\"vc41\":\"vc41\"}]}]}", value); DumpValueStruct(value); InitializeValue(value); fprintf(stderr, "\n---- test\n"); JSON_UnPackValueOmmit(NULL, "{\"int1\":10,\"int0\":[0,1,2,3,0,5,0,6],\"bool1\":" "false,\"arg1\":\"hogehoge\"}", value); size = JSON_SizeValueOmmit(NULL, value); fprintf(stderr, "size:%ld\n", size); buf = malloc(size); memset(buf, 0, size); JSON_PackValueOmmit(NULL, buf, value); fprintf(stderr, "size:%d %s\n", (int)strlen(buf), buf); free(buf); fprintf(stderr, "\n\n\n\n\n\n---- JSON_PackValueOmmitString\n"); InitializeValue(value); v = GetRecordItem(value, "command"); SetValueString(v, "a\"a\\a/a\ba\fa\na\ra\ta", NULL); v = GetItemLongName(value, "record1[0].col1"); SetValueString(v, "bbbb", NULL); #if 0 v = GetItemLongName(value,"record1[0].record2.col21"); SetValueString(v,"cccc",NULL); #endif v = GetItemLongName(value, "int1"); SetValueInteger(v, 10); v = GetItemLongName(value, "int2"); SetValueInteger(v, 20); v = GetItemLongName(value, "record3[1].record4[1].vc41"); SetValueString(v, "vc41", NULL); DumpValueStruct(value); size = JSON_SizeValueOmmitString(NULL, value); fprintf(stderr, "size:%ld\n", size); buf = malloc(size + 1); memset(buf, 0, size + 1); JSON_PackValueOmmitString(NULL, buf, value); fprintf(stderr, "size:%ld [%s]\n", strlen(buf), buf); free(buf); return 0; }
static void ExecuteDB_Server(MessageHandler *handler) { RecordStruct *rec; ValueStruct *value, *ret; PathStruct *path; DB_Operation *op; size_t size; int rno, pno, ono; DBCOMM_CTRL ctrl; char *rname, *pname, *func; ConvFuncs *conv; InitializeCTRL(&ctrl); conv = handler->serialize; while (TRUE) { dbgmsg("read"); LBS_EmitStart(dbbuff); RecvLargeString(fpDBR, dbbuff); ON_IO_ERROR(fpDBR, badio); ConvSetRecName(handler->conv, recDBCTRL->name); InitializeValue(recDBCTRL->value); conv->UnPackValue(handler->conv, LBS_Body(dbbuff), recDBCTRL->value); rname = ValueStringPointer(GetItemLongName(recDBCTRL->value, "rname")); strncpy(ctrl.rname, rname, SIZE_NAME); value = NULL; ret = NULL; if ((rname != NULL) && ((rno = (int)(long)g_hash_table_lookup(DB_Table, rname)) != 0)) { ctrl.rno = rno - 1; rec = ThisDB[ctrl.rno]; value = rec->value; pname = ValueStringPointer(GetItemLongName(recDBCTRL->value, "pname")); strncpy(ctrl.pname, pname, SIZE_NAME); if ((pno = (int)(long)g_hash_table_lookup(rec->opt.db->paths, pname)) != 0) { ctrl.pno = pno - 1; path = rec->opt.db->path[pno - 1]; value = (path->args != NULL) ? path->args : value; } else { ctrl.pno = 0; path = NULL; } } else { rec = NULL; path = NULL; } func = ValueStringPointer(GetItemLongName(recDBCTRL->value, "func")); if (*func != 0) { if (path == NULL) { Error("path is NULL"); } else if ((ono = (int)(long)g_hash_table_lookup(path->opHash, func)) != 0) { op = path->ops[ono - 1]; value = (op->args != NULL) ? op->args : value; } if (rec != NULL) { ConvSetRecName(handler->conv, rec->name); } else { Error("rec is NULL"); } InitializeValue(value); conv->UnPackValue(handler->conv, LBS_Body(dbbuff), value); strncpy(ctrl.func, func, SIZE_FUNC); ret = ExecDB_Process(&ctrl, rec, value); } else { ctrl.rc = 0; } dbgmsg("write"); SetValueInteger(GetItemLongName(recDBCTRL->value, "rc"), ctrl.rc); ConvSetRecName(handler->conv, recDBCTRL->name); LBS_EmitStart(dbbuff); size = conv->SizeValue(handler->conv, recDBCTRL->value); LBS_ReserveSize(dbbuff, size, FALSE); conv->PackValue(handler->conv, LBS_Body(dbbuff), recDBCTRL->value); LBS_EmitEnd(dbbuff); SendLargeString(fpDBW, dbbuff); ON_IO_ERROR(fpDBW, badio); if (ret != NULL) { Send(fpDBW, conv->fsep, strlen(conv->fsep)); ON_IO_ERROR(fpDBW, badio); LBS_EmitStart(dbbuff); if (rec != NULL) { ConvSetRecName(handler->conv, rec->name); } size = conv->SizeValue(handler->conv, ret); LBS_ReserveSize(dbbuff, size, FALSE); conv->PackValue(handler->conv, LBS_Body(dbbuff), ret); LBS_EmitEnd(dbbuff); SendLargeString(fpDBW, dbbuff); ON_IO_ERROR(fpDBW, badio); FreeValueStruct(ret); } Send(fpDBW, conv->bsep, strlen(conv->bsep)); ON_IO_ERROR(fpDBW, badio); } badio: return; }