Ejemplo n.º 1
0
/////////////////////////////////
//           TIME
/////////////////////////////////
TIME os_time_convert(time_t t)
{
	TIME ret;

	struct tm *nt;

	os_lock_lock(timelock);
	nt = localtime(&t);
/*
             struct tm {
                      int     tm_sec;          seconds 
                      int     tm_min;          minutes 
                      int     tm_hour;         hours 
                      int     tm_mday;         day of the month 
                      int     tm_mon;          month 
                      int     tm_year;         year 
                      int     tm_wday;         day of the week 
                      int     tm_yday;         day in the year 
                      int     tm_isdst;        daylight saving time 
              };

*/	

	ret.year = nt->tm_year + 1900;
	ret.month = nt->tm_mon + 1;
	ret.day = nt->tm_mday;
	ret.hour = nt->tm_hour;
	ret.minute = nt->tm_min;
	ret.second = nt->tm_sec;
	os_lock_unlock(timelock);

	return ret;

}
Ejemplo n.º 2
0
VOID *os_malloc(INT size)
{
	VOID *p;

	if(malloclock)
		os_lock_lock(malloclock);

	malloc_count ++;
	p = malloc(size);
	memset(p, 0, size);

	if(malloclock)
		os_lock_unlock(malloclock);

	//dprintf("malloc    count = %d\n", malloc_count);

	return p;
}
Ejemplo n.º 3
0
VOID setting_write(CHAR *filename, CHAR *key, CHAR *value)
{
	STRING *str;
	CHAR *tmpbuf;
	CHAR *pkey;
	CHAR *p;

	os_lock_lock(settinglock);	


	tmpbuf = setting_load_file(filename);
	str = string_new(tmpbuf);

	pkey = setting_find_key(tmpbuf, key, NULL);

	if(pkey != NULL)
	{
		string_truncate(str, pkey - tmpbuf);
		str = string_append(str, key);
		str = string_append(str, "=");
		str = string_append(str, value);
		str = string_append(str, "\r\n");

		p = strstr(pkey, "\n");
		if(p)
			str = string_append(str, p + 2);
		else
			str = string_append(str, "\n\n");
	}
	else
	{
		str = string_append(str, key);
		str = string_append(str, "=");
		str = string_append(str, value);
		str = string_append(str, "\r\n");
	}

	os_free(tmpbuf);

	setting_save_file(filename, str->str);
	string_free(str);
	
	os_lock_unlock(settinglock);
}
Ejemplo n.º 4
0
void DPRINTF(char *fmt, ...)
{
	
    char tmp[1024*10];
	va_list ap;

	

	if(debuglock) os_lock_lock(debuglock);
    
    va_start(ap, fmt);
    _vsnprintf(tmp, sizeof(tmp), fmt, ap);
    va_end(ap);

	OutputDebugStringA(tmp);
	//printf("%s", tmp);
	if(debuglock) os_lock_unlock(debuglock);

}
Ejemplo n.º 5
0
VOID *os_free_ex(VOID *p)
{
	if(!p) return NULL;

	if(p == malloclock) malloclock = NULL;

	if(malloclock)
		os_lock_lock(malloclock);

	malloc_count --;
	free(p);


	if(malloclock)
		os_lock_unlock(malloclock);

	//dprintf("free      count = %d\n", malloc_count);

	return NULL;
}
Ejemplo n.º 6
0
STRING *setting_read(CHAR *filename, CHAR *key, CHAR *def)
{
	
	STRING *str;
	CHAR *tmpbuf;
	CHAR *pvalue;

	os_lock_lock(settinglock);
	
	str = string_new(def);

	tmpbuf = setting_load_file(filename);

	setting_find_key(tmpbuf, key, &pvalue);
	setting_get_key_value(pvalue, str);

	os_free(tmpbuf);

	os_lock_unlock(settinglock);
	return str;
}