XS-libuv

 view release on metacpan or  search on metacpan

libuv-1.49.2/ChangeLog  view on Meta::CPAN


* Revert "win, test: fix double close in test runner" (Bartosz Sosnowski)

* win, test: remove surplus CloseHandle (Bartosz Sosnowski)


2017.08.17, Version 1.14.0 (Stable), e0d31e9e21870f88277746b6d59cf07b977cdfea

Changes since version 1.13.1:

* unix: check for NULL in uv_os_unsetenv for parameter name (André Klitzing)

* doc: add thread safety warning for process title (Matthew Taylor)

* unix: always copy process title into local buffer (Matthew Taylor)

* poll: add support for OOB TCP and GPIO interrupts (CurlyMoo)

* win,build: fix appveyor properly (Refael Ackermann)

* win: include filename in dlopen error message (Ben Noordhuis)

libuv-1.49.2/docs/src/misc.rst  view on Meta::CPAN

    in `buffer`, including the null terminator. If the environment variable
    exceeds the storage available in `buffer`, `UV_ENOBUFS` is returned, and
    `size` is set to the amount of storage required to hold the value. If no
    matching environment variable exists, `UV_ENOENT` is returned.

    .. warning::
        This function is not thread safe.

    .. versionadded:: 1.12.0

.. c:function:: int uv_os_setenv(const char* name, const char* value)

    Creates or updates the environment variable specified by `name` with
    `value`.

    .. warning::
        This function is not thread safe.

    .. versionadded:: 1.12.0

.. c:function:: int uv_os_unsetenv(const char* name)

    Deletes the environment variable specified by `name`. If no such environment
    variable exists, this function returns successfully.

    .. warning::
        This function is not thread safe.

    .. versionadded:: 1.12.0

.. c:function:: int uv_os_gethostname(char* buffer, size_t* size)

libuv-1.49.2/include/uv.h  view on Meta::CPAN

                                           int count);

struct uv_env_item_s {
  char* name;
  char* value;
};

UV_EXTERN int uv_os_environ(uv_env_item_t** envitems, int* count);
UV_EXTERN void uv_os_free_environ(uv_env_item_t* envitems, int count);
UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size);
UV_EXTERN int uv_os_setenv(const char* name, const char* value);
UV_EXTERN int uv_os_unsetenv(const char* name);

#ifdef MAXHOSTNAMELEN
# define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1)
#else
  /*
    Fallback for the maximum hostname size, including the null terminator. The
    Windows gethostname() documentation states that 256 bytes will always be
    large enough to hold the null-terminated hostname.
  */
# define UV_MAXHOSTNAMESIZE 256

libuv-1.49.2/src/unix/core.c  view on Meta::CPAN

    return UV_ENOBUFS;
  }

  memcpy(buffer, var, len + 1);
  *size = len;

  return 0;
}


int uv_os_setenv(const char* name, const char* value) {
  if (name == NULL || value == NULL)
    return UV_EINVAL;

  if (setenv(name, value, 1) != 0)
    return UV__ERR(errno);

  return 0;
}


int uv_os_unsetenv(const char* name) {
  if (name == NULL)
    return UV_EINVAL;

  if (unsetenv(name) != 0)
    return UV__ERR(errno);

  return 0;
}


int uv_os_gethostname(char* buffer, size_t* size) {
  /*
    On some platforms, if the input buffer is not large enough, gethostname()
    succeeds, but truncates the result. libuv can detect this and return ENOBUFS

libuv-1.49.2/src/win/util.c  view on Meta::CPAN

  if (name_w != NULL)
    uv__free(name_w);

  if (var != fastvar)
    uv__free(var);

  return r;
}


int uv_os_setenv(const char* name, const char* value) {
  wchar_t* name_w;
  wchar_t* value_w;
  int r;

  if (name == NULL || value == NULL)
    return UV_EINVAL;

  r = uv__convert_utf8_to_utf16(name, &name_w);

  if (r != 0)

libuv-1.49.2/src/win/util.c  view on Meta::CPAN

  uv__free(name_w);
  uv__free(value_w);

  if (r == 0)
    return uv_translate_sys_error(GetLastError());

  return 0;
}


int uv_os_unsetenv(const char* name) {
  wchar_t* name_w;
  int r;

  if (name == NULL)
    return UV_EINVAL;

  r = uv__convert_utf8_to_utf16(name, &name_w);

  if (r != 0)
    return r;

libuv-1.49.2/test/runner-unix.c  view on Meta::CPAN

void notify_parent_process(void) {
  char* arg;
  int fd;

  arg = getenv("UV_TEST_RUNNER_FD");
  if (arg == NULL)
    return;

  fd = atoi(arg);
  assert(fd > STDERR_FILENO);
  unsetenv("UV_TEST_RUNNER_FD");
  closefd(fd);
}


/* Do platform-specific initialization. */
void platform_init(int argc, char **argv) {
  /* Disable stdio output buffering. */
  setvbuf(stdout, NULL, _IONBF, 0);
  setvbuf(stderr, NULL, _IONBF, 0);
  signal(SIGPIPE, SIG_IGN);

libuv-1.49.2/test/runner-unix.c  view on Meta::CPAN

    return -1;
  }

  if (is_helper) {
    if (pipe(pipefd)) {
      perror("pipe");
      return -1;
    }

    snprintf(fdstr, sizeof(fdstr), "%d", pipefd[1]);
    if (setenv("UV_TEST_RUNNER_FD", fdstr, /* overwrite */ 1)) {
      perror("setenv");
      return -1;
    }
  }

  p->terminated = 0;
  p->status = 0;

#if defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH)
  pid = -1;
#else

libuv-1.49.2/test/runner-unix.c  view on Meta::CPAN


  /* parent */
  p->pid = pid;
  p->name = strdup(name);
  p->stdout_file = stdout_file;

  if (!is_helper)
    return 0;

  closefd(pipefd[1]);
  unsetenv("UV_TEST_RUNNER_FD");

  do
    rc = read(pipefd[0], &n, 1);
  while (rc == -1 && errno == EINTR);

  closefd(pipefd[0]);

  if (rc == -1) {
    perror("read");
    return -1;

libuv-1.49.2/test/test-env-vars.c  view on Meta::CPAN

  size_t size;
  int i, r, envcount, found, found_win_special;
  uv_env_item_t* envitems;

#if defined(_WIN32) && defined(__ASAN__)
  /* See investigation in https://github.com/libuv/libuv/issues/4338 */
  RETURN_SKIP("Test does not currently work on Windows under ASAN");
#endif

  /* Reject invalid inputs when setting an environment variable */
  r = uv_os_setenv(NULL, "foo");
  ASSERT_EQ(r, UV_EINVAL);
  r = uv_os_setenv(name, NULL);
  ASSERT_EQ(r, UV_EINVAL);
  r = uv_os_setenv(NULL, NULL);
  ASSERT_EQ(r, UV_EINVAL);

  /* Reject invalid inputs when retrieving an environment variable */
  size = BUF_SIZE;
  r = uv_os_getenv(NULL, buf, &size);
  ASSERT_EQ(r, UV_EINVAL);
  r = uv_os_getenv(name, NULL, &size);
  ASSERT_EQ(r, UV_EINVAL);
  r = uv_os_getenv(name, buf, NULL);
  ASSERT_EQ(r, UV_EINVAL);
  size = 0;
  r = uv_os_getenv(name, buf, &size);
  ASSERT_EQ(r, UV_EINVAL);

  /* Reject invalid inputs when deleting an environment variable */
  r = uv_os_unsetenv(NULL);
  ASSERT_EQ(r, UV_EINVAL);

  /* Successfully set an environment variable */
  r = uv_os_setenv(name, "123456789");
  ASSERT_OK(r);

  /* Successfully read an environment variable */
  size = BUF_SIZE;
  buf[0] = '\0';
  r = uv_os_getenv(name, buf, &size);
  ASSERT_OK(r);
  ASSERT_OK(strcmp(buf, "123456789"));
  ASSERT_EQ(size, BUF_SIZE - 1);

  /* Return UV_ENOBUFS if the buffer cannot hold the environment variable */
  size = BUF_SIZE - 1;
  buf[0] = '\0';
  r = uv_os_getenv(name, buf, &size);
  ASSERT_EQ(r, UV_ENOBUFS);
  ASSERT_EQ(size, BUF_SIZE);

  /* Successfully delete an environment variable */
  r = uv_os_unsetenv(name);
  ASSERT_OK(r);

  /* Return UV_ENOENT retrieving an environment variable that does not exist */
  r = uv_os_getenv(name, buf, &size);
  ASSERT_EQ(r, UV_ENOENT);

  /* Successfully delete an environment variable that does not exist */
  r = uv_os_unsetenv(name);
  ASSERT_OK(r);

  /* Setting an environment variable to the empty string does not delete it. */
  r = uv_os_setenv(name, "");
  ASSERT_OK(r);
  size = BUF_SIZE;
  r = uv_os_getenv(name, buf, &size);
  ASSERT_OK(r);
  ASSERT_OK(size);
  ASSERT_OK(strlen(buf));

  /* Check getting all env variables. */
  r = uv_os_setenv(name, "123456789");
  ASSERT_OK(r);
  r = uv_os_setenv(name2, "");
  ASSERT_OK(r);
#ifdef _WIN32
  /* Create a special environment variable on Windows in case there are no
     naturally occurring ones. */
  r = uv_os_setenv("=Z:", "\\");
  ASSERT_OK(r);
#endif

  r = uv_os_environ(&envitems, &envcount);
  ASSERT_OK(r);
  ASSERT_GT(envcount, 0);

  found = 0;
  found_win_special = 0;

libuv-1.49.2/test/test-env-vars.c  view on Meta::CPAN

  ASSERT_EQ(2, found);
#ifdef _WIN32
  ASSERT_GT(found_win_special, 0);
#else
  /* There's no rule saying a key can't start with '='. */
  (void) &found_win_special;
#endif

  uv_os_free_environ(envitems, envcount);

  r = uv_os_unsetenv(name);
  ASSERT_OK(r);

  r = uv_os_unsetenv(name2);
  ASSERT_OK(r);

  for (i = 1; i <= 4; i++) {
    size_t n;
    char* p;

    n = i * 32768;
    size = n + 1;

    p = malloc(size);
    ASSERT_NOT_NULL(p);

    memset(p, 'x', n);
    p[n] = '\0';

    ASSERT_OK(uv_os_setenv(name, p));
    ASSERT_OK(uv_os_getenv(name, p, &size));
    ASSERT_EQ(n, size);

    for (n = 0; n < size; n++)
      ASSERT_EQ('x', p[n]);

    ASSERT_OK(uv_os_unsetenv(name));
    free(p);
  }

  return 0;
}

libuv-1.49.2/test/test-homedir.c  view on Meta::CPAN

  r = uv_os_homedir(NULL, &len);
  ASSERT_EQ(r, UV_EINVAL);
  r = uv_os_homedir(homedir, NULL);
  ASSERT_EQ(r, UV_EINVAL);
  len = 0;
  r = uv_os_homedir(homedir, &len);
  ASSERT_EQ(r, UV_EINVAL);

#ifdef _WIN32
  /* Test empty environment variable */
  r = uv_os_setenv("USERPROFILE", "");
  ASSERT_EQ(r, 0);
  len = sizeof homedir;
  r = uv_os_homedir(homedir, &len);
  ASSERT_EQ(r, UV_ENOENT);
#endif

  return 0;
}

libuv-1.49.2/test/test-tmpdir.c  view on Meta::CPAN

  ASSERT_EQ(r, UV_EINVAL);
  r = uv_os_tmpdir(tmpdir, NULL);
  ASSERT_EQ(r, UV_EINVAL);
  len = 0;
  r = uv_os_tmpdir(tmpdir, &len);
  ASSERT_EQ(r, UV_EINVAL);

#ifdef _WIN32
  const char *name = "TMP";
  char tmpdir_win[] = "C:\\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
  r = uv_os_setenv(name, tmpdir_win);
  ASSERT_OK(r);
  char tmpdirx[PATHMAX];
  size_t lenx = sizeof tmpdirx;
  r = uv_os_tmpdir(tmpdirx, &lenx);
  ASSERT_OK(r);

  /* Test empty environment variable */
  r = uv_os_setenv("TMP", "");
  ASSERT_EQ(r, 0);
  len = sizeof tmpdir;
  r = uv_os_tmpdir(tmpdir, &len);
  ASSERT_EQ(r, UV_ENOENT);
#endif

  return 0;
}



( run in 0.567 second using v1.01-cache-2.11-cpan-a1d94b6210f )