diff options
-rw-r--r-- | util/buildAnnounce.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/util/buildAnnounce.c b/util/buildAnnounce.c index f3f75661..30c5e9fa 100644 --- a/util/buildAnnounce.c +++ b/util/buildAnnounce.c @@ -16,46 +16,57 @@ extern bcache_t *brdshm; extern boardheader_t *bcache; extern void resolve_boards(); +extern int numboards; -void buildchilds(int level,char *path,boardheader_t *bptr) +int cmpboardclass(boardheader_t **brd, boardheader_t **tmp) { + return (strncmp((*brd)->title, (*tmp)->title, 4)<<8)+ + strcasecmp((*brd)->brdname, (*tmp)->brdname); +} +void buildchilds(int level,char *path,int gid) { char newpath[512]; - boardheader_t *ptr; + int i,count=0; + boardheader_t *ptr, *selected[512]; fileheader_t item; - if(bptr->firstchild[1]==(boardheader_t*)~0 || bptr->firstchild[1]==NULL) - return; - for(ptr =(void*) bptr->firstchild[1]; - ptr!=(boardheader_t*)~0 ;ptr=ptr->next[1]){ - + for(i=0; i<numboards; i++) + { + ptr =&brdshm->bcache[i]; if( - (ptr->brdattr&(BRD_BAD | BRD_GROUPBOARD | BRD_NOCOUNT | BRD_HIDE))!=0 + ptr->gid != gid || + (ptr->brdattr&(BRD_BAD | BRD_HIDE))!=0 || (ptr->level && !(ptr->brdattr & BRD_POSTMASK))) continue; + selected[count++]=ptr; + } + qsort(&selected, count, sizeof(boardheader_t *), + cmpboardclass); + for(i=0;i<count;i++) + { + ptr=selected[i]; printf("%*.*s+-%-14s %-s \n",level*2,level*2,"| | | | | | | | |", ptr->brdname, ptr->title); + if(ptr->brdattr & BRD_GROUPBOARD){ sprintf(newpath,"%s/%s",path,ptr->brdname); mkdir(newpath,0766); - buildchilds(level+1,newpath,ptr); + buildchilds(level+1,newpath,ptr-bcache+1); } else{ - printf("%s4\n",ptr->brdname); sprintf(newpath,"/bin/ln -s "BBSHOME"/man/boards/%c/%s %s/%s", /* maybe something wrong with this ^^^^^ */ ptr->brdname[0], ptr->brdname,path,ptr->brdname); system(newpath); } - printf("%s5\n",ptr->brdname); - sprintf(newpath,"%s/.DIR",path); strcpy(item.owner,ptr->BM); strtok(item.owner,"/"); - strcpy(item.title,ptr->title+7); + sprintf(item.title,"%-13.13s %s", level?ptr->brdname:"", ptr->title+7); item.savemode = 'D'; sprintf(item.filename,ptr->brdname); + sprintf(newpath,"%s/.DIR",path); append_record(newpath, &item, sizeof(item)); - } + } } @@ -67,6 +78,6 @@ int main() system("rm -rf "GROUPROOT); mkdir(GROUPROOT,0766); resolve_boards(); - buildchilds(0,path,&bcache[0]); + buildchilds(0,path,1); return 0; } |