diff options
author | ptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-03-17 00:56:32 +0800 |
---|---|---|
committer | ptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-03-17 00:56:32 +0800 |
commit | 9379f70434f90a2fa69499966ae4e76f89cf72da (patch) | |
tree | 25d5c74b64cd99ce95ea7dd7103de039f1ec904a | |
parent | 622bcefba4f726e5c8236830b2889ec43f06be7f (diff) | |
download | pttbbs-9379f70434f90a2fa69499966ae4e76f89cf72da.tar pttbbs-9379f70434f90a2fa69499966ae4e76f89cf72da.tar.gz pttbbs-9379f70434f90a2fa69499966ae4e76f89cf72da.tar.bz2 pttbbs-9379f70434f90a2fa69499966ae4e76f89cf72da.tar.lz pttbbs-9379f70434f90a2fa69499966ae4e76f89cf72da.tar.xz pttbbs-9379f70434f90a2fa69499966ae4e76f89cf72da.tar.zst pttbbs-9379f70434f90a2fa69499966ae4e76f89cf72da.zip |
*** empty log message ***
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@34 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-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; } |