|
4 | 4 | * Support for grand unified configuration scheme, including SET
|
5 | 5 | * command, configuration file, and command line options.
|
6 | 6 | *
|
7 |
| - * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.4 2000/06/22 22:31:21 petere Exp $ |
| 7 | + * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.5 2000/07/03 20:46:05 petere Exp $ |
8 | 8 | *
|
9 | 9 | * Copyright 2000 by PostgreSQL Global Development Group
|
10 | 10 | * Written by Peter Eisentraut <peter_e@gmx.net>.
|
@@ -354,6 +354,9 @@ ResetAllOptions(void)
|
354 | 354 | }
|
355 | 355 | ConfigureNamesString[i].variable = str;
|
356 | 356 | }
|
| 357 | + |
| 358 | + if (getenv("PGPORT")) |
| 359 | + PostPortName = atoi(getenv("PGPORT")); |
357 | 360 | }
|
358 | 361 |
|
359 | 362 |
|
@@ -718,3 +721,49 @@ GetConfigOption(const char * name)
|
718 | 721 | }
|
719 | 722 | return NULL;
|
720 | 723 | }
|
| 724 | + |
| 725 | + |
| 726 | + |
| 727 | +/* |
| 728 | + * A little "long argument" simulation, although not quite GNU |
| 729 | + * compliant. Takes a string of the form "some-option=some value" and |
| 730 | + * returns name = "some_option" and value = "some value" in malloc'ed |
| 731 | + * storage. Note that '-' is converted to '_' in the option name. If |
| 732 | + * there is no '=' in the input string then value will be NULL. |
| 733 | + */ |
| 734 | +void |
| 735 | +ParseLongOption(const char * string, char ** name, char ** value) |
| 736 | +{ |
| 737 | + size_t equal_pos; |
| 738 | + char *cp; |
| 739 | + |
| 740 | + AssertArg(string); |
| 741 | + AssertArg(name); |
| 742 | + AssertArg(value); |
| 743 | + |
| 744 | + equal_pos = strcspn(string, "="); |
| 745 | + |
| 746 | + if (string[equal_pos] == '=') |
| 747 | + { |
| 748 | + *name = malloc(equal_pos + 1); |
| 749 | + if (!*name) |
| 750 | + elog(FATAL, "out of memory"); |
| 751 | + strncpy(*name, string, equal_pos); |
| 752 | + (*name)[equal_pos] = '\0'; |
| 753 | + |
| 754 | + *value = strdup(&string[equal_pos + 1]); |
| 755 | + if (!*value) |
| 756 | + elog(FATAL, "out of memory"); |
| 757 | + } |
| 758 | + else /* no equal sign in string */ |
| 759 | + { |
| 760 | + *name = strdup(string); |
| 761 | + if (!*name) |
| 762 | + elog(FATAL, "out of memory"); |
| 763 | + *value = NULL; |
| 764 | + } |
| 765 | + |
| 766 | + for(cp = *name; *cp; cp++) |
| 767 | + if (*cp == '-') |
| 768 | + *cp = '_'; |
| 769 | +} |
0 commit comments