diff options
author | jlovell <jlovell@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2006-03-08 23:30:01 +0000 |
---|---|---|
committer | jlovell <jlovell@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2006-03-08 23:30:01 +0000 |
commit | 480ef0fe29ab803f49dd87a7a21a6c61648539b8 (patch) | |
tree | 6bf8d167e23bb643ef2e0d48277e4312f86273f9 /scheduler/env.c | |
parent | 757d2cad8f3f75c420ad2e462b787cd9cf8a7a62 (diff) | |
download | cups-480ef0fe29ab803f49dd87a7a21a6c61648539b8.tar.gz |
Load cups into easysw/current.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@83 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'scheduler/env.c')
-rw-r--r-- | scheduler/env.c | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/scheduler/env.c b/scheduler/env.c index d10694818..f055b3a21 100644 --- a/scheduler/env.c +++ b/scheduler/env.c @@ -1,5 +1,5 @@ /* - * "$Id: env.c 5094 2006-02-09 01:00:26Z mike $" + * "$Id: env.c 5245 2006-03-08 13:09:49Z mike $" * * Environment management routines for the Common UNIX Printing System (CUPS). * @@ -161,16 +161,9 @@ void cupsdSetEnv(const char *name, /* I - Name of variable */ const char *value) /* I - Value of variable */ { - /* - * Check for room... - */ + int i, /* Looping var */ + namelen; /* Length of name */ - if (num_common_env >= (int)(sizeof(common_env) / sizeof(common_env[0]))) - { - cupsdLogMessage(CUPSD_LOG_ERROR, - "cupsdSetEnv: Too many environment variables set!"); - return; - } /* * If "value" is NULL, try getting value from current environment... @@ -183,15 +176,36 @@ cupsdSetEnv(const char *name, /* I - Name of variable */ return; /* - * Set the new environment variable... + * See if this variable has already been defined... */ - cupsdSetStringf(common_env + num_common_env, "%s=%s", name, value); + for (i = 0, namelen = strlen(name); i < num_common_env; i ++) + if (!strncmp(common_env[i], name, namelen) && common_env[i][namelen] == '=') + break; + + if (i >= num_common_env) + { + /* + * Check for room... + */ + + if (num_common_env >= (int)(sizeof(common_env) / sizeof(common_env[0]))) + { + cupsdLogMessage(CUPSD_LOG_ERROR, + "cupsdSetEnv: Too many environment variables set!"); + return; + } + + num_common_env ++; + } + + /* + * Set the new environment variable... + */ - cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSetEnv: %s\n", - common_env[num_common_env]); + cupsdSetStringf(common_env + i, "%s=%s", name, value); - num_common_env ++; + cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSetEnv: %s\n", common_env[i]); } @@ -225,5 +239,5 @@ cupsdSetEnvf(const char *name, /* I - Name of variable */ /* - * End of "$Id: env.c 5094 2006-02-09 01:00:26Z mike $". + * End of "$Id: env.c 5245 2006-03-08 13:09:49Z mike $". */ |