Separate modules by subdirectory

This commit is contained in:
Keith Winstein
2012-02-06 18:26:45 -05:00
parent 7e56af8fcd
commit 38c9e99882
58 changed files with 79 additions and 16 deletions
+23
View File
@@ -0,0 +1,23 @@
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include "swrite.h"
int swrite( int fd, const char *str, ssize_t len )
{
ssize_t total_bytes_written = 0;
ssize_t bytes_to_write = ( len >= 0 ) ? len : strlen( str );
while ( total_bytes_written < bytes_to_write ) {
ssize_t bytes_written = write( fd, str + total_bytes_written,
bytes_to_write - total_bytes_written );
if ( bytes_written <= 0 ) {
perror( "write" );
return -1;
} else {
total_bytes_written += bytes_written;
}
}
return 0;
}