31 lines
1.4 KiB
C++
31 lines
1.4 KiB
C++
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* utils.cpp :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/02/07 14:45:45 by apommier #+# #+# */
|
|
/* Updated: 2023/02/07 15:16:10 by apommier ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "../../../includes/ft_irc.hpp"
|
|
|
|
void cmd_error(fdList allFds, int user, std::string error)
|
|
{
|
|
write(allFds.userData[user].fd, ":irc.local ", error.size());
|
|
write(allFds.userData[user].fd, error.c_str(), error.size());
|
|
}
|
|
|
|
void split(std::string const &str, const char delim, std::vector<std::string> &out)
|
|
{
|
|
size_t start;
|
|
size_t end = 0;
|
|
|
|
while ((start = str.find_first_not_of(delim, end)) != std::string::npos)
|
|
{
|
|
end = str.find(delim, start);
|
|
out.push_back(str.substr(start, end - start));
|
|
}
|
|
} |