ALN  0.1.1
Macros | Typedefs | Functions
aln.h File Reference

Amazing Lucky Numbers Library API. More...

Go to the source code of this file.

Macros

#define ALN_API_EXPORT   __attribute__((visibility("default")))
 
#define ALN_API_IMPORT
 
#define ALN_API   ALN_API_IMPORT
 

Typedefs

typedef struct _ALN ALN
 Opaque structure representing the Amazing Lucky Numbers generator.
 

Functions

ALN_API ALNaln_new (unsigned int count, unsigned int min, unsigned int max, int allow_repeat)
 Creates a new ALN instance. More...
 
ALN_API void aln_free (ALN *aln)
 Frees an ALN instance. More...
 
ALN_API void aln_reset (ALN *aln)
 Resets an ALN instance. More...
 
ALN_API int aln_draw_number (ALN *aln, unsigned int *number)
 Draws a single lucky number. More...
 
ALN_API int aln_draw_all (ALN *aln)
 Draws all remaining lucky numbers. More...
 
ALN_API unsigned int aln_get_number (const ALN *aln, unsigned int index)
 Gets a specific lucky number by index. More...
 

Detailed Description

Amazing Lucky Numbers Library API.

This library provides functions to manage and generate lucky numbers.

Function Documentation

◆ aln_draw_all()

ALN_API int aln_draw_all ( ALN aln)

Draws all remaining lucky numbers.

This function draws all remaining lucky numbers from the ALN instance.

Parameters
alnPointer to the ALN instance.
Returns
int Status code indicating success or failure.
Return values
0Successfully drew all numbers.
-1Failed to draw all numbers.
See also
aln_draw_number()

◆ aln_draw_number()

ALN_API int aln_draw_number ( ALN aln,
unsigned int *  number 
)

Draws a single lucky number.

This function draws a single lucky number from the ALN instance.

Parameters
alnPointer to the ALN instance.
numberPointer to store the drawn number.
Returns
int Status code indicating success or failure.
Return values
0Successfully drew a number.
-1Failed to draw a number.
See also
aln_draw_all()

◆ aln_free()

ALN_API void aln_free ( ALN aln)

Frees an ALN instance.

This function deallocates an ALN instance created with aln_new.

Parameters
alnPointer to the ALN instance to free.
See also
aln_new()

◆ aln_get_number()

ALN_API unsigned int aln_get_number ( const ALN aln,
unsigned int  index 
)

Gets a specific lucky number by index.

This function retrieves a specific lucky number by its index in the ALN instance. Either aln_draw_number() or aln_draw_all() should be called before calling this function.

Parameters
alnPointer to the ALN instance.
indexThe index of the number to retrieve. Index starts from 0.
Returns
unsigned int The lucky number at the specified index.
See also
aln_draw_number()
aln_draw_all()

◆ aln_new()

ALN_API ALN* aln_new ( unsigned int  count,
unsigned int  min,
unsigned int  max,
int  allow_repeat 
)

Creates a new ALN instance.

This function allocates and initializes a new ALN instance for generating lucky numbers.

Parameters
countThe number of lucky numbers to generate.
minThe minimum value a generated number can be.
maxThe maximum value a generated number can be.
allow_repeatIf 1, allows duplicate numbers; if 0, numbers will be unique.
Returns
ALN* Pointer to the new ALN instance, or NULL on failure.
See also
aln_free()

◆ aln_reset()

ALN_API void aln_reset ( ALN aln)

Resets an ALN instance.

This function resets the state of the ALN instance, allowing numbers to be drawn again.

Parameters
alnPointer to the ALN instance to reset.