static Bool SendPanda( ScreenData *scr, NETFILE *fp) { Bool rc; ValueStruct *value; ENTER_FUNC; dbgprintf("ThisWindow = [%s]",scr->window); value = GetWindowValue(scr,scr->window); if (value == NULL) { Error("SendPanda invalid window[%s]",scr->window); } #ifdef DEBUG DumpValueStruct(value); #endif rc = SendTermServer(fp,scr,value); LEAVE_FUNC; return rc; }
static ValueStruct *_ReadXML(DBG_Struct *dbg, DBCOMM_CTRL *ctrl, RecordStruct *rec, ValueStruct *args) { xmlNodePtr node; xmlNodePtr root; ValueStruct *ret; int i; ret = NULL; ctrl->rc = MCP_BAD_OTHER; if (rec->type != RECORD_DB) { ctrl->rc = MCP_BAD_ARG; return NULL; } if (XMLDoc == NULL || XMLmode != MODE_READ) { return NULL; } root = xmlDocGetRootElement(XMLDoc); if (root == NULL || root->children == NULL) { return NULL; } for (node = root->children, i = 0; node != NULL; node = node->next, i++) { root = NULL; if (i == XMLpos) { root = node; break; } } XMLpos++; if (root == NULL) { return NULL; } ret = DuplicateValue(args, FALSE); ctrl->rc = XMLNode2Value(ret, root); #ifdef TRACE DumpValueStruct(ret); #endif return (ret); }
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; }