You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/08/12 19:40:59 UTC
svn commit: r803626 - in /commons/sandbox/runtime/trunk/src/main/native:
Makefile.in os/darwin/env.c os/hpux/env.c
Author: mturk
Date: Wed Aug 12 17:40:59 2009
New Revision: 803626
URL: http://svn.apache.org/viewvc?rev=803626&view=rev
Log:
Add mac and hpux env.c
Added:
commons/sandbox/runtime/trunk/src/main/native/os/darwin/env.c (with props)
commons/sandbox/runtime/trunk/src/main/native/os/hpux/env.c (with props)
Modified:
commons/sandbox/runtime/trunk/src/main/native/Makefile.in
Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=803626&r1=803625&r2=803626&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Wed Aug 12 17:40:59 2009
@@ -155,6 +155,7 @@
$(SRCDIR)/os/unix/time.$(OBJ) \
$(SRCDIR)/os/unix/uuid.$(OBJ) \
$(SRCDIR)/os/unix/uutils.$(OBJ) \
+ $(SRCDIR)/os/darwin/env.$(OBJ) \
$(SRCDIR)/os/darwin/platform.$(OBJ) \
$(SRCDIR)/os/darwin/pmutex.$(OBJ) \
$(SRCDIR)/os/darwin/pgroup.$(OBJ) \
@@ -175,6 +176,7 @@
$(SRCDIR)/os/unix/time.$(OBJ) \
$(SRCDIR)/os/unix/uuid.$(OBJ) \
$(SRCDIR)/os/unix/uutils.$(OBJ) \
+ $(SRCDIR)/os/hpux/env.$(OBJ) \
$(SRCDIR)/os/hpux/platform.$(OBJ) \
$(SRCDIR)/os/hpux/pgroup.$(OBJ) \
$(SRCDIR)/os/hpux/puser.$(OBJ) \
Added: commons/sandbox/runtime/trunk/src/main/native/os/darwin/env.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/env.c?rev=803626&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/env.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/env.c Wed Aug 12 17:40:59 2009
@@ -0,0 +1,39 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include "acr_arch.h"
+#include "acr_error.h"
+#include "acr_memory.h"
+#include "acr_env.h"
+
+
+ACR_DECLARE(char *) ACR_EnvGet(const char *var)
+{
+ return getenv(var);
+}
+
+ACR_DECLARE(int) ACR_EnvSet(const char *var, const char *val)
+{
+ return setenv(var, val, 1);
+}
+
+ACR_DECLARE(int) ACR_EnvDelete(const char *var)
+{
+ return unsetenv(var);
+}
+
Propchange: commons/sandbox/runtime/trunk/src/main/native/os/darwin/env.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/native/os/hpux/env.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/env.c?rev=803626&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/hpux/env.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/env.c Wed Aug 12 17:40:59 2009
@@ -0,0 +1,89 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include "acr_arch.h"
+#include "acr_error.h"
+#include "acr_memory.h"
+#include "acr_env.h"
+
+ACR_DECLARE(char *) ACR_EnvGet(const char *var)
+{
+ return getenv(var);
+}
+
+ACR_DECLARE(int) ACR_EnvSet(const char *var, const char *val)
+{
+ int rc;
+ char *estr;
+
+ if (!var || !*var || !val) {
+ errno = EINVAL;
+ return -1;
+ }
+ estr = (char *)malloc(strlen(var) + strlen(val) + 2);
+ if (!estr) /* not much we can do if no memory */
+ return -1;
+
+ /* Override the existing setting by forcibly defining the var */
+ sprintf(estr, "%s=%s", var, val);
+ if (putenv(estr)) {
+ int se = errno;
+ free(estr);
+ errno = se;
+ return -1;
+ }
+ free(estr);
+
+ return 0;
+}
+
+ACR_DECLARE(int) ACR_EnvDelete(const char *var)
+{
+ char *estr;
+
+ if (!var || !*var) {
+ errno = EINVAL;
+ return -1;
+ }
+ if (getenv(var) == NULL)
+ return 0; /* no work */
+ estr = (char *)malloc(strlen(var) + 2);
+ if (!estr) /* not much we can do if no memory */
+ return -1;
+
+ /* Override the existing setting by forcibly defining the var */
+ sprintf(estr, "%s=", var);
+ if (putenv(estr)) {
+ int se = errno;
+ free(estr);
+ errno = se;
+ return -1;
+ }
+
+ /* Now we can clobber the variable definition this way: */
+ strcpy(estr, "=");
+ /*
+ * This last putenv cleans up if we have multiple zero-length names as a
+ * result of unsetting multiple things.
+ */
+ putenv(estr);
+ free(estr);
+
+ return 0;
+}
+
Propchange: commons/sandbox/runtime/trunk/src/main/native/os/hpux/env.c
------------------------------------------------------------------------------
svn:eol-style = native