Rizin
unix-like reverse engineering framework and cli tools
system.h File Reference
#include <mspack.h>
#include <macros.h>
#include <string.h>

Go to the source code of this file.

Functions

int mspack_sys_filelen (struct mspack_system *system, struct mspack_file *file, off_t *length)
 
int mspack_valid_system (struct mspack_system *sys)
 

Variables

struct mspack_systemmspack_default_system
 

Function Documentation

◆ mspack_sys_filelen()

int mspack_sys_filelen ( struct mspack_system system,
struct mspack_file file,
off_t length 
)

Definition at line 66 of file system.c.

68 {
69  off_t current;
70 
71  if (!system || !file || !length) return MSPACK_ERR_OPEN;
72 
73  /* get current offset */
74  current = system->tell(file);
75 
76  /* seek to end of file */
77  if (system->seek(file, (off_t) 0, MSPACK_SYS_SEEK_END)) {
78  return MSPACK_ERR_SEEK;
79  }
80 
81  /* get offset of end of file */
82  *length = system->tell(file);
83 
84  /* seek back to original offset */
85  if (system->seek(file, current, MSPACK_SYS_SEEK_START)) {
86  return MSPACK_ERR_SEEK;
87  }
88 
89  return MSPACK_ERR_OK;
90 }
#define MSPACK_ERR_SEEK
Definition: mspack.h:495
#define MSPACK_SYS_SEEK_END
Definition: mspack.h:471
#define MSPACK_ERR_OK
Definition: mspack.h:485
#define MSPACK_ERR_OPEN
Definition: mspack.h:489
#define MSPACK_SYS_SEEK_START
Definition: mspack.h:467
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
int off_t
Definition: sftypes.h:41
Definition: gzappend.c:170
int(* seek)(struct mspack_file *file, off_t offset, int mode)
Definition: mspack.h:380
off_t(* tell)(struct mspack_file *file)
Definition: mspack.h:391

◆ mspack_valid_system()

int mspack_valid_system ( struct mspack_system sys)

Definition at line 58 of file system.c.

58  {
59  return (sys != NULL) && (sys->open != NULL) && (sys->close != NULL) &&
60  (sys->read != NULL) && (sys->write != NULL) && (sys->seek != NULL) &&
61  (sys->tell != NULL) && (sys->message != NULL) && (sys->alloc != NULL) &&
62  (sys->free != NULL) && (sys->copy != NULL) && (sys->null_ptr == NULL);
63 }
#define NULL
Definition: cris-opc.c:27
void(* copy)(void *src, void *dest, size_t bytes)
Definition: mspack.h:444
void(* close)(struct mspack_file *file)
Definition: mspack.h:321
struct mspack_file *(* open)(struct mspack_system *self, const char *filename, int mode)
Definition: mspack.h:310
void(* message)(struct mspack_file *file, const char *format,...)
Definition: mspack.h:407
void(* free)(void *ptr)
Definition: mspack.h:430
int(* read)(struct mspack_file *file, void *buffer, int bytes)
Definition: mspack.h:336
int(* write)(struct mspack_file *file, void *buffer, int bytes)
Definition: mspack.h:353
void * null_ptr
Definition: mspack.h:454
void *(* alloc)(struct mspack_system *self, size_t bytes)
Definition: mspack.h:421

Variable Documentation

◆ mspack_default_system

struct mspack_system* mspack_default_system
extern

Definition at line 238 of file system.c.