GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
segment/format.c File Reference
#include <grass/config.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <limits.h>
#include <grass/segment.h>
Include dependency graph for segment/format.c:

Go to the source code of this file.

Functions

int segment_format (int fd, int nrows, int ncols, int srows, int scols, int len)
 Format a segment file. More...
 
int segment_format_nofill (int fd, int nrows, int ncols, int srows, int scols, int len)
 Format a segment file. More...
 

Function Documentation

int segment_format ( int  fd,
int  nrows,
int  ncols,
int  srows,
int  scols,
int  len 
)

Format a segment file.

The segmentation routines require a disk file to be used for paging segments in and out of memory. This routine formats the file open for write on file descriptor fd for use as a segment file.

A segment file must be formatted before it can be processed by other segment routines. The configuration parameters nrows, ncols, srows, scols, and len are written to the beginning of the segment file which is then filled with zeros.

The corresponding nonsegmented data matrix, which is to be transferred to the segment file, is nrows by ncols. The segment file is to be formed of segments which are srows by scols. The data items have length len bytes. For example, if the data type is int, len is sizeof(int).

Parameters
[in]fdfile descriptor
[in]nrowsnumber of non-segmented rows
[in]ncolsnumber of non-segmented columns
[in]srowssegment rows
[in]scolssegment columns
[in]lenlength of data type
Returns
1 of successful
-1 if unable to seek or write fd
-3 if illegal parameters are passed

Definition at line 62 of file segment/format.c.

Referenced by main().

int segment_format_nofill ( int  fd,
int  nrows,
int  ncols,
int  srows,
int  scols,
int  len 
)

Format a segment file.

The segmentation routines require a disk file to be used for paging segments in and out of memory. This routine formats the file open for write on file descriptor fd for use as a segment file.

A segment file must be formatted before it can be processed by other segment routines. The configuration parameters nrows, ncols, srows, scols, and len are written to the beginning of the segment file which is then filled with zeros.

The corresponding nonsegmented data matrix, which is to be transferred to the segment file, is nrows by ncols. The segment file is to be formed of segments which are srows by scols. The data items have length len bytes. For example, if the data type is int, len is sizeof(int).

Note: This version of the function does not fill in the initialized data structures with zeros.

Parameters
[in]fdfile descriptor
[in]nrowsnumber of non-segmented rows
[in]ncolsnumber of non-segmented columns
[in]srowssegment rows
[in]scolssegment columns
[in]lenlength of data type
Returns
1 of successful
-1 if unable to seek or write fd
-3 if illegal parameters are passed

Definition at line 102 of file segment/format.c.