Kstars
22 #include <sys/types.h>
27 #include "byteorder.h"
32 #ifndef INDEX_ENTRY_SIZE
33 #define INDEX_ENTRY_SIZE 12
67 void charv2str(
char *str,
char *charv,
int n)
70 for (i = 0; i < n; ++i)
82 charv2str(str, e->
name, 10);
83 printf(
"\nData Field:\n");
84 printf(
" Name: %s\n", str);
85 printf(
" Size: %d\n", e->
size);
86 printf(
" Type: %d\n", e->type);
87 printf(
" Scale: %ld\n", e->
scale);
92 void swapbytes(
char byteswap,
void *ptr,
int nbytes)
100 destptr = (
char *)malloc(nbytes);
101 i = ((
char *)ptr + (nbytes - 1));
102 while (i >= (
char *)ptr)
111 memcpy(ptr, (
void *)destptr, nbytes);
115 u_int32_t trixel2number(
char *trixel)
119 for (index = HTM_LEVEL + 1; index >= 1; --index)
121 id += (trixel[index] -
'0') * (u_int16_t)round(pow(4, (HTM_LEVEL + 1 - index)));
123 id += ((trixel[0] ==
'S') ? round(pow(4, HTM_LEVEL + 1)) + 1 : 0);
127 char *number2trixel(
char *trixel, u_int16_t number)
130 u_int16_t hpv = (u_int16_t)round(pow(4, HTM_LEVEL)) * 2;
140 for (index = 1; index < HTM_LEVEL + 2; ++index)
147 trixel[HTM_LEVEL + 2] =
'\0';
159 int str2int32(int32_t *i,
const char *str,
int ndec)
168 *i = (int32_t)(round(dbl * pow(10, ndec)));
180 int str2int16(int16_t *i,
const char *str,
int ndec)
184 if (i ==
nullptr || str ==
nullptr)
189 *i = (int16_t)(round(dbl * pow(10, ndec)));
201 int str2charv(
char *a,
const char *str,
int n)
203 if (a ==
nullptr || str ==
nullptr)
208 for (
int i = 0; i < n; ++i)
210 a[i] = ((ret < 0) ?
'\0' : str[i]);
223 int isblank(
char *str)
230 if (*str !=
' ' && *str !=
'\n' && *str !=
'\r' && *str !=
'\t')
247 int writeDataElementDescription(FILE *f,
char *name, int8_t size,
enum dataType type, int32_t scale)
251 if (f ==
nullptr ||
name ==
nullptr)
254 str2charv(de.name,
name, 10);
262 int writeIndexEntry(FILE *hf, u_int32_t trixel_id, u_int32_t offset, u_int32_t nrec)
267 fwrite(&trixel_id, 4, 1, hf);
268 fwrite(&offset, 4, 1, hf);
269 fwrite(&nrec, 4, 1, hf);
272 if (4 + 4 + 4 != INDEX_ENTRY_SIZE)
274 fprintf(stderr,
"CODE ERROR: 4 + 4 + 4 != INDEX_ENTRY_SIZE\n");
char name[10]
Field name (eg.
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
qint8 size
Field size in bytes (eg.
KIOCORE_EXPORT QString number(KIO::filesize_t size)
A structure describing a data field in the binary file.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Aug 14 2022 04:13:54 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.