sort.h File Reference
NAF Core Library Flow Sorting API. More...
#include <naf/autoinc.h>
#include <naf/nafcore.h>
Go to the source code of this file.
Data Structures | |
| struct | _NAFSorter |
| A sort context for sorting NAFlows. More... | |
Defines | |
| #define | NAF_SORT_FIELDCOUNT 18 |
| Count of fields subject to sorting. | |
Typedefs | |
| typedef gboolean(*) | NAFSortFlushFn (void *ctx, NAFlow *flow, GError **err) |
| A sorter flush function. | |
| typedef _NAFSorter | NAFSorter |
| A sort context for sorting NAFlows. | |
Functions | |
| void | naf_sort_init (NAFSorter *sorter) |
| Initialize a new sorter. | |
| void | naf_sort_reinit (NAFSorter *sorter) |
| Reinitialize a sorter for sorting a new bin after a naf_sort_flush() call. | |
| void | naf_sort_begin (NAFSorter *sorter) |
| Begin sorting flows with an initalized or reinitialized NAFSorter. | |
| void | naf_sort_flow (NAFSorter *sorter, NAFlow *flow) |
| Add a flow to a sorter. | |
| void | naf_sort_flow_kv (NAFSorter *sorter, NAFlowKey *key, NAFlowVal *val) |
| Add a flow to a sorter. | |
| gboolean | naf_sort_flush (NAFSorter *sorter, NAFSortFlushFn ffn, void *fctx, GError **err) |
| Flush a sorter. | |
| void | naf_sort_print (NAFSorter *sorter, GString *str) |
| Print a parseable sort descriptor for a given sorter. | |
| gboolean | naf_sort_parse (GScanner *scanner, NAFSorter *sorter) |
| Parse a sort descriptor. | |
Detailed Description
NAF Core Library Flow Sorting API.Used by nafalize and nafilter. Defines an API for sorting collections of flows. The flow sorting API also provides a facility for parsing sort expressions from user input.
Define Documentation
| #define NAF_SORT_FIELDCOUNT 18 |
Count of fields subject to sorting.
When new fields are added to the NAFlow structure and the sort facility, update this count.
Typedef Documentation
| typedef gboolean(*) NAFSortFlushFn(void *ctx, NAFlow *flow, GError **err) |
A sorter flush function.
Called by naf_sort_flush to write a NAFlow to a private context. Used by nafalize and nafilter to write sorted NAFlow tree to output.
Function Documentation
| void naf_sort_begin | ( | NAFSorter * | sorter | ) |
Begin sorting flows with an initalized or reinitialized NAFSorter.
- Parameters:
-
sorter NAFSorter to start sorting flows with.
Add a flow to a sorter.
Inserts the flow into the sort tree. It is assumed this flow is in the same bin as the other flows in the sorter. The caller is responsible for the storage of the given NAFlow instance.
- Parameters:
-
sorter NAFSorter to add flow to. flow NAFlow to sort. This flow is added to the sorter by reference.
Add a flow to a sorter.
Copies the flow into the sort tree. It is assumed this flow is in the same bin as the other flows in the sorter. It is safe to reuse or free the key and val parameters after this call.
- Parameters:
-
sorter NAFSorter to add flow to. key NAFlowKey of flow to sort. This flow key is copied. val NAFlowVal of flow to sort. This flow value is copied.
| gboolean naf_sort_flush | ( | NAFSorter * | sorter, | |
| NAFSortFlushFn | ffn, | |||
| void * | fctx, | |||
| GError ** | err | |||
| ) |
Flush a sorter.
Calls the supplied sort flush function once per sorted flow, in sort order. Call this after adding all the flows in a given bin to the sorter.
- Parameters:
-
sorter NAFSorter to flush ffn Flush function to call for each NAFlow in the sorter fctx Context to pass to flush function err An error description
- Returns:
- TRUE if flush function succeeded for every flow, FALSE otherwise.
| void naf_sort_init | ( | NAFSorter * | sorter | ) |
Initialize a new sorter.
Call this once to zero the fields of an allocated sorter structure; use naf_sort_reinit() after flush to zero an active sorter, instead.
- Parameters:
-
sorter NAFSorter to initialize
| gboolean naf_sort_parse | ( | GScanner * | scanner, | |
| NAFSorter * | sorter | |||
| ) |
Parse a sort descriptor.
- Parameters:
-
scanner GScanner (from naf_lex_init()) to parse sort descriptor from. sorter NAFSorter to fill descriptor in on; must be newly intialized.
- Returns:
- FALSE if parsing failed
| void naf_sort_print | ( | NAFSorter * | sorter, | |
| GString * | str | |||
| ) |
Print a parseable sort descriptor for a given sorter.
- Parameters:
-
sorter NAFSorter to print descriptor from str GString to append parseable sort descriptor to
| void naf_sort_reinit | ( | NAFSorter * | sorter | ) |
Reinitialize a sorter for sorting a new bin after a naf_sort_flush() call.
Clears out the sorter tree and flow chunk, but leaves the descriptor prepared by naf_sort_parse() intact.
- Parameters:
-
sorter NAFSorter to reinitialize