Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial Platform-6.1 but with most recent krb5

  • Loading branch information...
commit 92ae378f29ee58a3df7e8f630e57d865bdaddc26 0 parents
gitsync authored
Showing with 31,262 additions and 0 deletions.
  1. +8 −0 centutils/LICENSE
  2. +64 −0 centutils/MakeKitBuild
  3. +9 −0 centutils/Makefile.am
  4. +2 −0  centutils/autogen.sh
  5. +218 −0 centutils/configure.in
  6. +10 −0 centutils/include/MakeKitBuild
  7. +20 −0 centutils/include/Makefile.am
  8. +147 −0 centutils/include/ctarray.h
  9. +78 −0 centutils/include/ctbase.h
  10. +148 −0 centutils/include/ctdef.h
  11. +214 −0 centutils/include/ctexec.h
  12. +431 −0 centutils/include/ctfileutils.h
  13. +201 −0 centutils/include/cthash.h
  14. +89 −0 centutils/include/ctmem.h
  15. +121 −0 centutils/include/ctprocutils.h
  16. +120 −0 centutils/include/ctrwlock.h
  17. +106 −0 centutils/include/ctshell.h
  18. +258 −0 centutils/include/ctstrutils.h
  19. +86 −0 centutils/include/ctsys.h
  20. +95 −0 centutils/include/ctsysfuncs.h
  21. +75 −0 centutils/include/cttext.h
  22. +71 −0 centutils/include/ctuser.h
  23. +181 −0 centutils/include/lwexc.h
  24. +504 −0 centutils/libcentutils/COPYING
  25. +9 −0 centutils/libcentutils/MakeKitBuild
  26. +27 −0 centutils/libcentutils/Makefile.am
  27. +162 −0 centutils/libcentutils/ctarray.c
  28. +447 −0 centutils/libcentutils/ctexec.c
  29. +2,159 −0 centutils/libcentutils/ctfileutils.c
  30. +525 −0 centutils/libcentutils/cthash.c
  31. +127 −0 centutils/libcentutils/ctmem.c
  32. +563 −0 centutils/libcentutils/ctprocutils.c
  33. +170 −0 centutils/libcentutils/ctrwlock.c
  34. +705 −0 centutils/libcentutils/ctshell.c
  35. +952 −0 centutils/libcentutils/ctstrutils.c
  36. +139 −0 centutils/libcentutils/ctsysfuncs.c
  37. +150 −0 centutils/libcentutils/cttext.c
  38. +172 −0 centutils/libcentutils/ctuser.c
  39. +380 −0 centutils/libcentutils/lwexc.c
  40. +7 −0 centutils/libgpglib/MakeKitBuild
  41. +49 −0 centutils/m4/as-ac-expand.m4
  42. +9 −0 centutils/test/MakeKitBuild
  43. +16 −0 centutils/test/Makefile.am
  44. +55 −0 centutils/test/test_ctfileutils.c
  45. +124 −0 centutils/test/test_ctshell.c
  46. +87 −0 curl/Android.mk
  47. +2,121 −0 curl/CHANGES
  48. +2 −0  curl/CMake/CMakeConfigurableFile.in
  49. +44 −0 curl/CMake/CheckTypeSize.c.in
  50. +57 −0 curl/CMake/CheckTypeSize.cmake
  51. +75 −0 curl/CMake/CurlCheckCSourceCompiles.cmake
  52. +83 −0 curl/CMake/CurlCheckCSourceRuns.cmake
  53. +690 −0 curl/CMake/CurlTests.c
  54. +19 −0 curl/CMake/FindOpenSSL.cmake
  55. +8 −0 curl/CMake/FindZLIB.cmake
  56. +250 −0 curl/CMake/OtherTests.cmake
  57. +121 −0 curl/CMake/Platforms/WindowsCache.cmake
  58. +31 −0 curl/CMake/Utilities.cmake
  59. +859 −0 curl/CMakeLists.txt
  60. +21 −0 curl/COPYING
  61. +78 −0 curl/MacOSX-Framework
  62. +12 −0 curl/MakeKitBuild
  63. +292 −0 curl/Makefile
  64. +153 −0 curl/Makefile.am
  65. +49 −0 curl/README
  66. +64 −0 curl/RELEASE-NOTES
  67. +3,247 −0 curl/acinclude.m4
  68. +903 −0 curl/aclocal.m4
  69. +3 −0  curl/autogen.sh
  70. +396 −0 curl/buildconf
  71. +142 −0 curl/compile
  72. +2,644 −0 curl/configure.ac
  73. +161 −0 curl/curl-config.in
  74. +50 −0 curl/curl-style.el
  75. +530 −0 curl/depcomp
  76. +228 −0 curl/docs/BINDINGS
  77. +81 −0 curl/docs/BUGS
  78. +257 −0 curl/docs/CONTRIBUTE
  79. +176 −0 curl/docs/DISTRO-DILEMMA
  80. +1,288 −0 curl/docs/FAQ
  81. +135 −0 curl/docs/FEATURES
  82. +186 −0 curl/docs/HISTORY
  83. +981 −0 curl/docs/INSTALL
  84. +302 −0 curl/docs/INSTALL.devcpp
  85. +488 −0 curl/docs/INTERNALS
  86. +235 −0 curl/docs/KNOWN_BUGS
  87. +126 −0 curl/docs/LICENSE-MIXING
  88. +971 −0 curl/docs/MANUAL
  89. +40 −0 curl/docs/Makefile.am
  90. +27 −0 curl/docs/README.netware
  91. +26 −0 curl/docs/README.win32
  92. +75 −0 curl/docs/RESOURCES
  93. +116 −0 curl/docs/SSLCERTS
  94. +782 −0 curl/docs/THANKS
  95. +601 −0 curl/docs/TODO
  96. +490 −0 curl/docs/TheArtOfHttpScripting
  97. +67 −0 curl/docs/VERSIONS
  98. +99 −0 curl/docs/curl-config.1
  99. +90 −0 curl/docs/curl-config.html
  100. BIN  curl/docs/curl-config.pdf
Sorry, we could not display the entire diff because too many files (17,491) changed.
8 centutils/LICENSE
@@ -0,0 +1,8 @@
+Code residing in the libcentutils directory is licensed
+under the GNU Lesser General Public License version 2.1.
+See libcentutils/COPYING for details.
+
+Code residing in the libgpglib directory is licensed
+under the GNU Library General Public License version 2.
+See libgpglib/COPYING for details.
+
64 centutils/MakeKitBuild
@@ -0,0 +1,64 @@
+SUBDIRS="include libcentutils test"
+
+configure()
+{
+ mk_config_header "include/config.h"
+
+ lw_define_feature_macros
+
+ mk_export MOD_EXT="${MK_DLO_EXT}"
+ mk_define MOD_EXT "\"${MK_DLO_EXT}"\"
+
+ MK_CFLAGS="$MK_CFLAGS -Wall -Werror -fno-strict-aliasing"
+
+ mk_export CONFIGDIR="${MK_SYSCONFDIR}"
+ mk_define CONFIGDIR "\"${MK_SYSCONFDIR}\""
+
+ mk_define PREFIXDIR "\"${MK_PREFIX}\""
+ mk_define LIBDIR "\"${MK_LIBDIR}\""
+
+ mk_check_endian
+
+ # Headers
+ mk_check_headers \
+ HEADERDEPS="sys/types.h" \
+ inttypes.h fcntl.h limits.h stdlib.h string.h \
+ strings.h syslog.h unistd.h sys/types.h fcntl.h \
+ sys/stat.h sys/param.h sys/pstat.h proc/readproc.h \
+ sys/ioctl.h sys/termio.h utmps.h utmpx.h utmp.h \
+ procfs.h sys/procfs.h kvm.h sys/sysctl.h sys/user.h \
+ time.h sys/time.h
+
+ # Types
+ mk_check_types \
+ HEADERDEPS="unistd.h time.h inttypes.h" \
+ pid_t "struct tm" \
+ int8 int16 int32 int64 \
+ uint8 uint16 uint32 uint64
+
+ mk_check_types \
+ HEADERDEPS="procfs.h sys/procfs.h" \
+ "struct psinfo"
+
+ # Libraries
+ mk_check_libraries \
+ proc kvm rt
+
+ mk_check_functions \
+ HEADERDEPS="signal.h stdlib.h kvm.h unistd.h" \
+ sigtimedwait bzero localtime_r memset \
+ select socket strchr strerror vsyslog \
+ rpl_malloc rpl_realloc mkdtemp _NSGetEnviron \
+
+ mk_check_functions \
+ HEADERDEPS="kvm.h sys/param.h sys/sysctl.h sys/user.h" \
+ LIBDEPS="$LIB_KVM" \
+ kvm_getprocs kvm_open
+
+ # Functions
+ mk_check_functions \
+ HEADERDEPS="ctype.h" \
+ isblank
+
+ mk_check_sizeofs "long long int" "long int"
+}
9 centutils/Makefile.am
@@ -0,0 +1,9 @@
+ACLOCAL_AMFLAGS = -I m4
+
+SUBDIRS = \
+ include \
+ libcentutils
+
+if HAVE_MOONUNIT
+SUBDIRS += test
+endif
2  centutils/autogen.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+autoreconf -fi
218 centutils/configure.in
@@ -0,0 +1,218 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.59)
+AC_INIT(centutils, 5.0.0, support@likewisesoftware.com)
+AC_CANONICAL_TARGET
+AM_INIT_AUTOMAKE([-Wall -Werror foreign])
+AC_CONFIG_HEADERS([include/config.h])
+
+AM_CPPFLAGS=""
+AM_CFLAGS=""
+AM_LDFLAGS=""
+
+# Platform-specific stuff
+
+MOD_EXT=".so"
+
+case "$host_os:$host_cpu" in
+ linux*:i?86|linux*:x86_64|linux*:s390*)
+ AC_DEFINE([__LWI_LINUX__], [], [Define if OS is Linux])
+ ;;
+ solaris*:i?86|solaris*:sparc*)
+ AC_DEFINE([__LWI_SOLARIS__], [], [Define if OS is Solaris])
+ AC_DEFINE([__EXTENSIONS__], [], [Solaris requires this macro to be defined to enable
+several function declarations like:
+settimeofday(3) in sys/time.h
+vsyslog(3) in syslog.h])
+ AC_DEFINE([_XOPEN_SOURCE], [500], [Define to desired XOPEN compliance level])
+ ;;
+ darwin*:*)
+ AC_DEFINE([__LWI_DARWIN__], [], [Define if OS is Darwin])
+ ;;
+ freebsd*:*)
+ AC_DEFINE([__LWI_FREEBSD__], [], [Define if OS is FreeBSD])
+ ;;
+ hpux*:hppa*)
+ MOD_EXT=".sl"
+ AC_DEFINE([__LWI_HP_UX__], [], [Define if OS is HP-UX])
+ AC_DEFINE([_XOPEN_SOURCE_EXTENDED], [1], [Define on HP-UX])
+ ;;
+ hpux*:ia64*)
+ AC_DEFINE([__LWI_HP_UX__], [], [Define if OS is HP-UX])
+ AC_DEFINE([_XOPEN_SOURCE_EXTENDED], [1], [Define on HP-UX])
+ ;;
+ aix*:*)
+ AC_DEFINE([__LWI_AIX__], [], [Define if OS is AIX])
+ AC_DEFINE([_LINUX_SOURCE_COMPAT], [], [Enable Linux source compatibility on AIX])
+ AC_DEFINE([_THREAD_SAFE_ERRNO], [1], [Define on AIX to turn errno into a thread-safe function])
+ ;;
+esac
+
+AC_SUBST(MOD_EXT)
+
+AC_DEFINE_UNQUOTED([MOD_EXT], ["$MOD_EXT"], [Extension of shared modules])
+
+# debugging
+
+AC_ARG_ENABLE([debug],
+ [AC_HELP_STRING([--enable-debug], [enable debugging (default: disabled)])],
+ [
+ if test x"$enableval" = x"yes"
+ then
+ AM_CFLAGS="$AM_CFLAGS -g -O0"
+ AM_CPPFLAGS="$AM_CPPFLAGS -DDEBUG"
+ fi
+ ])
+
+CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_GNU_SOURCE"
+
+AM_CFLAGS="$AM_CFLAGS -Wall -Werror -fno-strict-aliasing"
+
+AC_SUBST(AM_CPPFLAGS)
+AC_SUBST(AM_CFLAGS)
+
+centutilsconfdir="$sysconfdir"
+AC_SUBST(centutilsconfdir)
+AS_AC_EXPAND(CONFIGDIR, $centutilsconfdir)
+AC_DEFINE_UNQUOTED(CONFIGDIR, "$CONFIGDIR", [Config directory])
+
+AS_AC_EXPAND(providerdir, $libdir)
+
+AS_AC_EXPAND(PREFIXDIR, $prefix)
+AC_DEFINE_UNQUOTED(PREFIXDIR, "$PREFIXDIR", [Prefix directory])
+
+AS_AC_EXPAND(LIBDIR, $libdir)
+AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Library directory])
+
+AC_C_BIGENDIAN
+
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_LIBTOOL
+
+AC_CHECK_LIB([proc], [openproc], [PROC_LIBS="-lproc"])
+AC_CHECK_LIB([kvm], [kvm_open], [KVM_LIBS="-lkvm"])
+AC_CHECK_LIB([rt], [clock_settime], [RT_LIBS="-lrt"])
+
+AC_SUBST(PROC_LIBS)
+AC_SUBST(KVM_LIBS)
+AC_SUBST(RT_LIBS)
+
+# lwadvapi
+
+AC_ARG_WITH([lwadvapi],
+ [AC_HELP_STRING([--with-lwadvapi=<dir>], [use lwadvapi located in prefix <dir>])],
+ [
+ LWADVAPI_INCLUDES="-I$withval/include"
+ LWADVAPI_LDFLAGS="-L$withval/lib"
+ ])
+
+AC_ARG_WITH([lwadvapi-includes],
+ [AC_HELP_STRING([--with-lwadvapi-includes=<dir>], [use lwadvapi includes located in <dir>])],
+ [
+ LWADVAPI_INCLUDES="-I$withval"
+ ])
+
+AC_ARG_WITH([lwadvapi-libs],
+ [AC_HELP_STRING([--with-lwadvapi-libs=<dir>], [use lwadvapi libs located in <dir>])],
+ [
+ LWADVAPI_LDFLAGS="-L$withval"
+ ])
+
+LWADVAPI_LIBS="-llwadvapi"
+LWADVAPI_NOTHR_LIBS="-llwadvapi_nothr"
+
+AC_SUBST(LWADVAPI_INCLUDES)
+AC_SUBST(LWADVAPI_LDFLAGS)
+AC_SUBST(LWADVAPI_LIBS)
+AC_SUBST(LWADVAPI_NOTHR_LIBS)
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS([inttypes.h fcntl.h limits.h stdlib.h string.h strings.h syslog.h unistd.h sys/types.h fcntl.h sys/stat.h sys/param.h sys/pstat.h proc/readproc.h sys/ioctl.h sys/termio.h utmps.h utmpx.h utmp.h procfs.h sys/procfs.h kvm.h sys/sysctl.h sys/user.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_PID_T
+AC_HEADER_TIME
+AC_STRUCT_TM
+
+# Check for basic types
+AC_CHECK_TYPES([int8, int16, int32, int64], [], [],
+[#include <sys/types.h>
+ #if __ia64
+ #include <model.h>
+ #endif])
+AC_CHECK_TYPES([uint8, uint16, uint32, uint64])
+
+AC_CHECK_SIZEOF([long long int])
+AC_CHECK_SIZEOF([long int])
+
+# Checks for library functions.
+AC_FUNC_FORK
+AC_FUNC_SELECT_ARGTYPES
+AC_TYPE_SIGNAL
+AC_FUNC_STRFTIME
+AC_FUNC_VPRINTF
+AC_FUNC_STRERROR_R
+old_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS $RT_LIBS"
+AC_CHECK_FUNCS([atexit bzero localtime_r memset select socket strchr strerror vsyslog mkdtemp _NSGetEnviron kvm_open kvm_getprocs])
+
+# Checks for library functions.
+case `uname -s` in
+ HP-UX*)
+ ;;
+ *)
+ AC_CHECK_FUNCS(sigtimedwait)
+ ;;
+esac
+AC_CHECK_DECLS([isblank, pstat_getproc, KERN_PROC_PATHNAME], [], [], [
+#include <ctype.h>
+#if HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#if HAVE_SYS_SYSCTL_H
+#include <sys/sysctl.h>
+#endif
+#if HAVE_SYS_PSTAT_H
+#include <sys/pstat.h>
+#endif])
+AC_CHECK_TYPES([struct psinfo], , , [
+#if HAVE_PROCFS_H
+#include <procfs.h>
+#elif HAVE_SYS_PROCFS_H
+#include <sys/procfs.h>
+#endif
+])
+
+if test "$ac_cv_have_decl_pstat_getproc" = yes; then
+AM_CPPFLAGS="$AM_CPPFLAGS -D_PSTAT64"
+fi
+
+# Check for moonunit bits
+AC_CHECK_HEADERS([moonunit/moonunit.h], [HAVE_MOONUNIT_H=true], [HAVE_MOONUNIT_H=false])
+AC_CHECK_LIB(moonunit, Mu_Interface_Result, [HAVE_MOONUNIT_LIB=true], [HAVE_MOONUNIT_LIB=false])
+AC_CHECK_PROG(MOONUNIT_STUB, moonunit-stub, moonunit-stub, false)
+
+if test "${MOONUNIT_STUB}" = "moonunit-stub" && $HAVE_MOONUNIT_H && $HAVE_MOONUNIT_LIB
+then
+ HAVE_MOONUNIT="true"
+ LIB_moonunit="-lmoonunit"
+ AC_DEFINE([HAVE_MOONUNIT], [], [Have MoonUnit])
+else
+ HAVE_MOONUNIT="false"
+fi
+
+AC_SUBST(HAVE_MOONUNIT)
+AC_SUBST(LIB_moonunit)
+
+AM_CONDITIONAL(HAVE_MOONUNIT, $HAVE_MOONUNIT)
+
+AC_CONFIG_FILES([Makefile
+ include/Makefile
+ libcentutils/Makefile
+ test/Makefile])
+
+AC_OUTPUT
10 centutils/include/MakeKitBuild
@@ -0,0 +1,10 @@
+make()
+{
+ mk_headers \
+ HEADERDEPS="lw/base.h lwadvapi.h" \
+ MASTER=ctbase.h \
+ ctarray.h ctdef.h ctexec.h ctfileutils.h \
+ cthash.h ctmem.h ctprocutils.h ctrwlock.h \
+ ctshell.h ctstrutils.h ctsys.h cttext.h \
+ ctuser.h lwexc.h ctsysfuncs.h
+}
20 centutils/include/Makefile.am
@@ -0,0 +1,20 @@
+centutilsincludedir = $(includedir)
+
+centutilsinclude_HEADERS = \
+ ctarray.h \
+ ctbase.h \
+ ctdef.h \
+ ctexec.h \
+ ctfileutils.h \
+ cthash.h \
+ ctmem.h \
+ ctprocutils.h \
+ ctrwlock.h \
+ ctshell.h \
+ ctstrutils.h \
+ ctsys.h \
+ cttext.h \
+ ctuser.h \
+ lwexc.h \
+ ctsysfuncs.h
+
147 centutils/include/ctarray.h
@@ -0,0 +1,147 @@
+/* Editor Settings: expandtabs and use 4 spaces for indentation
+ * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
+ * -*- mode: c, c-basic-offset: 4 -*- */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+#ifndef __CT_ARRAY_H__
+#define __CT_ARRAY_H__
+
+/**
+ * @brief A dynamically resizeable array
+ *
+ * This encapsulates a dynamically resizeable array of a user defined type. The
+ * data pointer requires casting to the user's preferred type.
+ */
+
+typedef struct
+{
+ void *data;
+ /**
+ * The number of items in the array in terms of the type this array holds,
+ * not in terms of bytes.
+ */
+ size_t size;
+ /**
+ * The number of items that can be stored without having to reallocate
+ * memory. This is in items, not bytes
+ */
+ size_t capacity;
+} DynamicArray;
+
+
+
+LW_BEGIN_EXTERN_C
+
+DWORD CTArrayConstruct(DynamicArray* array, size_t itemSize);
+
+/**
+ * Change the available space in the array
+ *
+ * @errcode
+ * @canfail
+ */
+DWORD CTSetCapacity(DynamicArray *array, size_t itemSize, size_t capacity);
+
+/**
+ * Insert one or more items into the array at any position.
+ *
+ * @errcode
+ * @canfail
+ */
+DWORD CTArrayInsert(DynamicArray *array, int insertPos, int itemSize, const void *data, size_t dataLen);
+
+/**
+ * Append one or more items to the end of the array.
+ * dataLen is in number of elements, not number of bytes.
+ *
+ * @errcode
+ * @canfail
+ */
+DWORD CTArrayAppend(DynamicArray *array, int itemSize, const void *data, size_t dataLen);
+
+/**
+ * Remove one or more items from the array at any position. This will not
+ * shrink the allocated memory (capacity stays the same).
+ *
+ * @errcode
+ * @canfail
+ */
+DWORD CTArrayRemove(DynamicArray *array, int removePos, int itemSize, size_t dataLen);
+
+/**
+ * Pop items off of the head of the list. They first get copied into the user
+ * supplied buffer, then they are removed from the front of the array.
+ *
+ * @return the number of items removed
+ */
+size_t CTArrayRemoveHead(DynamicArray *array, int itemSize, void *store, size_t dataLen);
+
+/**
+ * Free the memory associated with a dynamic array, and zero out the pointers.
+ * The dynamic array essentialy becomes a zero length array. The object can be
+ * reused by appending new data after it has been freed.
+ *
+ * @wontfail
+ */
+void CTArrayFree(DynamicArray *array);
+
+void * CTArrayGetItem(DynamicArray* array, size_t index, size_t itemSize);
+
+// Only works when the DynamicArray holds (char *)
+ssize_t CTArrayFindString(DynamicArray* array, PCSTR find);
+
+LW_END_EXTERN_C
+
+
+#endif
78 centutils/include/ctbase.h
@@ -0,0 +1,78 @@
+/* Editor Settings: expandtabs and use 4 spaces for indentation
+ * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
+ * -*- mode: c, c-basic-offset: 4 -*- */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+#ifndef __CTBASE_H__
+#define __CTBASE_H__
+
+#include <lw/types.h>
+#include <lw/attrs.h>
+#include <lwerror.h>
+
+#include "ctsys.h"
+#include "ctdef.h"
+#include "ctmem.h"
+#include "ctrwlock.h"
+#include "ctstrutils.h"
+#include "ctfileutils.h"
+#include "ctsysfuncs.h"
+#include "ctprocutils.h"
+#include "cthash.h"
+#include "ctexec.h"
+#include "ctuser.h"
+#include "cttext.h"
+
+#endif /* __CTBASE_H__ */
+
148 centutils/include/ctdef.h
@@ -0,0 +1,148 @@
+/* Editor Settings: expandtabs and use 4 spaces for indentation
+ * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
+ * -*- mode: c, c-basic-offset: 4 -*- */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+#ifndef __CTDEF_H__
+#define __CTDEF_H__
+
+#ifndef WIN32
+#include <lw/types.h>
+#include <lw/attrs.h>
+#endif
+
+/*
+ Standard integer-related types and constants come from standard system
+ headers.
+
+ Standard integer types:
+ - {u,}int{8,16,32,64}_t
+
+ Standard MAX/MIN constants:
+ - INT{8,16,32,64}_{MIN,MAX}
+ - UINT{8,16,32,64}_MAX
+*/
+
+#ifndef CT_MAX
+#define CT_MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+
+#ifndef CT_MIN
+#define CT_MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
+typedef struct __DBLBYTE {
+ BYTE b1;
+ BYTE b2;
+} DBLBYTE, *PDBLBYTE;
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#define GOTO_CLEANUP() \
+ do { goto cleanup; } while (0)
+
+#define GOTO_CLEANUP_EE(EE) \
+ do { (EE) = __LINE__; goto cleanup; } while (0)
+
+#define GOTO_CLEANUP_ON_DWORD(ceError) \
+ do { if (ceError) goto cleanup; } while (0)
+
+#define GOTO_CLEANUP_ON_DWORD_EE(ceError, EE) \
+ do { if (ceError) { (EE) = __LINE__; goto cleanup; } } while (0)
+
+/* Deprecated -- please use GOTO_CLEANUP versions */
+#define CLEANUP_ON_DWORD(ceError) GOTO_CLEANUP_ON_DWORD(ceError)
+#define CLEANUP_ON_DWORD_EE(ceError, EE) GOTO_CLEANUP_ON_DWORD_EE(ceError, EE)
+
+#ifndef WIN32
+#define BAIL_ON_CENTERIS_ERROR(__ceError__) \
+ do { \
+ if ((__ceError__) != 0) { \
+ goto error; \
+ } \
+ } while (0)
+
+#endif
+
+#ifndef IsNullOrEmptyString
+
+#define IsNullOrEmptyString(pszStr) \
+ (pszStr == NULL || *pszStr == '\0')
+
+#endif
+
+#if defined(WORDS_BIGENDIAN)
+#define CONVERT_ENDIAN_DWORD(ui32val) \
+ ((ui32val & 0x000000FF) << 24 | \
+ (ui32val & 0x0000FF00) << 8 | \
+ (ui32val & 0x00FF0000) >> 8 | \
+ (ui32val & 0xFF000000) >> 24)
+
+#define CONVERT_ENDIAN_WORD(ui16val) \
+ ((ui16val & 0x00FF) << 8 | \
+ (ui16val & 0xFF00) >> 8)
+
+#else
+#define CONVERT_ENDIAN_DWORD(ui32val) (ui32val)
+#define CONVERT_ENDIAN_WORD(ui16val) (ui16val)
+#endif
+
+#endif /* __CTDEF_H__ */
+
214 centutils/include/ctexec.h
@@ -0,0 +1,214 @@
+/* Editor Settings: expandtabs and use 4 spaces for indentation
+ * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
+ * -*- mode: c, c-basic-offset: 4 -*- */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+#ifndef __CT_EXEC_H__
+#define __CT_EXEC_H__
+
+#include "ctbase.h"
+#include "lwexc.h"
+
+/**
+ * @defgroup CTExec Unix program interaction
+ */
+/*@{*/
+
+typedef struct __PROCINFO
+{
+ pid_t pid;
+ int fdin;
+ int fdout;
+ int fderr;
+} PROCINFO, *PPROCINFO;
+
+
+LW_BEGIN_EXTERN_C
+
+/**
+ * @brief Capture output of a Unix command
+ *
+ * Runs the specified Unix command and captures output
+ * to a buffer. The buffer is dynamically allocated and
+ * freeing it becomes the responsibility of the caller.
+ * The command is passed to the standard Unix shell
+ * (/bin/sh), which is reponsible for parsing and executing
+ * it; shell features such as pipelines may be used, but
+ * care must be taken to properly escape commands. The caller may need to
+ * free the output buffer even if the function fails.
+ * @see CTEscapeString
+ * @param command @in the Unix command to execute
+ * @param output @out the dynamically-allocated buffer containing
+ * the output of the command
+ * @errcode
+ * @canfail
+ */
+
+DWORD
+CTCaptureOutput(
+ PCSTR command,
+ PSTR* output
+ );
+
+/**
+ * @brief Run the specified unix command and only show the output if it fails
+ *
+ * Runs the specified Unix command and captures the output. An exception is
+ * returned if the command exits with a non-zero exit code. The output is only
+ * returned in the exception, otherwise the command runs silently.
+ * @see CTEscapeString
+ * @param command @in the Unix command to execute
+ * @errcode
+ * @canfail
+ */
+void CTCaptureOutputToExc(
+ PCSTR command,
+ LWException **exc
+ );
+
+/**
+ * @brief Capture output of a Unix command
+ *
+ * Runs the specified Unix command and captures output
+ * to a buffer. The buffer is dynamically allocated and
+ * freeing it becomes the responsibility of the caller.
+ * The command is passed to the standard Unix shell
+ * (/bin/sh), which is reponsible for parsing and executing
+ * it; shell features such as pipelines may be used, but
+ * care must be taken to properly escape commands. The caller may need to
+ * free the output buffer even if the function fails.
+ * @see CTEscapeString
+ * @param command @in the Unix command to execute
+ * @param captureStderr @in whether to capture stderr with stdout or to let it output to the caller's stderr.
+ * @param output @out the dynamically-allocated buffer containing
+ * the output of the command
+ * @errcode
+ * @canfail
+ */
+DWORD
+CTCaptureOutputWithStderr(
+ PCSTR command,
+ BOOLEAN captureStderr,
+ PSTR* output
+ );
+
+DWORD
+CTCaptureOutputWithStderrEx(
+ PCSTR command,
+ PCSTR* ppszArgs,
+ BOOLEAN captureStderr,
+ PSTR* output,
+ int* exitCode
+ );
+
+/**
+ * @brief Run a command
+ *
+ * Runs the specified Unix command and waits for it to
+ * complete. The command is passed to the standard Unix shell
+ * (/bin/sh), which is responsible for parsing and executing
+ * it; shell features such as pipelines may be used, but
+ * care must be taken to properly escape commands.
+ *
+ * This command returns ERROR_BAD_COMMAND if the program returns a non-
+ * zero exit code.
+ *
+ * @see CTEscapeString
+ * @param command @in the Unix command to execute
+ * @errcode
+ * @canfail
+ */
+DWORD
+CTRunCommand(
+ PCSTR command
+ );
+
+DWORD
+CTSpawnProcessWithFds(
+ PCSTR pszCommand,
+ const PSTR* ppszArgs,
+ int dwFdIn,
+ int dwFdOut,
+ int dwFdErr,
+ PPROCINFO* ppProcInfo
+ );
+
+DWORD
+CTSpawnProcessWithEnvironment(
+ PCSTR pszCommand,
+ const PSTR* ppszArgs,
+ const PSTR* ppszEnv,
+ int dwFdIn,
+ int dwFdOut,
+ int dwFdErr,
+ PPROCINFO* ppProcInfo
+ );
+
+void
+CTFreeProcInfo(
+ PPROCINFO pProcInfo
+ );
+
+DWORD
+CTGetExitStatus(
+ PPROCINFO pProcInfo,
+ PLONG plstatus
+ );
+
+LW_END_EXTERN_C
+
+
+/*@}*/
+
+#endif
431 centutils/include/ctfileutils.h
@@ -0,0 +1,431 @@
+/* Editor Settings: expandtabs and use 4 spaces for indentation
+ * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
+ * -*- mode: c, c-basic-offset: 4 -*- */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+#ifndef __CTFILEUTILS_H__
+#define __CTFILEUTILS_H__
+
+
+LW_BEGIN_EXTERN_C
+
+DWORD
+CTRemoveFile(
+ PCSTR pszPath
+ );
+
+DWORD
+CTRemoveDirectory(
+ PCSTR pszPath
+ );
+
+DWORD
+CTCheckFileExists(
+ PCSTR pszPath,
+ PBOOLEAN pbFileExists
+ );
+
+DWORD
+CTCheckLinkExists(
+ PCSTR pszPath,
+ PBOOLEAN pbLinkExists
+ );
+
+DWORD
+CTCheckFileOrLinkExists(
+ PCSTR pszPath,
+ PBOOLEAN pbExists
+ );
+
+DWORD
+CTGetSymLinkTarget(
+ PCSTR pszPath,
+ PSTR* ppszTargetPath
+ );
+
+DWORD
+CTCheckDirectoryExists(
+ PCSTR pszPath,
+ PBOOLEAN pbFileExists
+ );
+
+DWORD
+CTCheckSockExists(
+ PCSTR pszPath,
+ PBOOLEAN pbSockExists
+ );
+
+DWORD
+CTCreateSymLink(
+ PCSTR pszOldPath,
+ PCSTR pszNewPath
+ );
+
+DWORD
+CTMoveFile(
+ PCSTR pszSrcPath,
+ PCSTR pszDstPath
+ );
+
+DWORD
+CTMoveFileEx(
+ PCSTR pszSrcPath,
+ PCSTR pszDstPath,
+ BOOLEAN bCrossDevice
+ );
+
+DWORD
+CTSafeReplaceFile(
+ PCSTR finalName,
+ PCSTR replaceWith);
+
+DWORD
+CTCopyFileWithPerms(
+ PCSTR pszSrcPath,
+ PCSTR pszDstPath,
+ mode_t dwPerms
+ );
+
+DWORD
+CTGetOwnerUID(
+ PCSTR pszFilePath,
+ uid_t* pUid
+ );
+
+DWORD
+CTCopyFileWithOriginalPerms(
+ PCSTR pszSrcPath,
+ PCSTR pszDstPath
+ );
+
+DWORD
+CTChangePermissions(
+ PCSTR pszPath,
+ mode_t dwFileMode
+ );
+
+DWORD
+CTGetOwnerAndPermissions(
+ PCSTR pszSrcPath,
+ uid_t * uid,
+ gid_t * gid,
+ mode_t * mode
+ );
+
+DWORD
+CTGetFileTimeStamps(
+ PCSTR pszFilePath,
+ time_t *patime,
+ time_t *pmtime,
+ time_t *pctime );
+
+DWORD
+CTChangeOwner(
+ PCSTR pszPath,
+ uid_t uid,
+ gid_t gid
+ );
+
+DWORD
+CTChangeOwnerAndPermissions(
+ PCSTR pszPath,
+ uid_t uid,
+ gid_t gid,
+ mode_t dwFileMode
+ );
+
+/* Copies the file mode, owner, and group from the template file */
+DWORD
+CTCloneFilePerms(
+ PCSTR pszTemplatePath,
+ PCSTR pszDstPath
+ );
+
+DWORD
+CTCreateDirectory(
+ PCSTR pszPath,
+ mode_t dwFileMode
+ );
+
+DWORD
+CTCopyDirectory(
+ PCSTR source,
+ PCSTR dest
+ );
+
+/* Safely creates a temporary directory that is only accessible by the current
+ * user and root.
+ */
+DWORD
+CTCreateTempDirectory(
+ PSTR *pszPath
+ );
+
+DWORD
+CTGetMatchingFilePathsInFolder(
+ PCSTR pszDirPath,
+ PCSTR pszFileNameRegExp,
+ PSTR** pppszHostFilePaths,
+ PDWORD pdwNPaths
+ );
+
+DWORD
+CTGetMatchingDirPathsInFolder(
+ PCSTR pszDirPath,
+ PCSTR pszDirNameRegExp,
+ PSTR** pppszHostDirPaths,
+ PDWORD pdwNPaths
+ );
+
+DWORD
+CTCheckFileHoldsPattern(
+ PCSTR pszFilePath,
+ PCSTR pszPattern,
+ PBOOLEAN pbPatternExists
+ );
+
+DWORD
+CTFileContentsSame(
+ PCSTR pszFilePath1,
+ PCSTR pszFilePath2,
+ PBOOLEAN pbSame
+ );
+
+DWORD
+CTStreamContentsSame(
+ FILE *fp1,
+ FILE *fp2,
+ PBOOLEAN pbSame
+ );
+
+DWORD
+CTGetAbsolutePath(
+ PSTR pszRelativePath,
+ PSTR* ppszAbsolutePath
+ );
+
+DWORD
+CTRemoveFiles(
+ PSTR pszPath,
+ BOOLEAN fDirectory,
+ BOOLEAN fRecursive
+ );
+
+DWORD
+CTBackupFile(
+ PCSTR path
+ );
+
+DWORD
+CTReadFile(
+ PCSTR pszFilePath,
+ size_t sReadMax,
+ PSTR* ppBuffer,
+ PLONG pSize
+ );
+
+DWORD
+CTOpenFile(
+ PCSTR path,
+ PCSTR mode,
+ FILE** handle);
+
+DWORD
+CTSetCloseOnExec(
+ int fd);
+
+DWORD
+CTFileStreamWrite(
+ FILE* handle,
+ PCSTR data,
+ unsigned int size);
+
+DWORD
+CTFilePrintf(
+ FILE* handle,
+ PCSTR format,
+ ...
+ );
+
+//Use CTSafeCloseFile instead
+DWORD
+CTCloseFile(
+ FILE* handle);
+
+/* This function calls fclose on the handle and returns a centerror if
+ * something goes wrong.
+ *
+ * One way this function could fail is if an IO error occurs while the file
+ * buffers are being flushed, in which case the previous writes the file would
+ * be incomplete.
+ *
+ * Even if fclose fails, the man fclose man page says that the handle is
+ * invalid afterwards. This means that is an error to ever attempt to call
+ * fclose on the same handle twice. That could result in a memory double free,
+ * or segfault.
+ *
+ * To prevent the user from calling close twice, this function sets the handle
+ * to NULL whether or not the close is successful.
+ *
+ * If this function is called with *handle == NULL, it will simply return
+ * success.
+ */
+DWORD
+CTSafeCloseFile(
+ FILE** handle);
+
+DWORD
+CTMoveFileAcrossDevices(
+ PCSTR pszSrcPath,
+ PCSTR pszDstPath
+ );
+
+DWORD
+CTGetCurrentDirectoryPath(
+ PSTR* ppszPath
+ );
+
+/** This will run a sed expression on the src file and save the ouput into the dst file. It is safe to use the same path for the src and dst file names.
+
+The dst file will be backed up before it is changed. After the sed operation finishes, the dst file will have the permissions of the src file.
+
+The worst that can happen if this command is used to write to a user writeable directory, is that the function can fail if a user has already created the temporary file that this function uses.
+
+So, that means if this function succeeds, a nonroot user did not tampered with the output file before or during the sed operation.
+*/
+DWORD
+CTRunSedOnFile(
+ PCSTR pszSrcPath,
+ PCSTR pszDstPath,
+ BOOLEAN bDashN,
+ PCSTR pszExpression
+ );
+
+/* Sets changes to true if running sed on the source file with the given
+ * expression outputs data different from the source file.
+ */
+DWORD
+CTWillSedChangeFile(
+ PCSTR pszSrcPath,
+ PCSTR pszExpression,
+ BOOLEAN *changes
+ );
+
+DWORD
+CTFindSed(
+ PSTR *sedPath
+ );
+
+/* Searches for a file or link inside of a colon separated search path.
+ *
+ * If the file is found, then the result is stored in foundPath. If multiple
+ * paths are found, then the first one takes precedence. If the file is not
+ * found, then ERROR_FILE_NOT_FOUND is returned, and foundPath is set to
+ * NULL.
+ *
+ * It is the caller's responsibility to free foundPath.
+ */
+DWORD
+CTFindFileInPath(
+ PCSTR filename,
+ PCSTR searchPath,
+ PSTR* foundPath
+ );
+
+DWORD
+CTFindInPath(
+ PCSTR rootPrefix,
+ PCSTR filename,
+ PCSTR searchPath,
+ PSTR* foundPath
+ );
+
+DWORD
+CTGetFileTempPath(
+ PCSTR unresolvedSrcPath,
+ PSTR* resolvedSrcPath,
+ PSTR* tempPath
+ );
+
+DWORD
+CTGetFileDiff(
+ PCSTR first,
+ PCSTR second,
+ PSTR *diff,
+ BOOLEAN failIfNoDiff
+ );
+
+DWORD
+CTReadNextLine(
+ FILE* fp,
+ PSTR *output,
+ PBOOLEAN pbEndOfFile
+ );
+
+/* Reads a file and separates into individual lines
+ * The dynamic array must be initialized (at least zeroed out) beforehand
+ */
+DWORD
+CTReadLines(FILE *file, DynamicArray *dest);
+
+DWORD
+CTWriteLines(FILE *file, const DynamicArray *lines);
+
+void
+CTFreeLines(DynamicArray *lines);
+
+LW_END_EXTERN_C
+
+
+#endif /* __CTFILEUTILS_H__ */
201 centutils/include/cthash.h
@@ -0,0 +1,201 @@
+/* Editor Settings: expandtabs and use 4 spaces for indentation
+ * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
+ * -*- mode: c, c-basic-offset: 4 -*- */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+#ifndef __CT_HASH_H__
+#define __CT_HASH_H__
+
+LW_BEGIN_EXTERN_C
+
+typedef struct __CT_HASH_ENTRY CT_HASH_ENTRY;
+
+typedef int (*CT_HASH_KEY_COMPARE)(PCVOID, PCVOID);
+typedef size_t (*CT_HASH_KEY)(PCVOID);
+typedef void (*CT_HASH_FREE_ENTRY)(const CT_HASH_ENTRY *);
+typedef DWORD (*CT_HASH_COPY_ENTRY)(const CT_HASH_ENTRY *, CT_HASH_ENTRY *);
+
+struct __CT_HASH_ENTRY
+{
+ PVOID pKey;
+ PVOID pValue;
+ struct __CT_HASH_ENTRY* pNext;
+};
+
+typedef struct __CT_HASH_TABLE
+{
+ size_t sTableSize;
+ size_t sCount;
+ CT_HASH_ENTRY **ppEntries;
+ CT_HASH_KEY_COMPARE fnComparator;
+ CT_HASH_KEY fnHash;
+ CT_HASH_FREE_ENTRY fnFree;
+ CT_HASH_COPY_ENTRY fnCopy;
+} CT_HASH_TABLE, *PCT_HASH_TABLE;
+
+typedef struct __CT_HASH_ITERATOR
+{
+ CT_HASH_TABLE *pTable;
+ size_t sEntryIndex;
+ CT_HASH_ENTRY *pEntryPos;
+} CT_HASH_ITERATOR;
+
+DWORD
+CtHashCreate(
+ size_t sTableSize,
+ CT_HASH_KEY_COMPARE fnComparator,
+ CT_HASH_KEY fnHash,
+ CT_HASH_FREE_ENTRY fnFree, //optional
+ CT_HASH_COPY_ENTRY fnCopy, //optional
+ CT_HASH_TABLE** ppResult
+ );
+
+size_t
+CtHashGetKeyCount(
+ PCT_HASH_TABLE pTable
+ );
+
+void
+CtHashRemoveAll(
+ CT_HASH_TABLE* pResult);
+
+void
+CtHashSafeFree(
+ CT_HASH_TABLE** ppResult
+ );
+
+DWORD
+CtHashSetValue(
+ CT_HASH_TABLE *pTable,
+ PVOID pKey,
+ PVOID pValue
+ );
+
+//Returns ERROR_NOT_FOUND if pKey is not in the table
+DWORD
+CtHashGetValue(
+ CT_HASH_TABLE *pTable,
+ PCVOID pKey,
+ PVOID* ppValue
+ );
+
+BOOLEAN
+CtHashExists(
+ IN PCT_HASH_TABLE pTable,
+ IN PCVOID pKey
+ );
+
+DWORD
+CtHashCopy(
+ IN CT_HASH_TABLE *pTable,
+ OUT CT_HASH_TABLE **ppResult
+ );
+
+//Invalidates all iterators
+DWORD
+CtHashResize(
+ CT_HASH_TABLE *pTable,
+ size_t sTableSize
+ );
+
+DWORD
+CtHashGetIterator(
+ CT_HASH_TABLE *pTable,
+ CT_HASH_ITERATOR *pIterator
+ );
+
+// returns NULL after passing the last entry
+CT_HASH_ENTRY *
+CtHashNext(
+ CT_HASH_ITERATOR *pIterator
+ );
+
+DWORD
+CtHashRemoveKey(
+ CT_HASH_TABLE *pTable,
+ PVOID pKey
+ );
+
+
+DWORD
+CtHashRemoveKey(
+ CT_HASH_TABLE *pTable,
+ PVOID pKey
+ );
+
+int
+CtHashStringCompare(
+ PCVOID str1,
+ PCVOID str2
+ );
+
+size_t
+CtHashStringHash(
+ PCVOID str
+ );
+
+int
+CtHashPVoidCompare(
+ IN PCVOID pvData1,
+ IN PCVOID pvData2
+ );
+
+size_t
+CtHashPVoidHash(
+ IN PCVOID pvData
+ );
+
+LW_END_EXTERN_C
+
+#endif
89 centutils/include/ctmem.h
@@ -0,0 +1,89 @@
+/* Editor Settings: expandtabs and use 4 spaces for indentation
+ * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
+ * -*- mode: c, c-basic-offset: 4 -*- */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+#ifndef __CTMEM_H__
+#define __CTMEM_H__
+
+#define PPCAST(x) ((void **)(void *)(x))
+
+
+LW_BEGIN_EXTERN_C
+
+DWORD
+CTAllocateMemory(
+ DWORD dwSize,
+ PVOID * ppMemory
+ );
+
+DWORD
+CTReallocMemory(
+ PVOID pMemory,
+ PVOID * ppNewMemory,
+ DWORD dwSize
+ );
+
+#define CT_SAFE_FREE_MEMORY(mem) \
+ do { if (mem) { CTFreeMemory(mem); (mem) = NULL; } } while (0)
+
+void
+CTFreeMemory(
+ PVOID pMemory
+ );
+
+LW_END_EXTERN_C
+
+
+#endif /* __CTMEM_H__ */
121 centutils/include/ctprocutils.h
@@ -0,0 +1,121 @@
+/* Editor Settings: expandtabs and use 4 spaces for indentation
+ * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
+ * -*- mode: c, c-basic-offset: 4 -*- */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+#ifndef __CTPROCUTILS_H__
+#define __CTPROCUTILS_H__
+
+
+LW_BEGIN_EXTERN_C
+
+DWORD
+CTMatchProgramToPID(
+ PCSTR pszProgramName,
+ pid_t pid
+ );
+
+/* Find the pid(s) of processes whose executable machines programName. The program name does not include the path. Processes whose root directory does not match the current root directory are not returned. The caller should set count to the size of pid buffer. This function will set pid to the number of matching processes.
+ *
+ * If more programs match than there is space for in the buffer, as many processes as possible will be filled in. count will be set to how many processes matched, not how many were stored.
+ *
+ * If count is NULL, then it is assumed that the pid buffer has space for exactly 1 pid. In this case, if at least one pid is found, the first one is stored in the buffer. If no matching pids are found, DWORD_NO_SUCH_PROCESS is returned. When count is not NULL, it is not considered an error when no processes match.
+ *
+ * pid may be NULL. This is only useful when count is also NULL, in which case the error code can be used to determine whether a process is running or not without actually finding the pid.
+ *
+ * (uid_t)-1 is treated as wildcard for the owner parameter, and all uids will be matched in this case.
+ *
+ * Please check the implementation of this function before using it. It may not be implemented for your platform. In this case, it will return DWORD_NOT_IMPLEMENTED.
+ */
+DWORD
+CTGetPidOf(
+ PCSTR programName,
+ uid_t owner,
+ pid_t *pid,
+ size_t *count
+ );
+
+/* Like CTGetPidOf, except the entire command line (program name plus
+ * arguments) can be searched by setting cmdLine.
+ *
+ * Searching via programFilename may require root access.
+ */
+DWORD
+CTGetPidOfCmdLine(
+ PCSTR programName,
+ PCSTR programFilename,
+ PCSTR cmdLine,
+ uid_t owner,
+ pid_t *pid,
+ size_t *count
+ );
+
+DWORD
+CTIsProgramRunning(
+ PCSTR pszPidFile,
+ PCSTR pszProgramName,
+ pid_t *pPid,
+ PBOOLEAN pbRunning
+ );
+
+DWORD
+CTSendSignal(
+ pid_t pid,
+ int sig
+ );
+
+LW_END_EXTERN_C
+
+
+#endif /* __CTPROCUTILS_H__ */
120 centutils/include/ctrwlock.h
@@ -0,0 +1,120 @@
+/* Editor Settings: expandtabs and use 4 spaces for indentation
+ * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
+ * -*- mode: c, c-basic-offset: 4 -*- */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+#ifndef __CTRWLOCK_H__
+#define __CTRWLOCK_H__
+
+#include <pthread.h>
+
+typedef struct __CTRWLOCK {
+ pthread_mutex_t mutex;
+ pthread_cond_t read_condition;
+ pthread_cond_t write_condition;
+ int num_active_readers;
+ int num_active_writers;
+ int num_waiting_readers;
+ int num_waiting_writers;
+} CTRWLOCK, *PCTRWLOCK;
+
+#define CTRWLOCK_INITIALIZER \
+ { \
+ PTHREAD_MUTEX_INITIALIZER, \
+ PTHREAD_COND_INITIALIZER, \
+ PTHREAD_COND_INITIALIZER, \
+ 0, \
+ 0, \
+ 0, \
+ 0 \
+ }
+
+
+LW_BEGIN_EXTERN_C
+
+void
+CTInitRWLock(
+ PCTRWLOCK pLock
+ );
+
+DWORD
+CTFreeRWLock(
+ PCTRWLOCK pLock
+ );
+
+void
+CTAcquireReadLock(
+ PCTRWLOCK pLock
+ );
+
+void
+CTReleaseReadLock(
+ PCTRWLOCK pLock
+ );
+
+void
+CTAcquireWriteLock(
+ PCTRWLOCK pLock
+ );
+
+void
+CTReleaseWriteLock(
+ PCTRWLOCK pLock
+ );
+
+LW_END_EXTERN_C
+
+
+#endif /* __CTRWLOCK_H__ */
+
106 centutils/include/ctshell.h
@@ -0,0 +1,106 @@
+/* Editor Settings: expandtabs and use 4 spaces for indentation
+ * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
+ * -*- mode: c, c-basic-offset: 4 -*- */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+#ifndef __CTSHELL_H__
+#define __CTSHELL_H__
+
+#include "ctbase.h"
+
+typedef struct CTShellVar
+{
+ enum
+ {
+ SVAR_INT,
+ SVAR_STR,
+ SVAR_ARR,
+ SVAR_ZERO,
+ SVAR_OUT
+ } type;
+ const char* name;
+ union
+ {
+ int integer;
+ const char* string;
+ char const * const * array;
+ char** out;
+ } value;
+} CTShellVar;
+
+struct CTShellVar __CTVarInteger(const char* name, int value);
+struct CTShellVar __CTVarString(const char* name, const char* value);
+struct CTShellVar __CTVarArray(const char* name, char const * const * value);
+struct CTShellVar __CTVarOut(const char* name, char** out);
+struct CTShellVar __CTVarZero(const char* name);
+
+#define CTSHELL_INTEGER(name, value) (__CTVarInteger( #name , value))
+#define CTSHELL_STRING(name, value) (__CTVarString( #name , value))
+#define CTSHELL_ARRAY(name, value) (__CTVarArray( #name , (char const * const *) (value)))
+#define CTSHELL_BUFFER(name, value) (__CTVarOut( #name , value))
+#define CTSHELL_ZERO(name) (__CTVarZero( #name ))
+
+
+LW_BEGIN_EXTERN_C
+
+DWORD
+CTShell(const char* format, ...);
+
+DWORD
+CTShellEx(char * const envp[], const char* format, ...);
+
+LW_END_EXTERN_C
+
+
+#endif
258 centutils/include/ctstrutils.h
@@ -0,0 +1,258 @@
+/* Editor Settings: expandtabs and use 4 spaces for indentation
+ * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
+ * -*- mode: c, c-basic-offset: 4 -*- */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+#ifndef __CTSTRUTILS_H__
+#define __CTSTRUTILS_H__
+
+#include "ctarray.h"
+
+
+LW_BEGIN_EXTERN_C
+
+DWORD
+CTAllocateString(
+ PCSTR pszInputString,
+ PSTR * ppszOutputString
+ );
+
+#define CTStrdup CTAllocateString
+
+DWORD
+CTStrndup(
+ PCSTR pszInputString,
+ size_t size,
+ PSTR * ppszOutputString
+ );
+
+void
+CTFreeString(
+ PSTR pszString
+ );
+
+#define CT_SAFE_FREE_STRING(str) \
+ do { if (str) { CTFreeString(str); (str) = NULL; } } while (0)
+
+void
+CTFreeStringArray(
+ PSTR * ppStringArray,
+ DWORD dwCount
+ );
+
+void
+CTFreeNullTerminatedStringArray(
+ PSTR * ppStringArray
+ );
+
+void
+CTStripLeadingWhitespace(
+ PSTR pszString
+ );
+
+void
+CTStripTrailingWhitespace(
+ PSTR pszString
+ );
+
+void
+CTRemoveLeadingWhitespacesOnly(
+ PSTR pszString
+ );
+
+void
+CTRemoveTrailingWhitespacesOnly(
+ PSTR pszString
+ );
+
+void
+CTStripWhitespace(
+ PSTR pszString
+ );
+
+void
+CTStrToUpper(
+ PSTR pszString
+ );
+
+void
+CTStrToLower(
+ PSTR pszString
+ );
+
+DWORD
+CTEscapeString(
+ PCSTR pszOrig,
+ PSTR * ppszEscapedString
+ );
+
+DWORD
+CTAllocateStringPrintfV(
+ PSTR* result,
+ PCSTR format,
+ va_list args
+ );
+
+DWORD
+CTAllocateStringPrintf(
+ PSTR* result,
+ PCSTR format,
+ ...
+ );
+
+/** Returns true if substr(str, 0, strlen(prefix)) == prefix
+ */
+BOOLEAN
+CTStrStartsWith(
+ PCSTR str,
+ PCSTR prefix
+ );
+
+/** Returns true if substr(str, strlen(str) - strlen(suffix)) == suffix
+ */
+BOOLEAN
+CTStrEndsWith(
+ PCSTR str,
+ PCSTR suffix
+ );
+
+typedef DynamicArray StringBuffer;
+
+DWORD
+CTStringBufferConstruct(StringBuffer* buffer);
+
+//Sets the string to zero length, but does not free the data.
+void
+CTStringBufferClear(
+ StringBuffer* buffer
+ );
+
+//Frees the stringbuffer object
+void
+CTStringBufferDestroy(
+ StringBuffer* buffer
+ );
+
+//The returned string needs to be freed, but not buffer.
+char*
+CTStringBufferFreeze(
+ StringBuffer* buffer
+ );
+
+DWORD
+CTStringBufferAppend(
+ StringBuffer* buffer,
+ const char* str
+ );
+
+DWORD
+CTStringBufferAppendLength(
+ StringBuffer* buffer,
+ const char* str,
+ unsigned int length
+ );
+
+DWORD
+CTStringBufferAppendChar(
+ StringBuffer* buffer,
+ char c
+ );
+
+BOOLEAN
+CTIsAllDigit(
+ PCSTR pszVal
+ );
+
+DWORD CTDupOrNullStr(const char *src, char **dest);
+
+typedef struct
+{
+ char *value;
+ char *trailingSeparator;
+} CTParseToken;
+
+void CTFreeParseTokenContents(CTParseToken *token);
+void CTFreeParseToken(CTParseToken **token);
+/* Returns the length of the value and trailingSeparator */
+size_t CTGetTokenLen(const CTParseToken *token);
+/* Does not enlarge pos. Does not null terminate.
+ * Make sure pos already has enough space. Use GetTokenLen to calculate
+ * necessary length */
+void CTAppendTokenString(char **pos, const CTParseToken *token);
+/* Read a token from *pos, and update pos to point to the first character not
+ * included in the token.
+ *
+ * Token reading stops when a character inside of includeSeparators or
+ * excludeSeparators is found. If the character is inside of
+ * includeSeparators, it and any subsequent characters in includeSeparators
+ * will be added in the trailingSeparator string of the token.
+ *
+ * After the first separator is found, the value portion of the token will be
+ * trimmed on the right side. Any token inside of trimBack will be trimmed.
+ * The trimmed characters will be included in the trailingSeparator.
+ */
+DWORD CTReadToken(const char **pos, CTParseToken *store, const char *includeSeparators, const char *excludeSeparators, const char *trimBack);
+DWORD CTCopyTokenContents(CTParseToken *dest, const CTParseToken *source);
+DWORD CTCopyToken(const CTParseToken *source, CTParseToken **dest);
+
+DWORD CTWriteToken(FILE *file, CTParseToken *token);
+
+DWORD CTGetTerminalWidth(int terminalFid, int *width);
+DWORD CTWordWrap(PCSTR input, PSTR *output, int tabWidth, int columns);
+
+LW_END_EXTERN_C
+
+
+#endif /* __CTSTRUTILS_H__ */
+
86 centutils/include/ctsys.h
@@ -0,0 +1,86 @@
+/* Editor Settings: expandtabs and use 4 spaces for indentation
+ * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
+ * -*- mode: c, c-basic-offset: 4 -*- */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+#ifndef __CTSYS_H__
+#define __CTSYS_H__
+
+#ifdef UNICODE
+#undef UNICODE
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <time.h>
+#include <string.h>
+#include <strings.h>
+#include <errno.h>
+#include <netdb.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <regex.h>
+#include <dirent.h>
+#include <limits.h>
+#include <pwd.h>
+#include <grp.h>
+
+#endif /* __CTSYS_H__ */
+
+
95 centutils/include/ctsysfuncs.h
@@ -0,0 +1,95 @@
+/* Editor Settings: expandtabs and use 4 spaces for indentation
+ * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
+ * -*- mode: c, c-basic-offset: 4 -*- */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+#ifndef __SYSFUNCS_H__
+#define __SYSFUNCS_H__
+
+
+LW_BEGIN_EXTERN_C
+
+void
+sys_vsyslog(
+ int priority,
+ const char *format,
+ va_list ap
+ );
+
+#if !defined(HAVE_RPL_MALLOC)
+
+void*
+rpl_malloc(size_t n);
+
+#endif /* ! HAVE_RPL_MALLOC */
+
+#if !defined(HAVE_RPL_REALLOC)
+
+void*
+rpl_realloc(void* buf, size_t n);
+
+#endif /* ! HAVE_RPL_REALLOC */
+
+BOOLEAN
+IsRoot(void);
+
+#ifndef HAVE_MKDTEMP
+char *mkdtemp(char *temp);
+#endif
+
+LW_END_EXTERN_C
+
+
+#endif /* __SYSFUNCS_H__ */
+
75 centutils/include/cttext.h
@@ -0,0 +1,75 @@
+/* Editor Settings: expandtabs and use 4 spaces for indentation
+ * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
+ * -*- mode: c, c-basic-offset: 4 -*- */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+#ifndef __CT_TEXT_H__
+#define __CT_TEXT_H__
+
+
+LW_BEGIN_EXTERN_C
+
+DWORD
+CTTextFormatParagraph(
+ const char* source,
+ unsigned int indent_first,
+ unsigned int indent,
+ unsigned int max_width,
+ char** dest
+ );
+
+LW_END_EXTERN_C
+
+
+#endif
71 centutils/include/ctuser.h
@@ -0,0 +1,71 @@
+/* Editor Settings: expandtabs and use 4 spaces for indentation
+ * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
+ * -*- mode: c, c-basic-offset: 4 -*- */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+#ifndef CTUSER_H_
+#define CTUSER_H_
+
+
+LW_BEGIN_EXTERN_C
+
+//This function is not thread safe. Use your own locking before calling this function if you need it to be thread safe.
+//This function sets inX to true if a user is logged into X windows.
+DWORD
+CTIsUserInX(BOOLEAN *inX);
+
+LW_END_EXTERN_C
+
+
+#endif /*CTUSER_H_*/
181 centutils/include/lwexc.h
@@ -0,0 +1,181 @@
+/* Editor Settings: expandtabs and use 4 spaces for indentation
+ * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
+ * -*- mode: c, c-basic-offset: 4 -*- */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
+ * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
+ * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU
+ * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
+ * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
+ * license@likewisesoftware.com
+ */
+
+/*
+ * Copyright Likewise Software 2004-2008
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the license, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details. You should have received a copy
+ * of the GNU Lesser General Public License along with this program. If
+ * not, see <http://www.gnu.org/licenses/>.
+ *
+ * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
+ * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
+ * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE