Reformat code

This commit is contained in:
Fabio Scotto di Santolo
2025-07-04 10:39:07 +02:00
parent 2bea38d7fc
commit dd53e83af6
28 changed files with 632 additions and 524 deletions

View File

@@ -1,45 +1,44 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
int main(void) {
struct iovec iov[3];
int main(void)
{
struct iovec iov[3];
char *buf[] = {
"The term buccaneer comes from the word boucan.\n",
"A boucan is a wooden frame used for cooking meet.\n",
"Buccaneer is the West Indies name for a pirate.\n"
};
char *buf[] = {"The term buccaneer comes from the word boucan.\n",
"A boucan is a wooden frame used for cooking meet.\n",
"Buccaneer is the West Indies name for a pirate.\n"};
int fd = open("buccaneer.txt", O_WRONLY | O_CREAT | O_TRUNC);
if (fd == -1) {
perror("open");
return 1;
}
int fd = open("buccaneer.txt", O_WRONLY | O_CREAT | O_TRUNC);
if (fd == -1) {
perror("open");
return 1;
}
// fill out three iovec structures
for (int i = 0; i < 3; i++) {
iov[i].iov_base = buf[i];
iov[i].iov_len = strlen(buf[i]) + 1;
}
// fill out three iovec structures
for (int i = 0; i < 3; i++) {
iov[i].iov_base = buf[i];
iov[i].iov_len = strlen(buf[i]) + 1;
}
// with a single call, write them all out
ssize_t nr = writev(fd, iov, 3);
if (nr == -1) {
perror("writev");
return 1;
}
// with a single call, write them all out
ssize_t nr = writev(fd, iov, 3);
if (nr == -1) {
perror("writev");
return 1;
}
printf("wrote %lu bytes\n", nr);
printf("wrote %lu bytes\n", nr);
if (close(fd)) {
perror("close");
return 1;
}
if (close(fd)) {
perror("close");
return 1;
}
return 0;
return 0;
}