Ejemplo n.º 1
0
Archivo: main.cpp Proyecto: apqw/epi
	void check(Str... r){

		if(!checkexist(r...)){
			std::cerr<<checkstr(r...)<<" must be specified."<<std::endl;
			std::exit(1);
		}
	}
Ejemplo n.º 2
0
//从控制台输入数据创建账户
void createAccount(Account*& temp)
{
	char user[64];
	char password[64];
	char tps[64];
	cout<<"user : "******"password : "******"password again : "<<endl;
	cin>>tps;
	if(!checkexist(user) || !check47(user) || !check100(password) || !check2pas(password, tps)) ;
	else
		temp = new Account(user, password);
}
Ejemplo n.º 3
0
Archivo: main.cpp Proyecto: apqw/epi
	bool checkexist(First f,Second s,Rest...r){
		return cp.exist(f)&&checkexist(s,r...);
	}
Ejemplo n.º 4
0
int checkexist(FILE *fp, int bnum, int oldbnum,
               int oldftime, int newbnum, int newftime,
               int digesttime, char secstr, int loop, int *eva) {
//检查DIGESTLOG中涉及的文章是否仍然存在
//如果在文摘版面已经不存在,则返回0
//如果在文章版面仍然存在,检查是否在原始版面存在
//如果在原始版面存在,则将原记录重新写回DIGESTLOG
//如果在原始版面不存在,则将文章版面的记录写入DIGESTLOG
    char dir[STRLEN], boardname[STRLEN];
    struct fileheader fhdr;
    int fd, total, n, indigest, retv = 0;

    if (NULL == fp)
        return retv;

    strncpy(boardname, bbsinfo.bcache[bnum - 1].header.filename, STRLEN);
    if (!strcmp("Digest", boardname) || !strcmp("Digest", boardname + 1))
        indigest = 1;
    else
        indigest = 0;
    sprintf(dir, MY_BBS_HOME "/boards/%s/.DIR",  boardname);

    if ((total = file_size(dir) / sizeof (fhdr)) <= 0)
        return retv;
    if ((fd = open(dir, O_RDONLY, 0)) == -1)
        return retv;
    for (n = total - 1; n >= 0 && total - n < 3000; n--) {
        if (lseek(fd, n * sizeof (fhdr), SEEK_SET) < 0)
            break;
        if (read(fd, &fhdr, sizeof (fhdr)) != sizeof (fhdr))
            break;
        if (indigest && newftime == fhdr.filetime) {
            retv = 1;
            break;
        } else if((!indigest || (indigest && !loop))
                  && oldftime == fhdr.filetime) {
            retv = 1;
            break;
        }
    }
    if (indigest && loop) {
        if (retv != 0) {
            retv =  checkexist(fp, oldbnum, oldbnum,
                               oldftime, newbnum, newftime,
                               digesttime, secstr, 0, eva);
            if (retv == 0) {
                fprintf(fp, "%d\t%d\t%d\t%d\t%d\t%c\n",
                        digesttime,
                        newbnum, newftime, newbnum,
                        newftime, secstr);
                retv = 1;
            }
        }
    } else if (retv != 0)
        fprintf(fp, "%d\t%d\t%d\t%d\t%d\t%c\n", digesttime,
                oldbnum, oldftime, newbnum, newftime, secstr);
    close(fd);

    if (retv)
        *eva = fhdr.staravg50 * fhdr.hasvoted / 50;
    else
        *eva = 0;

    return retv;
}