Exemplo n.º 1
0
static double get_log_time()
{
    static double origin = 0;
    double time;
    time = sys_get_time();
    if (!origin) origin = time;
    return time - origin;
}
Exemplo n.º 2
0
int xtime_get(xtime *xt, int type)
	{	/* get current time */
	if (type != TIME_UTC || xt == 0)
		type = 0;
	else
		sys_get_time(xt);
	return (type);
	}
Exemplo n.º 3
0
int sys_get_datetime_string (
  int string_size,
  char *string
) {

SYS_TIME_TYPE tim;
int stat;

  stat = sys_get_time( &tim );
  strncpy( string, ctime( &tim.cal_time ), string_size );
  string[strlen(string)-1] = 0;

  return 1;

}
Exemplo n.º 4
0
/*
=================
engine_frame
=================
*/
erbool engine_frame (void)
{
    if (engine_quit_flag)
        return false;

    sys_get_time();

    snd_frame();
    r_frame();
    video_frame();
    g_frame();
    cmdbuf_frame();

    return true;
}
Exemplo n.º 5
0
/*
=================
engine_start
=================
*/
erbool engine_start (void)
{
    init_time();
    sys_get_time();

    INIT(cvar);
    INIT(cmd);
    INIT(cmdbuf);

    cmd_register("quit", NULL, &quit_f, 0);
    cmd_register("echo", NULL, &echo_f, 0);

    INIT(fs);
    INIT(keyboard);

    cmdbuf_add("exec config.cfg\n", CMD_SRC_ENGINE);
    cmdbuf_frame();

    INIT(mouse);
    INIT(image);
    INIT(video);
    INIT(gl);
    INIT(r);
    INIT(snd);
    INIT(g);

    cmdbuf_add("exec autoexec.cfg\n", CMD_SRC_ENGINE);
    cmdbuf_frame();

    /*
      put sys args into cmdbuf (which begin with '+')
      once again (after all cmds like 'map' were registered)
    */
    sys_arg_to_cmdbuf('+');
    cmdbuf_frame();

    return true;

error:

    engine_stop();

    return false;
}
Exemplo n.º 6
0
int sys_cvt_string_to_time (
  char *string,
  int string_size,
  SYS_TIME_PTR time
) {

char *tk, buf[255+1];
int stat, year;

  /* convert "day-month-year hour:min:sec" into machine time */

  /* get current time */
  stat = sys_get_time( time );
  if ( !( stat & 1 ) ) return stat;

  /* zero time fields */
  time->tm_time.tm_hour = 0;
  time->tm_time.tm_min = 0;
  time->tm_time.tm_sec = 0;

  /* parse string

       The date may be ommitted but if it is specified, all fields must
       be included

       The time may be ommitted or seconds may be ommitted or minutes:seconds
       may be ommitted

       The following are examples of legal strings:

       jan-1-2000
       jan-1-2000 3
       jan-1-2000 3:01
       jan-1-2000 3:12
       jan-1-2000 3:01:01
       jan-1-2000 3:12:01
       jan-1-2000 3:12:12
       3
       3:01
       3:12
       3:01:01
       3:12:01
       3:12:12

  */

  strncpy( buf, string, 255 );
  buf[255] = 0;

  tk = strtok( buf, " \t\n-:" );
  if ( !tk ) return SYS_FAIL;

  /* tk is either a month abbreviation or and integer */

  if ( isInteger( tk ) ) {

    /* date has been ommitted, get time fields */

    time->tm_time.tm_hour = atol( tk );

    tk = strtok( NULL, ": \t\n" );
    if ( !tk ) goto done; /* time fields may be ommitted */
    if ( !isInteger( tk ) ) return SYS_FAIL;
    time->tm_time.tm_min = atol( tk );

    tk = strtok( NULL, ": \t\n" );
    if ( !tk ) goto done; /* time fields may be ommitted */
    if ( !isInteger( tk ) ) return SYS_FAIL;
    time->tm_time.tm_sec = atol( tk );

  }
  else {

    /* tk should be a month abbreviation */

    /* date */
    stat = getMonth( tk, strlen(tk), &time->tm_time.tm_mon );
    if ( !( stat & 1 ) ) return SYS_FAIL;

    tk = strtok( NULL, "-" );
    if ( !tk ) return SYS_FAIL; /* date must be wholey specified */
    if ( !isInteger( tk ) ) return SYS_FAIL;
    time->tm_time.tm_mday = atol( tk );

    tk = strtok( NULL, " \t\n" );
    if ( !tk ) return SYS_FAIL; /* date must be wholey specified */
    if ( !isInteger( tk ) ) return SYS_FAIL;
    year = atol( tk );
    if ( year < 70 ) year += 2000;
    time->tm_time.tm_year =  year - 1900;

    /* time */
    tk = strtok( NULL, ": \t\n" );
    if ( !tk ) goto done; /* time fields may be ommitted */
    if ( !isInteger( tk ) ) return SYS_FAIL;
    time->tm_time.tm_hour = atol( tk );

    tk = strtok( NULL, ": \t\n" );
    if ( !tk ) goto done; /* time fields may be ommitted */
    if ( !isInteger( tk ) ) return SYS_FAIL;
    time->tm_time.tm_min = atol( tk );

    tk = strtok( NULL, ": \t\n" );
    if ( !tk ) goto done; /* time fields may be ommitted */
    if ( !isInteger( tk ) ) return SYS_FAIL;
    time->tm_time.tm_sec = atol( tk );

  }

done:

  time->cal_time = mktime( &time->tm_time );
  if ( time->cal_time == -1 ) return SYS_FAIL;

  return 1;

}
Exemplo n.º 7
0
/*
=================
mem_alloc_real
=================
*/
void *mem_alloc_real (mem_pool_t  pool,
                      uint32_t    size
#ifdef ENGINE_MEM_DEBUG
                      ,
                      const char *file,
                      const char *func,
                      int         line
#endif /* ENGINE_MEM_DEBUG */
    )
{
    uint32_t real;
    pool_t  *p = pool;
    alloc_t *a;

    if (NULL == p)
    {
#ifndef ENGINE_MEM_DEBUG
        sys_printf("NULL pool\n");
#else /* ENGINE_MEM_DEBUG */
        sys_printf("NULL pool (%s - %s:%i)\n", func, file, line);
#endif /* !ENGINE_MEM_DEBUG */
        return NULL;
    }

    if (SEN1_POOL != p->sen1)
    {
        p->name[sizeof(p->name) - 1] = 0;
        sys_printf("broken pool \"%s\" (%p)\n", p->name, p);
#ifdef ENGINE_MEM_DEBUG
        sys_printf("pool was allocated at %s - %s:%i\n", p->func, p->file, p->line);
#endif /* ENGINE_MEM_DEBUG */
        return NULL;
    }

    if (p->size_max && p->size_max < p->size + size)
    {
        sys_printf("pool \"%s\" overflow (%i bytes alloc failed)\n", p->name, size);
#ifdef ENGINE_MEM_DEBUG
        sys_printf("alloc was at %s - %s:%i\n", func, file, line);
#endif /* ENGINE_MEM_DEBUG */
        return NULL;
    }

    real = sizeof(*a) + size + sizeof(uint32_t);

    if (NULL == (a = malloc(real)))
    {
        sys_printf("failed to allocate %i bytes\n", real);
#ifdef ENGINE_MEM_DEBUG
        sys_printf("alloc was at %s - %s:%i\n", func, file, line);
#endif /* ENGINE_MEM_DEBUG */
        return NULL;
    }

    memset(a, 0, real);

    p->size      += size;
    p->size_real += real;

    a->sen1 = SEN1_ALLOC;
    a->size = size;
    a->pool = p;

#ifdef ENGINE_MEM_DEBUG
    a->file = file;
    a->func = func;
    a->line = line;
    a->time = sys_get_time();
#endif /* ENGINE_MEM_DEBUG */

    *((uint32_t *)(a->data + size)) = SEN2_ALLOC;

    if (NULL != p->allocs)
    {
        p->allocs->prev = a;
        a->next = p->allocs;
    }

    p->allocs = a;

    return a->data;
}