Data Structures | Defines | Typedefs | Functions | Variables

# resource.c File Reference

`#include "wizard/studio.h"`
`#include "wizard/exception.h"`
`#include "wizard/exception-private.h"`
`#include "wizard/hashmap.h"`
`#include "wizard/log.h"`
`#include "wizard/memory_.h"`
`#include "wizard/option.h"`
`#include "wizard/random_.h"`
`#include "wizard/resource_.h"`
`#include "wizard/semaphore.h"`
`#include "wizard/signature.h"`
`#include "wizard/splay-tree.h"`
`#include "wizard/string_.h"`
`#include "wizard/string-private.h"`
`#include "wizard/token.h"`
`#include "wizard/utility.h"`

## Data Structures

struct | _ResourceInfo

## Defines

#define | WizardResourceInfinity (~0UL)
#define | O_NOFOLLOW 0
#define | TMP_MAX 238328

## Typedefs

typedef struct _ResourceInfo | ResourceInfo

## Functions

WizardExport WizardBooleanType | AcquireUniqueFilename (char *path, ExceptionInfo *exception)
static void * | DestroyTemporaryResources (void *temporary_resource)
static WizardBooleanType | GetPathTemplate (const char *path, char *filename)
WizardExport int | AcquireUniqueFileResource (const char *path, char *filename, ExceptionInfo *exception)
WizardExport WizardBooleanType | AcquireWizardResource (const ResourceType type, const WizardSizeType size)
WizardExport void | AsynchronousResourceComponentTerminus (void)
WizardExport WizardSizeType | GetWizardResource (const ResourceType type)
WizardExport WizardSizeType | GetWizardResourceLimit (const ResourceType type)
WizardExport WizardBooleanType | ListWizardResourceInfo (FILE *file, ExceptionInfo *wizard_unused(exception))
WizardExport void | RelinquishWizardResource (const ResourceType type, const WizardSizeType size)
WizardExport WizardBooleanType | RelinquishUniqueFileResource (const char *path, const WizardBooleanType trash)
static ssize_t | WizardMax (const ssize_t x, const ssize_t y)
WizardExport WizardBooleanType | ResourceComponentGenesis (void)
WizardExport void | ResourceComponentTerminus (void)
WizardExport WizardBooleanType | SetWizardResourceLimit (const ResourceType type, const WizardSizeType limit)

## Variables

static RandomInfo * | random_info = (RandomInfo *) NULL
static ResourceInfo | resource_info
static SemaphoreInfo * | resource_semaphore = (SemaphoreInfo *) NULL
static SplayTreeInfo * | temporary_resources = (SplayTreeInfo *) NULL

## Define Documentation

#define O_NOFOLLOW 0

Referenced by AcquireUniqueFileResource().

#define TMP_MAX 238328

Referenced by AcquireUniqueFileResource().

#define WizardResourceInfinity (~0UL)

Referenced by ListWizardResourceInfo().

## Typedef Documentation

typedef struct _ResourceInfo ResourceInfo

## Function Documentation

WizardExport WizardBooleanType AcquireUniqueFilename | ( | char * | path,
|  | ExceptionInfo * | exception |
| ) |  |  |

References AcquireUniqueFileResource(), close, GetWizardModule, ThrowWizardException(), WizardFalse, and WizardTrue.

WizardExport int AcquireUniqueFileResource | ( | const char * | path,
|  | char * | filename,
|  | ExceptionInfo * | exception |
| ) |  |  |

References AcquireRandomInfo(), AcquireSemaphoreInfo(), AcquireWizardResource(), AddValueToSplayTree(), close, CompareSplayTreeString(), ConstantString(), DestroyStringInfo(), DestroyTemporaryResources(), FileResource, GetPathTemplate(), GetRandomKey(), GetStringInfoDatum(), GetStringInfoLength(), GetWizardModule, LockSemaphoreInfo(), LogWizardEvent(), NewSplayTree(), O_BINARY, O_NOFOLLOW, open, random_info, resource_semaphore, ResourceDomain, ResourceError, ResourceEvent, S_MODE, setmode, SHA256Hash, temporary_resources, ThrowWizardException(), TMP_MAX, UnlockSemaphoreInfo(), and WizardAssert.

Referenced by AcquireUniqueFilename().

WizardExport WizardBooleanType AcquireWizardResource | ( | const ResourceType | type,
|  | const WizardSizeType | size |
| ) |  |  |

References AcquireSemaphoreInfo(), _ResourceInfo::area, _ResourceInfo::area_limit, AreaResource, _ResourceInfo::disk, _ResourceInfo::disk_limit, DiskResource, _ResourceInfo::file, _ResourceInfo::file_limit, FileResource, FormatWizardSize(), GetWizardModule, LockSemaphoreInfo(), LogWizardEvent(), _ResourceInfo::map, _ResourceInfo::map_limit, MapResource, _ResourceInfo::memory, _ResourceInfo::memory_limit, MemoryResource, resource_info, resource_semaphore, ResourceEvent, UnlockSemaphoreInfo(), WizardFalse, WizardOptionToMnemonic(), WizardResourceOptions, and WizardTrue.

Referenced by AcquireUniqueFileResource().

WizardExport void AsynchronousResourceComponentTerminus | ( | void |  | ) |

References DestroyRandomInfo(), GetNextKeyInSplayTree(), random_info, ResetSplayTreeIterator(), and temporary_resources.

Referenced by WizardSignalHandler().

static void* DestroyTemporaryResources | ( | void * | temporary_resource | ) | `[static]`

References DestroyString().

Referenced by AcquireUniqueFileResource().

static WizardBooleanType GetPathTemplate | ( | const char * | path,
|  | char * | filename |
| ) |  |  | `[static]`

References ConstantString(), CopyWizardString(), DirectorySeparator, FormatWizardString(), GetEnvironmentValue(), WizardPathExtent, RelinquishWizardMemory(), S_ISDIR, and WizardTrue.

Referenced by AcquireUniqueFileResource().

WizardExport WizardSizeType GetWizardResource | ( | const ResourceType | type | ) |

References AcquireSemaphoreInfo(), _ResourceInfo::area, AreaResource, _ResourceInfo::disk, DiskResource, _ResourceInfo::file, FileResource, LockSemaphoreInfo(), _ResourceInfo::map, MapResource, _ResourceInfo::memory, MemoryResource, resource_info, resource_semaphore, and UnlockSemaphoreInfo().

WizardExport WizardSizeType GetWizardResourceLimit | ( | const ResourceType | type | ) |

References AcquireSemaphoreInfo(), _ResourceInfo::area_limit, AreaResource, _ResourceInfo::disk_limit, DiskResource, _ResourceInfo::file_limit, FileResource, LockSemaphoreInfo(), _ResourceInfo::map_limit, MapResource, _ResourceInfo::memory_limit, MemoryResource, resource_info, resource_semaphore, and UnlockSemaphoreInfo().

WizardExport WizardBooleanType ListWizardResourceInfo | ( | FILE * | file,
|  | ExceptionInfo * | wizard_unusedexception |
| ) |  |  |

References AcquireSemaphoreInfo(), _ResourceInfo::area_limit, CopyWizardString(), _ResourceInfo::disk_limit, _ResourceInfo::file_limit, FormatWizardSize(), LockSemaphoreInfo(), _ResourceInfo::map_limit, WizardPathExtent, _ResourceInfo::memory_limit, resource_info, resource_semaphore, UnlockSemaphoreInfo(), WizardFalse, WizardResourceInfinity, and WizardTrue.

WizardExport WizardBooleanType RelinquishUniqueFileResource | ( | const char * | path,
|  | const WizardBooleanType | trash |
| ) |  |  |

References DeleteNodeFromSplayTree(), GetNextKeyInSplayTree(), GetWizardModule, LocaleCompare(), LogWizardEvent(), ResetSplayTreeIterator(), ResourceDomain, ResourceEvent, temporary_resources, WizardAssert, WizardFalse, and WizardTrue.

WizardExport void RelinquishWizardResource | ( | const ResourceType | type,
|  | const WizardSizeType | size |
| ) |  |  |

References AcquireSemaphoreInfo(), _ResourceInfo::area, _ResourceInfo::area_limit, AreaResource, _ResourceInfo::disk, _ResourceInfo::disk_limit, DiskResource, _ResourceInfo::file, _ResourceInfo::file_limit, FileResource, FormatWizardSize(), GetWizardModule, LockSemaphoreInfo(), LogWizardEvent(), _ResourceInfo::map, _ResourceInfo::map_limit, MapResource, _ResourceInfo::memory, _ResourceInfo::memory_limit, MemoryResource, resource_info, resource_semaphore, ResourceEvent, UnlockSemaphoreInfo(), WizardFalse, WizardOptionToMnemonic(), WizardResourceOptions, and WizardTrue.

WizardExport WizardBooleanType ResourceComponentGenesis | ( | void |  | ) |

References _SC_OPEN_MAX, _SC_PAGESIZE, _SC_PHYS_PAGES, AcquireSemaphoreInfo(), AreaResource, DestroyString(), DiskResource, FileResource, GetEnvironmentValue(), MapResource, MemoryResource, resource_semaphore, SetWizardResourceLimit(), StringToUnsignedLong(), sysconf, WizardMax(), and WizardTrue.

Referenced by WizardsToolkitGenesis().

WizardExport void ResourceComponentTerminus | ( | void |  | ) |

References AcquireSemaphoreInfo(), DestroySemaphoreInfo(), DestroySplayTree(), LockSemaphoreInfo(), resource_semaphore, temporary_resources, and UnlockSemaphoreInfo().

Referenced by WizardsToolkitTerminus().

WizardExport WizardBooleanType SetWizardResourceLimit | ( | const ResourceType | type,
|  | const WizardSizeType | limit |
| ) |  |  |

References AcquireSemaphoreInfo(), _ResourceInfo::area_limit, AreaResource, _ResourceInfo::disk_limit, DiskResource, _ResourceInfo::file_limit, FileResource, LockSemaphoreInfo(), _ResourceInfo::map_limit, MapResource, _ResourceInfo::memory_limit, MemoryResource, resource_info, resource_semaphore, UnlockSemaphoreInfo(), and WizardTrue.

Referenced by ResourceComponentGenesis().

static ssize_t WizardMax | ( | const ssize_t | x,
|  | const ssize_t | y |
| ) |  |  | `[inline, static]`

Referenced by ResourceComponentGenesis().

## Variable Documentation

RandomInfo* random_info = (RandomInfo *) NULL`[static]`

Referenced by AcquireRandomInfo(), AcquireUniqueFileResource(), and AsynchronousResourceComponentTerminus().

ResourceInfo resource_info`[static]`

Initial value:

      {
        WizardULLConstant(0),
        WizardULLConstant(0),
        WizardULLConstant(0),
        WizardULLConstant(0),
        WizardULLConstant(0),
        WizardULLConstant(1536)*1024*1024/sizeof(void *),
        WizardULLConstant(1536)*1024*1024,
        WizardULLConstant(3072)*1024*1024,
        WizardResourceInfinity,
        WizardULLConstant(768)
      }

Referenced by AcquireWizardResource(), GetWizardResource(), GetWizardResourceLimit(), ListWizardResourceInfo(), RelinquishWizardResource(), and SetWizardResourceLimit().

SemaphoreInfo* resource_semaphore = (SemaphoreInfo *) NULL`[static]`

Referenced by AcquireUniqueFileResource(), AcquireWizardResource(), GetWizardResource(), GetWizardResourceLimit(), ListWizardResourceInfo(), RelinquishWizardResource(), ResourceComponentGenesis(), ResourceComponentTerminus(), and SetWizardResourceLimit().

SplayTreeInfo* temporary_resources = (SplayTreeInfo *) NULL`[static]`

Referenced by AcquireUniqueFileResource(), AsynchronousResourceComponentTerminus(), RelinquishUniqueFileResource(), and ResourceComponentTerminus().