rfc3164.c
author viric@llimona
Fri, 16 Jun 2006 18:25:03 +0200
changeset 61 4cd174a9b698
parent 53 667cd5966695
permissions -rw-r--r--
Added the setsockopt for IPV6_V6ONLY, in order to have IPv6 and IPv4 in two different sockets for the same port.

#include "rfc3164.h"
#include <stdio.h>  // snprintf
#include <unistd.h> // write
#include <string.h> // strlen


int process_message(char * restrict buffer)
{
	int i;
	/* char message[MESSAGE_LENGTH+1]; */

	for(i=0; i<MESSAGE_LENGTH; i++)
	{
		if (buffer[i] == '\n' || buffer[i] == '\0')
		{
			buffer[i] = '\0';
			break;
		}
		else if ((buffer[i] & 128) == 128 )
		{
			/* Convertim de 8bits a 7bits */
			buffer[i] = buffer[i] & ~128;
		}

		/* Han de ser caràcters imprimibles */
		if (buffer[i] < 32)
			buffer[i] = ' ';
	}
	if(i == MESSAGE_LENGTH)
		buffer[MESSAGE_LENGTH-1] = '\0';
	/* Debug */
	/* fprintf(stderr,"M: %s\n", buffer); */

	/*snprintf(message, MESSAGE_LENGTH+1,"%s\n", buffer); */
	/* write(1, message, strlen(message)); */

	return i;
}