void doSkipSection(FILE *fp, int *LineNum, char *lsfile, char *sectionName) { char *word; char *cp; while ((cp = getNextLineC_(fp, LineNum, TRUE)) != NULL) { word = getNextWord_(&cp); if (strcasecmp(word, "end") == 0) { word = getNextWord_(&cp); if (! word) { ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5407, "%s(%d): Section ended without section name, ignored"), lsfile, *LineNum); /* catgets 5407 */ } else { if (strcasecmp(word, sectionName) != 0) ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5408, "%s(%d): Section %s ended with wrong section name: %s, ignored"), lsfile, *LineNum, sectionName, word); /* catgets 5408 */ } return; } } ls_syslog(LOG_ERR, I18N_PREMATURE_EOF, "doSkipSection", lsfile, *LineNum, sectionName); }
char * getBeginLine(FILE *fp, int *LineNum) { char *sp; char *wp; for (;;) { sp = getNextLineC_(fp, LineNum, TRUE); if (! sp) return (NULL); wp = getNextWord_(&sp); if (wp && (strcasecmp(wp, "begin") == 0)) return sp; } }
int readHvalues(struct keymap *keyList, char *linep, FILE *fp, char *lsfile, int *LineNum, int exact, char *section) { static char fname[] = "readHvalues"; char *key; char *value; char *sp, *sp1; char error = FALSE; int i=0; sp = linep; key = getNextWord_(&linep); if ((sp1 = strchr(key, '=')) != NULL) *sp1 = '\0'; value = strchr(sp, '='); if (!value) { ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5402, "%s: %s(%d): missing '=' after keyword %s, section %s ignoring the line"), fname, lsfile, *LineNum, key, section); /* catgets 5402 */ } else { value++; while (*value == ' ') value++; if (value[0] == '\0') { ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5403, "%s: %s(%d): null value after keyword %s, section %s ignoring the line"), fname, lsfile, *LineNum, key, section); /* catgets 5403 */ } if (value[0] == '(') { value++; if ((sp1 = strrchr(value, ')')) != NULL) *sp1 = '\0'; } if (putValue(keyList, key, value) < 0) { ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5404, "%s: %s(%d): bad keyword %s in section %s, ignoring the line"), fname, lsfile, *LineNum, key, section); /* catgets 5404 */ } } if ((linep = getNextLineC_(fp, LineNum, TRUE)) != NULL) { if (isSectionEnd(linep, lsfile, LineNum, section)) { if (! exact) return 0; i = 0; while (keyList[i].key != NULL) { if (keyList[i].val == NULL) { ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5405, "%s: %s(%d): required keyword %s is missing in section %s, ignoring the section"), fname, lsfile, *LineNum, keyList[i].key, section); /* catgets 5405 */ error = TRUE; } i++; } if (error) { i = 0; while (keyList[i].key != NULL) { FREEUP(keyList[i].val); i++; } return -1; } return 0; } return readHvalues(keyList, linep, fp, lsfile, LineNum, exact, section); } ls_syslog(LOG_ERR, I18N_PREMATURE_EOF, fname, lsfile, *LineNum, section); return -1; }
int readconfenv_ (struct config_param *pList1, struct config_param *pList2, char *confPath) { char *key; char *value; char *line; FILE *fp; char filename[MAXFILENAMELEN]; struct config_param *plp; int lineNum = 0, saveErrNo; if (pList1) for (plp = pList1; plp->paramName != NULL; plp++) { if (plp->paramValue != NULL) { lserrno = LSE_BAD_ARGS; return (-1); } } if (pList2) for (plp = pList2; plp->paramName != NULL; plp++) { if (plp->paramValue != NULL) { lserrno = LSE_BAD_ARGS; return (-1); } } if (confPath) { { memset (filename, 0, sizeof (filename)); ls_strcat (filename, sizeof (filename), confPath); ls_strcat (filename, sizeof (filename), "/lsf.conf"); fp = fopen (filename, "r"); } } else { char *ep = getenv ("LSF_ENVDIR"); char buf[MAXFILENAMELEN]; if (ep == NULL) { sprintf (buf, "%s/lsf.conf", LSETCDIR); fp = fopen (buf, "r"); } else { memset (buf, 0, sizeof (buf)); ls_strcat (buf, sizeof (buf), ep); ls_strcat (buf, sizeof (buf), "/lsf.conf"); fp = fopen (buf, "r"); } } if (!fp) { lserrno = LSE_LSFCONF; return (-1); } lineNum = 0; errLineNum_ = 0; while ((line = getNextLineC_ (fp, &lineNum, TRUE)) != NULL) { int cc; cc = parseLine (line, &key, &value); if (cc < 0 && errLineNum_ == 0) { errLineNum_ = lineNum; saveErrNo = lserrno; continue; } if (!matchEnv (key, pList1) && !matchEnv (key, pList2)) continue; if (!setConfEnv (key, value, pList1) || !setConfEnv (key, value, pList2)) { fclose (fp); return (-1); } } fclose (fp); if (errLineNum_ != 0) { lserrno = saveErrNo; return (-1); } return (0); }