int			GSocketUdpServer::Send(const GString &s)
{
#if defined (GWIN)
	int		rc, err;
	WSABUF	DataBuf;
	DWORD	SendBytes = 0;
	DataBuf.len = s.Size();
	DataBuf.buf = s.ToChar();
	rc = WSASendTo(this->_socket, &DataBuf, 1, &SendBytes, NULL, reinterpret_cast <sockaddr*> (&this->_sockaddr), DataBuf.len, NULL, NULL);
	delete[] DataBuf.buf;
	if ((rc == SOCKET_ERROR) && (WSA_IO_PENDING != (err = WSAGetLastError())))
	{
		this->_lastError = GSocketUdpServer::ERROR_SEND;
		throw GException("GSocketUdpServer", "Error WSASend() !");
	}
	return (SendBytes);
#else
	int	l = 0;
	char	*tmp = s.ToChar();
	l = sendto(this->_socket, tmp, s.Size(), 0, 0, 0);
	delete[] tmp;
	if (l < 0)
	{
		this->_lastError = GSocketUdpServer::ERROR_SEND;
		throw GException("GSocketUdpServer", "Error send() !");
	}
	return (l);
#endif
}
예제 #2
0
void		GMessageBox::Error(const GString &Title, const GString &Texte)
{
#if defined (WIN32) | defined (_WIN32) |  defined (__WIN32) | defined (WIN) | defined (WIN64) | defined (__WIN64)
	char	*txt = Texte.ToChar();
	char	*ttl = Title.ToChar();
	MessageBox(NULL, txt, ttl, NULL);
	delete[] txt;
	delete[] ttl;
#endif
}
예제 #3
0
bool	GSqlDatabase::Connect(const GString &Host, const GString &Login, const GString &Database, const GString &Pass, unsigned int Port)
{
	char *host = Host.ToChar();
	char *login = Login.ToChar();
	char *pass = Pass.ToChar();
	char *database = Database.ToChar();
	MYSQL *res = mysql_real_connect(&(this->_mysql), host, login, pass, database, Port, NULL, 0);
	delete[] database;
	delete[] host;
	delete[] login;
	delete[] pass;
	if (res)
		return (true);
	return (false);
}
예제 #4
0
bool	GSqlDatabase::Query(const GString &Query)
{
	char *query = Query.ToChar();
	int res = mysql_query(&(this->_mysql), query);
	delete[] query;
	if (res)
		return (false);
	return (true);
}
예제 #5
0
bool	GSqlDatabase::SelectDatabase(const GString &DatabaseName)
{
	char *db = DatabaseName.ToChar();
	int res = mysql_select_db(&(this->_mysql), db);
	delete[] db;
	if (res)
		return (false);
	return (true);
}
예제 #6
0
GString			GSqlDatabase::EscapeString(const GString &Str)
{
	char *str = Str.ToChar();
	char *to = new char[Str.Size() * 2 + 1];
	unsigned long nb = mysql_real_escape_string(&(this->_mysql), to, str, Str.Size());
	delete[] str;
	GString res = GString::GetBuffer(to, nb);
	delete[] to;
	return (res);
}
예제 #7
0
bool			GFileInfos::IsDir(const GString &s)
{
#if defined (GWIN)
	if ((GetFileAttributes(s.ToLPCSTR()) & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) 
		return (true);
    return (false);
#else
	struct stat st;
	if (lstat(s.ToChar(), &st) == -1)
			GWarning::Warning("GFileInfos", "GFileInfos(const GString &)", "Cannot get struct stat !");
	if ((st.st_mode & S_IFDIR) != 0)
		return (true);
	return (false);
#endif
}
예제 #8
0
GException::GException(const GString &Error)
{
	this->_str = Error.ToChar();
}