Пример #1
0
u64 CInifileEx::r_u64(LPCSTR S, LPCSTR L)
{
	LPCSTR		C = r_string(S,L);
#ifndef _EDITOR
	return		_strtoui64(C,NULL,10);
#else
	return		(u64)_atoi64(C);
#endif
}
Пример #2
0
static void *
atop(const char *a)
{
#ifdef AMD64
    return (void *)_atoi64(a);
#else
    return (void *)atoi(a);
#endif
}
Пример #3
0
static int
vtxt_column (sqlite3_vtab_cursor * pCursor, sqlite3_context * pContext,
	     int column)
{
/* fetching value for the Nth column */
    int nCol = 1;
    int i;
    char buf[4096];
    int type;
    const char *value;
    VirtualTextCursorPtr cursor = (VirtualTextCursorPtr) pCursor;
    gaiaTextReaderPtr text = cursor->pVtab->reader;
    if (column == 0)
      {
	  /* the ROWNO column */
	  sqlite3_result_int (pContext, cursor->current_row);
	  return SQLITE_OK;
      }
    if (text->current_line_ready == 0)
	return SQLITE_ERROR;
    for (i = 0; i < text->max_fields; i++)
      {
	  if (nCol == column)
	    {
		if (!gaiaTextReaderFetchField (text, i, &type, &value))
		    sqlite3_result_null (pContext);
		else
		  {
		      if (type == VRTTXT_INTEGER)
			{
			    strcpy (buf, value);
			    text_clean_integer (buf);
#if defined(_WIN32) || defined(__MINGW32__)
/* CAVEAT - M$ runtime has non-standard functions for 64 bits */
			    sqlite3_result_int64 (pContext, _atoi64 (buf));
#else
			    sqlite3_result_int64 (pContext, atoll (buf));
#endif
			}
		      else if (type == VRTTXT_DOUBLE)
			{
			    strcpy (buf, value);
			    text_clean_double (buf);
			    sqlite3_result_double (pContext, atof (buf));
			}
		      else if (type == VRTTXT_TEXT)
			  sqlite3_result_text (pContext, value, strlen (value),
					       free);
		      else
			  sqlite3_result_null (pContext);
		  }
	    }
	  nCol++;
      }
    return SQLITE_OK;
}
Пример #4
0
   DALConnection::ExecutionResult
   PGConnection::TryExecute(const SQLCommand &command, String &sErrorMessage, __int64 *iInsertID, int iIgnoreErrors) 
   {
      String SQL = command.GetQueryString();

      try
      {
         // PG_query-doc:
         // Zero if the query was successful. Non-zero if an error occurred.
         // 
         AnsiString sQuery;
         if (!Unicode::WideToMultiByte(SQL, sQuery))
         {
            ErrorManager::Instance()->ReportError(ErrorManager::Critical, 5106, "PGConnection::TryExecute", "Could not convert string into multi-byte.");
            return DALConnection::DALUnknown;
         }

         PGresult *pResult = PQexec(m_pDBConn, sQuery);

         bool bIgnoreErrors = SQL.Find(_T("[IGNORE-ERRORS]")) >= 0;

         if (!bIgnoreErrors)
         {
            DALConnection::ExecutionResult result = CheckError(pResult, SQL, sErrorMessage);
            if (result != DALSuccess)
            {
               if (pResult != 0)
                  PQclear(pResult);

               return result;
            }
         }

         ExecStatusType iExecResult = PQresultStatus(pResult);
         
         // Check if a value has been returned. Will only occur if we've
         // inserted a value.
         if (iInsertID > 0 && iExecResult == PGRES_TUPLES_OK)
         {
            // pick the ID from the first row.
            char *pRetVal = PQgetvalue(pResult, 0, 0);
            *iInsertID = pRetVal ? _atoi64(pRetVal) : 0;
         }

         if (pResult != 0)
            PQclear(pResult);
        
      }
      catch (...)
      {
         sErrorMessage = "Source: PGConnection::TryExecute, Code: HM5084, Description: An unhanded error occurred while executing: " + SQL;
         return DALConnection::DALUnknown;
      }

      return DALConnection::DALSuccess;
   }
Пример #5
0
__int64 _RTLENTRY _EXPFUNC strtoll(
  const char * str,
  char**endptr,
  int base)
  // convert string to long long int
  {
   if (endptr != NULL)
	 *endptr = (char*)str + (base == 10 ? strspn(str, "0123456789"): 0);
   return(_atoi64(str));
  }
Пример #6
0
	LUA_EXPORT void steam_JoinChat(const char * pchSteamID)
	{
		
		if (!pchSteamID) return;
		
		uint64_t steamid64 = _atoi64( pchSteamID );
		if (steamid64==0) return;
		
		SteamID steamID(steamid64);
		client.JoinChat(steamID);
	}
Пример #7
0
uint64 TypeConvert::ToUint64(const char* str)
{
	if (!str)
		return 0;

#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
	return (uint64)(_atoi64(str));
#else
	return (uint64)atoll(str);
#endif
}
Пример #8
0
ICR_LONG icr__String_StringToLong(StringObjectData* lvalue)
{
	long long result = 0;
	char* val = icr__String_StringToCString(lvalue);

	result = _atoi64(val);

	icr__String_FreeCString(val);

	return result;
}
Пример #9
0
int64_t lp_config_get_int64(const LpConfig *lpconfig,const char *section, const char *key, int64_t default_value){
	const char *str=lp_config_get_string(lpconfig,section,key,NULL);
	if (str!=NULL) {
#ifdef WIN32
		return (int64_t)_atoi64(str);
#else
		return atoll(str);
#endif
	}
	else return default_value;
}
Пример #10
0
__int64 CQuery::GetInt64(int nCol)
{
	if (nCol > this->nCol)
		return CQUERYNOCOL;

	if (lCol[nCol-1]==SQL_NULL_DATA) {
		return CQUERYNULL;
	} else {
		return _atoi64(Col[nCol-1]);
	}
}
int assign_ulonglong(void* value_ptr, const char* value_string)
{
	int i_ret = APP_SUCCESS;
	char tmp_value[MAX_STRING_SIZE] = {0};

	strcpy_s(tmp_value, MAX_STRING_SIZE - 1, value_string);
//	StrTrimA(tmp_value, " 	");

	*((__int64*)value_ptr) = _atoi64(tmp_value);
	return i_ret;
}
Пример #12
0
static int parse_arguments_and_execute()
{
    enum
    {
        Argument_logical_sector = 0,
        Argument_file_name,
        Argument_help,
    };

    const std::vector<Parsing::Argument_descriptor> argument_map =
    {
        { Argument_logical_sector, u8"logical-sector", u8's', true,  u8"The logical block address (LBA) of the sector to read." },
        { Argument_file_name,      u8"file-name",      u8'f', true,  u8"The name of the file to hold the output. This file will be overwritten." },
        { Argument_help,           u8"help",           u8'?', false, nullptr },
    };
#ifndef NDEBUG
    Parsing::validate_argument_map(argument_map);
#endif

    const auto arguments = WindowsCommon::args_from_command_line();
    const auto options = Parsing::options_from_allowed_args(arguments, argument_map);

    int error_level = 0;
    if(options.count(Argument_help) == 0)
    {
        CHECK_EXCEPTION(options.count(Argument_logical_sector) > 0, u8"Missing a required argument: --" + std::string(argument_map[Argument_logical_sector].long_name));
        CHECK_EXCEPTION(options.count(Argument_file_name) > 0,      u8"Missing a required argument: --" + std::string(argument_map[Argument_file_name].long_name));

        // There is no _atoui64 function (and perhaps a private implementation is a good idea), but
        // reading an int64_t into a uint64_t will have no negative (ha!) consequences, as any sector
        // number is considered a valid sector to read.
        const uint64_t sector_number = _atoi64(options.at(Argument_logical_sector).c_str());
        GetSector::read_physical_drive_sector_to_file(0, sector_number, PortableRuntime::utf16_from_utf8(options.at(Argument_file_name)).c_str());
    }
    else
    {
        constexpr auto arg_program_name = 0;

        // Hold a reference to program_name_long for the duration of the output functions.
        const auto program_name_long = PortableRuntime::utf16_from_utf8(arguments[arg_program_name]);
        const auto program_name = PathFindFileNameW(program_name_long.c_str());

        std::fwprintf(stderr, L"Usage: %s [options]\nOptions:\n", program_name);
        std::fwprintf(stderr, PortableRuntime::utf16_from_utf8(Parsing::Options_help_text(argument_map)).c_str());
        std::fwprintf(stderr,
                      L"\nTo read the Master Boot Record:\n  %s -%c 1 -%c mbr.bin\n",
                      program_name,
                      argument_map[Argument_logical_sector].short_name,
                      argument_map[Argument_file_name].short_name);
        error_level = 1;
    }

    return error_level;
}
Пример #13
0
void FillValueTableNumber64(CValueTable* pValueTable, const char* str, 
						  size_t stRowIndex, size_t stColIndex, bool bNull)
{
#ifdef _WIN32
	T value = (T)_atoi64(str);
#else
	T value = (T)atoll(str);
#endif
	pValueTable->ExpandBuffer(stRowIndex, stColIndex, sizeof(T));
	pValueTable->SetValue(stRowIndex, stColIndex, &value, sizeof(T), bNull);
}
Пример #14
0
__int64 CQuery::GetAsInteger64(LPTSTR ColName)
{
	int iIndex =this->FindIndex(ColName);

	if ( iIndex != -1 )
	{
		return _atoi64(this->m_SQLData[iIndex]);
	}

	return -1;
}
int AddStuInfoFromFile()
{
	int tmpi;
	char student_number_char[13 + 1];
	char mobile_phone_number_char[11 + 1];	
	char qq_number_char[10 + 1];	
	FILE * pFile = NULL;
	
	pFile = fopen(STU_INFO_FILE, "r");
	if(!pFile)
	{
		printf("读取改进后的同学录系统失败!\n");
		return FAILURE;
	}
	else
		printf("欢迎进入改进后的同学录系统!\n");
		printf("程序员:戴嘉乐\n");
		printf("辅导老师:潘晔\n"); 
	
	memset(StudentNumber,0,8);
	memset(MobilePhoneNumber,0,8);
	memset(QQNumber,0,8);
	memset(Name,0,MAX_STU_COUNT * (10 + 1));
	memset(Email,0,MAX_STU_COUNT * (20 + 1));	
	
	while(!feof(pFile))
	{		
		fscanf(pFile,"%s",student_number_char);
		fscanf(pFile,"\t%s",Name[CurrentStudentCount]);
		fscanf(pFile,"\t%s",mobile_phone_number_char);
		fscanf(pFile,"\t%s",Email[CurrentStudentCount]);
		fscanf(pFile,"\t%s\n",qq_number_char);
		StudentNumber[CurrentStudentCount] = _atoi64(student_number_char);
		MobilePhoneNumber[CurrentStudentCount] = _atoi64(mobile_phone_number_char);		
		QQNumber[CurrentStudentCount] = _atoi64(qq_number_char);		
		CurrentStudentCount++;
	}
	
	fclose(pFile);
	return SUCCESS;
}
Пример #16
0
int64 TypeConvert::ToInt64(const char* str)
{
	if (!str)
		return 0;

	// todo:fix
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
	return (int64)_atoi64(str);
#else
	return atoll(str);
#endif
}
Пример #17
0
const char * TiXmlElement::Attribute(const char * name, int* i) const
{
	const char * s = Attribute(name);
	if (i)
	{
		if (s)
			*i = (int)_atoi64(s);
		else
			*i = 0;
	}
	return s;
}
Пример #18
0
LRESULT CObjectsPage::OnEditEnd(WPARAM nItem, LPARAM nSubItem)
{
	// Get item label
	CString label = m_List.GetItemText(nItem, 0);
	CString text = m_List.GetItemText(nItem, nSubItem);

	__int64 iValue = _atoi64(text);
	double fValue = atof(text);

	// Resume updating
	pausedUpdating = false;

	// Check for common labels
	if (pMyObject) {

		if (label == "X")
			pMyObject->info.x = fValue;
		else if (label == "Y")
			pMyObject->info.y = fValue;
		else if (label == "Width")
			pMyObject->info.w = fValue;
		else if (label == "Height")
			pMyObject->info.h = fValue;
		else if (label == "Angle")
			pMyObject->info.angle = fValue;
		else if (label == "Opacity") {
			pMyObject->info.pInfo->filter.a = fValue / 100.0f;
		}
		
		// Work out which object owned the edited line
		CRunObject* lineOwner = lineOwners[nItem];
		if (lineOwner)
			lineOwner->OnDebuggerValueChanged(label, text);

		// Update bounding box for non system objects
		if (pMyObject->pType != NULL)
			pRuntime->UpdateBoundingBox(pMyObject);
	}

	// Save scroll position
	int nScroll = m_List.GetScrollPos(SB_VERT);

	// Force full refresh by clearing old display
	objDebugDisplay.resize(0);
	RefreshInspection();

	// Restore scroll position
	m_List.SetSelectionMark(nItem);
	m_List.SetCurSel(nItem, TRUE);
	m_List.SetScrollPos(SB_VERT, nScroll, TRUE);

	return 0;
}
Пример #19
0
	LUA_EXPORT void steam_SendChatMessage(const char * room,const char * message)
	{
		if (!room || !message) return;
		
		uint64_t steamid64 = _atoi64( room );
		if (steamid64==0) return;
		
		SteamID steamID(steamid64);
		
		client.SendChatMessage(steamID,message);
		
	}
Пример #20
0
bool tinyxml_tool::get_int64_attribute(TiXmlElement* pElm, const char* name, long long& v)
{
	if(!pElm) return false;
	const char* pv = pElm->Attribute(name);
	if(!pv) return false;
#ifdef _WIN32
    v = _atoi64(pv);
#else
    v = atol(pv);
#endif
	return true;
}
Пример #21
0
void KadUDPKey::fromInt64String(char *str)
{
#ifdef WIN32
	__int64 key_num;
	key_num = _atoi64(str);
#else
	long long key_num;
	key_num = atoll(str);
#endif
	m_dwKey = key_num >> 32;
	m_dwIP = key_num&(-1);
}
void vmsBrowserCachedFlvTrafficCollector::Initialize()
{
	if (!m_vCompletedDialogs.empty ())
		return;

	vmsBrowserFlvHistory *phist;
	vmsIeFlvHistory iehist;

	if (GetModuleHandle ("iexplore.exe"))
		phist = &iehist;
	else
		return;

	phist->Gather ();

	for (int i = 0; i < phist->getItemCount (); i++)
	{
		const vmsBrowserFlvHistory::Item *item = phist->getItem (i);

		HttpDialogPtr spDlg;
		spDlg.CreateInstance ();
		spDlg->nID = InterlockedIncrement (&m_nNextDlgID);
		
		spDlg->enState = HttpDialog::DONE;

		spDlg->strRequestUrl = item->strUrl;

		LPCSTR psz1 = strstr (item->strUrl.c_str (), "://");
		if (psz1)
		{
			psz1 += 3;
			LPCSTR psz2 = strchr (psz1, '/');
			if (psz2)
				spDlg->strRequestHost.assign (psz1, psz2-psz1);
		}

		spDlg->pHttpResponse = new vmsHttpResponseParser;
		spDlg->pHttpResponse->ParseHeader (item->strHttpResponse.c_str ());

		spDlg->strResponseHeaders = item->strHttpResponse;

		spDlg->enCT = HttpDialog::FLV;

		const vmsHttpParser::HdrField *pCL = spDlg->pHttpResponse->FieldByName ("Content-Length");
		if (pCL != NULL)
			spDlg->nContentLength = (UINT64)_atoi64 (pCL->strValue.c_str ());

		EnterCriticalSection (&m_csModifyDialogsVector);
		m_vCompletedDialogs.push_back (spDlg);
		LeaveCriticalSection (&m_csModifyDialogsVector);
	}
}
Пример #23
0
    longint LongInt::Parse(const char* s, int /*length*/)
    {
        if (s)
        {
#           if (defined(BIBIM_PLATFORM_WINDOWS))
                return static_cast<longint>(_atoi64(s));
#           else
                return static_cast<longint>(atoll(s));
#           endif
        }
        else
            return 0;
    }
Пример #24
0
	// Cast content to a 64 bit int
	inline __int64 GetInt64() const
	{
		switch (eType) {
		case EXPTYPE_INTEGER:
			return eData.iVal;
		case EXPTYPE_FLOAT:
			return (__int64)eData.fVal;
		case EXPTYPE_STRING:
			return _atoi64(*(eData.str));
		default:
			return 0;
		}
	}
Пример #25
0
/**@ingroup tsk_string_group
*/
int64_t tsk_atoll(const char* str)
{
	// FIXME: use HAVE_ATOLL and use macro instead of function
	if(str){
#if defined(_MSC_VER)
		return _atoi64(str);
#elif defined(__GNUC__)
		return atoll(str);
#else
		return atol(str); 
#endif
	}
	return 0;
}
Пример #26
0
// Called when a debugger value has been changed.
void ExtObject::OnDebuggerValueChanged(const char* name, const char* value)
{
	// For convenience, we prepare these values with CString for operator==,
	// and precalculated integer and float conversions.
	CString label = name;
	__int64 iValue = _atoi64(value);
	double fValue = atof(value);

	// Example:
	// if (label == "My item")
	//     myValue = iValue;
	if (CheckDebugVariableChange(name, value, privateVars, this, pRuntime))
		return;
}
Пример #27
0
int main(int argc, char *argv[])
{
    char   *input, *output;
    int64_t start,  end;

#if 1
    if (argc < 5) {
        printf(
            "ffspliter: tools for spliter media file\n"
            "usage: ffspliter input start end output\n"
            "input support any file format a        \n"
            "output support only flv and mp4 format \n"
            "start and end time is in ms unit       \n"
        );
        return -1;
    }

    input  = argv[1];
    output = argv[4];
    start  = _atoi64(argv[2]);
    end    = _atoi64(argv[3]);
#else
    input  = "rtmp://live.hkstv.hk.lxdns.com/live/hks";
    output = "c:\\record.mp4";
    start  = -1;
    end    = 60000;
#endif

    // set console ctrl handler
    SetConsoleCtrlHandler((PHANDLER_ROUTINE)console_ctrl_handler, TRUE);

    // start split media file
    split_media_file(output, input, start, end, split_progress_callback);

    _getch();
    return 0;
}
Пример #28
0
void recalibrate(void) {
	int i;

	ULONGLONG basetscs[nreps];  // basetsc for each round
	ULONGLONG basests[nreps];   // basest for each round

        char buf[100] = "0";

	// read calibration
	HKEY key;
	DWORD cbData;
	RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\NetSem\\TTHEE",0,KEY_READ,&key);
	cbData = sizeof(tscfreq);
	RegQueryValueEx(key,"tscfreq",NULL,NULL,(BYTE *)&tscfreq,&cbData);
	cbData = sizeof(tscsd);
	RegQueryValueEx(key,"tscsd",NULL,NULL,(BYTE *)&tscsd,&cbData);
	// double error = double(tscsd) / double(tscfreq);
        cbData = sizeof(buf)-1;
	RegQueryValueEx(key,"ugly_hack_offset",NULL,NULL,(BYTE *)buf,&cbData);
        buf[cbData] = '\0';
        ugly_hack_offset = _atoi64(buf);

	// get base times
	for (i=0; i<nreps; i++) {
		FILETIME baseft;
		Sleep(5);  // to be sure we're on a tick boundary
		basetscs[i] = gettsc();  // get this first because it changes very fast
		GetSystemTimeAsFileTime(&baseft);  // no rush; we have 1/64 sec to read this before it changes
		basests[i] = ((ULONGLONG)baseft.dwHighDateTime)<<32 | ((ULONGLONG)baseft.dwLowDateTime);
	}

	basetsc = basetscs[nreps-1];
	/* Now: we want to know the correct basest for the latest basetsc.  Each measurement can be
	   extrapolated to give us a basest for the latest basetsc.  But if there was a delay between the
	   tick and our process being scheduled in a particular round, this will show up as the basetsc
	   being high, a.k.a., the basest being low.  Thus, we take the highest computed basest. */
	basest = basests[nreps-1];
	for (i=0; i<nreps; i++) {
		ULONGLONG basestx = basests[i] + (10000000 * (basetscs[nreps-1] - basetscs[i])) / tscfreq;
			// don't worry about overflow; at 500MHz (glia) it won't overflow until just over an hour
		if (basestx > basest) {
			basest = basestx;
		}
	}

        basest -= ugly_hack_offset;   // apply the hack offset.

	lastrecal = basest;  // we just recalibrated.
}
Пример #29
0
/* parse the segment number.
 * The extra %c picks up characters that might be after the number,
 * so that page5_hash doesn't match for page5.
 */
int64_t	af_segname_page_number(const char *name)
{
#ifdef KERNEL_LIBRARY
#define PAGE_NAME "page"
	if(_strnicmp(name,PAGE_NAME,strlen(PAGE_NAME))==0)
	{
		int64_t pagenum;
		for (int i=strlen(PAGE_NAME);i<strlen(name);i++)
			if (!isdigit(name[i])) return -1;

		pagenum = _atoi64(name+strlen(PAGE_NAME));
		return pagenum;
	}
#define SEG_NAME "seg"
	if(_strnicmp(name,SEG_NAME,strlen(SEG_NAME))==0)
	{
		int64_t pagenum;
		for (int i=strlen(SEG_NAME);i<strlen(name);i++)
			if (!isdigit(name[i])) return -1;

		pagenum = _atoi64(name+strlen(SEG_NAME));
		return pagenum;
	}
	return -1;
#else
    int64_t pagenum;
    char  ch;
    if(sscanf(name,AF_PAGE"%c",&pagenum,&ch)==1){
	return pagenum;			// new-style page number
    }
    if(sscanf(name,AF_SEG_D"%c",&pagenum,&ch)==1){
	return pagenum;			// old-style page number
    }
    return -1;
#endif
}
Пример #30
0
int libCallback(void *, int colNumber, char* values[], char* colNames[])
{
	if (colNumber == 4) {
		long long pid = _atoi64(values[0]);
		char *title = values[1];
		char *artist = values[2];
		char *album = values[3];

		LibraryItem *item = new LibraryItem(pid, title, artist, album);

		libItems.push_back(item);
	}

	return 0;
}