For
ii I searched for a method to create directories recursive with all parents. There was no standard c function to do this. mkdir(char *path, mode_t mode) only creates one directory, not the whole path tree. This is what we implemented:
static void _mkdir(const char *dir) {
char tmp[256];
char *p = NULL;
size_t len;
snprintf(tmp, sizeof(tmp),"%s",dir);
len = strlen(tmp);
if(tmp[len - 1] == '/')
tmp[len - 1] = 0;
for(p = tmp + 1; *p; p++)
if(*p == '/') {
*p = 0;
mkdir(tmp, S_IRWXU);
*p = '/';
}
mkdir(tmp, S_IRWXU);
}
Now _mkdir ("/home/nion/irc/server/channel"); works. If someone knows a better and maybe shorter variant please let me know.