unix: add os information #675

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
@mmalecki

mmalecki commented Jan 4, 2013

This still needs Windows version.

/cc @bnoordhuis

@bnoordhuis

View changes

src/unix/os.c
+#include <string.h>
+#include <sys/utsname.h>
+
+uv_err_t uv_hostname(char* hostname, size_t size) {

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Jan 4, 2013

Contributor

Style: two newlines between functions and headers / declarations.

@bnoordhuis

bnoordhuis Jan 4, 2013

Contributor

Style: two newlines between functions and headers / declarations.

@bnoordhuis

View changes

src/unix/os.c
+#include <sys/utsname.h>
+
+uv_err_t uv_hostname(char* hostname, size_t size) {
+ int r = gethostname(hostname, size);

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Jan 4, 2013

Contributor

Style: split the declaration and the assignment.

@bnoordhuis

bnoordhuis Jan 4, 2013

Contributor

Style: split the declaration and the assignment.

@bnoordhuis

View changes

src/unix/os.c
+
+ if (r < 0) {
+ return uv__new_sys_error(errno);
+ }

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Jan 4, 2013

Contributor

In general, single line if statements don't have braces, i.e.:

if (r == -1)
  return uv__new_sys_error(errno);
@bnoordhuis

bnoordhuis Jan 4, 2013

Contributor

In general, single line if statements don't have braces, i.e.:

if (r == -1)
  return uv__new_sys_error(errno);
@bnoordhuis

View changes

src/unix/os.c
+ }
+
+ strncpy(type, info.sysname, size - 1);
+ type[size] = '\0';

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Jan 4, 2013

Contributor

Use uv_strlcpy() here.

@bnoordhuis

bnoordhuis Jan 4, 2013

Contributor

Use uv_strlcpy() here.

@bnoordhuis

View changes

test/test-platform-output.c
@@ -83,5 +83,17 @@
}
uv_free_interface_addresses(interfaces, count);
+ err = uv_hostname(buffer, 512);

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Jan 4, 2013

Contributor

s/512/sizeof(buffer)/

@bnoordhuis

bnoordhuis Jan 4, 2013

Contributor

s/512/sizeof(buffer)/

@bnoordhuis

View changes

include/uv.h
@@ -1467,6 +1467,10 @@ UV_EXTERN uv_err_t uv_interface_addresses(uv_interface_address_t** addresses,
UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses,
int count);
+UV_EXTERN uv_err_t uv_hostname(char* hostname, size_t size);
+UV_EXTERN uv_err_t uv_os_type(char* type, size_t size);
+UV_EXTERN uv_err_t uv_os_release(char* release, size_t size);

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Jan 4, 2013

Contributor

Can you add some short comments describing what the function does and what inputs it takes / outputs it produces?

@bnoordhuis

bnoordhuis Jan 4, 2013

Contributor

Can you add some short comments describing what the function does and what inputs it takes / outputs it produces?

@mmalecki

This comment has been minimized.

Show comment Hide comment
@mmalecki

mmalecki Jan 8, 2013

@bnoordhuis all fixed.

mmalecki commented Jan 8, 2013

@bnoordhuis all fixed.

@bnoordhuis

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Jan 9, 2013

Contributor

LGTM but it needs Windows stubs (bonus points for working implementations). I suggest that you copy out an empty string besides returning UV_ENOSYS.

Contributor

bnoordhuis commented Jan 9, 2013

LGTM but it needs Windows stubs (bonus points for working implementations). I suggest that you copy out an empty string besides returning UV_ENOSYS.

@bnoordhuis

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Jul 25, 2013

Contributor

@mmalecki Are you still planning on finishing this? It'll need some rebasing to apply to master.

Contributor

bnoordhuis commented Jul 25, 2013

@mmalecki Are you still planning on finishing this? It'll need some rebasing to apply to master.

@bnoordhuis

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Sep 25, 2013

Contributor

No followup, closing.

Contributor

bnoordhuis commented Sep 25, 2013

No followup, closing.

@bnoordhuis bnoordhuis closed this Sep 25, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment