精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>已关闭版区>>● BBS系统>>BBS 技巧>>将Maple BBS .DIR转换成FB BBS .Names,

主题:将Maple BBS .DIR转换成FB BBS .Names,
发信人: [email protected].()
整理人: (1999-11-30 12:01:25), 站内信件
出  处: cs3.xmu.edu.cn


在UNIX版上前一阵有好心人[email protected]
[email protected]等将台湾BBS精华区取到本地
做GB转换,广为传播等,我后来从ftp://202.114.2.3上取了
一份,并放在ftp://cs3.xmu.edu.cn/pub/collect/bbs/twbbs
下,解开一看,是Maple BBS的.DIR格式,不能在FB BBS
上观看,今天花了一上午时间编了一程序,专门转换所有.DIR
到.Names,算是我也出点力气。:-)

(附程序源码, 也可以到
ftp://cs3.xmu.edu.cn/pub/collect/linux/bbs/DIR2Name.tgz取)


/*----------------------------------------------------------------------*/
/* DIR2Name.c                                                           */
/*                                                                      */
/*            (ftp://cs3.xmu.edu.cn/pub/collect/linux/bbs/DIR2Name.tgz  */
/*    (Comments, I love comments!)                                      */
/*    Program by [email protected]                                 */
/*    date: Dec 26, 1997                                                */
/*                                                                      */
/*    This program intend to convert Maple BBS .DIR                     */
/*    to FireBird BBS .Names format.                                    */
/*    For anybody who is SYSOP of FireBird BBS and                      */
/*    want to convert .DIR to .Names                                    */
/*                                                                      */
/*    Syntax: DIR2Name pathname                                         */
/*    Sample: DIR2Name . > .Names                                       */
/*                                                                      */
/*    I bundle a shell program name as "superDIR2Name"                  */
/*    with DIR2Name.c, just put DIR2Name&superDIR2Name                  */
/*    in /usr/local/bin. And directly run superDIR2Name                 */
/*    under the root dir of Maple man directory, you                    */
/*    can convert whole directory to FB .Names format.                  */
/*                                                                      */
/*            any problem contact [email protected], THX                */
/*----------------------------------------------------------------------*/


#include <sys/file.h>
#include <sys/stat.h>
#include <time.h>
#include <dirent.h>
#include <string.h>

#define FNLEN 33  /* Length of filename  */
#define IDLEN   12             /* Length of bid/uid */
#define TTLEN    72            /* Length of title */

typedef unsigned char uschar;  /* length = 1 */

struct DIRfh  /* .DIR File Header format */
{
  char filename[FNLEN];         /* M.9876543210.A */
  char savemode;                /* file save mode */
  char owner[IDLEN + 2];        /* uid[.] */
  char date[6];                 /* [02/02] or space(5) */
  char title[TTLEN + 1];
  uschar filemode;              /* must be last field @ boards.c */
};

/*
 * usage:       DIR2Name path
 *
 * compile:     gcc -o DIR2Name DIR2Name.c
 */

main(argc, argv)
  int argc;
  char *argv[];
{
  char t_dir[30];

  int fin;
  struct stat st;

  int i, total;
  int insize;
  char *iptr, *key, *hit;
  struct DIRfh fh0;

  time_t filetime;
  struct tm *ptime;

  if (argc < 2 || argc > 3)
  {
    printf("Usage:\t%s path\n", argv[0]);
    exit(-1);
  }

  getcwd(t_dir, 29);
  chdir(argv[1]);

  insize = sizeof(struct DIRfh);
  iptr = (char *) &fh0;
  key = &(fh0.filename[2]);

  if ((fin = open(".DIR", O_RDONLY)) == -1)
  {
    printf(".DIR open error\n");
    exit(-1);
  }

  fstat(fin, &st);

  /* read original .DIR */

  i = 0;

  printf("#\n");
  printf("# Title=\n");
  printf("#\n");
  while (read(fin, iptr, insize) == insize)
  {
        printf("Name=%s\n", fh0.title);
        printf("Path=~/%s\n", fh0.filename);
        printf("Numb=%d\n", ++i);
        printf("#\n");

  }
  close(fin);
  chdir(t_dir);  
}

--
※ 来源:·古庙钟声 cs3.xmu.edu.cn·[FROM: :).xmu.edu.cn]

[关闭][返回]