~ctwm/ctwm/trunk

« back to all changes in this revision

Viewing changes to parse_m4.c

  • Committer: Matthew Fuller
  • Date: 2016-01-25 05:27:27 UTC
  • mto: This revision was merged to the branch mainline in revision 430.
  • Revision ID: fullermd@over-yonder.net-20160125052727-um9t40rou8ur6l5w
Add a few gross flow comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
/* Technically should sysconf() this, but good enough for our purposes */
105
105
#define MAXHOSTNAME 255
106
106
 
 
107
/*
 
108
 * Writes out a temp file of all the m4 defs appropriate for this run,
 
109
 * and returns the file name
 
110
 */
107
111
static char *m4_defs(Display *display, char *host)
108
112
{
109
113
        Screen *screen;
116
120
        FILE *tmpf;
117
121
        char *user;
118
122
 
 
123
        /* Create temp file */
119
124
        fd = mkstemp(tmp_name);
120
125
        if(fd < 0) {
121
126
                perror("mkstemp failed in m4_defs");
126
131
                perror("gethostname failed in m4_defs");
127
132
                exit(1);
128
133
        }
 
134
 
 
135
 
 
136
        /*
 
137
         * Now start writing the defs into it.
 
138
         */
129
139
        hostname = gethostbyname(client);
130
140
        strcpy(server, XDisplayName(host));
131
141
        colon = strchr(server, ':');
215
225
        else {
216
226
                fputs(MkDef("TWM_CAPTIVE", "No"), tmpf);
217
227
        }
 
228
 
 
229
 
 
230
        /*
 
231
         * We might be keeping it, in which case tell the user where it is;
 
232
         * this is mostly a debugging option.  Otherwise, delete it by
 
233
         * telling m4 to do so when it reads it; this is fairly fugly, and I
 
234
         * have more than half a mind to dike it out and properly clean up
 
235
         * ourselves.
 
236
         */
218
237
        if(CLarg.KeepTmpFile) {
219
238
                fprintf(stderr, "Left file: %s\n", tmp_name);
220
239
        }
221
240
        else {
222
241
                fprintf(tmpf, "syscmd(/bin/rm %s)\n", tmp_name);
223
242
        }
 
243
 
 
244
 
 
245
        /* Close out and hand it back */
224
246
        fclose(tmpf);
225
247
        return(tmp_name);
226
248
}