2004-12-09 22:57:09 +00:00
|
|
|
static __attribute__((used)) char* rcsid = "$CVSHeader$";
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (c) 2004 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "libemile.h"
|
|
|
|
#include "emile.h"
|
|
|
|
#include "../second/head.h"
|
|
|
|
|
2004-12-10 00:22:50 +00:00
|
|
|
int emile_second_set_output(int fd, unsigned int enable_mask,
|
|
|
|
unsigned int disable_mask,
|
|
|
|
unsigned int bitrate0, int datasize0,
|
2004-12-09 22:57:09 +00:00
|
|
|
int parity0, int stopbits0,
|
2004-12-10 00:22:50 +00:00
|
|
|
unsigned int bitrate1, int datasize1,
|
2004-12-09 22:57:09 +00:00
|
|
|
int parity1, int stopbits1, int gestaltid)
|
|
|
|
{
|
|
|
|
emile_l2_header_t header;
|
|
|
|
off_t location;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
location = lseek(fd, 0, SEEK_CUR);
|
|
|
|
if (location == -1)
|
2004-12-12 22:59:38 +00:00
|
|
|
return EEMILE_CANNOT_READ_SECOND;
|
2004-12-09 22:57:09 +00:00
|
|
|
|
|
|
|
ret = read(fd, &header, sizeof(header));
|
|
|
|
if (ret != sizeof(header))
|
2004-12-12 22:59:38 +00:00
|
|
|
return EEMILE_CANNOT_READ_SECOND;
|
2004-12-09 22:57:09 +00:00
|
|
|
|
|
|
|
if (!EMILE_COMPAT(EMILE_03_SIGNATURE, read_long(&header.signature)))
|
2004-12-12 22:59:38 +00:00
|
|
|
return EEMILE_INVALID_SECOND;
|
2004-12-09 22:57:09 +00:00
|
|
|
|
|
|
|
header.console_mask |= enable_mask;
|
|
|
|
header.console_mask &= ~disable_mask;
|
|
|
|
|
|
|
|
if (bitrate0)
|
|
|
|
header.serial0_bitrate = bitrate0;
|
|
|
|
if (bitrate1)
|
|
|
|
header.serial1_bitrate = bitrate1;
|
|
|
|
|
|
|
|
if (datasize0 != -1)
|
|
|
|
header.serial0_datasize = datasize0;
|
|
|
|
if (datasize1 != -1)
|
|
|
|
header.serial1_datasize = datasize1;
|
|
|
|
|
|
|
|
if (stopbits0 != -1)
|
|
|
|
header.serial0_stopbits = stopbits0;
|
|
|
|
if (stopbits1 != -1)
|
|
|
|
header.serial1_stopbits = stopbits1;
|
|
|
|
|
|
|
|
if (parity0 != -1)
|
|
|
|
header.serial0_parity = parity0;
|
|
|
|
if (parity1 != -1)
|
|
|
|
header.serial1_parity = parity1;
|
|
|
|
|
2005-09-10 00:06:08 +00:00
|
|
|
if (gestaltid != -1)
|
|
|
|
header.gestaltID = gestaltid; /* 0 means unset ... */
|
2004-12-09 22:57:09 +00:00
|
|
|
|
|
|
|
ret = lseek(fd, location, SEEK_SET);
|
|
|
|
if (ret == -1)
|
2004-12-12 22:59:38 +00:00
|
|
|
return EEMILE_CANNOT_WRITE_SECOND;
|
2004-12-09 22:57:09 +00:00
|
|
|
|
|
|
|
ret = write(fd, &header, sizeof(header));
|
|
|
|
if (ret != sizeof(header))
|
2004-12-12 22:59:38 +00:00
|
|
|
return EEMILE_CANNOT_WRITE_SECOND;
|
2004-12-09 22:57:09 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|