Fix link problem by removing all inline functions defined in .h files.

This commit is contained in:
Vreixo Formoso 2008-01-12 03:54:53 +01:00
parent c00d84f0f2
commit 8115ba6c24
6 changed files with 292 additions and 99 deletions

View File

@ -39,3 +39,73 @@ void iso_filesystem_unref(IsoFilesystem *fs)
free(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);
}

View File

@ -278,71 +278,176 @@ void iso_file_source_unref(IsoFileSource *src);
/* /*
* this are just helpers to invoque methods in class * 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) * Get the path, relative to the filesystem this file source
{ * belongs to.
return src->class->get_name(src); *
} * @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) * Get the name of the file, with the dir component of the path.
{ *
return src->class->lstat(src, info); * @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) * Get information about the file.
{ * @return
return src->class->access(src); * 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) * 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
return src->class->stat(src, info); * 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) * Get information about the file. If the file is a symlink, the info
{ * returned refers to the destination.
return src->class->open(src); *
} * @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) * Opens the source.
{ * @return 1 on success, < 0 on error
return src->class->close(src); * 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) * Close a previuously openned file
{ * @return 1 on success, < 0 on error
return src->class->read(src, buf, count); * 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) * Attempts to read up to count bytes from the given source into
{ * the buffer starting at buf.
return src->class->readdir(src, child); *
} * 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) * Read a directory.
{ *
return src->class->readlink(src, buf, bufsiz); * 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) * Read the destination of a symlink. You don't need to open the file
{ * to call this.
return src->class->get_filesystem(src); *
} * @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_ref(IsoFilesystem *fs);
void iso_filesystem_unref(IsoFilesystem *fs); void iso_filesystem_unref(IsoFilesystem *fs);

View File

@ -369,3 +369,46 @@ void iso_stream_unref(IsoStream *stream)
free(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);
}

View File

@ -106,48 +106,20 @@ struct Iso_Stream
void iso_stream_ref(IsoStream *stream); void iso_stream_ref(IsoStream *stream);
void iso_stream_unref(IsoStream *stream); void iso_stream_unref(IsoStream *stream);
extern inline int iso_stream_open(IsoStream *stream);
int iso_stream_open(IsoStream *stream)
{
return stream->class->open(stream);
}
extern inline int iso_stream_close(IsoStream *stream);
int iso_stream_close(IsoStream *stream)
{
return stream->class->close(stream);
}
extern inline off_t iso_stream_get_size(IsoStream *stream);
off_t iso_stream_get_size(IsoStream *stream)
{
return stream->class->get_size(stream);
}
extern inline int iso_stream_read(IsoStream *stream, void *buf, size_t count);
int iso_stream_read(IsoStream *stream, void *buf, size_t count)
{
return stream->class->read(stream, buf, count);
}
extern inline int iso_stream_is_repeatable(IsoStream *stream);
int iso_stream_is_repeatable(IsoStream *stream)
{
return stream->class->is_repeatable(stream);
}
extern inline
void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
ino_t *ino_id) ino_t *ino_id);
{
stream->class->get_id(stream, fs_id, dev_id, ino_id);
}
extern inline char *iso_stream_get_name(IsoStream *stream);
char *iso_stream_get_name(IsoStream *stream)
{
return stream->class->get_name(stream);
}
/** /**
* Create a stream to read from a IsoFileSource. * Create a stream to read from a IsoFileSource.

View File

@ -25,6 +25,16 @@
#define __USE_GNU #define __USE_GNU
#include <unistd.h> #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 int_pow(int base, int power)
{ {
int result = 1; int result = 1;

View File

@ -20,15 +20,8 @@
# define MIN(a, b) (((a) < (b)) ? (a) : (b)) # define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif #endif
extern inline int div_up(unsigned int n, unsigned int div) int div_up(unsigned int n, unsigned int div);
{ int round_up(unsigned int n, unsigned int mul);
return (n + div - 1) / div;
}
extern inline int round_up(unsigned int n, unsigned int mul)
{
return div_up(n, mul) * mul;
}
int int_pow(int base, int power); int int_pow(int base, int power);