예제 #1
0
static void timeinfo(t_bnettime bnt)
{
    time_t  t;
    char    out[1024];
    bn_long num;
    
    bnettime_to_bn_long(bnt,&num);
    t = bnettime_to_time(bnt);
    strftime(out,sizeof(out),"%Y %b %d %H:%M:%S",localtime(&t));
    printf("%20s  %g   u:0x%08x l:0x%08x\n",out,(double)t,bn_long_get_a(num),bn_long_get_b(num));
}
예제 #2
0
파일: file.cpp 프로젝트: DizKragnet/pvpgn
static char const * file_get_info(char const * rawname, unsigned int * len, bn_long * modtime)
{
    char *filename;
    t_bnettime   bt;
    struct stat sfile;

    if (!rawname) {
	eventlog(eventlog_level_error,__FUNCTION__,"got NULL rawname");
	return NULL;
    }

    if (!len) {
	eventlog(eventlog_level_error,__FUNCTION__,"got NULL len");
	return NULL;
    }

    if (!modtime) {
	eventlog(eventlog_level_error,__FUNCTION__,"got NULL modtime");
	return NULL;
    }

    if (std::strchr(rawname,'/') || std::strchr(rawname,'\\')) {
	eventlog(eventlog_level_warn,__FUNCTION__,"got rawname containing '/' or '\\' \"%s\"",rawname);
	return NULL;
    }

    filename = buildpath(prefs_get_filedir(), rawname);

    if (stat(filename, &sfile)<0) { /* if it doesn't exist, try to replace with default file */
	xfree((void*)filename);
	filename = file_find_default(rawname);
	if (!filename) return NULL; /* no default version */

	if (stat(filename, &sfile)<0) { /* try again */
	    /* FIXME: check for lower-case version of filename */
	    xfree(filename);
	    return NULL;
	}
    }

    *len = (unsigned int)sfile.st_size;
    bt = time_to_bnettime(sfile.st_mtime,0);
    bnettime_to_bn_long(bt,modtime);

    return filename;
}
예제 #3
0
파일: file.cpp 프로젝트: Grief-Code/pvpgn
		static char const * file_get_info(char const * rawname, unsigned int * len, bn_long * modtime)
		{
			const char *filename;
			t_bnettime   bt;
			struct stat sfile;

			if (!rawname) {
				eventlog(eventlog_level_error, __FUNCTION__, "got NULL rawname");
				return NULL;
			}

			if (!len) {
				eventlog(eventlog_level_error, __FUNCTION__, "got NULL len");
				return NULL;
			}

			if (!modtime) {
				eventlog(eventlog_level_error, __FUNCTION__, "got NULL modtime");
				return NULL;
			}

			if (std::strchr(rawname, '/') || std::strchr(rawname, '\\')) {
				eventlog(eventlog_level_warn, __FUNCTION__, "got rawname containing '/' or '\\' \"%s\"", rawname);
				return NULL;
			}


			filename = file_find_localized(rawname);
			// if localized file not found in "i18n"
			if (!filename || stat(filename, &sfile) < 0)
			{
				// try find it in "files"
				filename = buildpath(prefs_get_filedir(), rawname);
				if (stat(filename, &sfile) < 0) { /* try again */
					/* FIXME: check for lower-case version of filename */
					return NULL;
				}
			}

			*len = (unsigned int)sfile.st_size;
			bt = time_to_bnettime(sfile.st_mtime, 0);
			bnettime_to_bn_long(bt, modtime);

			return filename;
		}