|
|
|
@ -251,9 +251,10 @@ s_nodelist *nodelist_open(const char *dir, const char *name, int mode)
|
|
|
|
|
s_nodelist tmp;
|
|
|
|
|
const char *openmode;
|
|
|
|
|
int lockmode;
|
|
|
|
|
|
|
|
|
|
char *ext; /* extension */
|
|
|
|
|
memset(&tmp, '\0', sizeof(s_nodelist));
|
|
|
|
|
|
|
|
|
|
const char *lastname;
|
|
|
|
|
const char *cutname=name+strlen(name)-3;
|
|
|
|
|
/*
|
|
|
|
|
* Select nodelist index open mode
|
|
|
|
|
*/
|
|
|
|
@ -273,13 +274,63 @@ s_nodelist *nodelist_open(const char *dir, const char *name, int mode)
|
|
|
|
|
/*
|
|
|
|
|
* Get nodelist and nodelist index file names
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if( *name == DIRSEPCHR )
|
|
|
|
|
/* if nodelist name contains full path */
|
|
|
|
|
{
|
|
|
|
|
strnxcpy(tmp.name_nodelist, name, sizeof(tmp.name_nodelist));
|
|
|
|
|
/* May be i will fix this later. I havent got much
|
|
|
|
|
* time. Sorry :)
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
strnxcpy(tmp.name_nodelist, name, sizeof(tmp.name_nodelist));
|
|
|
|
|
strnxcpy(tmp.name_index, name, sizeof(tmp.name_index));
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
logerr("nodelist.c: you shold specify only filename, without path");
|
|
|
|
|
exit(255);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/* if only just a filename */
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* checking, if nodelist name contains mask (see
|
|
|
|
|
* example config for details) */
|
|
|
|
|
if( strcmp(name+strlen(name)-3, "999") == 0)
|
|
|
|
|
{
|
|
|
|
|
int count;
|
|
|
|
|
/* struct dirent *nodelistdir;*/
|
|
|
|
|
struct stat *tmpbuf;
|
|
|
|
|
/* nodelistdir = opendir(dir);*/
|
|
|
|
|
const char *tmpseek;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 23.00 coming, and i am not at home :(
|
|
|
|
|
* Later i will rewrite this part with seekdir(3)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
for (count=0; count<365; count++)
|
|
|
|
|
{
|
|
|
|
|
tmpseek = '\0';
|
|
|
|
|
strnxcpy(tmpseek, dir, sizeof(&tmpseek));
|
|
|
|
|
if ((strcmp(&tmpseek[strlen(&tmpseek)-1], DIRSEPCHR)) != 0)
|
|
|
|
|
{
|
|
|
|
|
strnxcpy(&tmpseek, DIRSEPCHR, sizeof(tmpseek));
|
|
|
|
|
}
|
|
|
|
|
strnxcpy(&tmpseek, name, sizeof(&tmpseek));
|
|
|
|
|
sprintf(&tmpseek, "%i", count);
|
|
|
|
|
if( stat(tmpseek, tmpbuf) == 0)
|
|
|
|
|
{
|
|
|
|
|
name = tmpseek;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* mydir = readdir(nodelistdir);
|
|
|
|
|
if (stat(nodelistdir.d_name, tmpbuf) == 0)
|
|
|
|
|
lastname = nodelistdir.d_name;
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
/* closedir(nodelistdir);*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strnxcpy(tmp.name_nodelist, dir, sizeof(tmp.name_nodelist));
|
|
|
|
|
strnxcat(tmp.name_nodelist, name, sizeof(tmp.name_nodelist));
|
|
|
|
|
strnxcpy(tmp.name_index, tmp.name_nodelist, sizeof(tmp.name_index));
|
|
|
|
|