⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 conffile.c

📁 开源备份软件源码 AMANDA, the Advanced Maryland Automatic Network Disk Archiver, is a backup system that a
💻 C
📖 第 1 页 / 共 5 页
字号:
	}	break;    case CONF_DEFINE:	if (is_client) {	    handle_invalid_keyword(tokenval.v.s);	} else {	    get_conftoken(CONF_ANY);	    if(tok == CONF_DUMPTYPE) get_dumptype();	    else if(tok == CONF_TAPETYPE) get_tapetype();	    else if(tok == CONF_INTERFACE) get_interface();	    else conf_parserror(_("DUMPTYPE, INTERFACE or TAPETYPE expected"));	}	break;    case CONF_NL:	/* empty line */	break;    case CONF_END:	/* end of file */	return 0;    /* if it's not a known punctuation mark, then check the parse table and use the     * read_function we find there. */    default:	{	    for(np = parsetable; np->token != CONF_UNKNOWN; np++) 		if(np->token == tok) break;	    if(np->token == CONF_UNKNOWN) {                handle_invalid_keyword(tokenval.v.s);	    } else {		np->read_function(np, &conf_data[np->parm]);		if(np->validate_function)		    np->validate_function(np, &conf_data[np->parm]);	    }	}    }    if(tok != CONF_NL)	get_conftoken(CONF_NL);    return 1;}static voidhandle_invalid_keyword(    const char * token){    /* Procedure for deprecated keywords:     * 1) At time of deprecation, add to warning_deprecated below.     *    Note the date of deprecation.     * 2) After two years, move the keyword to error_deprecated below.     *    Note the date of the move.     * 3) After two more years, drop the token entirely. */    static const char * warning_deprecated[] = {        "rawtapedev",  /* 2007-01-23 */        "tapebufs",    /* 2007-10-15 */	"netusage",    /* historical since 1997-08-11, deprecated 2007-10-23 */        NULL    };    static const char * error_deprecated[] = {        NULL    };    const char ** s;    for (s = warning_deprecated; *s != NULL; s ++) {        if (strcmp(*s, token) == 0) {            conf_parswarn(_("warning: Keyword %s is deprecated."),                           token);            break;        }    }    if (*s == NULL) {        for (s = error_deprecated; *s != NULL; s ++) {            if (strcmp(*s, token) == 0) {                conf_parserror(_("error: Keyword %s is deprecated."),                               token);                return;            }        }    }    if (*s == NULL) {        conf_parserror(_("configuration keyword expected"));    }    for (;;) {        char c = conftoken_getc();        if (c == '\n' || c == -1) {            conftoken_ungetc(c);            return;        }    }    g_assert_not_reached();}static voidread_block(    conf_var_t    *read_var,    val_t    *valarray,    char     *errormsg,    int       read_brace,    void      (*copy_function)(void)){    conf_var_t *np;    int    done;    if(read_brace) {	get_conftoken(CONF_LBRACE);	get_conftoken(CONF_NL);    }    done = 0;    do {	current_line_num += 1;	get_conftoken(CONF_ANY);	switch(tok) {	case CONF_RBRACE:	    done = 1;	    break;	case CONF_NL:	/* empty line */	    break;	case CONF_END:	/* end of file */	    done = 1;	    break;	/* inherit from a "parent" */        case CONF_IDENT:        case CONF_STRING:	    if(copy_function) 		copy_function();	    else		conf_parserror(_("ident not expected"));	    break;	default:	    {		for(np = read_var; np->token != CONF_UNKNOWN; np++)		    if(np->token == tok) break;		if(np->token == CONF_UNKNOWN)		    conf_parserror(errormsg);		else {		    np->read_function(np, &valarray[np->parm]);		    if(np->validate_function)			np->validate_function(np, &valarray[np->parm]);		}	    }	}	if(tok != CONF_NL && tok != CONF_END && tok != CONF_RBRACE)	    get_conftoken(CONF_NL);    } while(!done);}static voidget_holdingdisk(    void){    int save_overwrites;    save_overwrites = allow_overwrites;    allow_overwrites = 1;    init_holdingdisk_defaults();    get_conftoken(CONF_IDENT);    hdcur.name = stralloc(tokenval.v.s);    hdcur.seen = current_line_num;    read_block(holding_var, hdcur.value,	       _("holding disk parameter expected"), 1, NULL);    get_conftoken(CONF_NL);    save_holdingdisk();    allow_overwrites = save_overwrites;}static voidinit_holdingdisk_defaults(    void){    conf_init_str(&hdcur.value[HOLDING_COMMENT]  , "");    conf_init_str(&hdcur.value[HOLDING_DISKDIR]  , "");    conf_init_am64(&hdcur.value[HOLDING_DISKSIZE] , (off_t)0);                    /* 1 Gb = 1M counted in 1Kb blocks */    conf_init_am64(&hdcur.value[HOLDING_CHUNKSIZE], (off_t)1024*1024);}static voidsave_holdingdisk(    void){    holdingdisk_t *hp;    hp = alloc(sizeof(holdingdisk_t));    *hp = hdcur;    hp->next = holdinglist;    holdinglist = hp;}/* WARNING: * This function is called both from this module and from diskfile.c. Modify * with caution. */dumptype_t *read_dumptype(    char *name,    FILE *from,    char *fname,    int *linenum){    int save_overwrites;    FILE *saved_conf = NULL;    char *saved_fname = NULL;    if (from) {	saved_conf = current_file;	current_file = from;    }    if (fname) {	saved_fname = current_filename;	current_filename = fname;    }    if (linenum)	current_line_num = *linenum;    save_overwrites = allow_overwrites;    allow_overwrites = 1;    init_dumptype_defaults();    if (name) {	dpcur.name = name;    } else {	get_conftoken(CONF_IDENT);	dpcur.name = stralloc(tokenval.v.s);    }    dpcur.seen = current_line_num;    read_block(dumptype_var, dpcur.value,	       _("dumptype parameter expected"),	       (name == NULL), copy_dumptype);    if(!name) /* !name => reading disklist, not conffile */	get_conftoken(CONF_NL);    /* XXX - there was a stupidity check in here for skip-incr and    ** skip-full.  This check should probably be somewhere else. */    save_dumptype();    allow_overwrites = save_overwrites;    if (linenum)	*linenum = current_line_num;    if (fname)	current_filename = saved_fname;    if (from)	current_file = saved_conf;    return lookup_dumptype(dpcur.name);}static voidget_dumptype(void){    read_dumptype(NULL, NULL, NULL, NULL);}static voidinit_dumptype_defaults(void){    dpcur.name = NULL;    conf_init_str   (&dpcur.value[DUMPTYPE_COMMENT]           , "");    conf_init_str   (&dpcur.value[DUMPTYPE_PROGRAM]           , "DUMP");    conf_init_str   (&dpcur.value[DUMPTYPE_SRVCOMPPROG]       , "");    conf_init_str   (&dpcur.value[DUMPTYPE_CLNTCOMPPROG]      , "");    conf_init_str   (&dpcur.value[DUMPTYPE_SRV_ENCRYPT]       , "");    conf_init_str   (&dpcur.value[DUMPTYPE_CLNT_ENCRYPT]      , "");    conf_init_str   (&dpcur.value[DUMPTYPE_AMANDAD_PATH]      , "X");    conf_init_str   (&dpcur.value[DUMPTYPE_CLIENT_USERNAME]   , "X");    conf_init_str   (&dpcur.value[DUMPTYPE_SSH_KEYS]          , "X");    conf_init_str   (&dpcur.value[DUMPTYPE_SECURITY_DRIVER]   , "BSD");    conf_init_exinclude(&dpcur.value[DUMPTYPE_EXCLUDE]);    conf_init_exinclude(&dpcur.value[DUMPTYPE_INCLUDE]);    conf_init_priority (&dpcur.value[DUMPTYPE_PRIORITY]          , 1);    conf_init_int      (&dpcur.value[DUMPTYPE_DUMPCYCLE]         , conf_data[CNF_DUMPCYCLE].v.i);    conf_init_int      (&dpcur.value[DUMPTYPE_MAXDUMPS]          , conf_data[CNF_MAXDUMPS].v.i);    conf_init_int      (&dpcur.value[DUMPTYPE_MAXPROMOTEDAY]     , 10000);    conf_init_int      (&dpcur.value[DUMPTYPE_BUMPPERCENT]       , conf_data[CNF_BUMPPERCENT].v.i);    conf_init_am64     (&dpcur.value[DUMPTYPE_BUMPSIZE]          , conf_data[CNF_BUMPSIZE].v.am64);    conf_init_int      (&dpcur.value[DUMPTYPE_BUMPDAYS]          , conf_data[CNF_BUMPDAYS].v.i);    conf_init_real     (&dpcur.value[DUMPTYPE_BUMPMULT]          , conf_data[CNF_BUMPMULT].v.r);    conf_init_time     (&dpcur.value[DUMPTYPE_STARTTIME]         , (time_t)0);    conf_init_strategy (&dpcur.value[DUMPTYPE_STRATEGY]          , DS_STANDARD);    conf_init_estimate (&dpcur.value[DUMPTYPE_ESTIMATE]          , ES_CLIENT);    conf_init_compress (&dpcur.value[DUMPTYPE_COMPRESS]          , COMP_FAST);    conf_init_encrypt  (&dpcur.value[DUMPTYPE_ENCRYPT]           , ENCRYPT_NONE);    conf_init_str   (&dpcur.value[DUMPTYPE_SRV_DECRYPT_OPT]   , "-d");    conf_init_str   (&dpcur.value[DUMPTYPE_CLNT_DECRYPT_OPT]  , "-d");    conf_init_rate     (&dpcur.value[DUMPTYPE_COMPRATE]          , 0.50, 0.50);    conf_init_am64     (&dpcur.value[DUMPTYPE_TAPE_SPLITSIZE]    , (off_t)0);    conf_init_am64     (&dpcur.value[DUMPTYPE_FALLBACK_SPLITSIZE], (off_t)10 * 1024);    conf_init_str   (&dpcur.value[DUMPTYPE_SPLIT_DISKBUFFER]  , NULL);    conf_init_bool     (&dpcur.value[DUMPTYPE_RECORD]            , 1);    conf_init_bool     (&dpcur.value[DUMPTYPE_SKIP_INCR]         , 0);    conf_init_bool     (&dpcur.value[DUMPTYPE_SKIP_FULL]         , 0);    conf_init_holding  (&dpcur.value[DUMPTYPE_HOLDINGDISK]       , HOLD_AUTO);    conf_init_bool     (&dpcur.value[DUMPTYPE_KENCRYPT]          , 0);    conf_init_bool     (&dpcur.value[DUMPTYPE_IGNORE]            , 0);    conf_init_bool     (&dpcur.value[DUMPTYPE_INDEX]             , 1);}static voidsave_dumptype(void){    dumptype_t *dp, *dp1;;    dp = lookup_dumptype(dpcur.name);    if(dp != (dumptype_t *)0) {	conf_parserror(_("dumptype %s already defined on line %d"), dp->name, dp->seen);	return;    }    dp = alloc(sizeof(dumptype_t));    *dp = dpcur;    dp->next = NULL;    /* add at end of list */    if(!dumplist)	dumplist = dp;    else {	dp1 = dumplist;	while (dp1->next != NULL) {	     dp1 = dp1->next;	}	dp1->next = dp;    }}static voidcopy_dumptype(void){    dumptype_t *dt;    int i;    dt = lookup_dumptype(tokenval.v.s);    if(dt == NULL) {	conf_parserror(_("dumptype parameter expected"));	return;    }    for(i=0; i < DUMPTYPE_DUMPTYPE; i++) {	if(dt->value[i].seen) {	    free_val_t(&dpcur.value[i]);	    copy_v

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -