Example #1
0
extern	void
InitTerm(void)
{
ENTER_FUNC;
	RecParserInit();
	if (ThisEnv->linkrec != NULL) {
		InitializeValue(ThisEnv->linkrec->value);
	}
LEAVE_FUNC;
}
Example #2
0
static void InitSystem(void) {
  InitMessage("glserver", NULL);
  InitDirectory();
  SetUpDirectory(Directory, NULL, NULL, NULL, P_NONE);
  if (ThisEnv == NULL) {
    Error("DI file parse error.");
  }
  ParseURL(&Auth, AuthURL, "file");
  InitNET();
  RecParserInit();
}
Example #3
0
static	void
SessionThread(
	void	*para)
{
	SessionCtrl *ctrl;
	GHashTable *hash;
ENTER_FUNC;
	workq = NewQueue();
	hash = NewNameHash();
	RecParserInit();
	while (TRUE) {
		ctrl = (SessionCtrl *)DeQueue(workq);
		switch (ctrl->type) {
		case SESSION_CONTROL_INSERT:
			InsertSession(hash,ctrl);
			break;
		case SESSION_CONTROL_UPDATE:
			UpdateSession(hash,ctrl);
			break;
		case SESSION_CONTROL_DELETE:
			DeleteSession(hash,ctrl);
			break;
		case SESSION_CONTROL_LOOKUP:
			LookupSession(hash,ctrl);
			break;
		case SESSION_CONTROL_GET_SESSION_NUM:
			GetSessionNum(hash,ctrl);
			break;
		case SESSION_CONTROL_GET_DATA:
			GetData(hash,ctrl);
			break;
		case SESSION_CONTROL_GET_MESSAGE:
			GetMessage(hash,ctrl);
			break;
		case SESSION_CONTROL_RESET_MESSAGE:
			ResetMessage(hash,ctrl);
			break;
		case SESSION_CONTROL_SET_MESSAGE:
			SetMessage(hash,ctrl);
			break;
		case SESSION_CONTROL_SET_MESSAGE_ALL:
			SetMessageAll(hash,ctrl);
			break;
		case SESSION_CONTROL_GET_DATA_ALL:
			GetDataAll(hash,ctrl);
			break;
		}
		EnQueue(ctrl->waitq,ctrl);
	}
	pthread_exit(NULL);
LEAVE_FUNC;
}
Example #4
0
extern	void
Init_rubymondai(void)
{
ENTER_FUNC;
    mPanda = rb_define_module("Rubymondai");
    cArrayValue = rb_define_class_under(mPanda, "ArrayValue", rb_cObject);
    rb_define_method(cArrayValue, "length", aryval_length, 0);
    rb_define_method(cArrayValue, "size", aryval_length, 0);
    rb_define_method(cArrayValue, "[]", aryval_aref, 1);
    rb_define_method(cArrayValue, "[]=", aryval_aset, 2);
    rb_define_method(cArrayValue, "index", aryval_index, 1);
    cRecordValue = rb_define_class_under(mPanda, "RecordValue", rb_cObject);
	rb_define_alloc_func(cRecordValue, recval_alloc);
	rb_define_private_method(cRecordValue, "initialize", recval_initialize, 1);
    rb_define_method(cRecordValue, "length", recval_length, 0);
    rb_define_method(cRecordValue, "size", recval_length, 0);
    rb_define_method(cRecordValue, "clear", recval_clear, 0);
    rb_define_method(cRecordValue, "[]", recval_aref, 1);
    rb_define_method(cRecordValue, "[]=", recval_aset, 2);

	RecParserInit();
    codeset = "utf-8";
LEAVE_FUNC;
}
Example #5
0
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;
}
Example #6
0
extern	int
main(
	int		argc,
	char	**argv)
{
#define	SIZE_DATA		128

	char	name[SIZE_DATA];
	unsigned char	*p;
	int		i;
	ValueStruct	*val
		,		*val2;
	unsigned char	*buff;
	char	method[SIZE_LONGNAME+1];
	FILE	*fp;

	RecordDir = ".";
	RecParserInit();
	val = BuildMcpArea(10);

	/*	set	*/
	printf("***** Value setting *****\n");
	SetValueString(GetItemLongName(val,"func"),"aaa",SRC_CODE);
	SetValueString(GetItemLongName(val,"rc"),"0",SRC_CODE);

	SetValueString(GetItemLongName(val,"dc.window"),"1 Ë",SRC_CODE);
	SetValueString(GetItemLongName(val,"dc.widget"),"widget",SRC_CODE);
	SetValueString(GetItemLongName(val,"dc.event"),"1002 ",SRC_CODE);
	SetValueString(GetItemLongName(val,"dc.fromwin"),"fromwin",SRC_CODE);
	SetValueString(GetItemLongName(val,"dc.status"),"status",SRC_CODE);
	SetValueString(GetItemLongName(val,"dc.puttype"),"puttype",SRC_CODE);
	SetValueString(GetItemLongName(val,"dc.term"),"term",SRC_CODE);
	SetValueString(GetItemLongName(val,"dc.user"),"user",SRC_CODE);

	for	( i = 0 ; i < N_PATH ; i ++ ) {
		sprintf(name,"db.path[%d].blocks",i);
		SetValueInteger(GetItemLongName(val,name),i);
		sprintf(name,"db.path[%d].rname",i);
		SetValueInteger(GetItemLongName(val,name),i);
		sprintf(name,"db.path[%d].pname",i);
		SetValueInteger(GetItemLongName(val,name),i);
		sprintf(name,"db.path[%d].name",i);
		SetValueString(GetItemLongName(val,name),name,SRC_CODE);
	}

	SetValueString(GetItemLongName(val,"private.count"),"1",SRC_CODE);
	for	( i = 0 ; i < 100 ; i ++ ) {
		sprintf(name,"private.swindow[%d]",i);
		SetValueString(GetItemLongName(val,name),name,SRC_CODE);
	}
	for	( i = 0 ; i < ValueArraySize(GetItemLongName(val,"private.state")) ; i ++ ) {
		sprintf(name,"private.state[%d]",i);
		SetValueString(GetItemLongName(val,name),name,SRC_CODE);
	}
	for	( i = 0 ; i < ValueArraySize(GetItemLongName(val,"private.index")) ; i ++ ) {
		sprintf(name,"private.index[%d]",i);
		SetValueString(GetItemLongName(val,name),name,SRC_CODE);
	}
	SetValueString(GetItemLongName(val,"private.pstatus"),"1",SRC_CODE);
	SetValueString(GetItemLongName(val,"private.pputtype"),"2",SRC_CODE);
	SetValueString(GetItemLongName(val,"private.prc"),"3",SRC_CODE);
	buff = xmalloc(SIZE_BUFF);
	memset(buff,0,SIZE_BUFF);
	for	( p = buff, i = 0 ; i < 256 ; i ++ , p ++) {
		*p = (unsigned char)i;
	}
	SetValueBinary(GetItemLongName(val,"bin"),buff,256);


	printf("***** SOAP ****\n");
	memset(buff,0,SIZE_BUFF);

	SOAP_PackValue(buff,val,"Put","mcp","http://oreore",TRUE,FALSE);

	printf("%s\n",buff);
	fp = fopen("test.SOAP","w");
	fprintf(fp,"%s\n",buff);
	fclose(fp);

	val2 = DuplicateValue(val,FALSE);

	SOAP_UnPackValue(val2,(char *)buff,method);

	printf("method = [%s]\n",method);
	DumpByXML(val2,"mcparea");

	SOAP_PackValue(buff,val,"Put","mcp","http://oreore",TRUE,FALSE);
	val2 = SOAP_LoadValue((char *)buff,method);
	printf("method = [%s]\n",method);
	DumpByXML(val2,"mcparea");
	//DumpValueStruct(val2);

	return	(0);
}