src/archive_open.c
/**
 * @brief Open the specified file for use with libarchive.
 *
 * This call sets up all of the libarchive callbacks properly for fwup.
 *
 * @param a a libarchive handle
 * @param filename the file to open or NULL for stdin
 * @return a libarchive error code (e.g., ARCHIVE_OK or ARCHIVE_FATAL)
 */
@brief Open the specified file for use with libarchive.
This call sets up all of the libarchive callbacks properly for fwup.

@param a a libarchive handle
@param filename the file to open or NULL for stdin
@return a libarchive error code
@brief Open the specified file for use with libarchive . This call sets up all of the libarchive callbacks properly for fwup . @param a a libarchive handle @param filename the file to open or NULL for stdin @return a libarchive error code
int fwup_archive_open_filename(struct archive *a, const char *filename)
{
    if (!fwup_framing ||
            (filename != NULL && filename[0] != '\0'))
        return archive_read_open_filename(a, filename, DEFAULT_LIBARCHIVE_BLOCK_SIZE);
    struct fwup_archive_data *ad = (struct fwup_archive_data *) malloc(sizeof(struct fwup_archive_data));
    if (ad == NULL) {
        archive_set_error(a, ENOMEM, "No memory");
        return ARCHIVE_FATAL;
    }
    return archive_read_open(a, ad, framed_stdin_open, framed_stdin_read, framed_stdin_close);
}
int fwup_archive_open_filename ( struct archive * a , const char * filename ) { if ( ! fwup_framing || ( filename != NULL && filename [ 0 ] != ' \0 ' ) ) return archive_read_open_filename ( a , filename , DEFAULT_LIBARCHIVE_BLOCK_SIZE ) ; struct fwup_archive_data * ad = ( struct fwup_archive_data * ) malloc ( sizeof ( struct fwup_archive_data ) ) ; if ( ad == NULL ) { archive_set_error ( a , ENOMEM , " " ) ; return ARCHIVE_FATAL ; } return archive_read_open ( a , ad , framed_stdin_open , framed_stdin_read , framed_stdin_close ) ; }
@brief Open the specified file for use with libarchive.
@brief Open the specified file for use with libarchive .
// If framing isn't enabled or we're reading from a file, then // the built-in libarchive reading functions are fine. // Reading from stdin with framing