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 }
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 }
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); }
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); }
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); }
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); }
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 }
GException::GException(const GString &Error) { this->_str = Error.ToChar(); }