# genutils.c File Reference

`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include "libdali.h"`

Include dependency graph for genutils.c:

## Functions
int | dl_splitstreamid (char *streamid, char *w, char *x, char *y, char *z, char *type)
| Split a stream ID into separate components: "W_X_Y_Z/TYPE".
int | dl_bigendianhost ()
| Determine byte order of host machine.
double | dl_dabs (double value)
| Return absolute value of double value.
int | dl_readline (int fd, char *buffer, int buflen)
| Read a line from a file stream.

## Detailed Description

General utility functions.

Author:
  Chad Trabant, IRIS Data Management Center

Version: 2008.192

## Function Documentation

int dl_bigendianhost | ( | void |  | ) |

Determine byte order of host machine.

Determine the byte order of the host machine. Due to the lack of portable defines to determine host byte order this run-time test is provided. The code actually tests for little-endianess, the only other alternative is assumed to be big endian.

Returns:
  0 if the host is little endian, otherwise 1.

double dl_dabs | ( | double | value | ) |

Return absolute value of double value.

Determine the absolute value of an input double, actually just test if the input double is positive multiplying by -1.0 if not and return it.

Returns:
  Positive value of input double.

int dl_readline | ( | int | fd,
|  | char * | buffer,
|  | int | buflen |
| ) |  |  |

Read a line from a file stream.

Read characters from a stream (specified as a file descriptor) until a newline character '
' is read and place them into the supplied buffer. Reading stops when either a newline character is read or buflen-1 characters have been read. The buffer will always contain a NULL-terminated string.

Returns:
  The number of characters read on success and -1 on error.

int dl_splitstreamid | ( | char * | streamid,
|  | char * | w,
|  | char * | x,
|  | char * | y,
|  | char * | z,
|  | char * | type |
| ) |  |  |

Split a stream ID into separate components: "W_X_Y_Z/TYPE".

Split stream ID into separate components from the composite form: "W_X_Y_Z/TYPE" where the underscores and slash separate the components. Memory for each component must already be allocated. If a specific component is not desired set the appropriate argument to NULL.

While the stream name components are completely generic the (strongly) suggested form for geophysical data is "NET_STA_LOC_CHAN/TYPE" where NETwork, STAtion, LOCation and CHANnel follow the FDSN SEED conventions.

Returns:
  0 on success and -1 on error.