Example #1
0
float CIniFile::GetFloat(CString Section, CString Item, float Value)
{
	CString strtemp;
	strtemp.Format(_T("%f"),Value);
	strtemp = GetFileString(Section, Item, strtemp);
	return  _ttof(strtemp);
}
Example #2
0
int CIniFile::GetInt(CString Section, CString Item, int Value)
{
	int nValve;
	CString strtemp;
	strtemp.Format(_T("%d"),Value);
	strtemp = GetFileString(Section, Item, strtemp);
	return _ttoi(strtemp);
}
Example #3
0
void CAgentService::LoadVariable()
{
	VAROBJECT 	*pObject;
	ENVENTRY	env_t;
	char		szBuffer[100];
	long		addr=0;
	int			n;

	// Initialize Variable
	VARAPI_Initialize(VARCONF_FILENAME, m_Root_node, TRUE);

	GetLocalAddress(szBuffer);
	addr = inet_addr(szBuffer);
	pObject = VARAPI_GetObjectByName("ethIpAddr");
	if (pObject != NULL) memcpy(pObject->var.stream.p, &addr, sizeof(IPADDR));

	memset(&env_t, 0, sizeof(ENVENTRY));
	GetEnvInfo(env_t.envKernelVersion, env_t.envGccVersion, env_t.envCpuName, &env_t.envCpuMips);

	pObject = VARAPI_GetObjectByName("envKernelVersion");
	if (pObject != NULL) strcpy(pObject->var.stream.p, env_t.envKernelVersion);

	pObject = VARAPI_GetObjectByName("envGccVersion");
	if (pObject != NULL) strcpy(pObject->var.stream.p, env_t.envGccVersion);

	pObject = VARAPI_GetObjectByName("envCpuName");
	if (pObject != NULL) strcpy(pObject->var.stream.p, env_t.envCpuName);

	pObject = VARAPI_GetObjectByName("envCpuMips");
	if (pObject != NULL) pObject->var.stream.u32 = HostToLittleShort(env_t.envCpuMips);

    /** Rewriter(Q) : testmode가 무엇인지 확인해야 함 */
	GetFileValue("/app/conf/testmode", &n);
	m_bGprsPerfTestMode = (n > 0) ? TRUE : FALSE;

    if(GetFileString("/app/conf/mcusystype", szBuffer, sizeof(szBuffer), "OUTDOOR", TRUE)
            && strncasecmp(szBuffer,"INDOOR",strlen("INDOOR"))==0) {
        m_nSystemType = MCU_TYPE_INDOOR;
    }

    /*-- Pulse Meter Type을 읽어온다 --*/
    LoadSensorType();

    /*-- Patch 정보를 읽어온다 --*/
    LoadPatchList();

    /*-- Patch 5-1949 --*/
#if     defined(__PATCH_5_1949__)
    m_nDebugLevel &= (*m_pbPatch_5_1949 ? 0x00 : 0xFF);
#endif
    
}
BOOL CLauncherService::LoadSetting()
{
    FILE    *fp;

    fp = fopen(VARCONF_FILENAME, "rb");
    if (fp == NULL)
    {

        fp = fopen(VARCONF_OLD_FILENAME, "rb");
        if (fp == NULL)
        {
            system("rm -rf /app/data/*");
            system("rm -rf /app/sensor/*");
            system("rm -rf /app/member/*");
            system("rm -rf /app/log/*");

            SetFileValue("/app/conf/ethernet.type", ETHER_TYPE_PPP);
            SetFileValue("/app/conf/mobile.type", MOBILE_TYPE_GSM);
            SetFileValue("/app/conf/mobile.mode", MOBILE_MODE_CSD);
            SetFileString("/app/conf/server.addr", "0.0.0.0");    // Server address

        }
        else
        {
            fclose(fp);
        }
    }
    else
    {
        fclose(fp);
    }


    GetVersionString(fullVersionString);

    SetFileString("/app/conf/version", fullVersionString);
    GetFileValue("/app/conf/ethernet.type", &m_nEthernetType);
    GetFileValue("/app/conf/mobile.type", &m_nMobileType);
    GetFileValue("/app/conf/mobile.mode", &m_nMobileMode);
    GetFileValue("/app/conf/mobile.vendor", &m_nMobileVendor);
    GetFileString("/app/conf/server.addr", m_szServer, sizeof(m_szServer));
    GetFileValue("/app/conf/powertype.mcu", (int *)&m_nPowerType);

    /** Issue #109 
     *  Database 관련 정리를 위한 Script 실행 
     */
    system("/app/sw/script/RunAllTask.script 2> /dev/null");
    system("/app/sw/script/CheckTask.script & 2> /dev/null");

    return TRUE;
}
Example #5
0
TEST_FIXTURE(FileFixture, GetFileString_SetFileString)
{
    const char *size10 = "0123456789";
    const char *size10cr = "0123456789\r\n";
    const char *size120 = 
        "0123456789012345678901234567890123456789" 
        "0123456789012345678901234567890123456789"
        "0123456789012345678901234567890123456789";
    char buff[64];

    /** 정상적인 데이터 저장 */
    remove(validFile);
    CHECK_EQUAL(1, SetFileString(validFile, size10));
    CHECK_EQUAL(1, GetFileString(validFile, buff, sizeof(buff), size10, TRUE));
    CHECK_EQUAL(0, strcmp(size10, buff));

    /** 잘못된 파일에 저장 안되야 함 */
    CHECK_EQUAL(0, SetFileString(invalidFile, size10));
    CHECK_EQUAL(0, GetFileString(invalidFile, buff, sizeof(buff), size10, TRUE));

    /** 디렉토리에서 읽기가 실패해야 함  */
    CHECK_EQUAL(0, SetFileString(validDirectory, size10));
    CHECK_EQUAL(0, GetFileString(validDirectory, buff, sizeof(buff), size10, TRUE));

    /** \r, \n 이 있을 때 bClear가 TRUE 면 제거해줘야 한다 */
    remove(validFile);
    CHECK_EQUAL(1, SetFileString(validFile, size10cr));
    CHECK_EQUAL(1, GetFileString(validFile, buff, sizeof(buff), size10cr, TRUE));
    CHECK_EQUAL(0, strcmp(size10, buff));

    /** 너무 큰 데이터는 읽지 못해야 한다.
      * 큰 데이터를 쓸 수는 있지만 Buffer size 가 데이터 보다 작을 경우
      * 읽을 수 있는 만큼 읽고 0을 리턴해야 한다. */
    remove(validFile);
    CHECK_EQUAL(1, SetFileString(validFile, size120));
    CHECK_EQUAL(0, GetFileString(validFile, buff, sizeof(buff), NULL, TRUE));
    CHECK_EQUAL(0, strncmp(size120, buff, sizeof(buff) - 1));
}
BREditArguments::BREditArguments(int argc, char **argv)

// BREDIT can accept three different types of command lines:
//
// 1. BREDIT filename.  This is for general purpose editing (perhaps
//    from a //DOS prompt.  It assumes no WWIV handling of codes,
//    sysop mode, and enhanced editing.
//
// 2. BREDIT filename 80 25 200 [params]
//    where [params] is a space-delimited set of options (in any order):
//
//    S   Local Mode
//    D   Disables Enhanced mode
//    E   Disable built-in handling of enhanced mode
//    H   Disables BREDIT's built in extended ANSI handler
//

{
// Set up defaults

	ScreenLines=24;
	MaxColumns=80;
	AnonymousStatus=0;
	MaxLines=300;
	EnhancedMode=AUTO;
        DoEnhancedIO=0;
	WWIVColorChanges=(getenv("BBS")==NULL) ? 0 : 1;
	SysOpMode=0;
	EditFilename=NULL;
	strcpy(HelpFile, argv[0]);
	strcpy(strchr(HelpFile, '.'), ".HLP");
        if (argc==2)
        {
                SysOpMode=1;
                WWIVColorChanges=0;
                EditFilename=argv[1];
        }
        else if (argc > 4)
        {
		EditFilename=argv[1];
		MaxColumns=atoi(argv[2]);
		ScreenLines=atoi(argv[3])-1;
		MaxLines=atoi(argv[4]);

		int i;

		for(i=5;i<argc;i++) {
                        switch(toupper(argv[i][0]))
                        {
			case 'S':
				SysOpMode=1;
				EnhancedMode=ON;
                                DoEnhancedIO=1;
				break;
			case 'D':
				EnhancedMode=OFF;
				break;
			case 'E':
				EnhancedMode=ON;
				break;
			case 'H':
				DoEnhancedIO=0;
				break;
			}
		}
		FILE *stream;
		char s[81];

		TitleChangeable=0;
		EnableTag=1;
                if ((stream=fopen("EDITOR.INF", "rb"))!=NULL)
                {
			TitleChangeable=1;
			GetFileString(Title, stream);
			GetFileString(Destination, stream);
			if (strchr(Destination, '#'))
                        {
				EnableTag=0;
                        }
			GetFileString(s, stream); // User number
			GetFileString(s, stream); // User name
			GetFileString(s, stream); // User real name
			GetFileString(s, stream); // User SL

			if (atoi(s)==255)
                        {
				SysOpMode=1;
                        }
			GetFileString(s, stream);
			if (atoi(s)==1)
                        {
				EnableTag=0;
                        }
			fclose(stream);
		}
        }
        else
        {
		printf("\n\nBREdit - Full Screen Editor version %s\n\n"
					"Invalid parameters given\n\n"
                                        "BREDIT Filename [Columns Rows MaxLines [S D E H]]\n\n"
					"See BREDIT.DOC for more information on paramters.\n\n", VERSION);
		exit(1);
	}
}
Example #7
0
CString CIniFile::GetString(CString Section, CString Item, CString Value)
{
	return GetFileString(Section, Item, Value);
}
Example #8
0
	int fggets(TTCHAR* *ln, FILE *f, IN OUT bool& bOwnBuffer, IN const int nDefaultBufferSizeChars)
//	int fggets(CTemplateSmartPtrArray<TTCHAR>& spln, FILE *f, const int nDefaultBufferSizeChars)
{
   int		cursize, rdsize, nOldSize;
   TTCHAR	*buffer, *temp, *rdpoint, *crlocn;
	
	bOwnBuffer = false;

	ASSERT(*ln != NULL || nDefaultBufferSizeChars==0);

	// DP 24/06/2007: Allow default buffer to be passed in for reading. Avoids need for "new"s/"delete"s in 99% of cases
	if (nDefaultBufferSizeChars == 0 || *ln == NULL)
	{
		// DP 29/3/2006: Changed to use new
		buffer = new TTCHAR[INITSIZE];
		if (NULL == buffer)
			return FGGETS_NOMEM;

		// DP 24/06/2007: Signal that we own the buffer now
		bOwnBuffer = true;
	}
	else
	{
		buffer = *ln;
	}

   *ln = NULL; /* default */
//   if (NULL == (buffer = (char*)malloc(INITSIZE)))

	// DP 29/3/2006: Added oldsize variable
	// Initialise original size to default buffer size or INITSIZE, whichever applies
	cursize = rdsize = nOldSize = (nDefaultBufferSizeChars==0 ? INITSIZE:nDefaultBufferSizeChars);
   rdpoint = buffer;
   *buffer = '\0';

//   if (NULL == fgets(rdpoint, rdsize, f)) 
   if (NULL == GetFileString(rdpoint, rdsize, f)) 
	{
//      free(buffer);
		// DP 29/3/2006: Changed to use delete
		if (bOwnBuffer)
		{
			delete buffer;
		}
      return EOF;
   }

   /* initial read succeeded, now decide about expansion */
//   while (NULL == (crlocn = strchr(rdpoint, '\n'))) 
   while (NULL == (crlocn = FindCharInString(rdpoint, '\n'))) 
	{
      /* line is not completed, expand */

		// DP 29/3/2006: Save current buffer size
		nOldSize = cursize;

      /* set up cursize, rdpoint and rdsize, expand buffer */
      rdsize = DELTASIZE + 1;   /* allow for a final '\0' */
      cursize += DELTASIZE;
//      if (NULL == (temp = (char*)realloc(buffer, (size_t)cursize))) {

		// DP 29/3/2006: Changed to use custom realloc
      if (NULL == (temp = ReallocString<TTCHAR>(buffer, (size_t)cursize, (size_t)nOldSize, bOwnBuffer))) 
		{
         /* ran out of memory */
         *ln = buffer; /* partial line, next call may fail */
         return FGGETS_NOMEM;
      }
      buffer = temp;
      /* Read into the '\0' up */
      rdpoint = buffer + (cursize - DELTASIZE - 1);

      /* get the next piece of this line */
//      if (NULL == fgets(rdpoint, rdsize, f)) {
      if (NULL == GetFileString(rdpoint, rdsize, f)) 
		{
         /* early EOF encountered */
//         crlocn = strchr(buffer, '\0');
         crlocn = FindCharInString(buffer, '\0');
         break;
      }
   } /* while line not complete */

   *crlocn = '\0';  /* mark line end, strip \n */
   rdsize = (int)(crlocn - buffer);

//   if (NULL == (temp = (char*)realloc(buffer, (size_t)rdsize + 1))) {

	// DP 29/3/2006: Changed to use custom realloc
   if (NULL == (temp = ReallocString<TTCHAR>(buffer, (size_t)rdsize + 1, (size_t)cursize, bOwnBuffer))) 
	{
      *ln = buffer;  /* without reducing it */
      return FGGETS_OK;
   }
   *ln = temp;
   return FGGETS_OK;
} /* fggets */