Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual

Page 268

Advertising
background image

KTD-S0057-I

Page 264 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


if

(!gp_dir)

{

if (read (fd_io, str, sizeof (str)) < 0)

return

-1;

str [1] = '\0';

*val = atoi (str);

return lseek (fd_io, 0, SEEK_SET);

}

else

{

if (param3 != (char *) NULL)

{

if (strcasecmp (param3, IO_LOW) && strcasecmp (param3, IO_HIGH))

return

-1;

}

if (write (fd_io, param3, strlen (param3)) != strlen (param3))

return

-1;

return lseek (fd_io, 0, SEEK_SET);

}

}

return

-1;

}


int main (void)
{

int fifo_rd, fifo_wr, value;

mode_t oldmask = umask (0);

static char buff_rd [RD_SIZE];

static char buff_wr [WR_SIZE];

if (mkfifo (root_rd, S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH) < 0)

{

umask

(oldmask);

ERROR;

}

if (mkfifo (root_wr, S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH) < 0)

{

unlink

(root_rd);

umask

(oldmask);

ERROR;

}

if ((fifo_rd = open (root_rd, O_RDONLY)) < 0 || (fifo_wr = open (root_wr, O_WRONLY)) < 0)

{

unlink

(root_rd);

unlink

(root_wr);

umask

(oldmask);

ERROR;

}

Advertising
This manual is related to the following products: