Fix link problem by removing all inline functions defined in .h files.
This commit is contained in:
parent
c00d84f0f2
commit
8115ba6c24
@ -39,3 +39,73 @@ void iso_filesystem_unref(IsoFilesystem *fs)
|
||||
free(fs);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* this are just helpers to invoque methods in class
|
||||
*/
|
||||
|
||||
inline
|
||||
char* iso_file_source_get_path(IsoFileSource *src)
|
||||
{
|
||||
return src->class->get_path(src);
|
||||
}
|
||||
|
||||
inline
|
||||
char* iso_file_source_get_name(IsoFileSource *src)
|
||||
{
|
||||
return src->class->get_name(src);
|
||||
}
|
||||
|
||||
inline
|
||||
int iso_file_source_lstat(IsoFileSource *src, struct stat *info)
|
||||
{
|
||||
return src->class->lstat(src, info);
|
||||
}
|
||||
|
||||
inline
|
||||
int iso_file_source_access(IsoFileSource *src)
|
||||
{
|
||||
return src->class->access(src);
|
||||
}
|
||||
|
||||
inline
|
||||
int iso_file_source_stat(IsoFileSource *src, struct stat *info)
|
||||
{
|
||||
return src->class->stat(src, info);
|
||||
}
|
||||
|
||||
inline
|
||||
int iso_file_source_open(IsoFileSource *src)
|
||||
{
|
||||
return src->class->open(src);
|
||||
}
|
||||
|
||||
inline
|
||||
int iso_file_source_close(IsoFileSource *src)
|
||||
{
|
||||
return src->class->close(src);
|
||||
}
|
||||
|
||||
inline
|
||||
int iso_file_source_read(IsoFileSource *src, void *buf, size_t count)
|
||||
{
|
||||
return src->class->read(src, buf, count);
|
||||
}
|
||||
|
||||
inline
|
||||
int iso_file_source_readdir(IsoFileSource *src, IsoFileSource **child)
|
||||
{
|
||||
return src->class->readdir(src, child);
|
||||
}
|
||||
|
||||
inline
|
||||
int iso_file_source_readlink(IsoFileSource *src, char *buf, size_t bufsiz)
|
||||
{
|
||||
return src->class->readlink(src, buf, bufsiz);
|
||||
}
|
||||
|
||||
inline
|
||||
IsoFilesystem* iso_file_source_get_filesystem(IsoFileSource *src)
|
||||
{
|
||||
return src->class->get_filesystem(src);
|
||||
}
|
||||
|
215
src/fsource.h
215
src/fsource.h
@ -278,71 +278,176 @@ void iso_file_source_unref(IsoFileSource *src);
|
||||
/*
|
||||
* this are just helpers to invoque methods in class
|
||||
*/
|
||||
extern inline
|
||||
char* iso_file_source_get_path(IsoFileSource *src)
|
||||
{
|
||||
return src->class->get_path(src);
|
||||
}
|
||||
|
||||
extern inline
|
||||
char* iso_file_source_get_name(IsoFileSource *src)
|
||||
{
|
||||
return src->class->get_name(src);
|
||||
}
|
||||
/**
|
||||
* Get the path, relative to the filesystem this file source
|
||||
* belongs to.
|
||||
*
|
||||
* @return
|
||||
* the path of the FileSource inside the filesystem, it should be
|
||||
* freed when no more needed.
|
||||
*/
|
||||
char* iso_file_source_get_path(IsoFileSource *src);
|
||||
|
||||
extern inline
|
||||
int iso_file_source_lstat(IsoFileSource *src, struct stat *info)
|
||||
{
|
||||
return src->class->lstat(src, info);
|
||||
}
|
||||
/**
|
||||
* Get the name of the file, with the dir component of the path.
|
||||
*
|
||||
* @return
|
||||
* the name of the file, it should be freed when no more needed.
|
||||
*/
|
||||
char* iso_file_source_get_name(IsoFileSource *src);
|
||||
|
||||
extern inline
|
||||
int iso_file_source_access(IsoFileSource *src)
|
||||
{
|
||||
return src->class->access(src);
|
||||
}
|
||||
/**
|
||||
* Get information about the file.
|
||||
* @return
|
||||
* 1 success, < 0 error
|
||||
* Error codes:
|
||||
* ISO_FILE_ACCESS_DENIED
|
||||
* ISO_FILE_BAD_PATH
|
||||
* ISO_FILE_DOESNT_EXIST
|
||||
* ISO_MEM_ERROR
|
||||
* ISO_FILE_ERROR
|
||||
* ISO_NULL_POINTER
|
||||
*/
|
||||
int iso_file_source_lstat(IsoFileSource *src, struct stat *info);
|
||||
|
||||
extern inline
|
||||
int iso_file_source_stat(IsoFileSource *src, struct stat *info)
|
||||
{
|
||||
return src->class->stat(src, info);
|
||||
}
|
||||
/**
|
||||
* Check if the process has access to read file contents. Note that this
|
||||
* is not necessarily related with (l)stat functions. For example, in a
|
||||
* filesystem implementation to deal with an ISO image, if the user has
|
||||
* read access to the image it will be able to read all files inside it,
|
||||
* despite of the particular permission of each file in the RR tree, that
|
||||
* are what the above functions return.
|
||||
*
|
||||
* @return
|
||||
* 1 if process has read access, < 0 on error
|
||||
* Error codes:
|
||||
* ISO_FILE_ACCESS_DENIED
|
||||
* ISO_FILE_BAD_PATH
|
||||
* ISO_FILE_DOESNT_EXIST
|
||||
* ISO_MEM_ERROR
|
||||
* ISO_FILE_ERROR
|
||||
* ISO_NULL_POINTER
|
||||
*/
|
||||
int iso_file_source_access(IsoFileSource *src);
|
||||
|
||||
extern inline
|
||||
int iso_file_source_open(IsoFileSource *src)
|
||||
{
|
||||
return src->class->open(src);
|
||||
}
|
||||
/**
|
||||
* Get information about the file. If the file is a symlink, the info
|
||||
* returned refers to the destination.
|
||||
*
|
||||
* @return
|
||||
* 1 success, < 0 error
|
||||
* Error codes:
|
||||
* ISO_FILE_ACCESS_DENIED
|
||||
* ISO_FILE_BAD_PATH
|
||||
* ISO_FILE_DOESNT_EXIST
|
||||
* ISO_MEM_ERROR
|
||||
* ISO_FILE_ERROR
|
||||
* ISO_NULL_POINTER
|
||||
*/
|
||||
int iso_file_source_stat(IsoFileSource *src, struct stat *info);
|
||||
|
||||
extern inline
|
||||
int iso_file_source_close(IsoFileSource *src)
|
||||
{
|
||||
return src->class->close(src);
|
||||
}
|
||||
/**
|
||||
* Opens the source.
|
||||
* @return 1 on success, < 0 on error
|
||||
* Error codes:
|
||||
* ISO_FILE_ALREADY_OPENNED
|
||||
* ISO_FILE_ACCESS_DENIED
|
||||
* ISO_FILE_BAD_PATH
|
||||
* ISO_FILE_DOESNT_EXIST
|
||||
* ISO_MEM_ERROR
|
||||
* ISO_FILE_ERROR
|
||||
* ISO_NULL_POINTER
|
||||
*/
|
||||
int iso_file_source_open(IsoFileSource *src);
|
||||
|
||||
extern inline
|
||||
int iso_file_source_read(IsoFileSource *src, void *buf, size_t count)
|
||||
{
|
||||
return src->class->read(src, buf, count);
|
||||
}
|
||||
/**
|
||||
* Close a previuously openned file
|
||||
* @return 1 on success, < 0 on error
|
||||
* Error codes:
|
||||
* ISO_FILE_ERROR
|
||||
* ISO_NULL_POINTER
|
||||
* ISO_FILE_NOT_OPENNED
|
||||
*/
|
||||
int iso_file_source_close(IsoFileSource *src);
|
||||
|
||||
extern inline
|
||||
int iso_file_source_readdir(IsoFileSource *src, IsoFileSource **child)
|
||||
{
|
||||
return src->class->readdir(src, child);
|
||||
}
|
||||
/**
|
||||
* Attempts to read up to count bytes from the given source into
|
||||
* the buffer starting at buf.
|
||||
*
|
||||
* The file src must be open() before calling this, and close() when no
|
||||
* more needed. Not valid for dirs. On symlinks it reads the destination
|
||||
* file.
|
||||
*
|
||||
* @return
|
||||
* number of bytes read, 0 if EOF, < 0 on error
|
||||
* Error codes:
|
||||
* ISO_FILE_ERROR
|
||||
* ISO_NULL_POINTER
|
||||
* ISO_FILE_NOT_OPENNED
|
||||
* ISO_WRONG_ARG_VALUE -> if count == 0
|
||||
* ISO_FILE_IS_DIR
|
||||
* ISO_MEM_ERROR
|
||||
* ISO_INTERRUPTED
|
||||
*/
|
||||
int iso_file_source_read(IsoFileSource *src, void *buf, size_t count);
|
||||
|
||||
extern inline
|
||||
int iso_file_source_readlink(IsoFileSource *src, char *buf, size_t bufsiz)
|
||||
{
|
||||
return src->class->readlink(src, buf, bufsiz);
|
||||
}
|
||||
/**
|
||||
* Read a directory.
|
||||
*
|
||||
* Each call to this function will return a new children, until we reach
|
||||
* the end of file (i.e, no more children), in that case it returns 0.
|
||||
*
|
||||
* The dir must be open() before calling this, and close() when no more
|
||||
* needed. Only valid for dirs.
|
||||
*
|
||||
* Note that "." and ".." children MUST NOT BE returned.
|
||||
*
|
||||
* @param child
|
||||
* pointer to be filled with the given child. Undefined on error or OEF
|
||||
* @return
|
||||
* 1 on success, 0 if EOF (no more children), < 0 on error
|
||||
* Error codes:
|
||||
* ISO_FILE_ERROR
|
||||
* ISO_NULL_POINTER
|
||||
* ISO_FILE_NOT_OPENNED
|
||||
* ISO_FILE_IS_NOT_DIR
|
||||
* ISO_MEM_ERROR
|
||||
*/
|
||||
int iso_file_source_readdir(IsoFileSource *src, IsoFileSource **child);
|
||||
|
||||
extern inline
|
||||
IsoFilesystem* iso_file_source_get_filesystem(IsoFileSource *src)
|
||||
{
|
||||
return src->class->get_filesystem(src);
|
||||
}
|
||||
/**
|
||||
* Read the destination of a symlink. You don't need to open the file
|
||||
* to call this.
|
||||
*
|
||||
* @param buf
|
||||
* allocated buffer of at least bufsiz bytes.
|
||||
* The dest. will be copied there, and it will be NULL-terminated
|
||||
* @param bufsiz
|
||||
* characters to be copied. Destination link will be truncated if
|
||||
* it is larger than given size. This include the \0 character.
|
||||
* @return
|
||||
* 1 on success, < 0 on error
|
||||
* Error codes:
|
||||
* ISO_FILE_ERROR
|
||||
* ISO_NULL_POINTER
|
||||
* ISO_WRONG_ARG_VALUE -> if bufsiz <= 0
|
||||
* ISO_FILE_IS_NOT_SYMLINK
|
||||
* ISO_MEM_ERROR
|
||||
* ISO_FILE_BAD_PATH
|
||||
* ISO_FILE_DOESNT_EXIST
|
||||
*
|
||||
*/
|
||||
int iso_file_source_readlink(IsoFileSource *src, char *buf, size_t bufsiz);
|
||||
|
||||
/**
|
||||
* Get the filesystem for this source. No extra ref is added, so you
|
||||
* musn't unref the IsoFilesystem.
|
||||
*
|
||||
* @return
|
||||
* The filesystem, NULL on error
|
||||
*/
|
||||
IsoFilesystem* iso_file_source_get_filesystem(IsoFileSource *src);
|
||||
|
||||
void iso_filesystem_ref(IsoFilesystem *fs);
|
||||
void iso_filesystem_unref(IsoFilesystem *fs);
|
||||
|
43
src/stream.c
43
src/stream.c
@ -369,3 +369,46 @@ void iso_stream_unref(IsoStream *stream)
|
||||
free(stream);
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
int iso_stream_open(IsoStream *stream)
|
||||
{
|
||||
return stream->class->open(stream);
|
||||
}
|
||||
|
||||
inline
|
||||
int iso_stream_close(IsoStream *stream)
|
||||
{
|
||||
return stream->class->close(stream);
|
||||
}
|
||||
|
||||
inline
|
||||
off_t iso_stream_get_size(IsoStream *stream)
|
||||
{
|
||||
return stream->class->get_size(stream);
|
||||
}
|
||||
|
||||
inline
|
||||
int iso_stream_read(IsoStream *stream, void *buf, size_t count)
|
||||
{
|
||||
return stream->class->read(stream, buf, count);
|
||||
}
|
||||
|
||||
inline
|
||||
int iso_stream_is_repeatable(IsoStream *stream)
|
||||
{
|
||||
return stream->class->is_repeatable(stream);
|
||||
}
|
||||
|
||||
inline
|
||||
void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
|
||||
ino_t *ino_id)
|
||||
{
|
||||
stream->class->get_id(stream, fs_id, dev_id, ino_id);
|
||||
}
|
||||
|
||||
inline
|
||||
char *iso_stream_get_name(IsoStream *stream)
|
||||
{
|
||||
return stream->class->get_name(stream);
|
||||
}
|
||||
|
42
src/stream.h
42
src/stream.h
@ -106,48 +106,20 @@ struct Iso_Stream
|
||||
void iso_stream_ref(IsoStream *stream);
|
||||
void iso_stream_unref(IsoStream *stream);
|
||||
|
||||
extern inline
|
||||
int iso_stream_open(IsoStream *stream)
|
||||
{
|
||||
return stream->class->open(stream);
|
||||
}
|
||||
int iso_stream_open(IsoStream *stream);
|
||||
|
||||
extern inline
|
||||
int iso_stream_close(IsoStream *stream)
|
||||
{
|
||||
return stream->class->close(stream);
|
||||
}
|
||||
int iso_stream_close(IsoStream *stream);
|
||||
|
||||
extern inline
|
||||
off_t iso_stream_get_size(IsoStream *stream)
|
||||
{
|
||||
return stream->class->get_size(stream);
|
||||
}
|
||||
off_t iso_stream_get_size(IsoStream *stream);
|
||||
|
||||
extern inline
|
||||
int iso_stream_read(IsoStream *stream, void *buf, size_t count)
|
||||
{
|
||||
return stream->class->read(stream, buf, count);
|
||||
}
|
||||
int iso_stream_read(IsoStream *stream, void *buf, size_t count);
|
||||
|
||||
extern inline
|
||||
int iso_stream_is_repeatable(IsoStream *stream)
|
||||
{
|
||||
return stream->class->is_repeatable(stream);
|
||||
}
|
||||
int iso_stream_is_repeatable(IsoStream *stream);
|
||||
|
||||
extern inline
|
||||
void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
|
||||
ino_t *ino_id)
|
||||
{
|
||||
stream->class->get_id(stream, fs_id, dev_id, ino_id);
|
||||
}
|
||||
ino_t *ino_id);
|
||||
|
||||
extern inline
|
||||
char *iso_stream_get_name(IsoStream *stream)
|
||||
{
|
||||
return stream->class->get_name(stream);
|
||||
}
|
||||
char *iso_stream_get_name(IsoStream *stream);
|
||||
|
||||
/**
|
||||
* Create a stream to read from a IsoFileSource.
|
||||
|
10
src/util.c
10
src/util.c
@ -25,6 +25,16 @@
|
||||
#define __USE_GNU
|
||||
#include <unistd.h>
|
||||
|
||||
inline int div_up(unsigned int n, unsigned int div)
|
||||
{
|
||||
return (n + div - 1) / div;
|
||||
}
|
||||
|
||||
inline int round_up(unsigned int n, unsigned int mul)
|
||||
{
|
||||
return div_up(n, mul) * mul;
|
||||
}
|
||||
|
||||
int int_pow(int base, int power)
|
||||
{
|
||||
int result = 1;
|
||||
|
11
src/util.h
11
src/util.h
@ -20,15 +20,8 @@
|
||||
# define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
extern inline int div_up(unsigned int n, unsigned int div)
|
||||
{
|
||||
return (n + div - 1) / div;
|
||||
}
|
||||
|
||||
extern inline int round_up(unsigned int n, unsigned int mul)
|
||||
{
|
||||
return div_up(n, mul) * mul;
|
||||
}
|
||||
int div_up(unsigned int n, unsigned int div);
|
||||
int round_up(unsigned int n, unsigned int mul);
|
||||
|
||||
int int_pow(int base, int power);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user