Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef HISTORY
- #define HISTORY
- /*
- * ================ *
- * === Includes === *
- * ================ *
- */
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- /*
- * =================== *
- * === Definitions === *
- * =================== *
- */
- #define BLOCKS 64
- #define BLOCK_SIZE 8
- /*
- * ==============
- * === Macros ===
- * ==============
- */
- // Shortcut for the number of commands in history
- #define h_len() h_meta_len
- /*
- * ===============
- * === Typedef ===
- * ===============
- */
- // A struct to represent the meta blocks of this command history management
- // module
- typedef struct h_metablock_str
- {
- // Contains a pointer to the next block
- struct h_metablock_str* next;
- // Contains the length of the command
- int length;
- // Contains the indices of the data in the bitmap and data structure
- int dataindex[15];
- } h_metablock;
- /*
- * =============== *
- * === Globals === *
- * =============== *
- */
- short h_bitmap[BLOCKS]; // This is the bitmap
- char h_data[BLOCKS][BLOCK_SIZE]; // This is the block of data
- // h_meta is the pointer to the first meta-block
- h_metablock* h_meta = NULL;
- int h_meta_len = 0;
- /*
- * ================= *
- * === Functions === *
- * ================= *
- */
- /*
- * Add the input params to input history
- */
- void h_add(char** param);
- /*
- * Allocate space in the data blocks for the input amount of blocks
- */
- int* h_allocate(int blocks);
- /*
- * Remove the oldest command in history
- */
- void h_removeoldest();
- /*
- * Reconstructs and returns the string for the input meta block
- */
- char* h_meta_getcmd(h_metablock* metablock);
- /*
- * Calls h_meta_getcmd on the nth newest command in history and returns the
- * result
- */
- char* h_cmd_index(int index);
- /*
- * Free all resources allocated by the history module
- */
- void h_free();
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement