Skip to content

Instantly share code, notes, and snippets.

#include <strings.h>
void bzero(void *dest, size_t nbytes);
void bcopy(const void *src, void *dest, size_t nbytes);
int bcmp(const void *ptr1, const void *ptr2, size_t nbytes);
/* Returns: 0 if equal, nonzero if unequal */
#include <netinet/in.h>
uint16_t htons(uint16_t host16bitvalue);
uint32_t htonl(uint32_t host32bitvalue);
/* Both return: value in network byte order */
uint16_t ntohs(uint16_t net16bitvalue);
uint32_t ntohl(uint32_t net32bitvalue);
#include "unp.h"
int
main(int argc, char **argv)
{
union {
short s;
char c[sizeof(short)];
} un;
#include <unistd.h> /* System V */
#include <sys/ioctl.h> /* BSD and Linux */
int ioctl(int fd, int request, ...);
/* Returns: −1 on error, something else if OK */
#include <fcntl.h>
int fcntl(int fd, int cmd, ... /* int arg */ );
/* Returns: depends on cmd if OK (see following), −1 on error */
#include <unistd.h>
int fsync(int fd);
int fdatasync(int fd);
/* Returns: 0 if OK, −1 on error */
void sync(void);
#include <unistd.h>
int dup(int fd);
int dup2(int fd, int fd2);
/* Both return: new file descriptor if OK, −1 on error */
#include <unistd.h>
ssize_t pread(int fd, void *buf, size_t nbytes, off_t offset);
/* Returns: number of bytes read, 0 if end of file, −1 on error */
ssize_t pwrite(int fd, const void *buf, size_t nbytes, off_t offset);
/* Returns: number of bytes written if OK, −1 on error */
#!/bin/bash
# This script is to be run inside the container
for n in hosts localtime nsswitch.conf resolv.conf services;
do cp /etc/$n /var/spool/postfix/etc;
done
postfix start
#include <unistd.h>
ssize_t write(int fd, const void *buf, size_t nbytes);
/* Returns: number of bytes written if OK, −1 on error */