Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _GNU_SOURCE
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- #include <stddef.h>
- #include <utmp.h>
- #include <arpa/inet.h>
- const int utmp_len = sizeof(struct utmp);
- int main(int argc, const char * argv[]) {
- struct utmp z;
- const int32_t * x = z.ut_addr_v6;
- char buf[INET6_ADDRSTRLEN];
- const char *text;
- while(read(STDIN_FILENO, &z, utmp_len) == utmp_len) {
- text = inet_ntop(
- (x[1] || x[2] || x[3]) ? (AF_INET6) : (AF_INET),
- x,
- buf, sizeof(buf));
- printf("%s\n", text);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment