33# include <sys/types.h>
37#include "ctwm_atoms.h"
46#ifndef SYSTEM_INIT_FILE
47#error "No SYSTEM_INIT_FILE set"
61# pragma GCC diagnostic push
62# pragma GCC diagnostic ignored "-Wredundant-decls"
64# pragma GCC diagnostic pop
88static char overflowbuff[20];
89static int overflowlen;
104static bool doparse(
int (*ifunc)(
void),
const char *srctypename,
105 const char *srcname);
111static int m4twmFileInput(
void);
114#if defined(YYDEBUG) && YYDEBUG
136 char *tryname = NULL;
149#define TRY(fn) if((ret = ParseTwmrc(fn)) != -1) { goto DONE_TRYING; } (void)0
153 asprintf(&tryname,
"%s.%d", filename,
Scr->screen);
154 if(tryname == NULL) {
170 asprintf(&tryname,
"%s/.ctwmrc.%d",
Home,
Scr->screen);
171 if(tryname == NULL) {
180 sprintf(tryname,
"%s/.ctwmrc",
Home);
184 sprintf(tryname,
"%s/.twmrc.%d",
Home,
Scr->screen);
188 sprintf(tryname,
"%s/.twmrc",
Home);
194 if((ret =
ParseTwmrc(SYSTEM_INIT_FILE)) != -1) {
195 if(ret && filename) {
200 "%s: unable to open twmrc file %s, using %s instead\n",
219 "%s: unable to open twmrc file %s, using built-in defaults instead\n",
244 fprintf(stderr,
"%s(): Trying %s\n", __func__, filename);
251 twmrc = fopen(filename,
"r");
260 if(
CLarg.GoThroughM4) {
268 status =
doparse(m4twmFileInput,
"file", filename);
313doparse(
int (*ifunc)(
void),
const char *srctypename,
328 fprintf(stderr,
"%s: errors found in twm %s",
331 fprintf(stderr,
" \"%s\"", srcname);
333 fprintf(stderr,
"\n");
350#define MAX_INCLUDES 10
364 return (
int) overflowbuff[--overflowlen];
386 if(strncmp(
buff,
"include", 7) == 0) {
388 char *p =
buff + 7, *q;
394 for(q = p; *q && !isspace(*q); q++) {
399 if((fp = fopen(p,
"r")) == NULL) {
400 fprintf(stderr,
"%s: Unable to open included init file %s\n",
405 fprintf(stderr,
"%s: init file includes nested too deep\n",
424static int m4twmFileInput(
void)
427 static FILE *cp = NULL;
429 if(cp == NULL &&
CLarg.keepM4_filename) {
430 cp = fopen(
CLarg.keepM4_filename,
"w");
433 "%s: unable to create m4 output %s, ignoring\n",
435 CLarg.keepM4_filename = NULL;
441 return((
int) overflowbuff[--overflowlen]);
457 if(sscanf(
buff,
"#line %d", &line)) {
477 return (
int) overflowbuff[--overflowlen];
506 if(overflowlen <
sizeof overflowbuff) {
507 overflowbuff[overflowlen++] = (char) c;
511 fprintf(stderr,
"unable to unput character (%c)\n",
static bool ParseStringList(const char **sl)
static bool doparse(int(*ifunc)(void), const char *srctypename, const char *srcname)
static const char * currentString
static int twmStringListInput(void)
static const char ** stringListSource
static int twmFileInput(void)
void twmrc_error_prefix(void)
static struct incl rc_includes[10]
int(* twmInputFunc)(void)
static int ParseTwmrc(const char *filename)
Try parsing a file as a ctwmrc.
bool LoadTwmrc(const char *filename)
Principal entry point from top-level code to parse the config file.
FILE * start_m4(FILE *fraw)