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

Telnet服务器

开发平台:

Unix_Linux

  1. struct userec2 {                  /* Structure used to hold information in */
  2.         char            userid[IDLEN+2];   /* PASSFILE */
  3.         char            fill[30];
  4.         time_t          firstlogin;     
  5.         char            lasthost[16];
  6.         unsigned int    numlogins;
  7.         unsigned int    numposts;
  8.         char            flags[2];
  9.         char            passwd[PASSLEN];
  10.         char            username[NAMELEN];
  11.         char            ident[NAMELEN];
  12.         char            termtype[STRLEN];
  13.         unsigned        userlevel;
  14.         time_t          lastlogin;
  15.         time_t          unused_time;
  16.         char            realname[NAMELEN];
  17.         char            address[STRLEN];
  18.         char            email[STRLEN];
  19. };
  20. struct adduserec {                  /* Structure used to add .PASSWDS */
  21.         int             signature;
  22.         int             userdefine;
  23.         time_t          notetime;     
  24.         int             noteline;
  25.         int             notemode;
  26.         int             unuse1;
  27.         int             unuse2;
  28. }
  29. main()
  30. {
  31.         FILE *rec,*rec2;
  32.         int i=0;
  33.         struct userec2 user;
  34.         struct adduserec add;
  35.         rec=fopen("./.PASSWDS","rb");
  36.         rec2=fopen("./.PASSWDS.tmp","wb");
  37.         add.userdefine=-1;
  38.         add.signature=-1;
  39.         add.notemode=-1;
  40.         add.unuse1=-1;
  41.         add.unuse2=-1;
  42.         printf("Records transfer...");
  43.         while(1)
  44.         {
  45.                 i++;
  46.                 if(fread(&user,sizeof(user),1,rec)<=0) break;
  47.                 fwrite(&user,sizeof(user),1,rec2);     
  48.                 fwrite(&add,sizeof(add),1,rec2);
  49.         }
  50.         printf("n%d records changed...n",i);
  51.         fclose(rec);
  52.         fclose(rec2);
  53. }