Esempio n. 1
0
/*
 * string db_sig(void)
 *   Return the unQLite database engine unique signature.
 * Parameter
 *   None
 * Return
 *    unQLite signature.
 */
static int unqliteBuiltin_db_sig(jx9_context *pCtx,int argc,jx9_value **argv)
{
	SXUNUSED(argc); /* cc warning */
	SXUNUSED(argv);
	jx9_result_string(pCtx,UNQLITE_IDENT,sizeof(UNQLITE_IDENT)-1);
	return JX9_OK;
}
Esempio n. 2
0
/*
 * string db_copyright(void)
 * string db_credits(void)
 *   Return the unQLite database engine copyright notice.
 * Parameter
 *   None
 * Return
 *    Copyright notice.
 */
static int unqliteBuiltin_db_credits(jx9_context *pCtx,int argc,jx9_value **argv)
{
	SXUNUSED(argc); /* cc warning */
	SXUNUSED(argv);
	jx9_result_string(pCtx,UNQLITE_COPYRIGHT,(int)sizeof(UNQLITE_COPYRIGHT)-1);
	return JX9_OK;
}
Esempio n. 3
0
/*
 * string db_version(void)
 *   Return the current version of the unQLite database engine.
 * Parameter
 *   None
 * Return
 *    unQLite version number (string).
 */
static int unqliteBuiltin_db_version(jx9_context *pCtx,int argc,jx9_value **argv)
{
	SXUNUSED(argc); /* cc warning */
	SXUNUSED(argv);
	jx9_result_string(pCtx,UNQLITE_VERSION,(int)sizeof(UNQLITE_VERSION)-1);
	return JX9_OK;
}
Esempio n. 4
0
/*
 * Standard JSON decoder callback.
 */
static int VmJsonDefaultDecoder(jx9_context *pCtx, jx9_value *pKey, jx9_value *pWorker, void *pUserData)
{
	/* Return the value directly */
	jx9_result_value(pCtx, pWorker); /* Will make it's own copy */
	SXUNUSED(pKey); /* cc warning */
	SXUNUSED(pUserData);
	/* All done */
	return SXRET_OK;
}
Esempio n. 5
0
/*
 * string db_errlog(void)
 *   Return the database error log.
 * Parameter
 *   None
 * Return
 *    Database error log (string).
 */
static int unqliteBuiltin_db_errlog(jx9_context *pCtx,int argc,jx9_value **argv)
{
	unqlite_vm *pVm;
	SyBlob *pErr;
	
	SXUNUSED(argc); /* cc warning */
	SXUNUSED(argv);

	pVm = (unqlite_vm *)jx9_context_user_data(pCtx);
	/* Point to the error log */
	pErr = &pVm->pDb->sErr;
	/* Return the log */
	jx9_result_string(pCtx,(const char *)SyBlobData(pErr),(int)SyBlobLength(pErr));
	return JX9_OK;
}
Esempio n. 6
0
/*
 * bool db_rollback(void)
 *   Manually rollback a transaction.
 * Parameter
 *   None
 * Return
 *    TRUE if the transaction was successfuly rolled back. FALSE otherwise
 */
static int unqliteBuiltin_db_rollback(jx9_context *pCtx,int argc,jx9_value **argv)
{
	unqlite_vm *pVm;
	unqlite *pDb;
	int rc;
	SXUNUSED(argc); /* cc warning */
	SXUNUSED(argv);
	/* Point to the unqlite Vm */
	pVm = (unqlite_vm *)jx9_context_user_data(pCtx);
	/* Point to the underlying database handle  */
	pDb = pVm->pDb;
	/* Rollback the transaction if any */
	rc = unqlitePagerRollback(pDb->sDB.pPager,TRUE);
	/* Rollback result */
	jx9_result_bool(pCtx,rc == UNQLITE_OK );
	return JX9_OK;
}
Esempio n. 7
0
/*
 * DIRECTORY_SEPARATOR.
 * Expand the directory separator character.
 */
static void JX9_DIRSEP_Const(jx9_value *pVal, void *pUnused)
{
	SXUNUSED(pUnused);
#ifdef __WINNT__
	jx9_value_string(pVal, "\\", (int)sizeof(char));
#else
	jx9_value_string(pVal, "/", (int)sizeof(char));
#endif
}
Esempio n. 8
0
/*
 * The following JSON decoder callback is invoked each time
 * a JSON array representation [i.e: [15, "hello", FALSE] ]
 * is being decoded.
 */
static int VmJsonArrayDecoder(jx9_context *pCtx, jx9_value *pKey, jx9_value *pWorker, void *pUserData)
{
	jx9_value *pArray = (jx9_value *)pUserData;
	/* Insert the entry */
	jx9_array_add_elem(pArray, pKey, pWorker); /* Will make it's own copy */
	SXUNUSED(pCtx); /* cc warning */
	/* All done */
	return SXRET_OK;
}
Esempio n. 9
0
/*
 * JX9_EOL
 *  Expand the correct 'End Of Line' symbol for this platform.
 */
static void JX9_EOL_Const(jx9_value *pVal, void *pUnused)
{
	SXUNUSED(pUnused);
#ifdef __WINNT__
	jx9_value_string(pVal, "\r\n", (int)sizeof("\r\n")-1);
#else
	jx9_value_string(pVal, "\n", (int)sizeof(char));
#endif
}
Esempio n. 10
0
/*
 * Array walker callback (Refer to jx9_array_walk()).
 */
static int CollectionRecordArrayWalker(jx9_value *pKey,jx9_value *pData,void *pUserData)
{
	unqlite_col *pCol = (unqlite_col *)pUserData;
	int rc;
	/* Perform the insertion */
	rc = CollectionStore(pCol,pData);
	if( rc != UNQLITE_OK ){
		SXUNUSED(pKey); /* cc warning */
	}
	return rc;
}
Esempio n. 11
0
/*
 * Perform a store operation on a given collection.
 */
UNQLITE_PRIVATE int unqliteCollectionPut(unqlite_col *pCol,jx9_value *pValue,int iFlag)
{
	int rc;
	if( !jx9_value_is_json_object(pValue) && jx9_value_is_json_array(pValue) ){
		/* Iterate over the array and store its members in the collection */
		rc = jx9_array_walk(pValue,CollectionRecordArrayWalker,pCol);
		SXUNUSED(iFlag); /* cc warning */
	}else{
		rc = CollectionStore(pCol,pValue);
	}
	return rc;
}
Esempio n. 12
0
/*
 * JX9_OS
 * __OS__
 *  Expand the name of the host Operating System.
 */
static void JX9_OS_Const(jx9_value *pVal, void *pUnused)
{
#if defined(__WINNT__)
	jx9_value_string(pVal, "WinNT", (int)sizeof("WinNT")-1);
#elif defined(__UNIXES__)
	struct utsname sInfo;
	if( uname(&sInfo) != 0 ){
		jx9_value_string(pVal, "Unix", (int)sizeof("Unix")-1);
	}else{
		jx9_value_string(pVal, sInfo.sysname, -1);
	}
#else
	jx9_value_string(pVal,"Host OS", (int)sizeof("Host OS")-1);
#endif
	SXUNUSED(pUnused);
}
Esempio n. 13
0
/*
 * __DATE__
 *  Expand the current date in the ISO-8601 format.
 */
static void JX9_DATE_Const(jx9_value *pVal, void *pUnused)
{
	Sytm sTm;
#ifdef __WINNT__
	SYSTEMTIME sOS;
	GetSystemTime(&sOS);
	SYSTEMTIME_TO_SYTM(&sOS, &sTm);
#else
	struct tm *pTm;
	time_t t;
	time(&t);
	pTm = gmtime(&t);
	STRUCT_TM_TO_SYTM(pTm, &sTm);
#endif
	SXUNUSED(pUnused); /* cc warning */
	/* Expand */
	jx9_value_string_format(pVal, "%04d-%02d-%02d", sTm.tm_year, sTm.tm_mon+1, sTm.tm_mday);
}
Esempio n. 14
0
/*
 * The following walker callback is invoked each time we need
 * to encode an array to JSON.
 */
static int VmJsonArrayEncode(jx9_value *pKey, jx9_value *pValue, void *pUserData)
{
	json_private_data *pJson = (json_private_data *)pUserData;
	if( pJson->nRecCount > 31 ){
		/* Recursion limit reached, return immediately */
		SXUNUSED(pKey); /* cc warning */
		return JX9_OK;
	}
	if( !pJson->isFirst ){
		/* Append the colon first */
		SyBlobAppend(pJson->pOut,",",(int)sizeof(char));
	}
	/* Encode the value */
	pJson->nRecCount++;
	VmJsonEncode(pValue, pJson);
	pJson->nRecCount--;
	pJson->isFirst = 0;
	return JX9_OK;
}
Esempio n. 15
0
/*
 * ASSERT_CALLBACK.
 *  Expand the value of JX9_ASSERT_CALLBACK defined in jx9Int.h
 */
static void JX9_ASSERT_CALLBACK_Const(jx9_value *pVal, void *pUserData)
{
	SXUNUSED(pUserData); /* cc warning */
	jx9_value_int(pVal, JX9_ASSERT_CALLBACK);
}
Esempio n. 16
0
/*
 * ASSERT_QUIET_EVAL.
 *  Expand the value of JX9_ASSERT_QUIET_EVAL defined in jx9Int.h
 */
static void JX9_ASSERT_QUIET_EVAL_Const(jx9_value *pVal, void *pUserData)
{
	SXUNUSED(pUserData); /* cc warning */
	jx9_value_int(pVal, JX9_ASSERT_QUIET_EVAL);
}
Esempio n. 17
0
/*
 * ASSERT_WARNING.
 *  Expand the value of JX9_ASSERT_WARNING defined in jx9Int.h
 */
static void JX9_ASSERT_WARNING_Const(jx9_value *pVal, void *pUserData)
{
	SXUNUSED(pUserData); /* cc warning */
	jx9_value_int(pVal, JX9_ASSERT_WARNING);
}
Esempio n. 18
0
/*
 * ASSERT_ACTIVE.
 *  Expand the value of JX9_ASSERT_ACTIVE defined in jx9Int.h
 */
static void JX9_ASSERT_ACTIVE_Const(jx9_value *pVal, void *pUserData)
{
	SXUNUSED(pUserData); /* cc warning */
	jx9_value_int(pVal, JX9_ASSERT_DISABLE);
}
Esempio n. 19
0
/*
 * PATHINFO_FILENAME
 *  Expand 4.
 */
static void JX9_PATHINFO_FILENAME_Const(jx9_value *pVal, void *pUserData)
{
	SXUNUSED(pUserData); /* cc warning */
	jx9_value_int(pVal, 4);
}
Esempio n. 20
0
/*
 * JX9_INT_SIZE
 * Expand the size in bytes of a 64-bit integer.
 */
static void JX9_INTSIZE_Const(jx9_value *pVal, void *pUnused)
{
	SXUNUSED(pUnused);
	jx9_value_int64(pVal, sizeof(sxi64));
}
Esempio n. 21
0
/*
 * FNM_CASEFOLD
 *  Expand 0x08 (Must be a power of two)
 */
static void JX9_FNM_CASEFOLD_Const(jx9_value *pVal, void *pUserData)
{
	SXUNUSED(pUserData); /* cc warning */
	jx9_value_int(pVal, 0x08);
}
Esempio n. 22
0
/*
 * FNM_PATHNAME
 *  Expand 0x02 (Must be a power of two)
 */
static void JX9_FNM_PATHNAME_Const(jx9_value *pVal, void *pUserData)
{
	SXUNUSED(pUserData); /* cc warning */
	jx9_value_int(pVal, 0x02);
}
Esempio n. 23
0
/*
 * FNM_NOESCAPE
 *  Expand 0x01 (Must be a power of two)
 */
static void JX9_FNM_NOESCAPE_Const(jx9_value *pVal, void *pUserData)
{
	SXUNUSED(pUserData); /* cc warning */
	jx9_value_int(pVal, 0x01);
}
Esempio n. 24
0
/*
 * JX9_URL_FRAGMENT.
 * Expand 8
 */
static void JX9_JX9_URL_FRAGMENT_Const(jx9_value *pVal, void *pUserData)
{
	SXUNUSED(pUserData); /* cc warning */
	jx9_value_int(pVal, 8);
}
Esempio n. 25
0
/*
 * JX9_URL_PATH.
 * Expand 6
 */
static void JX9_JX9_URL_PATH_Const(jx9_value *pVal, void *pUserData)
{
	SXUNUSED(pUserData); /* cc warning */
	jx9_value_int(pVal, 6);
}
Esempio n. 26
0
/*
 * SEEK_END.
 *  Expand 2
 */
static void JX9_SEEK_END_Const(jx9_value *pVal, void *pUserData)
{
	SXUNUSED(pUserData); /* cc warning */
	jx9_value_int(pVal, 2);
}
Esempio n. 27
0
/*
 * LOCK_SH.
 *  Expand 2
 */
static void JX9_LOCK_SH_Const(jx9_value *pVal, void *pUserData)
{
	SXUNUSED(pUserData); /* cc warning */
	jx9_value_int(pVal, 1);
}
Esempio n. 28
0
/*
 * PATHINFO_EXTENSION
 *  Expand 3.
 */
static void JX9_PATHINFO_EXTENSION_Const(jx9_value *pVal, void *pUserData)
{
	SXUNUSED(pUserData); /* cc warning */
	jx9_value_int(pVal, 3);
}
Esempio n. 29
0
/*
 * JX9_QUERY_RFC3986
 * Expand 1
 */
static void JX9_JX9_QUERY_RFC3986_Const(jx9_value *pVal, void *pUserData)
{
	SXUNUSED(pUserData); /* cc warning */
	jx9_value_int(pVal, 2);
}
Esempio n. 30
0
/*
 * HTML_SPECIALCHARS
 *  Expand 2
 */
static void JX9_HTML_SPECIALCHARS_Const(jx9_value *pVal, void *pUserData)
{
	SXUNUSED(pUserData); /* cc warning */
	jx9_value_int(pVal, 2);
}