ocpf_context.c File Reference

OCPF context API. More...

#include "libocpf/ocpf.h"

Functions

struct ocpf_context * ocpf_context_add (struct ocpf *ocpf_ctx, const char *filename, uint32_t *context_id, uint8_t flags, bool *existing)
 
int ocpf_context_delete (struct ocpf *ocpf_ctx, struct ocpf_context *ctx)
 
stat h stat h struct ocpf_context * ocpf_context_init (TALLOC_CTX *mem_ctx, const char *filename, uint8_t flags, uint32_t context_id)
 
struct ocpf_context * ocpf_context_search_by_context_id (struct ocpf_context *ctx, uint32_t context_id)
 
struct ocpf_context * ocpf_context_search_by_filename (struct ocpf_context *ctx, const char *filename)
 

Detailed Description

OCPF context API.

Function Documentation

struct ocpf_context* ocpf_context_add ( struct ocpf ocpf_ctx,
const char *  filename,
uint32_t *  context_id,
uint8_t  flags,
bool *  existing 
)

Add an OCPF context to the list

Parameters
ocpf_ctxpointer to the global ocpf context
filenamepointer to the
context_idpointer to the context_id the function returns
flagsFlags controlling how the OCPF should be opened
existingboolean returned by the function to specify if the context was already existing or not
Returns
valid ocpf context pointer on success, otherwise NULL

References ocpf_context_init().

Referenced by ocpf_new_context().

int ocpf_context_delete ( struct ocpf ocpf_ctx,
struct ocpf_context *  ctx 
)

Delete an OCPF context

Parameters
ocpf_ctxpointer to the global ocpf context
ctxpointer to the OCPF context to delete
Returns
0 on success, 1 if there were still a ref_count, otherwise -1 on errors.

Referenced by ocpf_del_context().

stat h stat h struct ocpf_context* ocpf_context_init ( TALLOC_CTX *  mem_ctx,
const char *  filename,
uint8_t  flags,
uint32_t  context_id 
)

Initialize a new OCPF context

Parameters
mem_ctxpointer to the memory context
filenamethe OCPF filename used for this context
flagsFlags controlling how the OCPF should be opened
context_idthe identifier representing the context
context_idthe context identifier to use for this context
Returns
new allocated OCPF context on success, otherwise NULL

References ctx.

Referenced by ocpf_context_add().

struct ocpf_context* ocpf_context_search_by_context_id ( struct ocpf_context *  ctx,
uint32_t  context_id 
)
struct ocpf_context* ocpf_context_search_by_filename ( struct ocpf_context *  ctx,
const char *  filename 
)

Search a context given its filename

Parameters
ctxpointer to the ocpf context list
filenamethe filename to use for search
Returns
pointer to valid ocpf context on success, otherwise NULL

Creative Commons License
Creative Commons Attribution icon Creative Commons Share Alike icon
This content is licensed under the Creative Commons
Attribution ShareAlike License v. 3.0:
http://creativecommons.org/licenses/by-sa/3.0/