Loading...
Searching...
No Matches
format.c File Reference

Segment formatting routines. More...

`#include <inttypes.h>`
`#include <stdio.h>`
`#include <string.h>`
`#include <errno.h>`
`#include <unistd.h>`
`#include <limits.h>`
`#include <grass/gis.h>`
`#include <grass/glocale.h>`
`#include "local_proto.h"`
Include dependency graph for segment/format.c:

Go to the source code of this file.

## Functions

int | Segment_format (int fd, off_t nrows, off_t ncols, int srows, int scols, int len)
| Format a segment file.
int | Segment_format_nofill (int fd, off_t nrows, off_t ncols, int srows, int scols, int len)
| Format a segment file.

## Detailed Description

Segment formatting routines.

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
  GRASS Development Team

Date
  2005-2018

Definition in file segment/format.c.

## Function Documentation

## Segment_format()

int Segment_format | ( | int | fd,
|  | off_t | nrows,
|  | off_t | 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] | fd | file descriptor
  [in] | nrows | number of non-segmented rows
  [in] | ncols | number of non-segmented columns
  [in] | srows | segment rows
  [in] | scols | segment columns
  [in] | len | length of data type

Returns
  1 of successful
  -1 if unable to seek or write fd
  -3 if illegal parameters are passed

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

## Segment_format_nofill()

int Segment_format_nofill | ( | int | fd,
|  | off_t | nrows,
|  | off_t | 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] | fd | file descriptor
  [in] | nrows | number of non-segmented rows
  [in] | ncols | number of non-segmented columns
  [in] | srows | segment rows
  [in] | scols | segment columns
  [in] | len | length of data type

Returns
  1 of successful
  -1 if unable to seek or write fd
  -3 if illegal parameters are passed

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

Referenced by Segment_open().