/usr/include/tilp2/tifiles.h is in libtifiles-dev 1.1.2-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | /* Hey EMACS -*- linux-c -*- */
/* $Id: tifiles.h 4264 2009-05-29 21:46:26Z roms $ */
/* libTIFILES - file format library, a part of the TiLP project
* Copyright (C) 1999-2005 Romain Lievin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __TIFILES_H__
#define __TIFILES_H__
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "export2.h"
#include "stdints2.h"
#include "typesxx.h"
/***********************/
/* Types & Definitions */
/***********************/
/* Conditionnals */
//#define CHECKSUM_ENABLED
/* Versioning */
#ifdef __WIN32__
# define LIBFILES_VERSION "1.1.2"
#else
# define LIBFILES_VERSION VERSION
#endif
/* Types */
// TI-XX: up to 4*8 chars + 1, NSpire, up to 4*255 chars + 1
#define FLDNAME_MAX 1024
#define VARNAME_MAX 1024
#define FULNAME_MAX 2048
/**
* CalcModel:
*
* An enumeration which contains the following calculator types:
**/
#if !defined(__TICONV_H__)
typedef enum
{
CALC_NONE = 0,
CALC_TI73, CALC_TI82, CALC_TI83, CALC_TI83P, CALC_TI84P, CALC_TI85, CALC_TI86,
CALC_TI89, CALC_TI89T, CALC_TI92, CALC_TI92P, CALC_V200,
CALC_TI84P_USB, CALC_TI89T_USB, CALC_NSPIRE, CALC_MAX
} CalcModel;
#endif
#define FILES_NCALCS CALC_MAX // # of supported calcs
/**
* FileAttr:
*
* An enumeration which contains the different variable attributes.
**/
typedef enum
{
ATTRB_NONE = 0, ATTRB_LOCKED = 1, ATTRB_PROTECTED, ATTRB_ARCHIVED = 3,
} FileAttr;
/**
* FileClass:
*
* An enumeration which contains the following class of TI files:
**/
typedef enum
{
TIFILE_SINGLE = 1, TIFILE_GROUP = 2, TIFILE_REGULAR = 3, TIFILE_BACKUP = 4,
TIFILE_FLASH = 8, TIFILE_TIGROUP = 16, TIFILE_OS = 32, TIFILE_APP = 64,
} FileClass;
/**
* FileEncoding:
*
* An enumeration which contains the following encodings:
**/
typedef enum
{
ENCODING_ASCII = 1, ENCODING_LATIN1, ENCODING_UNICODE,
} FileEncoding;
/**
* DeviceType:
*
* An enumeration which contains soem device IDs for FLASH apps:
**/
typedef enum
{
DEVICE_TYPE_83P = 0x73,
DEVICE_TYPE_73 = 0x74,
DEVICE_TYPE_89 = 0x98,
DEVICE_TYPE_92P = 0x88,
} DeviceType;
/* Structures (common to all calcs) */
/**
* VarEntry:
* @folder: name of folder (TI9x only) or ""
* @name: name of variable (raw on-calc encoding)
* @type: vartype ID
* @attr: TI83+/89/92+ only (ATTRB_NONE or ARCHIVED)
* @size: size of data (uint16_t for TI8x)
* @data: pure data
* @action: used by ticalcs library (must be set to 0)
*
* A generic structure used to store the content of a TI variable.
**/
typedef struct
{
char folder[FLDNAME_MAX];
char name[VARNAME_MAX];
uint8_t type;
uint8_t attr;
uint32_t size;
uint8_t* data;
int action;
} VarEntry;
/**
* FileContent:
* @model: calculator model
* @default_folder: name of the default folder (TI9x only)
* @comment: comment aembedded in file (like "Single file received by TiLP")
* @num_entries: number of variables stored after
* @entries: a NULL-terminated array of #TiVarEntry structures
* @checksum: checksum of file
*
* A generic structure used to store the content of a single/grouped TI file.
* Please note that:
* - entries must be NULL-terminated. Parsing is based on this property.
* - num_entries must be exact. Counting relies on this.
*
* Note: NSpire uses only one entry (no grouping support).
*
**/
typedef struct
{
CalcModel model;
char default_folder[FLDNAME_MAX]; // TI9x only
char comment[43]; // Ti8x: 42 max, Ti9x: 40 max
int num_entries;
VarEntry** entries;
uint16_t checksum;
CalcModel model_dst;
} FileContent;
/**
* BackupContent:
* @model: calculator model
* @comment: comment embedded in file (like "Backup file received by TiLP")
* @checksum: checksum of file
*
* A generic structure used to store the content of a backup file.
**/
typedef struct
{
CalcModel model;
char comment[43]; // 41 on TI9x
char rom_version[9]; // TI92 only
uint16_t mem_address; // TI8x only
uint8_t type;
uint32_t data_length; // TI9x only
uint8_t* data_part;
uint16_t data_length1; // TI8x only
uint8_t* data_part1;
uint16_t data_length2; // TI8x only
uint8_t* data_part2;
uint16_t data_length3; // TI8x only
uint8_t* data_part3;
uint16_t data_length4; // TI86 only
uint8_t* data_part4;
uint16_t checksum;
} BackupContent;
#define FLASH_PAGE_SIZE 16384
/**
* FlashHeader:
* @revision_major:
* @revision_minor:
* @flags:
* @object_type:
* @revision_day:
* @revision_month:
* @revision_year:
* @name: name of FLASH app or "basecode" for OS or '' for certificate
* @device_type: a device ID (TI89: 0x88, TI92+:0x98, ...)
* @data_type: var type ID (app, os, certificate, ...)
* @data_length: length of data part
*
* A generic structure used to store the header before data of a FLASH file.
**/
typedef struct
{
uint8_t revision_major;
uint8_t revision_minor;
uint8_t flags;
uint8_t object_type;
uint8_t revision_day;
uint8_t revision_month;
uint16_t revision_year;
char name[9];
uint8_t device_type;
uint8_t data_type;
uint32_t data_length;
} FlashHeader;
/**
* FlashPage:
* @offset: FLASH offset (see TI link guide).
* @page: FLASH page (see TI link guide).
* @flag: see link guide.
* @size: length of pure data (up to 16384 bytes)
* @data: pure FLASH data.
*
* A generic structure used to store the content of a TI8x memory page for FLASH.
**/
typedef struct
{
uint16_t addr;
uint16_t page;
uint8_t flag;
uint16_t size;
uint8_t* data;
} FlashPage;
/**
* FlashContent:
* @model: a calculator model.
* @revision_major:
* @revision_minor:
* @flags:
* @object_type:
* @revision_day:
* @revision_month:
* @revision_year:
* @name: name of FLASH app or OS
* @device_type: a device ID
* @data_type: a type ID
* @hw_id: hardware ID (used on TI9x only, 0 otherwise)
* @data_length: length of pure data
* @data_part: pure FLASH data (TI9x only) or license or certificate
* @num_pages: number of FLASH pages (TI8x only)
* @pages: NULL-terminated array of FLASH pages (TI8x only)
* @next: pointer to next structure (linked list of contents)
*
* A generic structure used to store the content of a FLASH file (os or app).
**/
typedef struct _FlashContent FlashContent;
struct _FlashContent
{
CalcModel model;
//FlashHeader header;
uint8_t revision_major;
uint8_t revision_minor;
uint8_t flags;
uint8_t object_type;
uint8_t revision_day;
uint8_t revision_month;
uint16_t revision_year;
char name[9];
uint8_t device_type;
uint8_t data_type;
uint8_t hw_id;
uint32_t data_length;
uint8_t* data_part; // TI9x only
int num_pages; // TI8x only
FlashPage** pages; // TI8x only
FlashContent* next; // TI9x only
};
typedef struct
{
char* filename;
FileClass type;
union {
FileContent* regular;
FlashContent* flash;
void* data;
} content;
} TigEntry;
/**
* TigContent:
* @model: a calculator model
* @comment: a global comment for archive
* @comp_level: compression level (0: store, 1 to 4: slow to fast)
* @num_entries: the number of entries
* @entries: a NULL-terminated array of #TigEntry structures
*
* A generic structure used to store the content of a TiGroup file.
**/
typedef struct
{
CalcModel model;
char* comment;
int comp_level;
TigEntry** var_entries;
int n_vars;
TigEntry** app_entries;
int n_apps;
CalcModel model_dst;
} TigContent;
/* Functions */
// namespace scheme: library_class_function like tifiles_fext_get
#ifdef __cplusplus
extern "C" {
#endif
/****************/
/* Entry points */
/****************/
TIEXPORT2 int TICALL tifiles_library_init(void);
TIEXPORT2 int TICALL tifiles_library_exit(void);
/*********************/
/* General functions */
/*********************/
// tifiles.c
TIEXPORT2 const char* TICALL tifiles_version_get (void);
// error.c
TIEXPORT2 int TICALL tifiles_error_get (int number, char **message);
// type2str.c
TIEXPORT2 const char* TICALL tifiles_model_to_string (CalcModel type);
TIEXPORT2 CalcModel TICALL tifiles_string_to_model (const char *str);
TIEXPORT2 const char* TICALL tifiles_attribute_to_string (FileAttr atrb);
TIEXPORT2 FileAttr TICALL tifiles_string_to_attribute (const char *str);
TIEXPORT2 const char* TICALL tifiles_class_to_string (FileClass type);
TIEXPORT2 FileClass TICALL tifiles_string_to_class (const char *str);
// filetypes.c
TIEXPORT2 const char* TICALL tifiles_fext_of_group (CalcModel model);
TIEXPORT2 const char* TICALL tifiles_fext_of_backup (CalcModel model);
TIEXPORT2 const char* TICALL tifiles_fext_of_flash_app(CalcModel model);
TIEXPORT2 const char* TICALL tifiles_fext_of_flash_os (CalcModel model);
TIEXPORT2 const char* TICALL tifiles_fext_of_certif (CalcModel model);
TIEXPORT2 char* TICALL tifiles_fext_get (const char *filename);
TIEXPORT2 char* TICALL tifiles_fext_dup (const char *filename);
TIEXPORT2 int TICALL tifiles_file_is_ti (const char *filename);
TIEXPORT2 int TICALL tifiles_file_is_single (const char *filename);
TIEXPORT2 int TICALL tifiles_file_is_group (const char *filename);
TIEXPORT2 int TICALL tifiles_file_is_regular (const char *filename);
TIEXPORT2 int TICALL tifiles_file_is_backup (const char *filename);
TIEXPORT2 int TICALL tifiles_file_is_os(const char *filename);
TIEXPORT2 int TICALL tifiles_file_is_app(const char *filename);
TIEXPORT2 int TICALL tifiles_file_is_tib (const char *filename);
TIEXPORT2 int TICALL tifiles_file_is_flash (const char *filename);
TIEXPORT2 int TICALL tifiles_file_is_tigroup (const char *filename);
TIEXPORT2 int TICALL tifiles_file_is_tno(const char *filename);
TIEXPORT2 int TICALL tifiles_file_test(const char *filename, FileClass type, CalcModel target);
TIEXPORT2 CalcModel TICALL tifiles_file_get_model (const char *filename);
TIEXPORT2 FileClass TICALL tifiles_file_get_class (const char *filename);
TIEXPORT2 const char* TICALL tifiles_file_get_type (const char *filename);
TIEXPORT2 const char* TICALL tifiles_file_get_icon (const char *filename);
// typesXX.c
TIEXPORT2 const char* TICALL tifiles_vartype2string (CalcModel model, uint8_t data);
TIEXPORT2 uint8_t TICALL tifiles_string2vartype (CalcModel model, const char *s);
TIEXPORT2 const char* TICALL tifiles_vartype2fext (CalcModel model, uint8_t data);
TIEXPORT2 uint8_t TICALL tifiles_fext2vartype (CalcModel model, const char *s);
TIEXPORT2 const char* TICALL tifiles_vartype2type (CalcModel model, uint8_t id);
TIEXPORT2 const char* TICALL tifiles_vartype2icon (CalcModel model, uint8_t id);
TIEXPORT2 const char* TICALL tifiles_calctype2signature (CalcModel model);
TIEXPORT2 CalcModel TICALL tifiles_signature2calctype (const char *signature);
TIEXPORT2 uint8_t TICALL tifiles_folder_type (CalcModel model);
TIEXPORT2 uint8_t TICALL tifiles_flash_type (CalcModel model);
TIEXPORT2 uint8_t TICALL tifiles_idlist_type (CalcModel model);
// misc.c
TIEXPORT2 int TICALL tifiles_calc_is_ti8x (CalcModel model);
TIEXPORT2 int TICALL tifiles_calc_is_ti9x (CalcModel model);
TIEXPORT2 int TICALL tifiles_calc_are_compat(CalcModel model1, CalcModel model2);
TIEXPORT2 int TICALL tifiles_has_folder (CalcModel model);
TIEXPORT2 int TICALL tifiles_is_flash (CalcModel model);
TIEXPORT2 int TICALL tifiles_has_backup(CalcModel model);
TIEXPORT2 uint16_t TICALL tifiles_checksum(uint8_t * buffer, int size);
TIEXPORT2 int tifiles_hexdump(uint8_t* ptr, unsigned int length);
TIEXPORT2 char* TICALL tifiles_get_varname(const char *full_name);
TIEXPORT2 char* TICALL tifiles_get_fldname(const char *full_name);
TIEXPORT2 char* TICALL tifiles_build_fullname(CalcModel model,
char *full_name,
const char *fldname,
const char *varname);
TIEXPORT2 char* TICALL tifiles_build_filename(CalcModel model, const VarEntry *ve);
// filesXX.c
TIEXPORT2 FileContent* TICALL tifiles_content_create_regular(CalcModel model);
TIEXPORT2 int TICALL tifiles_content_delete_regular(FileContent *content);
TIEXPORT2 int TICALL tifiles_file_read_regular(const char *filename, FileContent *content);
TIEXPORT2 int TICALL tifiles_file_write_regular(const char *filename, FileContent *content, char **filename2);
TIEXPORT2 int TICALL tifiles_file_display_regular(FileContent *content);
TIEXPORT2 BackupContent* TICALL tifiles_content_create_backup(CalcModel model);
TIEXPORT2 int TICALL tifiles_content_delete_backup(BackupContent *content);
TIEXPORT2 int TICALL tifiles_file_read_backup(const char *filename, BackupContent *content);
TIEXPORT2 int TICALL tifiles_file_write_backup(const char *filename, BackupContent *content);
TIEXPORT2 int TICALL tifiles_file_display_backup(BackupContent *content);
TIEXPORT2 FlashContent* TICALL tifiles_content_create_flash(CalcModel model);
TIEXPORT2 int TICALL tifiles_content_delete_flash(FlashContent *content);
TIEXPORT2 int TICALL tifiles_file_read_flash(const char *filename, FlashContent *content);
TIEXPORT2 int TICALL tifiles_file_write_flash (const char *filename, FlashContent *content);
TIEXPORT2 int TICALL tifiles_file_write_flash2(const char *filename, FlashContent *content, char **filename2);
TIEXPORT2 int TICALL tifiles_file_display_flash(FlashContent *content);
TIEXPORT2 FileContent* TICALL tifiles_content_dup_regular(FileContent *content);
TIEXPORT2 FlashContent* TICALL tifiles_content_dup_flash(FlashContent *content);
TIEXPORT2 int TICALL tifiles_file_display(const char *filename);
// grouped.c
TIEXPORT2 FileContent** TICALL tifiles_content_create_group(int n_entries);
TIEXPORT2 int TICALL tifiles_content_delete_group(FileContent **array);
TIEXPORT2 int TICALL tifiles_group_contents(FileContent **src_contents, FileContent **dst_content);
TIEXPORT2 int TICALL tifiles_ungroup_content(FileContent *src_content, FileContent ***dst_contents);
TIEXPORT2 int TICALL tifiles_group_files(char **src_filenames, const char *dst_filename);
TIEXPORT2 int TICALL tifiles_ungroup_file(const char *src_filename, char ***dst_filenames);
TIEXPORT2 int TICALL tifiles_content_add_entry(FileContent *content, VarEntry *ve);
TIEXPORT2 int TICALL tifiles_content_del_entry(FileContent *content, VarEntry *ve);
TIEXPORT2 int TICALL tifiles_group_add_file(const char *src_filename, const char *dst_filename);
TIEXPORT2 int TICALL tifiles_group_del_file(VarEntry *entry, const char *dst_filename);
// tigroup.c -> filesXX.c
TIEXPORT2 TigContent* TICALL tifiles_content_create_tigroup(CalcModel model, int);
TIEXPORT2 int TICALL tifiles_content_delete_tigroup(TigContent *content);
TIEXPORT2 int TICALL tifiles_file_read_tigroup(const char *filename, TigContent *content);
TIEXPORT2 int TICALL tifiles_file_write_tigroup(const char *filename, TigContent *content);
TIEXPORT2 int TICALL tifiles_file_display_tigroup(const char *filename);
/// tigroup.c -> grouped.c
TIEXPORT2 int TICALL tifiles_tigroup_contents(FileContent **src_contents1, FlashContent **src_contents2, TigContent **dst_content);
TIEXPORT2 int TICALL tifiles_untigroup_content(TigContent *src_content, FileContent ***dst_contents1, FlashContent ***dst_contents2);
TIEXPORT2 int TICALL tifiles_tigroup_files(char **src_filenames, const char *dst_filename);
TIEXPORT2 int TICALL tifiles_untigroup_file(const char *src_filename, char ***dst_filenames);
TIEXPORT2 int TICALL tifiles_content_add_te(TigContent *content, TigEntry *te);
TIEXPORT2 int TICALL tifiles_content_del_te(TigContent *content, TigEntry *te);
TIEXPORT2 int TICALL tifiles_tigroup_add_file(const char *src_filename, const char *dst_filename);
TIEXPORT2 int TICALL tifiles_tigroup_del_file(TigEntry *entry, const char *dst_filename);
// tigroup.c -> ve_fp.c
TIEXPORT2 TigEntry* TICALL tifiles_te_create(const char *filename, FileClass type, CalcModel model);
TIEXPORT2 int TICALL tifiles_te_delete(TigEntry* entry);
TIEXPORT2 TigEntry** TICALL tifiles_te_create_array(int nelts);
TIEXPORT2 TigEntry** TICALL tifiles_te_resize_array(TigEntry**, int nelts);
TIEXPORT2 void TICALL tifiles_te_delete_array(TigEntry**);
TIEXPORT2 int TICALL tifiles_te_sizeof_array(TigEntry**);
// comment.c
TIEXPORT2 const char* TICALL tifiles_comment_set_single(void);
TIEXPORT2 const char* TICALL tifiles_comment_set_group(void);
TIEXPORT2 const char* TICALL tifiles_comment_set_backup(void);
TIEXPORT2 const char* TICALL tifiles_comment_set_tigroup(void);
// ve_fp.c
TIEXPORT2 VarEntry* TICALL tifiles_ve_create(void);
TIEXPORT2 VarEntry* TICALL tifiles_ve_create_with_data(uint32_t size);
TIEXPORT2 void TICALL tifiles_ve_delete(VarEntry*);
TIEXPORT2 void* tifiles_ve_alloc_data(size_t size);
TIEXPORT2 VarEntry* TICALL tifiles_ve_copy(VarEntry* dst, VarEntry* src);
TIEXPORT2 VarEntry* TICALL tifiles_ve_dup(VarEntry* src);
TIEXPORT2 VarEntry** TICALL tifiles_ve_create_array(int nelts);
TIEXPORT2 VarEntry** TICALL tifiles_ve_resize_array(VarEntry**, int nelts);
TIEXPORT2 void TICALL tifiles_ve_delete_array(VarEntry**);
TIEXPORT2 FlashPage* TICALL tifiles_fp_create(void);
TIEXPORT2 FlashPage* TICALL tifiles_fp_create_with_data(uint32_t size);
TIEXPORT2 void TICALL tifiles_fp_delete(FlashPage*);
TIEXPORT2 void* TICALL tifiles_fp_alloc_data(size_t size);
TIEXPORT2 FlashPage** TICALL tifiles_fp_create_array(int nelts);
TIEXPORT2 void TICALL tifiles_fp_delete_array(FlashPage**);
// undocumented
TIEXPORT2 int** tifiles_create_table_of_entries(FileContent *content, int *nfolders);
/************************/
/* Deprecated functions */
/************************/
#ifdef __cplusplus
}
#endif
#endif
|