stream

stream

Functions

Types and Values

Description

Functions

open_stream_fd_for_write ()

Stream *
open_stream_fd_for_write (int fd);

Creates a new Stream from fd , so that stream data can be written to fd using write_chunk().

In contrast to open_stream_for_write(), this function does not write any of the usual headers. This function is mostly for use when multiple substreams need to be multiplexed into a single master stream. The master would be opened using open_stream_for_write(), and the substreams using this function.

Parameters

fd

File descriptor (e.g. from open()) to use for stream data.

 

Returns

a Stream, or NULL on failure.


open_stream_for_read ()

Stream *
open_stream_for_read (const char *filename);

open_stream_for_write ()

Stream *
open_stream_for_write (const char *filename);

Creates a new stream with name filename , and adds the stream format and version headers.

You may want to follow this with a call to write_command() to record the command line.

Parameters

filename

Filename of new stream

 

Returns

a Stream, or NULL on failure.


open_stream_for_write_2 ()

Stream *
open_stream_for_write_2 (const char *filename,
                         const char *geom_filename,
                         int argc,
                         char *argv[]);

Creates a new stream with name filename , and adds the stream format and version header, plus a verbatim copy of the geometry file

You may want to follow this with a call to write_command() to record the command line.

Parameters

filename

Filename of new stream

 

geom_filename

The geometry filename to copy

 

argc

The number of arguments to the program

 

argv

The arguments to the program

 

Returns

a Stream, or NULL on failure.


get_stream_fd ()

int
get_stream_fd (Stream *st);

This function gets the integer file descriptor for st , a bit like fileno().

This is useful in conjunction with open_stream_fd_for_write(), to get the underlying file descriptor to which the multiplexed stream data should be written. In this case, the only other operations you should ever do (or have done) on st are open_stream_for_write() and close_stream().

Parameters

st

A Stream

 

Returns

an integer file descriptor


close_stream ()

void
close_stream (Stream *st);

read_chunk ()

int
read_chunk (Stream *st,
            struct image *image);

read_chunk_2 ()

int
read_chunk_2 (Stream *st,
              struct image *image,
              StreamReadFlags srf);

write_chunk ()

int
write_chunk (Stream *st,
             struct image *image,
             struct hdfile *hdfile,
             int include_peaks,
             int include_reflections,
             struct event *ev);

rewind_stream ()

int
rewind_stream (Stream *st);

Attempts to set the file pointer for st to the start of the stream, so that later calls to read_chunk() will repeat the sequence of chunks from the start.

Programs must not assume that this operation always succeeds!

Parameters

st

A Stream

 

Returns

non-zero if the stream could not be rewound.


is_stream ()

int
is_stream (const char *filename);

write_command ()

void
write_command (Stream *st,
               int argc,
               char *argv[]);

Writes the command line to st . argc and argv should be exactly as were given to main(). This should usually be called immediately after open_stream_for_write().

Parameters

st

A Stream

 

argc

number of arguments

 

argv

command-line arguments

 

write_geometry_file ()

void
write_geometry_file (Stream *st,
                     const char *geom_filename);

Writes the content of the geometry file to st . This should usually be called immediately after write_command().

Parameters

st

A Stream

 

geom_filename

geomtry file name

 

Types and Values

Stream

typedef struct _stream Stream;

enum StreamReadFlags

A bitfield of things that can be read from a stream. Use this (and read_chunk_2()) to read the stream faster if you don't need the entire contents of the stream.

Using either or both of STREAM_READ_REFLECTIONS and STREAM_READ_UNITCELL implies STREAM_READ_CRYSTALS .

Members

STREAM_READ_UNITCELL

Read the unit cell

 

STREAM_READ_REFLECTIONS

Read the integrated reflections

 

STREAM_READ_PEAKS

Read the peak search results

 

STREAM_READ_CRYSTALS

Read the general information about crystals

 

CHUNK_END_MARKER

#define CHUNK_END_MARKER "----- End chunk -----"

CHUNK_START_MARKER

#define CHUNK_START_MARKER "----- Begin chunk -----"

CRYSTAL_END_MARKER

#define CRYSTAL_END_MARKER "--- End crystal"

CRYSTAL_START_MARKER

#define CRYSTAL_START_MARKER "--- Begin crystal"

PEAK_LIST_END_MARKER

#define PEAK_LIST_END_MARKER "End of peak list"

PEAK_LIST_START_MARKER

#define PEAK_LIST_START_MARKER "Peaks from peak search"

REFLECTION_END_MARKER

#define REFLECTION_END_MARKER "End of reflections"

REFLECTION_START_MARKER

#define REFLECTION_START_MARKER "Reflections measured after indexing"

GEOM_END_MARKER

#define GEOM_END_MARKER "----- End geometry file -----"

GEOM_START_MARKER

#define GEOM_START_MARKER "----- Begin geometry file -----"

struct stuff_from_stream

struct stuff_from_stream {
	char **fields;
	int n_fields;
};