|
39 | 39 | * Portions Copyright (c) 1994, Regents of the University of California
|
40 | 40 | * Portions taken from FreeBSD.
|
41 | 41 | *
|
42 |
| - * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.54 2004/09/02 17:58:41 tgl Exp $ |
| 42 | + * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.55 2004/10/06 09:01:18 momjian Exp $ |
43 | 43 | *
|
44 | 44 | *-------------------------------------------------------------------------
|
45 | 45 | */
|
@@ -147,6 +147,9 @@ charbackend_exec[MAXPGPATH];
|
147 | 147 | staticvoid*xmalloc(size_tsize);
|
148 | 148 | staticchar*xstrdup(constchar*s);
|
149 | 149 | staticchar**replace_token(char**lines,char*token,char*replacement);
|
| 150 | +#ifdefWIN32 |
| 151 | +staticchar**filter_lines_with_token(char**lines,char*token); |
| 152 | +#endif |
150 | 153 | staticchar**readfile(char*path);
|
151 | 154 | staticvoidwritefile(char*path,char**lines);
|
152 | 155 | staticintmkdir_p(char*path,mode_tomode);
|
@@ -310,6 +313,34 @@ replace_token(char **lines, char *token, char *replacement)
|
310 | 313 |
|
311 | 314 | }
|
312 | 315 |
|
| 316 | +/* |
| 317 | + * make a copy of lines without any that contain the token |
| 318 | + * a sort of poor man's grep -v |
| 319 | + * |
| 320 | + */ |
| 321 | +#ifdefWIN32 |
| 322 | +staticchar** |
| 323 | +filter_lines_with_token(char**lines,char*token) |
| 324 | +{ |
| 325 | +intnumlines=1; |
| 326 | +inti,src,dst; |
| 327 | +char**result; |
| 328 | + |
| 329 | +for (i=0;lines[i];i++) |
| 330 | +numlines++; |
| 331 | + |
| 332 | +result= (char**)xmalloc(numlines*sizeof(char*)); |
| 333 | + |
| 334 | +for (src=0,dst=0;src<numlines;src++) |
| 335 | +{ |
| 336 | +if (lines[src]==NULL||strstr(lines[src],token)==NULL) |
| 337 | +result[dst++]=lines[src]; |
| 338 | +} |
| 339 | + |
| 340 | +returnresult; |
| 341 | +} |
| 342 | +#endif |
| 343 | + |
313 | 344 | /*
|
314 | 345 | * get the lines from a text file
|
315 | 346 | */
|
@@ -1093,6 +1124,12 @@ setup_config(void)
|
1093 | 1124 |
|
1094 | 1125 | conflines=readfile(hba_file);
|
1095 | 1126 |
|
| 1127 | +#ifdefWIN32 |
| 1128 | +conflines=filter_lines_with_token(conflines,"@remove-line-for-win32@"); |
| 1129 | +#else |
| 1130 | +conflines=replace_token(conflines,"@remove-line-for-win32@",""); |
| 1131 | +#endif |
| 1132 | + |
1096 | 1133 | #ifndefHAVE_IPV6
|
1097 | 1134 | conflines=replace_token(conflines,
|
1098 | 1135 | "host all all ::1",
|
|