示例#1
0
static void WriteDecodedSFCC(SFCCState *s)
{
    char *start = s->output.data;
    char *end = s->output.data + s->output.size;
    uint16_t len = s->output.len;
    char *ptr = s->output.data + len;
    int copy_len = 0;

    if(ptr < end)
    {
        if(s->cur_flags)
        {
            *ptr = (char)ConvertToChar(s->cur_flags, s->buf, s->buflen);
            ptr++;
        }
        else
        {
            if((end - ptr) < s->buflen)
                copy_len = end - ptr;
            else
                copy_len = s->buflen;
            memcpy(ptr , s->buf , copy_len);
            ptr = ptr + copy_len;
        }
    }

    s->output.len = (ptr -start);
    s->cur_flags = 0;
    s->buflen = 0;

}
示例#2
0
// Create the sqlite temp directory
static void sqlite_init()
{
	 //Note to Windows users(1): 
	 //From http://www.sqlite.org/c3ref/open.html
	 //The encoding used for the filename argument of sqlite3_open() and sqlite3_open_v2() must be UTF-8, 
	 // not whatever codepage is currently defined. 
	 //Filenames containing international characters must be converted to UTF-8 prior to passing them into 
	 //sqlite3_open() or sqlite3_open_v2().

	 //Note to Windows Runtime users (2): 
	 //From: http://www.sqlite.org/c3ref/temp_directory.html (and above link)
	 //The temporary directory must be set prior to calling sqlite3_open or sqlite3_open_v2. 
	 //Otherwise, various features that require the use of temporary files may fail. 
	 //Here is an example of how to do this using C++ with the Windows Runtime:  (Modified for Compact):


	LPCWSTR zPath = L"c:\\Temp\\Sqlite";
	LPCWSTR logfFile = L"c:\\Temp\\Sqlite.log";

	fstream = _wfopen(logfFile, L"w");
	//Create the sqlite temp dir directory if it doesn't exist
	//Assume if it does exist then the temp dir has been set already
	if (!FileExists(zPath))
	{
		char  zPathBuf[MAX_PATH + 1];
		ConvertToChar(zPath, zPathBuf);
		sqlite3_temp_directory = sqlite3_mprintf("%s", zPathBuf);
		fwprintf(fstream, L"Set sqlite temp directory\r\n");
	}

}
示例#3
0
	int RGUICombobox::getItem(lua_State* L)
	{
		ifistrue(isElementSet);
		
		lua_pushstring(L,ConvertToChar(extended_self->getItem((irr::u32)lua_tonumber(L,2))));
		return 1;
		
		endifisvalid();
	}
示例#4
0
void
IMI::ConvertWaypoint(const Waypoint &wp, TWaypoint &imiWp)
{
  // set name
  ConvertToChar(wp.name.c_str(), imiWp.name, sizeof(imiWp.name));

  // set latitude
  imiWp.lat = AngleConverter(wp.location.latitude).value;

  // set longitude
  imiWp.lon = AngleConverter(wp.location.longitude).value;
}
示例#5
0
bool
IMI::DeclarationWrite(Port &port, const Declaration &decl,
                      OperationEnvironment &env)
{
  if (!_connected)
    return false;

  TDeclaration imiDecl;
  memset(&imiDecl, 0, sizeof(imiDecl));

  // idecl.date ignored - will be set by FR
  ConvertToChar(decl.pilot_name, imiDecl.header.plt,
                  sizeof(imiDecl.header.plt));
  ConvertToChar(decl.aircraft_type, imiDecl.header.gty,
                  sizeof(imiDecl.header.gty));
  ConvertToChar(decl.aircraft_registration, imiDecl.header.gid,
                  sizeof(imiDecl.header.gid));
  ConvertToChar(decl.competition_id, imiDecl.header.cid,
                  sizeof(imiDecl.header.cid));
  ConvertToChar(_T("XCSOARTASK"), imiDecl.header.tskName,
                  sizeof(imiDecl.header.tskName));

  ConvertWaypoint(decl.turnpoints[0].waypoint, imiDecl.wp[0]);

  unsigned size = decl.Size();
  for (unsigned i = 0; i < size; i++) {
    ConvertWaypoint(decl.turnpoints[i].waypoint, imiDecl.wp[i + 1]);
    ConvertOZ(decl.turnpoints[i], i == 0, i == size - 1,
              imiDecl.wp[i + 1]);
  }

  ConvertWaypoint(decl.turnpoints[size - 1].waypoint,
              imiDecl.wp[size + 1]);

  // send declaration for current task
  return SendRet(port, env, MSG_DECLARATION, &imiDecl, sizeof(imiDecl),
                 MSG_ACK_SUCCESS, 0, -1) != nullptr;
}
示例#6
0
BOOL ShutdownFastStartService(const WCHAR *wsInstallPath)
{
  BOOL result = TRUE;

  // Class name: appName + "MessageWindow"
  WCHAR sClassName[c_nTempBufSize];
  _snwprintf(sClassName, c_nTempBufSize, L"%s%s", Strings.GetString(StrID_AppShortName), L"MessageWindow");

  HWND handle = ::FindWindowW(sClassName, NULL);
  if (handle)
  {
    char sPath[MAX_PATH];
    ConvertToChar(wsInstallPath, sPath, MAX_PATH);
    size_t pathLen = strlen(sPath);
    if (pathLen > 0 && sPath[pathLen-1] != '\\')
    {
      strcat(sPath, "\\");
      pathLen++;
    }

    char sCopyData[MAX_PATH * 3];
    _snprintf(sCopyData, MAX_PATH * 2, "\"%s%S.exe\" -shutdown-faststart", sPath, Strings.GetString(StrID_AppShortName));
    size_t cmdLineLen = strlen(sCopyData);

    char *sRest = sCopyData + cmdLineLen + 1;
    strcpy(sRest, sPath);

    COPYDATASTRUCT cds = {
      1,
      pathLen + 1 + cmdLineLen,
      (void*) sCopyData
    };
    ::SendMessage(handle, WM_COPYDATA, 0, (LPARAM)&cds);

    // Wait until it's shut down or for some timeout
    for (int i = 0; i < 20 && handle; i++)
    {
      Sleep(500);
      handle = ::FindWindowW(sClassName, NULL);
    }

    // The window must not exist if the service shut down properly
    result = (handle == NULL);
  }
  return result;
}