Exemple #1
0
Result ProcessString(Arg& a, Version::VersionResource& res)
{
  cout << "Setting string \"" << a.name << "\"...";
  int occurrences = 0;
  // enumerate StringFileInfo (really should only be 1 of these)
  for(list<Version::StringFileInfo>::iterator itSFI = res.stringFileInfo.begin(); itSFI != res.stringFileInfo.end(); ++ itSFI)
  {
    // enumerate string tables
    for(list<Version::StringTable>::iterator itST = itSFI->items.begin(); itST != itSFI->items.end(); ++ itST)
    {
      // enumerate strings
      for(list<Version::String>::iterator itS = itST->items.begin(); itS != itST->items.end(); ++ itS)
      {
        Version::String& s = *itS;
        if(StringEquals(s.hdr.key, LibCC::ToUTF16(a.name)))
        {
					StringConvert(s.value, a.value);
          occurrences ++;
        }
      }
    }
  }

  if(occurrences)
  {
    cout << "Done (" << occurrences << " occurrences replaced)." << endl;
  }
  else
  {
    // make sure there's a string table to place it.
    if(!res.stringFileInfo.size())
    {
      cout << endl;
			return Result::Failure("Error: No string file info block is in the version resource, so I can't add a new string to it.");;
    }
    if(!res.stringFileInfo.front().items.size())
    {
      cout << endl;
      return Result::Failure("Error: No string tables were in the version resource, so I can't add a new string to it.");;
    }
    Version::StringTable& st = res.stringFileInfo.front().items.front();
    Version::String s;
    StringConvert(s.value, a.value);
    StringConvert(s.hdr.key, a.name);
    s.hdr.type = 1;
    st.items.push_back(s);

    cout << "Done (1 new string added)." << endl;
  }

	return Result::Success();
}
Exemple #2
0
 inline LONG RegQueryValueExStringX(HKEY hKey, const Char* lpValueName, DWORD Reserved, std::basic_string<Char>& strX)
 {
   std::wstring valueName;
   std::wstring strW;
   if(lpValueName)
   {
     StringConvert(lpValueName, valueName);
   }
   LONG r;
   if(ERROR_SUCCESS == (r = RegQueryValueExStringX(hKey, lpValueName ? valueName.c_str() : 0, Reserved, REG_SZ, strW)))
   {
     StringConvert(strW, strX);
   }
   return r;
 }
Exemple #3
0
  inline LONG RegEnumKeyExX(HKEY hKey, DWORD dwIndex, std::basic_string<Char>& outName, DWORD& maxNameSize)
  {
    std::wstring outNameW;
    LONG ret = RegEnumKeyExX(hKey, dwIndex, outNameW, maxNameSize);
		StringConvert(outNameW, outName);
    return ret;
  }
Exemple #4
0
  inline LONG RegSetValueExStringX( HKEY hKey, const Char* lpValueName, DWORD Reserved, DWORD dwType, const Char* strX)
  {
    std::wstring valueName;
		std::wstring strW = ToUTF16(strX);
    if(lpValueName)
    {
      StringConvert(lpValueName, valueName);
    }
    return RegSetValueExW(hKey, lpValueName ? valueName.c_str() : 0, Reserved, REG_SZ, (const BYTE*)(strW.c_str()), (DWORD)(strW.size() + 1) * sizeof(wchar_t));
  }
Exemple #5
0
 inline LONG RegQueryValueExX(HKEY hKey, const Char* szValueName, DWORD* type, BYTE* data, DWORD* cbData)
 {
   std::wstring valueName;
   if(szValueName)
   {
     std::wstring strW;
     StringConvert(szValueName, valueName);
   }
   return RegQueryValueExX(hKey, szValueName ? valueName.c_str() : 0, type, data, cbData);
 }
Exemple #6
0
  inline HRESULT SHGetFolderPathX(std::basic_string<Char, Traits, Alloc>& sOut, int nFolder)
  {
    bool r = false;
		Blob<wchar_t, BlobTraits<true, MAX_PATH> > buf;
		HRESULT hr;
		if(SUCCEEDED(hr = SHGetFolderPathW(NULL, nFolder, NULL, SHGFP_TYPE_CURRENT, buf.GetBuffer())))
    {
			StringConvert(buf.GetBuffer(), sOut);
    }
		return hr;
  }
DWORD WINAPI ProcessThreadStub(LPVOID lpParam) 
{
	TRACE("----- ProcessThreadStub");
	CCommCommander* comm = (CCommCommander*) lpParam;

	CString* SongBegingArr = StringConvert(comm->m_SongBegin," ");
	CString* SongCancelArr = StringConvert(comm->m_SongCancel," ");
	CString* SongIdelArr = StringConvert(comm->m_SongIdel," ");
	int songBeginLen = (comm->m_SongBegin.GetLength()+1)/3;
	int SongCancelLen = (comm->m_SongCancel.GetLength()+1)/3;
	int SongIdealLen = (comm->m_SongIdel.GetLength()+1)/3;
	TRACE("\n HEX length %d, %d , %d",songBeginLen,SongCancelLen,SongIdealLen);
	while ((comm->m_stoppingFlag) == false) { 
		int processedBytesNum = 0;
		//10 is good value, if 100, too slow
		Sleep(10);
		for(int i=0; i < comm->m_innerBufferLength; i++)
		{
			int j = 0;
			//SongBegin----------------------------------------------------------
			for(j=0; j < songBeginLen; j++)
			{			
				char *str;
				unsigned char tmp2 = comm->m_innerBuffer[i+j];
				unsigned char tmpint = (unsigned char)strtoul(SongBegingArr[j],&str,16);
								
				if (tmp2 != tmpint)
					break;				
			}
			if (j == songBeginLen)				
			{
				comm->m_Status = SONG_BEGIN;
				processedBytesNum = i+j;
				break;
			}

			//SongCancel---------------------------------------------------------			
			for(j=0; j < SongCancelLen; j++)
			{
				char *str;
				unsigned int tmp2 = (unsigned int) comm->m_innerBuffer[i+j];
				unsigned int tmpint = (unsigned int)strtoul(SongCancelArr[j],&str,16);
				if (tmp2 != tmpint)
					break;
			}
			if (j == SongCancelLen)
			{
				comm->m_Status = SONG_CANCEL;
				processedBytesNum = i+j;
				break;
			}

			//SongIdel-----------------------------------------------------------
			for(j=0; j < SongIdealLen; j++)
			{
				char *str;
				unsigned int tmp2 = (unsigned int) comm->m_innerBuffer[i+j];
				unsigned int tmpint = (unsigned int)strtoul(SongIdelArr[j],&str,16);
				//TRACE("\n HEX___ left:%u char:%c,right: %u",tmp2,comm->m_innerBuffer[i+j],tmpint);
				if (tmp2 != tmpint)
					break;
			}
			if (j == SongIdealLen)
			{
				comm->m_Status = SONG_IDEL;
				processedBytesNum = i+j;
				break;
			}
		} // for

		if (processedBytesNum > 0){
			int keepLength = comm->m_innerBufferLength - processedBytesNum;
			for(int i = 0; i < keepLength; i++)
			{
				comm->m_innerBuffer[i] = comm->m_innerBuffer[processedBytesNum + i];			
			}
			ZeroMemory(comm->m_innerBuffer + keepLength, ACC_BUFFER_SIZE - keepLength );
			comm->m_innerBufferLength = keepLength;			
			SetEvent(comm->m_ReceiveEvent);
		}
	}// while
	TRACE("\n+++++++++++++++++Exit ProcessThreadStub ");
	return S_OK;
}
Exemple #8
0
/*--------------------------------------------------------------------------*/
int sci_scanf(char *fname, unsigned long fname_len)
{
    static char *String = NULL;
    static int l1 = 0, m1 = 0, n1 = 0, iarg = 0, maxrow = 0, nrow = 0, rowcount = 0, ncol = 0;
    int args = 0, retval = 0, retval_s = 0, lline = 0, iflag = 0, err = 0, n_count = 0;
    entry *data = NULL;
    rec_entry buf[MAXSCAN];
    sfdir type[MAXSCAN], type_s[MAXSCAN];

    Nbvars = 0;
    CheckRhs(1, 2);

    if (Rhs == 2)
    {
        GetRhsVar(1, MATRIX_OF_INTEGER_DATATYPE, &m1, &n1, &l1);
        if (m1 * n1 != 1)
        {
            Scierror(999, _("%s: Wrong size for input argument #%d: Scalar expected.\n"), fname, 1);
            return 0;
        }
        iarg = 2;
        maxrow = *istk(l1);
    }
    else
    {
        iarg = 1;
        maxrow = 1;
    }

    GetRhsVar(iarg, STRING_DATATYPE, &m1, &n1, &l1);
    /** format **/
    n_count = StringConvert(cstk(l1)) + 1;  /* conversion */

    if (n_count > 1)
    {
        Scierror(999, _("%s: Specified format cannot include any '\\n'\n"), fname);
        return 0;
    }

    nrow = maxrow;
    rowcount = -1;              /* number-1 of result lines already got */
    while (1)
    {
        rowcount++;
        if ((maxrow >= 0) && (rowcount >= maxrow))
        {
            break;
        }

        /* get a line */
        C2F(xscion) (&iflag);

        String = getConsoleInputLine();
        if (String == NULL)
        {
            Scierror(999, _("%s: Data mismatch.\n"), fname);
            return 0;
        }
        lline = (int)strlen(String);

        if (lline == 0)
        {
            FREE(String);
            String = strdup(" ");
        }

        /** use the scaned line as input **/
        args = Rhs;             /* args set to Rhs on entry */
        if (do_xxscanf("scanf", (FILE *) 0, cstk(l1), &args, String, &retval, buf, type) < 0)
        {
            if (String)
            {
                FREE(String);
                String = NULL;
            }
            return 0;
        }
        if (String)
        {
            FREE(String);
            String = NULL;
        }

        if ((err = Store_Scan(&nrow, &ncol, type_s, type, &retval, &retval_s, buf, &data, rowcount, args)) < 0)
        {
            switch (err)
            {
                case MISMATCH:
                    if (maxrow >= 0)
                    {
                        Free_Scan(rowcount, ncol, type_s, &data);
                        Scierror(999, _("%s: Data mismatch.\n"), fname);
                        return 0;
                    }
                    break;

                case MEM_LACK:
                    Free_Scan(rowcount, ncol, type_s, &data);
                    Scierror(999, _("%s: No more memory.\n"), fname);
                    return 0;
            }
        }
    }                           /*  while (1) */

    /* create Scilab variables with each column of data */
    err = Sci_Store(rowcount, ncol, data, type_s, retval_s);
    Free_Scan(rowcount, ncol, type_s, &data);
    if (err == MEM_LACK)
    {
        Scierror(999, _("%s: No more memory.\n"), fname);
    }
    return 0;
}
Exemple #9
0
  inline LONG RegCreateKeyExX(HKEY hKey, const Char* szSubKey, DWORD dwOptions, REGSAM Sam, PHKEY pResult, DWORD* pdwDisposition)
  {
    std::wstring buf;
		StringConvert(szSubKey, buf);
    return RegCreateKeyExW(hKey, buf.c_str(), 0, 0, dwOptions, Sam, 0, pResult, pdwDisposition);
  }
Exemple #10
0
/*--------------------------------------------------------------------------*/
int sci_fscanf(char *fname,unsigned long fname_len)
{
	static int l1, m1, n1,l2,m2,n2,iarg,maxrow,nrow,rowcount,ncol;
	FILE  *f;
	int args,retval,err;
	int retval_s=0;
	entry *data=NULL;
	long int pos;
	int param1=0;

	rec_entry buf[MAXSCAN];
	sfdir  type[MAXSCAN],type_s[MAXSCAN];

	Nbvars = 0;
	CheckRhs(2,3);

	if (Rhs==3)
	{
		GetRhsVar(1,MATRIX_OF_INTEGER_DATATYPE,&m1,&n1,&l1);
		if (m1*n1 != 1 )
		{
			Scierror(999,_("%s: Wrong size for input argument #%d: Scalar expected.\n"),fname,1);
			return 0;
		}
		iarg=2;
		maxrow=*istk(l1);
	}
	else
	{
		iarg=1;
		maxrow=1;
	}

	GetRhsVar(iarg,MATRIX_OF_INTEGER_DATATYPE,&m1,&n1,&l1);
	GetRhsVar(iarg+1,STRING_DATATYPE,&m2,&n2,&l2);/* format */

	param1 = *istk(l1);
	StringConvert(cstk(l2));  /* conversion */

	switch (param1)
	{
	case 0:
		// stderr
		f = (FILE *)0;
		break;
	case 5:
		f = stdin;
		break;
	case 6:
		// stdout
		f = (FILE *)0;
		break;
	default:
		f = GetFileOpenedInScilab(param1);
		break;
	}

	if (f == (FILE *)0)
	{
		Scierror(999,_("%s: Wrong file descriptor: %d.\n"),fname,param1);
		return 0;
	}

	nrow = maxrow;
	rowcount = -1;

	while (1)
	{
		rowcount++;
		if ((maxrow >= 0) && (rowcount >= maxrow)) break;
		args = Rhs; /* args set to Rhs on entry */
		pos=ftell(f);
		if ( do_xxscanf("fscanf",f,cstk(l2),&args,(char *)0,&retval,buf,type) < 0 )  return 0;
		if ( retval == EOF)
		{
			/*
			Scierror(999,"Error: in %s: end of file reached\n",fname);
			*/
			break;
		}
		if ((err=Store_Scan(&nrow,&ncol,type_s,type,&retval,&retval_s,buf,&data,rowcount,args)) <0 )
		{
			switch (err)
			{
			case MISMATCH:
				if (maxrow>=0)
				{
					Free_Scan(rowcount,ncol,type_s,&data);
					Scierror(999,_("%s: Data mismatch.\n"),fname);
					return 0;
				}
				fseek(f,pos,SEEK_SET);
				break;

			case MEM_LACK:
				Free_Scan(rowcount,ncol,type_s,&data);
				Scierror(999,_("%s: No more memory.\n"),fname);
				return 0;
				break;
			}
			if (err==MISMATCH) break;
		}
	} /* while */

	/* create Scilab variable with each column of data */
	err=Sci_Store(rowcount,ncol,data,type_s,retval_s);
	Free_Scan(rowcount,ncol,type_s,&data);
	if (err==MEM_LACK) { Scierror(999,_("%s: No more memory.\n"),fname);}
	return 0;
}