rehome.c
上传用户:minyiyu
上传日期:2018-12-24
资源大小:864k
文件大小:1k
源码类别:

Telnet服务器

开发平台:

Unix_Linux

  1. #include "../../include/bbs.h"
  2. #include "../../include/permissions.h"
  3. #include "UPDATE.h"
  4. int
  5. report()
  6. {
  7.         return;
  8. }
  9. main()
  10. {
  11.         FILE *rec;
  12.         int i;
  13.         char buf[256];
  14.         char buf2[256];
  15.         struct userec user;
  16.         rec=fopen(PASS,"rb");
  17.         printf("1. Create Index directoryn");
  18.         for(i='A';i<='Z';i++)
  19.         {
  20.                 sprintf(buf,"%s/home/%c",BBSHOME,i);
  21.                 mkdir(buf,0760);
  22.                 chown(buf,9999,99);
  23.                 sprintf(buf,"%s/mail/%c",BBSHOME,i);
  24.                 mkdir(buf,0760);
  25.                 chown(buf,9999,99);
  26.         }
  27.         i=0;        
  28.         printf("2. Moving User Directoryn");
  29.         while(1)
  30.         {
  31. /*                break;  */
  32.                 if(fread(&user,sizeof(user),1,rec)<=0) break;
  33.                 i++;
  34.                 if(user.numlogins<=0)
  35.                         continue;
  36.                 sprintf(buf,"%s/home/%s",BBSHOME,user.userid);
  37.                 sprintf(buf2,"%s/home/%c/%s",BBSHOME,toupper(user.userid[0]),user.userid);
  38.                 rename(buf,buf2);
  39.                 sprintf(buf,"%s/mail/%s",BBSHOME,user.userid);
  40.                 sprintf(buf2,"%s/mail/%c/%s",BBSHOME,toupper(user.userid[0]),user.userid);
  41.                 rename(buf,buf2);
  42.         }
  43.         printf("3. Done.n");
  44.         fclose(rec);
  45. }