shapereader
Read ESRI shapefiles
shx.h
Go to the documentation of this file.
1/*
2 * Read ESRI shapefiles
3 *
4 * Copyright (C) 2023 Andreas Vögele
5 *
6 * This library is free software; you can redistribute it and/or modify it
7 * under either the terms of the ISC License or the same terms as Perl.
8 */
9
10/* SPDX-License-Identifier: ISC OR Artistic-1.0-Perl OR GPL-1.0-or-later */
11
16#ifndef _SHAPEREADER_SHX_H
17#define _SHAPEREADER_SHX_H
18
19#include "shp.h"
20#include <stddef.h>
21#include <stdio.h>
22
27
31typedef struct shx_record_t {
32 size_t file_offset;
33 size_t record_size;
35
40
51extern shx_file_t *shx_init_file(shx_file_t *fh, FILE *fp, void *user_data);
52
62#ifdef __GNUC__
63extern void shx_set_error(shx_file_t *fh, const char *format, ...)
64 __attribute__((format(printf, 2, 3)));
65#else
66extern void shx_set_error(shx_file_t *fh, const char *format, ...);
67#endif
68
81 const shx_header_t *header);
82
96 const shx_header_t *header,
97 const shx_record_t *record);
98
138extern int shx_read(shx_file_t *fh, shx_header_callback_t handle_header,
139 shx_record_callback_t handle_record);
140
154extern int shx_read_header(shx_file_t *fh, shx_header_t *header);
155
182extern int shx_read_record(shx_file_t *fh, shx_record_t *record);
183
202extern int shx_seek_record(shx_file_t *fh, size_t record_number,
203 shx_record_t *record);
204
205#endif
shp_header_t shx_header_t
Header.
Definition: shx.h:26
void shx_set_error(shx_file_t *fh, const char *format,...)
Set an error message.
Definition: shx.c:26
shx_file_t * shx_init_file(shx_file_t *fh, FILE *fp, void *user_data)
Initialize a file handle.
Definition: shx.c:20
shp_file_t shx_file_t
File handle.
Definition: shx.h:39
int(* shx_header_callback_t)(shx_file_t *fh, const shx_header_t *header)
Handle the file header.
Definition: shx.h:80
int shx_read(shx_file_t *fh, shx_header_callback_t handle_header, shx_record_callback_t handle_record)
Read an index file.
Definition: shx.c:138
int(* shx_record_callback_t)(shx_file_t *fh, const shx_header_t *header, const shx_record_t *record)
Handle a record.
Definition: shx.h:95
int shx_read_header(shx_file_t *fh, shx_header_t *header)
Read the file header.
Definition: shx.c:39
int shx_read_record(shx_file_t *fh, shx_record_t *record)
Read an index record.
Definition: shx.c:95
int shx_seek_record(shx_file_t *fh, size_t record_number, shx_record_t *record)
Read an index record by record number.
Definition: shx.c:108
File handle.
Definition: shp.h:114
File header.
Definition: shp.h:58
Index record.
Definition: shx.h:31
size_t record_size
Content length in bytes.
Definition: shx.h:33
size_t file_offset
Offset in the ".shp" file in bytes.
Definition: shx.h:32