<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>

#include <sys/ipc.h>
#include <sys/types.h>
#include <sys/msg.h>

#include "noteboard.h"

int main() {
  msgbuf buf;
  int msgqid;
  key_t key;
  
  key = MSGQUE_KEY;
  
  if((msgqid = msgget(key, 0644 | IPC_CREAT)) == -1) {
    perror("msgget");
    exit(1);
  }
  
  printf("Enter lines of text, ^D to quit:\n");
  buf.mtype = 1;
  buf.note.sender = getpid();
  
  while(fgets(buf.note.text, sizeof buf.note.text, stdin) != NULL) {
    int len = strlen(buf.note.text);
    
    if (buf.note.text[len-1] == '\n') buf.note.text[len-1] = '\0';
    if (msgsnd(msgqid, &buf, len+1, 0) == -1) 
    perror("msgsnd");
  }
  
  // destroy the box
  if (msgctl(msgqid, IPC_RMID, NULL) == -1) {<commit_msg>Update writer.c<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>

#include <sys/ipc.h>
#include <sys/types.h>
#include <sys/msg.h>

#include "noteboard.h"

int main() {
  msgbuf buf;
  int msgqid;
  key_t key;
  
  key = MSGQUE_KEY;
  
  if((msgqid = msgget(key, 0644 | IPC_CREAT)) == -1) {
    perror("msgget");
    exit(1);
  }
  
  printf("Enter lines of text, ^D to quit:\n");
  buf.mtype = 1;
  buf.note.sender = getpid();
  
  while(fgets(buf.note.text, NOTE_SIZE, stdin) != NULL) {
    int len = strlen(buf.note.text);
    
    if (buf.note.text[len-1] == '\n') buf.note.text[len-1] = '\0';
    if (msgsnd(msgqid, &buf, len+1, 0) == -1) 
    perror("msgsnd");
  }
  
  // destroy the box
  if (msgctl(msgqid, IPC_RMID, NULL) == -1) {
{'fraction_non_alphanumeric': 0.1989828353464717, 'fraction_numerical': 0.017800381436745075, 'mean_word_length': 2.974747474747475, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '774465', 'n_tokens_mistral': 715, 'n_tokens_neox': 694, 'n_words': 144}