Lines Matching refs:cfg
54 #include "cfg.h"
249 cfg_perror_str = dgettext("cfg",
296 * checks cfg->cf_node for filtering
304 cfg_filter_node(CFGFILE *cfg, struct parser *tbl, char *buf, char *tag)
311 if (!cfg->cf_node) /* no filter always good */
329 cfg->cf_node, strlen(cfg->cf_node), ptr, strlen(ptr));
331 if (strcmp(ptr, cfg->cf_node) == 0)
340 cfg_insert_node(CFGFILE *cfg, struct parser *tbl, char *buf, char *tag)
351 if ((fld < 0) && !(cfg->cf_node)) /* no cnode field always good */
355 if (cfg->cf_node)
356 strcat(tmpbuf, cfg->cf_node);
370 cfg_is_cnode(CFGFILE *cfg, struct parser *tbl, char *buf, char *tag)
392 cfg_get_cstring(CFGFILE *cfg, const char *key, void *value, int value_len)
410 if (cfg == NULL) {
411 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
416 if (!cfg_rdlock(cfg)) {
417 cfg_perror_str = dgettext("cfg", CFG_NOTLOCKED);
444 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
456 for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
460 cfg_perror_str = dgettext("cfg", CFG_RDFAILED);
471 if (cfg_filter_node(cfg, &chead[0], buf, section))
484 if (cfp >= &cfg->cf[2]) {
486 cfg_perror_str = dgettext("cfg", strerror(errno));
511 dgettext("cfg",
530 cfg_perror_str = dgettext("cfg", strerror(errno));
548 cfg_find_cstring(CFGFILE *cfg, const char *target,
562 if (cfg == NULL) {
563 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
575 cfg_perror_str = dgettext("cfg", strerror(errno));
581 if ((rc = cfg_get_section(cfg, &list, section)) <= 0) {
613 if ((rc = cfg_get_section(cfg, &list, section)) <= 0) {
686 cfg_put_cstring(CFGFILE *cfg, const char *key, void *value, int val_len)
707 if (cfg == NULL) {
708 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
719 if (!cfg_wrlock(cfg)) {
720 cfg_perror_str = dgettext("cfg", CFG_RDFAILED);
726 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
731 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
743 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
768 for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
773 dgettext("cfg", CFG_RDFAILED);
785 if (cfg_filter_node(cfg, &chead[0], tmpbuf,
799 if (cfp >= &cfg->cf[2]) {
801 cfg_perror_str = dgettext("cfg", strerror(errno));
823 cfg_perror_str = dgettext("cfg", strerror(errno));
840 cfg_insert_node(cfg, &chead[0], buf, section);
861 for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
866 dgettext("cfg", CFG_RDFAILED);
878 if (cfg_filter_node(cfg, &chead[0], buf,
892 if (cfp >= &cfg->cf[2]) {
894 cfg_perror_str = dgettext("cfg", strerror(errno));
921 cfg_insert_node(cfg, &chead[0],
969 cfg_insert_node(cfg, &chead[0], buf, section);
973 if (cfg_is_cnode(cfg, &chead[0], buf, section) &&
974 cfg->cf[1].cf_fd)
975 cfp = &cfg->cf[1];
977 cfp = &cfg->cf[0];
981 cfg_perror_str = dgettext("cfg", CFG_RDFAILED);
1149 cfg_get_options(CFGFILE *cfg, int section, const char *basekey, char *tag,
1157 if (cfg == NULL) {
1158 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
1169 rc = cfg_get_cstring(cfg, basekey, buf, CFG_MAX_BUF);
1200 * -1 incorrect section, or read error from cfg DB
1203 cfg_put_options(CFGFILE *cfg, int section, const char *basekey, char *tag,
1211 if (cfg == NULL) {
1212 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
1221 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
1226 if (cfg_get_cstring(cfg, basekey, buf, CFG_MAX_BUF) < 0) {
1227 /* cfg severity & perror_str set up cfg_get_cstring() */
1234 cfg_perror_str = dgettext("cfg", "Buffer too small");
1255 cfg_perror_str = dgettext("cfg", "Buffer too small");
1260 if (cfg_put_cstring(cfg, basekey, p, strlen(p)) < 0) {
1287 cfg_perror_str = dgettext("cfg", "Buffer too small");
1292 if (cfg_put_cstring(cfg, basekey, buf, CFG_MAX_BUF) < 0) {
1308 * -1 incorrect section, or read error from cfg DB
1311 cfg_get_single_option(CFGFILE *cfg, int section, const char *basekey, char *tag,
1319 if (cfg == NULL) {
1320 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
1329 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
1332 if (cfg_get_cstring(cfg, basekey, buf, CFG_MAX_BUF) < 0) {
1341 cfg_perror_str = dgettext("cfg", "Buffer too small");
1352 cfg_perror_str = dgettext("cfg", "Option not found");
1393 cfg_del_option(CFGFILE *cfg, int section, const char *basekey, char *tag)
1400 if (cfg == NULL) {
1401 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
1409 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
1412 if (cfg_get_cstring(cfg, basekey, buf, CFG_MAX_BUF) < 0) {
1421 cfg_perror_str = dgettext("cfg", "Buffer too small");
1431 rc = cfg_put_cstring(cfg, basekey, p + 1, strlen(p + 1));
1433 rc = cfg_put_cstring(cfg, basekey, "-", 1);
1459 return (cfg_put_cstring(cfg, basekey, buf, strlen(buf)));
1522 (void) fprintf(stderr, "initial cfg header read\n");
1529 (void) fprintf(stderr, "cfg: seek header failed\n");
1537 (void) fprintf(stderr, "cfg: read magic number failed\n");
1544 (void) fprintf(stderr, "cfg: seek header failed\n");
1552 (void) fprintf(stderr, "cfg: read header failed\n");
1576 (void) fprintf(stderr, "cfg: read parse config failed\n");
1591 (void) fprintf(stderr, "cfg: read ccopy1 section failed\n");
1599 (void) fprintf(stderr, "cfg: seek (SEEK_CUR) failed\n");
1613 (void) fprintf(stderr, "cfg: read ccopy2 section failed\n");
1622 (void) fprintf(stderr, "cfg: seek (SEEK_CUR) failed\n");
1634 (void) fprintf(stderr, "cfg: read h_sizes1 failed\n");
1643 (void) fprintf(stderr, "cfg: read h_sizes2 failed\n");
1679 cfg_lock(CFGFILE *cfg, CFGLOCK mode)
1685 if (cfg == NULL) {
1686 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
1695 if (mode == CFG_WRLOCK && (cfg->cf[0].cf_flag & CFG_RDONLY)) {
1718 cfg->cf[1].cf_lock = cfg->cf[0].cf_lock = cfg->cf[0].cf_fd;
1720 if (!((cfg->cf[0].cf_flag & CFG_RDONLY) &&
1729 if (fcntl(cfg->cf[0].cf_lock, F_SETLKW, &lk) < 0)
1735 for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
1742 "cfg header match, skipping re-read\n");
1752 (void) fprintf(stderr, "re-reading cfg, header mismatch\n");
1835 (void) fprintf(stderr, "cfg: map_cfglists failed\n");
1851 cfg_perror_str = dgettext("cfg", CFG_EGENERIC);
1883 cfg_unlock(CFGFILE *cfg)
1885 if (cfg == NULL) {
1886 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
1891 cfp_unlock(&cfg->cf[0]);
1892 cfp_unlock(&cfg->cf[1]);
1899 cfg_rdlock(CFGFILE *cfg)
1904 if (cfg == NULL) {
1905 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
1911 for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
1952 cfg_wrlock(CFGFILE *cfg)
1957 if (cfg == NULL) {
1958 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
1964 for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
1968 (void) fprintf(stderr, "cfg wrlock: cf_head == NULL\n");
1977 (void) fprintf(stderr, "cfg wrlock: cf_head != NULL\n");
2001 cfg_get_lock(CFGFILE *cfg, CFGLOCK *lock, pid_t *pid)
2006 if (cfg == NULL) {
2007 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
2025 if (cfg_wrlock(cfg)) {
2031 if (cfg_rdlock(cfg)) {
2038 cfg->cf[1].cf_lock = cfg->cf[0].cf_lock = cfg->cf[0].cf_fd;
2046 if (fcntl(cfg->cf[0].cf_lock, F_GETLK, &lk) < 0)
2075 cfg_commit(CFGFILE *cfg)
2083 if (cfg == NULL) {
2084 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
2089 if (!cfg_wrlock(cfg))
2093 for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
2103 (void) fprintf(stderr, "cfg: seek header failed\n");
2169 "cfg: write list sizes1 failed rc\n");
2203 "cfg: write list sizes2 failed\n");
2223 cfg_perror_str = dgettext("cfg",
2241 cfg_rewind(CFGFILE *cfg, int section)
2282 cfg_perror_str = dgettext("cfg", strerror(errno));
2289 cfg_perror_str = dgettext("cfg",
2306 cfg_perror_str = dgettext("cfg",
2312 cfg_perror_str = dgettext("cfg",
2324 cfg_perror_str = dgettext("cfg",
2337 cfg_perror_str = dgettext("cfg",
2367 cfg_update_parser_config(CFGFILE *cfg, const char *key, int section)
2377 if (cfg == NULL) {
2378 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
2383 cfp = FP_SUN_CLUSTER(cfg);
2384 if (!cfg_wrlock(cfg))
2421 cfg_perror_str = dgettext("cfg",
2525 * i to the index of the cfg which members need allocing
2539 (void) fprintf(stderr, "alloced %d cfg lists \n", n + 1);
2556 cfg_perror_str = dgettext("cfg", "unable to"
2562 cfg_perror_str = dgettext("cfg", "unable to alloc cfglist");
2797 cfg_close(CFGFILE *cfg)
2801 if (cfg == NULL) {
2802 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
2808 for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
2850 free(cfg);
2851 cfg = NULL;
2861 cfg_get_resource(CFGFILE *cfg)
2863 if (cfg == NULL) {
2864 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
2869 return (cfg->cf_node);
2878 cfg_resource(CFGFILE *cfg, const char *node)
2880 if (cfg == NULL) {
2881 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
2886 if (cfg->cf_node) {
2890 cfg->cf_node, (node?node:"NULL"));
2892 free(cfg->cf_node);
2893 cfg->cf_node = NULL;
2901 cfg->cf_node = strdup(node);
2912 CFGFILE *cfg;
2923 if ((cfg = (CFGFILE *)calloc(1, sizeof (*cfg))) == NULL) {
2924 cfg_perror_str = dgettext("cfg",
2930 cfp = &cfg->cf[0];
2947 cfp = &cfg->cf[1];
2959 for (cfp = &cfg->cf[0]; cfp->cf_name && (cfp <= &cfg->cf[1]); cfp++) {
2961 cfg_perror_str = dgettext("cfg",
2970 cfg_perror_str = dgettext("cfg",
2977 cfg_perror_str = dgettext("cfg",
2995 cfg_perror_str = dgettext("cfg",
3004 cfg_perror_str = dgettext("cfg",
3015 if (cfg_severity && (cfp <= &cfg->cf[1])) {
3016 cfp = &cfg->cf[0];
3019 cfp = &cfg->cf[1];
3022 free(cfg);
3032 return (cfg);
3057 (void) fprintf(stderr, "cfg: invalidate hsizes failed\n");
3072 cfg_cfg_isempty(CFGFILE *cfg)
3076 if (cfg == NULL) {
3077 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
3082 cfp = FP_SUN_CLUSTER(cfg);
3095 cfg_get_num_entries(CFGFILE *cfg, char *section)
3101 if (cfg == NULL) {
3102 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
3113 for (cfp = &cfg->cf[0]; cfp->cf_fd && (cfp <= &cfg->cf[1]); cfp++)
3128 cfg_get_section(CFGFILE *cfg, char ***list, const char *section)
3137 if (cfg == NULL) {
3138 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
3150 for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
3154 cfg_perror_str = dgettext("cfg", CFG_RDFAILED);
3203 cfg_get_tags(CFGFILE *cfg, char ***taglist)
3208 if (cfg == NULL) {
3209 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
3214 if (!cfg_rdlock(cfg)) {
3247 cfg_is_cfg(CFGFILE *cfg)
3251 cfp_t *cfp = FP_SUN_CLUSTER(cfg);
3255 cfg_perror_str = dgettext("cfg", "Fail to read configuration");
3263 cfg_perror_str = dgettext("cfg",
3331 cfg_get_srtdsec(CFGFILE *cfg, char ***list, const char *section,
3342 if (cfg == NULL) {
3343 cfg_perror_str = dgettext("cfg", CFG_EINVAL);
3349 cfg_perror_str = dgettext("cfg", CFG_RDFAILED);
3360 for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
3364 cfg_perror_str = dgettext("cfg", CFG_RDFAILED);
3381 cfg_perror_str = dgettext("cfg", "cfg_get_srtdsec: "
3407 cfg_perror_str = dgettext("cfg", "cfg_get_srtdsec: "
3441 cfg_perror_str = dgettext("cfg", "cfg_get_srtdsec: "
3497 cfg_perror_str = dgettext("cfg", "unable to stat config");
3551 cfg_perror_str = dgettext("cfg", "cfg_hdrcmp: No memory");
3556 cfg_perror_str = dgettext("cfg", "cfg_hdrcmp: seek failed");
3564 cfg_perror_str = dgettext("cfg", "cfg_hdrcmp: read failed");