toolbox

Check-in [c80a11437c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:townsign: use tmp_file() in font_file()
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c80a11437c494e1fd493ee1c9dc79abf590a4da2d21770e3a8e92e4c1be81027
User & Date: jef 2019-08-23 19:40:12
Context
2019-09-06
21:24
radios-check: fix typo in man page check-in: d22c440c86 user: jef tags: trunk
2019-08-23
19:40
townsign: use tmp_file() in font_file() check-in: c80a11437c user: jef tags: trunk
19:08
townsign: unlink town file properly check-in: f160722ec0 user: jef tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/townsign/townsign.c.

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
...
132
133
134
135
136
137
138

















139
140
141
142
143
144
145
{
	int fd;
	char buff[4096];
	ssize_t nread;

	fd = open(file, O_RDONLY);
	if (fd == -1)
		die("catfile error");
	while ((nread = read(fd, buff, sizeof(buff))) > 0) {
		if (write(1, buff, nread) < nread)
			die("write error");
	}
	close(fd);
}

char *
font_file()
{
	char *filename;
	int fd;

	filename = xstrdup("/tmp/townsign.XXXXXX");
	fd = mkstemp(filename);
	if (fd == -1)
		die("unable to create temp file:");
	if (write(fd, font_ttf, font_ttf_len) != font_ttf_len)
		die("write error:");
	close(fd);

	return filename;
}

char *
tmp_file()
{
	char *tmpfile;
	int fd;

	tmpfile = xstrdup("/tmp/townsign.XXXXXX");
................................................................................
	fd = mkstemp(tmpfile);
	if (fd == -1)
		die("unable to create temp file:");
	close(fd);

	return tmpfile;
}


















/*
 * Road sign routines
 */

struct roadprefs
roadprefs_scale(struct roadprefs prefs, float scale)







|







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

















108
109
110
111
112
113
114
...
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
{
	int fd;
	char buff[4096];
	ssize_t nread;

	fd = open(file, O_RDONLY);
	if (fd == -1)
		die("cat_file error");
	while ((nread = read(fd, buff, sizeof(buff))) > 0) {
		if (write(1, buff, nread) < nread)
			die("write error");
	}
	close(fd);
}


















char *
tmp_file()
{
	char *tmpfile;
	int fd;

	tmpfile = xstrdup("/tmp/townsign.XXXXXX");
................................................................................
	fd = mkstemp(tmpfile);
	if (fd == -1)
		die("unable to create temp file:");
	close(fd);

	return tmpfile;
}

char *
font_file()
{
	char *fontfile;
	int fd;

	fontfile = tmp_file();
	fd = open(fontfile, O_WRONLY);
	if (fd == -1)
		die("unable to open temp font file:");
	if (write(fd, font_ttf, font_ttf_len) != font_ttf_len)
		die("write error:");
	close(fd);

	return fontfile;
}

/*
 * Road sign routines
 */

struct roadprefs
roadprefs_scale(struct roadprefs prefs, float scale)