c84264bb398c51438bb5230fc6b4a2a75a5bd923
Stefan Schuermans first incomplete begin_proc...

Stefan Schuermans authored 4 years ago

liblwptpl/src/write.c  1) #include "write.h"
liblwptpl/src/write.c  2) 
Stefan Schuermans implement proc_end event

Stefan Schuermans authored 4 years ago

liblwptpl/src/write.c  3) #include <fcntl.h>
Stefan Schuermans add header to events to sep...

Stefan Schuermans authored 4 years ago

liblwptpl/src/write.c  4) #include <stdint.h>
Stefan Schuermans first incomplete begin_proc...

Stefan Schuermans authored 4 years ago

liblwptpl/src/write.c  5) #include <stdlib.h>
Stefan Schuermans implement proc_end event

Stefan Schuermans authored 4 years ago

liblwptpl/src/write.c  6) #include <string.h>
liblwptpl/src/write.c  7) #include <sys/file.h>
liblwptpl/src/write.c  8) #include <unistd.h>
Stefan Schuermans first incomplete begin_proc...

Stefan Schuermans authored 4 years ago

liblwptpl/src/write.c  9) 
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

libuptpl/src/write.c  10) struct uptpl_event_header_s {
libuptpl/src/write.c  11)   uint8_t magic[4]; /**< u p t 0 */
Stefan Schuermans formatting

Stefan Schuermans authored 4 years ago

libuptpl/src/write.c  12)   uint8_t size[4];  /**< size of payload in network byte oder */
Stefan Schuermans add header to events to sep...

Stefan Schuermans authored 4 years ago

liblwptpl/src/write.c 13) } __attribute__((packed));
liblwptpl/src/write.c 14) 
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

libuptpl/src/write.c  15) void uptpl_write(void const *data, size_t size) {
Stefan Schuermans formatting

Stefan Schuermans authored 4 years ago

libuptpl/src/write.c  16)   if (!data || !size || size > 0xFFFFFFFF) {
Stefan Schuermans implement proc_end event

Stefan Schuermans authored 4 years ago

liblwptpl/src/write.c 17)     return;
liblwptpl/src/write.c 18)   }
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

libuptpl/src/write.c  19)   char const *filename = getenv("UPTPL_OUTPUT");
Stefan Schuermans formatting

Stefan Schuermans authored 4 years ago

libuptpl/src/write.c  20)   if (!filename) {
Stefan Schuermans implement proc_end event

Stefan Schuermans authored 4 years ago

liblwptpl/src/write.c 21)     return;
liblwptpl/src/write.c 22)   }
liblwptpl/src/write.c 23)   int fd = open(filename, O_WRONLY | O_APPEND);
liblwptpl/src/write.c 24)   if (fd == -1) {
liblwptpl/src/write.c 25)     return;
liblwptpl/src/write.c 26)   }
liblwptpl/src/write.c 27)   if (flock(fd, LOCK_EX) == -1) {
liblwptpl/src/write.c 28)     close(fd);
liblwptpl/src/write.c 29)     return;
liblwptpl/src/write.c 30)   }
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

libuptpl/src/write.c  31)   struct uptpl_event_header_s uptpl_event_header = {
Stefan Schuermans formatting

Stefan Schuermans authored 4 years ago

libuptpl/src/write.c  32)       .magic = {'u', 'p', 't', '0'},
libuptpl/src/write.c  33)       .size = {
libuptpl/src/write.c  34)           (size >> 24) & 0xFF,
libuptpl/src/write.c  35)           (size >> 16) & 0xFF,
libuptpl/src/write.c  36)           (size >> 8) & 0xFF,
libuptpl/src/write.c  37)           size & 0xFF,
libuptpl/src/write.c  38)       }};
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

libuptpl/src/write.c  39)   write(fd, &uptpl_event_header, sizeof(uptpl_event_header));
Stefan Schuermans implement proc_end event

Stefan Schuermans authored 4 years ago

liblwptpl/src/write.c 40)   write(fd, data, size);
liblwptpl/src/write.c 41)   flock(fd, LOCK_UN);
liblwptpl/src/write.c 42)   close(fd);