This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fcntl.h> /* open */ | |
#include <sys/stat.h> /* open */ | |
#include <unistd.h> /* close */ | |
#include <sys/ioctl.h> /* ioctl */ | |
#include <time.h> /* struct tm */ | |
/* | |
* @param pathname The /dev/rtc (or /dev/rtc0, /dev/rtc1, etc.) can be opened | |
* only once until it is closed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <netinet/in.h> /* in_addr_t */ | |
in_addr_t calc_broadcast(in_addr_t addr, in_addr_t netmask) | |
{ | |
return addr | ~netmask; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <errno.h> /* errno */ | |
#include <arpa/inet.h> /* htonl */ | |
#include <netinet/in.h> /* in_addr_t */ | |
/** | |
* @param start start IP adress in host byte order | |
* @param end end IP address in host byte order | |
* @param addr_cb callback | |
* @param data callback argument. | |
* @return If failed, between_addr() returns -1. Otherwise, retrun a value from callback |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <netinet/in.h> /* in_addr_t */ | |
in_addr_t calc_network(in_addr_t addr, in_addr_t netmask) | |
{ | |
return addr & netmask; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <time.h> | |
double get_timezone(void) | |
{ | |
time_t t, utc, local; | |
struct tm tm; | |
t = time(NULL); | |
utc = mktime(gmtime_r(&t, &tm)); | |
local = mktime(localtime_r(&t, &tm)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
set -u | |
function usage() { | |
echo "Usage: $(basename $0): [-d] args" | |
echo " -d Make a directory instead of a file." | |
} |