Esempio n. 1
0
void DispRec(int total, FILE *fp)
{
	int i, x, y;
	unsigned long size = 0;
	struct ffblk pinfo, temp;
	struct _DATE *date;

	for (x = 0; x < total - 1; ++x) {
		for (y = 0; y < total - x - 1; ++y) {
			GetRec(y, &pinfo);
			GetRec((y + 1), &temp);
			if (stricmp(pinfo.ff_name, temp.ff_name) > 0)
				SwapRec(y + 1, y);
		}
	}

	for (i = 0; i < total; i++) {
		fseek(fp, i * sizeof(struct ffblk), SEEK_SET);
		fread(&pinfo, sizeof(struct ffblk), 1, fp);
		date = (struct _DATE*) &pinfo.ff_fdate;
		printf("%-13s %10ld ", pinfo.ff_name, pinfo.ff_fsize);
		printf("%02d/%02d/%02d\n", date->day, date->month, date->year + 1980);
		size += pinfo.ff_fsize;
	}
	printf("%d dosya  %lu Byte listelendi..\n", total, size);
}
Esempio n. 2
0
emUInt64 emRecFileModel::CalcMemoryNeed()
{
	emUInt64 fileSize;

	// Problem: GetRec().CalcRecMemNeed() is too costly for calling
	// it after each step of reading. Therefore, when reading, we
	// call it on certain read steps only.
	if (Reader && ReadStep) {
		if (ReadStepOfMemCalc<=ReadStep) {
			MemoryNeed=GetRec().CalcRecMemNeed();
			fileSize=Reader->GetFileSize();
			if (fileSize>MemoryNeed) {
				MemoryNeed=fileSize;
				MemoryNeedOutOfDate=true; // Because it's an estimation.
			}
			else {
				MemoryNeedOutOfDate=false;
			}
			ReadStepOfMemCalc=ReadStep+(ReadStep+3)/4;
		}
	}
	else if (MemoryNeedOutOfDate) {
		MemoryNeed=GetRec().CalcRecMemNeed();
		MemoryNeedOutOfDate=false;
	}
	return MemoryNeed;
}
Esempio n. 3
0
void emConfigModel::TryLoad() throw(emString)
{
	GetRec().TryLoad(InstallPath);
	if (Unsaved) {
		Unsaved=false;
		Signal(ChangeSignal);
	}
}
Esempio n. 4
0
bool CDBCmd::GetRec(int fieldno, int& n)
{
	char* ret = GetRec(fieldno);
	if (ret == NULL)
		return false;

	n = atoi(ret);
	return true;
}
Esempio n. 5
0
bool CDBCmd::GetRec(int fieldno, unsigned short& n)
{
	int t;
	if (!GetRec(fieldno, t))
		return false;

	n = (unsigned short)t;
	return true;
}
Esempio n. 6
0
bool CDBCmd::GetRec(int fieldno, unsigned char& ch)
{
	int t;
	if (!GetRec(fieldno, t))
		return false;

	ch = (unsigned char)t;
	return true;
}
Esempio n. 7
0
bool CDBCmd::GetRec(int fieldno, float& f)
{
	char* ret = GetRec(fieldno);
	if (ret == NULL)
		return false;

	f = (float)atof(ret);
	return true;
}
Esempio n. 8
0
bool CDBCmd::GetRec(int fieldno, LONGLONG& ll)
{
	char* ret = GetRec(fieldno);
	if (ret == NULL)
		return false;

	ll = ATOLL(ret);
	return true;
}
Esempio n. 9
0
void emConfigModel::TrySave(bool force) throw(emString)
{
	if (Unsaved || force) {
		GetRec().TrySave(InstallPath);
		if (Unsaved) {
			Unsaved=false;
			Signal(ChangeSignal);
		}
	}
}
Esempio n. 10
0
//********************************************************************************************************************
//get the Timestamp at the specified position
//********************************************************************************************************************
ierr TimeBuf::GetTimeStamp(int64& TimeStamp, const unsigned int AtPos)
{
	__int8* lpRec;
	int Ret;

	Ret = GetRec((void**)(&lpRec), AtPos);
	if (Ret != NLX_OK) { return(Ret); }

	TimeStamp = *( (int64*)( &(lpRec[TimestampOffsetBytes]) ) );

	return(NLX_OK);
}
Esempio n. 11
0
void emRecFileModel::TryStartSaving() throw(emString)
{
	ProtectFileState++;
	Writer=new emRecFileWriter;
	try {
		Writer->TryStartWriting(GetRec(),GetFilePath());
	}
	catch (emString errorMessage) {
		ProtectFileState--;
		throw errorMessage;
	}
	ProtectFileState--;
}
Esempio n. 12
0
void TRecSet::FilterBy(const TFilter& Filter) {
    // prepare an empty key-dat vector for storing records that pass the filter
    const int Recs = GetRecs();
    TUInt64IntKdV NewRecIdFqV(Recs, 0);
    for (int RecN = 0; RecN < Recs; RecN++) {
        const TUInt64IntKd& RecIdFq = RecIdFqV[RecN];
        const TRec Rec = GetRec(RecN);
        // check the filter
        if (Filter.Filter(Rec)) { NewRecIdFqV.Add(RecIdFq); }
    }
    // overwrite old result vector with filtered list
    RecIdFqV = NewRecIdFqV;
}
Esempio n. 13
0
void emRecFileModel::TryStartLoading() throw(emString)
{
	ProtectFileState++;
	Reader=new emRecFileReader;
	try {
		Reader->TryStartReading(GetRec(),GetFilePath());
	}
	catch (emString errorMessage) {
		ProtectFileState--;
		throw errorMessage;
	}
	ProtectFileState--;
	ReadStep=1;
	ReadStepOfMemCalc=1;
}
Esempio n. 14
0
void emConfigModel::TryLoadOrInstall(const char * insSrcPath) throw(emString)
{
	if (emIsExistingPath(InstallPath)) {
		TryLoad();
	}
	else {
		emTryMakeDirectories(emGetParentPath(InstallPath));
		if (insSrcPath) {
			emTryCopyFileOrTree(InstallPath,insSrcPath);
			TryLoad();
		}
		else {
			GetRec().SetToDefault();
			TrySave(true);
		}
	}
}
Esempio n. 15
0
bool CDBCmd::GetRec(const char* fieldname, unsigned char& ch)
{
	return GetRec(FindField(fieldname), ch);
}
Esempio n. 16
0
static Bool
PreInit(ScrnInfoPtr pScrn, int flags)
{
    modesettingPtr ms;
    rgb defaultWeight = { 0, 0, 0 };
    EntityInfoPtr pEnt;
    EntPtr msEnt = NULL;
    char *BusID = NULL;
    const char *devicename;
    Bool prefer_shadow = TRUE;
    uint64_t value = 0;
    int ret;
    int bppflags;
    int defaultdepth, defaultbpp;

    if (pScrn->numEntities != 1)
	return FALSE;

    pEnt = xf86GetEntityInfo(pScrn->entityList[0]);

    if (flags & PROBE_DETECT) {
	return FALSE;
    }

    /* Allocate driverPrivate */
    if (!GetRec(pScrn))
	return FALSE;

    ms = modesettingPTR(pScrn);
    ms->SaveGeneration = -1;
    ms->pEnt = pEnt;

    pScrn->displayWidth = 640;	       /* default it */

    /* Allocate an entity private if necessary */
    if (xf86IsEntityShared(pScrn->entityList[0])) {
	msEnt = xf86GetEntityPrivate(pScrn->entityList[0],
				     modesettingEntityIndex)->ptr;
	ms->entityPrivate = msEnt;
    } else
	ms->entityPrivate = NULL;

    if (xf86IsEntityShared(pScrn->entityList[0])) {
	if (xf86IsPrimInitDone(pScrn->entityList[0])) {
	    /* do something */
	} else {
	    xf86SetPrimInitDone(pScrn->entityList[0]);
	}
    }

    pScrn->monitor = pScrn->confScreen->monitor;
    pScrn->progClock = TRUE;
    pScrn->rgbBits = 8;

#if XSERVER_PLATFORM_BUS
    if (pEnt->location.type == BUS_PLATFORM) {
#ifdef XF86_PDEV_SERVER_FD
        if (pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD)
            ms->fd = xf86_get_platform_device_int_attrib(pEnt->location.id.plat, ODEV_ATTRIB_FD, -1);
        else
#endif
        {
            char *path = xf86_get_platform_device_attrib(pEnt->location.id.plat, ODEV_ATTRIB_PATH);
            ms->fd = open_hw(path);
        }
    }
    else 
#endif
    if (pEnt->location.type == BUS_PCI) {
        ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index);
        if (ms->PciInfo) {
            BusID = malloc(64);
            sprintf(BusID, "PCI:%d:%d:%d",
#if XSERVER_LIBPCIACCESS
                    ((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
                    ms->PciInfo->dev, ms->PciInfo->func
#else
                    ((pciConfigPtr) ms->PciInfo->thisCard)->busnum,
                    ((pciConfigPtr) ms->PciInfo->thisCard)->devnum,
                    ((pciConfigPtr) ms->PciInfo->thisCard)->funcnum
#endif
                );
        }
        ms->fd = drmOpen(NULL, BusID);
    } else {
        devicename = xf86FindOptionValue(ms->pEnt->device->options, "kmsdev");
        ms->fd = open_hw(devicename);
    }
    if (ms->fd < 0)
	return FALSE;

    ms->drmmode.fd = ms->fd;

#ifdef MODESETTING_OUTPUT_SLAVE_SUPPORT
    pScrn->capabilities = 0;
#ifdef DRM_CAP_PRIME
    ret = drmGetCap(ms->fd, DRM_CAP_PRIME, &value);
    if (ret == 0) {
        if (value & DRM_PRIME_CAP_IMPORT)
            pScrn->capabilities |= RR_Capability_SinkOutput;
    }
#endif
#endif
    drmmode_get_default_bpp(pScrn, &ms->drmmode, &defaultdepth, &defaultbpp);
    if (defaultdepth == 24 && defaultbpp == 24)
	    bppflags = SupportConvert32to24 | Support24bppFb;
    else
	    bppflags = PreferConvert24to32 | SupportConvert24to32 | Support32bppFb;
    
    if (!xf86SetDepthBpp
	(pScrn, defaultdepth, defaultdepth, defaultbpp, bppflags))
	return FALSE;

    switch (pScrn->depth) {
    case 15:
    case 16:
    case 24:
	break;
    default:
	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
		   "Given depth (%d) is not supported by the driver\n",
		   pScrn->depth);
	return FALSE;
    }
    xf86PrintDepthBpp(pScrn);

    /* Process the options */
    xf86CollectOptions(pScrn, NULL);
    if (!(ms->Options = malloc(sizeof(Options))))
	return FALSE;
    memcpy(ms->Options, Options, sizeof(Options));
    xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options);

    if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight))
	return FALSE;
    if (!xf86SetDefaultVisual(pScrn, -1))
	return FALSE;

    if (xf86ReturnOptValBool(ms->Options, OPTION_SW_CURSOR, FALSE)) {
	ms->drmmode.sw_cursor = TRUE;
    }

    ret = drmGetCap(ms->fd, DRM_CAP_DUMB_PREFER_SHADOW, &value);
    if (!ret) {
	prefer_shadow = !!value;
    }

    ms->cursor_width = 64;
    ms->cursor_height = 64;
    ret = drmGetCap(ms->fd, DRM_CAP_CURSOR_WIDTH, &value);
    if (!ret) {
	ms->cursor_width = value;
    }
    ret = drmGetCap(ms->fd, DRM_CAP_CURSOR_HEIGHT, &value);
    if (!ret) {
	ms->cursor_height = value;
    }

    ms->drmmode.shadow_enable = xf86ReturnOptValBool(ms->Options, OPTION_SHADOW_FB, prefer_shadow);

    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ShadowFB: preferred %s, enabled %s\n", prefer_shadow ? "YES" : "NO", ms->drmmode.shadow_enable ? "YES" : "NO");
    if (drmmode_pre_init(pScrn, &ms->drmmode, pScrn->bitsPerPixel / 8) == FALSE) {
	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS setup failed\n");
	goto fail;
    }

    /*
     * If the driver can do gamma correction, it should call xf86SetGamma() here.
     */
    {
	Gamma zeros = { 0.0, 0.0, 0.0 };

	if (!xf86SetGamma(pScrn, zeros)) {
	    return FALSE;
	}
    }

    if (pScrn->modes == NULL) {
	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n");
	return FALSE;
    }

    pScrn->currentMode = pScrn->modes;

    /* Set display resolution */
    xf86SetDpi(pScrn, 0, 0);

    /* Load the required sub modules */
    if (!xf86LoadSubModule(pScrn, "fb")) {
	return FALSE;
    }

    if (ms->drmmode.shadow_enable) {
	if (!xf86LoadSubModule(pScrn, "shadow")) {
	    return FALSE;
	}
    }

    return TRUE;
    fail:
    return FALSE;
}
Esempio n. 17
0
char* CDBCmd::GetRec(const char* fieldname)
{
	return GetRec(FindField(fieldname));
}
Esempio n. 18
0
bool CDBCmd::GetRec(int fieldno, CLCString& str, bool bTrim)
{
	// 데이터 읽기
	char* ret = GetRec(fieldno);

	// NULL이면 오류
	if (ret == NULL)
		return false;

	char* p = ret;

	// left trim 처리
	if (bTrim)
	{
		while (*p && isspace(*p))
			p++;
	}

	// 시작 포인트 설정
	char* pStart = p;

	// 시작 포인트 이후 길이가 1보다 작으면
	if (strlen(pStart) < 1)
	{
		str = "";
		return true;
	}

	// 끝 포인트 설정(NULL 앞자리)
	char* pEnd = pStart + strlen(pStart) - 1;

	// right trim 처리
	if (bTrim)
	{
		while (pEnd >= pStart)
		{
			if (isspace(*pEnd))
				pEnd--;
			else
				break;
	}
	}

	// trim에 의해 길이가 0가 되면 리턴
	if (pEnd < pStart)
	{
		str = "";
		return true;
	}

	// 여기에 오면 pStart에서 pEnd까지 문자를 복사하면 됨
	int len = pEnd - pStart + 2;	// 결과 문자열 길이 (NULL 포함)

	// 출력 버퍼의 크기와 비교 작은 것을 택함
	if (len > str.BufferSize())
		len = str.BufferSize();

	char* tmp = new char[len];
	memcpy(tmp, pStart, len - 1);
	tmp[len - 1] = '\0';
	str = tmp;
	delete [] tmp;

	return true;
}
Esempio n. 19
0
void emRecFileModel::ResetData()
{
	ProtectFileState++;
	GetRec().SetToDefault();
	ProtectFileState--;
}
Esempio n. 20
0
bool CDBCmd::GetRec(const char* fieldname, LONGLONG& ll)
{
	return GetRec(FindField(fieldname), ll);
}
Esempio n. 21
0
bool CDBCmd::GetRec(const char* fieldname, float& f)
{
	return GetRec(FindField(fieldname), f);
}
Esempio n. 22
0
bool CDBCmd::GetRec(const char* fieldname, CLCString& str, bool bTrim)
{
	return GetRec(FindField(fieldname), str, bTrim);
}
static Bool
TegraPreInit(ScrnInfoPtr pScrn, int flags)
{
    TegraPtr tegra;
    rgb defaultWeight = { 0, 0, 0 };
    EntityInfoPtr pEnt;
    EntPtr tegraEnt = NULL;
    Bool prefer_shadow = TRUE;
    uint64_t value = 0;
    int ret;
    int bppflags;
    int defaultdepth, defaultbpp;
    Gamma zeros = { 0.0, 0.0, 0.0 };
    const char *path;

    if (pScrn->numEntities != 1)
        return FALSE;

    pEnt = xf86GetEntityInfo(pScrn->entityList[0]);

    if (flags & PROBE_DETECT)
        return FALSE;

    /* Allocate driverPrivate */
    if (!GetRec(pScrn))
        return FALSE;

    tegra = TegraPTR(pScrn);
    tegra->pEnt = pEnt;

    pScrn->displayWidth = 640; /* default it */

    /* Allocate an entity private if necessary */
    if (xf86IsEntityShared(pScrn->entityList[0])) {
        tegraEnt = xf86GetEntityPrivate(pScrn->entityList[0],
                                        tegraEntityIndex)->ptr;
        tegra->entityPrivate = tegraEnt;
    } else
        tegra->entityPrivate = NULL;

    if (xf86IsEntityShared(pScrn->entityList[0])) {
        if (xf86IsPrimInitDone(pScrn->entityList[0])) {
            /* do something */
        } else {
            xf86SetPrimInitDone(pScrn->entityList[0]);
        }
    }

    pScrn->monitor = pScrn->confScreen->monitor;
    pScrn->progClock = TRUE;
    pScrn->rgbBits = 8;

    switch (pEnt->location.type) {
#ifdef XSERVER_PLATFORM_BUS
    case BUS_PLATFORM:
        path = xf86_get_platform_device_attrib(pEnt->location.id.plat,
                                               ODEV_ATTRIB_PATH);
        break;
#endif

    default:
        path = xf86GetOptValString(tegra->pEnt->device->options,
                                   OPTION_DEVICE_PATH);
        break;
    }

    tegra->fd = TegraOpenHardware(path);
    if (tegra->fd < 0)
        return FALSE;

    tegra->drmmode.fd = tegra->fd;

#ifdef TEGRA_OUTPUT_SLAVE_SUPPORT
    pScrn->capabilities = 0;
#ifdef DRM_CAP_PRIME
    ret = drmGetCap(tegra->fd, DRM_CAP_PRIME, &value);
    if (ret == 0) {
        if (value & DRM_PRIME_CAP_IMPORT)
            pScrn->capabilities |= RR_Capability_SinkOutput;
    }
#endif
#endif
    drmmode_get_default_bpp(pScrn, &tegra->drmmode, &defaultdepth, &defaultbpp);
    if (defaultdepth == 24 && defaultbpp == 24)
        bppflags = Support24bppFb;
    else
        bppflags = PreferConvert24to32 | SupportConvert24to32 | Support32bppFb;

    if (!xf86SetDepthBpp(pScrn, defaultdepth, defaultdepth, defaultbpp,
                         bppflags))
        return FALSE;

    switch (pScrn->depth) {
    case 15:
    case 16:
    case 24:
        break;

    default:
        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                   "Given depth (%d) is not supported by the driver\n",
                   pScrn->depth);
        return FALSE;
    }

    xf86PrintDepthBpp(pScrn);

    /* Process the options */
    xf86CollectOptions(pScrn, NULL);

    tegra->Options = malloc(sizeof(Options));
    if (!tegra->Options)
        return FALSE;

    memcpy(tegra->Options, Options, sizeof(Options));
    xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, tegra->Options);

    if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight))
        return FALSE;

    if (!xf86SetDefaultVisual(pScrn, -1))
        return FALSE;

    if (xf86ReturnOptValBool(tegra->Options, OPTION_SW_CURSOR, FALSE))
        tegra->drmmode.want_sw_cursor = TRUE;

    ret = drmGetCap(tegra->fd, DRM_CAP_DUMB_PREFER_SHADOW, &value);
    if (!ret)
        prefer_shadow = !!value;

    tegra->drmmode.shadow_enable = xf86ReturnOptValBool(tegra->Options,
                                                        OPTION_SHADOW_FB,
                                                        prefer_shadow);

    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
               "ShadowFB: preferred %s, enabled %s\n",
               prefer_shadow ? "YES" : "NO",
               tegra->drmmode.shadow_enable ? "YES" : "NO");

    if (!drmmode_pre_init(pScrn, &tegra->drmmode, pScrn->bitsPerPixel / 8)) {
        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS setup failed\n");
        return FALSE;
    }

    if (tegra->drmmode.need_sw_cursor)
        tegra->drmmode.want_sw_cursor = TRUE;

    /*
     * If the driver can do gamma correction, it should call xf86SetGamma() here.
     */
    if (!xf86SetGamma(pScrn, zeros))
        return FALSE;

    if (pScrn->modes == NULL) {
        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n");
        return FALSE;
    }

    pScrn->currentMode = pScrn->modes;

    /* Set display resolution */
    xf86SetDpi(pScrn, 0, 0);

    /* Load the required sub modules */
    if (!xf86LoadSubModule(pScrn, "fb"))
        return FALSE;

    if (tegra->drmmode.shadow_enable) {
        if (!xf86LoadSubModule(pScrn, "shadow"))
            return FALSE;
    }

    return TRUE;
}
Esempio n. 24
0
bool CDBCmd::GetRec(const char* fieldname, unsigned short& n)
{
	return GetRec(FindField(fieldname), n);
}
Esempio n. 25
0
bool CDBCmd::GetRec(const char* fieldname, int& n)
{
	return GetRec(FindField(fieldname), n);
}