Data Structures | Defines | Enumerations | Functions

# blob.c File Reference

`#include "wizard/studio.h"`
`#include "wizard/blob.h"`
`#include "wizard/blob-private.h"`
`#include "wizard/cipher.h"`
`#include "wizard/exception.h"`
`#include "wizard/exception-private.h"`
`#include "wizard/memory_.h"`
`#include "wizard/semaphore.h"`
`#include "wizard/string-private.h"`
`#include "wizard/utility.h"`
`#include "bzlib.h"`
`#include "zlib.h"`

## Data Structures

struct | _BlobInfo

## Defines

#define | WizardMaxBlobExtent 65541
#define | MAP_FAILED ((void *) -1)
#define | MS_SYNC 0x04

## Enumerations

enum | StreamType { UndefinedStream, FileStream, StandardStream, PipeStream, ZipStream, BZipStream, BlobStream }

## Functions

static unsigned char * | DetachBlob (BlobInfo *)
static void | AttachBlob (BlobInfo *blob_info, const void *blob, const size_t length)
WizardExport WizardBooleanType | CloseBlob (BlobInfo *blob_info)
WizardExport BlobInfo * | DestroyBlob (BlobInfo *blob_info)
WizardExport int | EOFBlob (BlobInfo *blob_info)
WizardExport unsigned char * | FileToBlob (const char *filename, const size_t extent, size_t *length, ExceptionInfo *exception)
WizardExport const char * | GetBlobFilename (const BlobInfo *blob_info)
WizardExport void | GetBlobInfo (BlobInfo *blob_info)
WizardExport WizardSizeType | GetBlobSize (BlobInfo *blob_info)
WizardExport struct stat * | GetBlobProperties (const BlobInfo *blob_info)
WizardExport void * | MapBlob (int file, const MapMode mode, const WizardOffsetType offset, const size_t length)
WizardExport BlobInfo * | OpenBlob (const char *filename, const BlobMode mode, const WizardBooleanType compress, ExceptionInfo *exception)
static size_t | WizardMin (const size_t x, const size_t y)
WizardExport ssize_t | ReadBlob (BlobInfo *blob_info, const size_t length, unsigned char *data)
static const unsigned char * | ReadBlobStream (BlobInfo *blob_info, const size_t length, unsigned char *data, ssize_t *count)
WizardExport int | ReadBlobByte (BlobInfo *blob_info)
WizardExport ssize_t | ReadBlobChunk (BlobInfo *blob_info, const size_t length, unsigned char *data)
WizardExport WizardBooleanType | SetBlobExtent (BlobInfo *blob_info, const WizardSizeType extent)
WizardExport int | SyncBlob (BlobInfo *blob_info)
WizardExport WizardOffsetType | TellBlob (const BlobInfo *blob_info)
WizardExport WizardBooleanType | UnmapBlob (void *map, const size_t length)
WizardExport ssize_t | WriteBlob (BlobInfo *blob_info, const size_t length, const unsigned char *data)
static ssize_t | WriteBlobStream (BlobInfo *blob_info, const size_t length, const unsigned char *data)
WizardExport ssize_t | WriteBlobByte (BlobInfo *blob_info, const unsigned char value)
WizardExport ssize_t | WriteBlobChunk (BlobInfo *blob_info, const size_t length, const unsigned char *data)
WizardExport ssize_t | WriteBlobString (BlobInfo *blob_info, const char *string)

## Define Documentation

#define MAP_FAILED ((void *) -1)

#define MS_SYNC 0x04

Referenced by SyncBlob().

#define WizardMaxBlobExtent 65541

Referenced by AttachBlob(), and GetBlobInfo().

## Enumeration Type Documentation

enum StreamType

Enumerator:

  UndefinedStream |
  FileStream |
  StandardStream |
  PipeStream |
  ZipStream |
  BZipStream |
  BlobStream |

## Function Documentation

static void AttachBlob | ( | BlobInfo * | blob_info,
|  | const void * | blob,
|  | const size_t | length |
| ) |  |  | `[static]`

References _BlobInfo::data, _BlobInfo::debug, _BlobInfo::extent, _BlobInfo::file, GetWizardModule, _BlobInfo::length, LogWizardEvent(), _BlobInfo::mapped, _BlobInfo::offset, _BlobInfo::quantum, TraceEvent, _BlobInfo::type, WizardFalse, and WizardMaxBlobExtent.

Referenced by OpenBlob().

WizardExport WizardBooleanType CloseBlob | ( | BlobInfo * | blob_info | ) |

References BlobStream, BZipStream, _BlobInfo::debug, DetachBlob(), _BlobInfo::eof, _BlobInfo::exempt, _BlobInfo::file, _BlobInfo::filename, FileStream, GetBlobSize(), GetWizardModule, LogWizardEvent(), pclose, PipeStream, _BlobInfo::signature, _BlobInfo::size, StandardStream, _BlobInfo::status, SyncBlob(), TraceEvent, _BlobInfo::type, UndefinedStream, WizardFalse, WizardSignature, WizardTrue, and ZipStream.

WizardExport BlobInfo* DestroyBlob | ( | BlobInfo * | blob_info | ) |

References CloseBlob(), _BlobInfo::data, _BlobInfo::debug, DestroySemaphoreInfo(), _BlobInfo::filename, GetWizardModule, _BlobInfo::length, LockSemaphoreInfo(), LogWizardEvent(), _BlobInfo::mapped, _BlobInfo::reference_count, RelinquishWizardMemory(), _BlobInfo::semaphore, _BlobInfo::signature, TraceEvent, UnlockSemaphoreInfo(), UnmapBlob(), WizardFalse, and WizardSignature.

static unsigned char * DetachBlob | ( | BlobInfo * | blob_info | ) | `[static]`

References _BlobInfo::data, _BlobInfo::debug, _BlobInfo::eof, _BlobInfo::exempt, _BlobInfo::file, GetWizardModule, _BlobInfo::length, LogWizardEvent(), _BlobInfo::mapped, _BlobInfo::offset, TraceEvent, _BlobInfo::type, UnmapBlob(), and WizardFalse.

Referenced by CloseBlob(), SetBlobExtent(), and WriteBlob().

WizardExport int EOFBlob | ( | BlobInfo * | blob_info | ) |

References BlobStream, BZipStream, _BlobInfo::debug, _BlobInfo::eof, _BlobInfo::file, FileStream, GetWizardModule, LogWizardEvent(), PipeStream, _BlobInfo::signature, StandardStream, TraceEvent, _BlobInfo::type, UndefinedStream, WizardFalse, WizardSignature, WizardTrue, and ZipStream.

WizardExport unsigned char* FileToBlob | ( | const char * | filename,
|  | const size_t | extent,
|  | size_t * | length,
|  | ExceptionInfo * | exception |
| ) |  |  |

References AcquireQuantumMemory(), BlobError, close, fileno, GetWizardModule, LogWizardEvent(), MapBlob(), MaxCipherBlocksize, Min, O_BINARY, open, read, ReadMode, RelinquishWizardMemory(), ResizeQuantumMemory(), SSIZE_MAX, ThrowWizardException(), TraceEvent, UnmapBlob(), WizardMaxBufferExtent, and WizardSeek.

Referenced by FileToString(), and FileToStringInfo().

WizardExport const char* GetBlobFilename | ( | const BlobInfo * | blob_info | ) |

References _BlobInfo::debug, _BlobInfo::filename, GetWizardModule, LogWizardEvent(), TraceEvent, and WizardFalse.

WizardExport void GetBlobInfo | ( | BlobInfo * | blob_info | ) |

References AllocateSemaphoreInfo(), _BlobInfo::debug, IsEventLogging(), _BlobInfo::quantum, _BlobInfo::reference_count, ResetWizardMemory(), _BlobInfo::semaphore, _BlobInfo::signature, _BlobInfo::type, and WizardMaxBlobExtent.

Referenced by OpenBlob().

WizardExport struct stat* GetBlobProperties | ( | const BlobInfo * | blob_info | ) | `[read]`

References _BlobInfo::debug, _BlobInfo::filename, GetWizardModule, LogWizardEvent(), _BlobInfo::properties, TraceEvent, and WizardFalse.

WizardExport WizardSizeType GetBlobSize | ( | BlobInfo * | blob_info | ) |

References BlobStream, BZipStream, _BlobInfo::debug, _BlobInfo::file, _BlobInfo::filename, fileno, FileStream, GetWizardModule, _BlobInfo::length, LogWizardEvent(), PipeStream, _BlobInfo::properties, _BlobInfo::size, StandardStream, TraceEvent, _BlobInfo::type, UndefinedStream, WizardFalse, and ZipStream.

Referenced by CloseBlob(), and OpenBlob().

WizardExport void* MapBlob | ( | int | file,
|  | const MapMode | mode,
|  | const WizardOffsetType | offset,
|  | const size_t | length |
| ) |  |  |

References IOMode, mmap, PROT_READ, ReadMode, and WriteMode.

Referenced by ConfigureFileToStringInfo(), FileToBlob(), OpenBlob(), and SetBlobExtent().

WizardExport BlobInfo* OpenBlob | ( | const char * | filename,
|  | const BlobMode | mode,
|  | const WizardBooleanType | compress,
|  | ExceptionInfo * | exception |
| ) |  |  |

References AcquireWizardMemory(), AttachBlob(), BlobEvent, BZipStream, CopyWizardString(), _BlobInfo::exempt, ExtensionPath, fdopen, _BlobInfo::file, _BlobInfo::filename, fileno, FileStream, GetBlobInfo(), GetBlobSize(), GetPathComponent(), GetWizardModule, LocaleCompare(), LocaleNCompare(), LogWizardEvent(), MapBlob(), _BlobInfo::mapped, WizardPathExtent, popen, _BlobInfo::properties, ReadBinaryBlobMode, ReadBlobMode, RelinquishWizardMemory(), ResetWizardMemory(), setmode, _BlobInfo::size, _BlobInfo::status, StringToLong(), ThrowWizardException(), TraceEvent, _BlobInfo::type, UndefinedStream, WizardFalse, WizardOpenStream(), WizardTrue, WriteBinaryBlobMode, WriteBlobMode, and ZipStream.

WizardExport ssize_t ReadBlob | ( | BlobInfo * | blob_info,
|  | const size_t | length,
|  | unsigned char * | data |
| ) |  |  |

References BlobStream, BZipStream, _BlobInfo::data, _BlobInfo::eof, _BlobInfo::file, FileStream, _BlobInfo::length, _BlobInfo::offset, PipeStream, _BlobInfo::signature, StandardStream, _BlobInfo::type, UndefinedStream, WizardMin(), WizardSignature, WizardTrue, and ZipStream.

WizardExport int ReadBlobByte | ( | BlobInfo * | blob_info | ) |

References ReadBlobStream(), _BlobInfo::signature, and WizardSignature.

WizardExport ssize_t ReadBlobChunk | ( | BlobInfo * | blob_info,
|  | const size_t | length,
|  | unsigned char * | data |
| ) |  |  |

References BlobStream, ReadBlob(), _BlobInfo::signature, SSIZE_MAX, _BlobInfo::type, UndefinedStream, WizardMin(), and WizardSignature.

static const unsigned char* ReadBlobStream | ( | BlobInfo * | blob_info,
|  | const size_t | length,
|  | unsigned char * | data,
|  | ssize_t * | count |
| ) |  |  | `[inline, static]`

References BlobStream, _BlobInfo::data, _BlobInfo::eof, _BlobInfo::length, _BlobInfo::offset, ReadBlob(), _BlobInfo::type, WizardMin(), and WizardTrue.

Referenced by ReadBlobByte().

WizardExport WizardBooleanType SetBlobExtent | ( | BlobInfo * | blob_info,
|  | const WizardSizeType | extent |
| ) |  |  |

References BlobStream, BZipStream, _BlobInfo::data, DetachBlob(), _BlobInfo::extent, _BlobInfo::file, fileno, FileStream, _BlobInfo::length, MapBlob(), _BlobInfo::mapped, PipeStream, ResizeQuantumMemory(), _BlobInfo::signature, StandardStream, SyncBlob(), TellBlob(), _BlobInfo::type, UndefinedStream, UnmapBlob(), WizardFalse, WizardSignature, WizardTrue, and ZipStream.

Referenced by WriteBlobStream().

WizardExport int SyncBlob | ( | BlobInfo * | blob_info | ) |

References BlobStream, BZipStream, _BlobInfo::data, _BlobInfo::file, _BlobInfo::filename, FileStream, GetWizardModule, _BlobInfo::length, LogWizardEvent(), _BlobInfo::mapped, MS_SYNC, msync, PipeStream, _BlobInfo::signature, StandardStream, TraceEvent, _BlobInfo::type, UndefinedStream, WizardFalse, WizardSignature, and ZipStream.

Referenced by CloseBlob(), SetBlobExtent(), and WriteBlob().

WizardExport WizardOffsetType TellBlob | ( | const BlobInfo * | blob_info | ) |

References BlobStream, BZipStream, _BlobInfo::file, _BlobInfo::filename, FileStream, GetWizardModule, LogWizardEvent(), _BlobInfo::offset, PipeStream, _BlobInfo::signature, StandardStream, TraceEvent, _BlobInfo::type, UndefinedStream, WizardSignature, and ZipStream.

Referenced by SetBlobExtent().

WizardExport WizardBooleanType UnmapBlob | ( | void * | map,
|  | const size_t | length |
| ) |  |  |

References munmap, WizardFalse, and WizardTrue.

Referenced by ConfigureFileToStringInfo(), DestroyBlob(), DestroyWizardMemory(), DetachBlob(), FileToBlob(), and SetBlobExtent().

static size_t WizardMin | ( | const size_t | x,
|  | const size_t | y |
| ) |  |  | `[inline, static]`

Referenced by ReadBlob(), ReadBlobChunk(), ReadBlobStream(), and WriteBlobChunk().

WizardExport ssize_t WriteBlob | ( | BlobInfo * | blob_info,
|  | const size_t | length,
|  | const unsigned char * | data |
| ) |  |  |

References BlobStream, BZipStream, _BlobInfo::data, DetachBlob(), _BlobInfo::extent, _BlobInfo::file, FileStream, _BlobInfo::length, _BlobInfo::mapped, _BlobInfo::offset, PipeStream, _BlobInfo::quantum, ResizeQuantumMemory(), _BlobInfo::signature, StandardStream, SyncBlob(), _BlobInfo::type, UndefinedStream, WizardFalse, WizardSignature, and ZipStream.

WizardExport ssize_t WriteBlobByte | ( | BlobInfo * | blob_info,
|  | const unsigned char | value |
| ) |  |  |

References _BlobInfo::signature, WizardSignature, and WriteBlobStream().

WizardExport ssize_t WriteBlobChunk | ( | BlobInfo * | blob_info,
|  | const size_t | length,
|  | const unsigned char * | data |
| ) |  |  |

References BlobStream, _BlobInfo::signature, SSIZE_MAX, _BlobInfo::type, WizardMin(), WizardSignature, and WriteBlob().

static ssize_t WriteBlobStream | ( | BlobInfo * | blob_info,
|  | const size_t | length,
|  | const unsigned char * | data |
| ) |  |  | `[inline, static]`

References BlobStream, _BlobInfo::data, _BlobInfo::extent, _BlobInfo::length, _BlobInfo::offset, _BlobInfo::quantum, SetBlobExtent(), _BlobInfo::type, UndefinedStream, and WriteBlob().

Referenced by WriteBlobByte(), and WriteBlobString().

WizardExport ssize_t WriteBlobString | ( | BlobInfo * | blob_info,
|  | const char * | string |
| ) |  |  |

References _BlobInfo::signature, WizardSignature, and WriteBlobStream().