NeoMutt  2024-10-02-37-gfa9146
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
data.c File Reference

String auto-completion data. More...

#include "config.h"
#include <string.h>
#include "mutt/lib.h"
#include "data.h"
+ Include dependency graph for data.c:

Go to the source code of this file.

Functions

void completion_data_free_match_strings (struct CompletionData *cd)
 Free the Completion strings.
 
void completion_data_free (struct CompletionData **ptr)
 Free the Completion Data.
 
struct CompletionDatacompletion_data_new (void)
 Create new Completion Data.
 
void completion_data_reset (struct CompletionData *cd)
 Wipe the stored Completion Data.
 

Detailed Description

String auto-completion data.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file data.c.

Function Documentation

◆ completion_data_free_match_strings()

void completion_data_free_match_strings ( struct CompletionData cd)

Free the Completion strings.

Parameters
cdCompletion Data

Definition at line 38 of file data.c.

39{
40 if (!cd || !cd->free_match_strings)
41 return;
42
43 for (int i = 0; i < cd->num_matched; i++)
44 FREE(&cd->match_list[i]);
45
46 cd->free_match_strings = false;
47}
#define FREE(x)
Definition: memory.h:45
bool free_match_strings
Should the strings in match_list be freed?
Definition: data.h:39
int num_matched
Number of matches for completion.
Definition: data.h:35
const char ** match_list
Matching strings.
Definition: data.h:37
+ Here is the caller graph for this function:

◆ completion_data_free()

void completion_data_free ( struct CompletionData **  ptr)

Free the Completion Data.

Parameters
ptrCompletionData to free

Definition at line 53 of file data.c.

54{
55 if (!ptr || !*ptr)
56 return;
57
58 struct CompletionData *cd = *ptr;
59
61
62 FREE(&cd->match_list);
63
64 FREE(ptr);
65}
void completion_data_free_match_strings(struct CompletionData *cd)
Free the Completion strings.
Definition: data.c:38
State data for auto-completion.
Definition: data.h:33
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ completion_data_new()

struct CompletionData * completion_data_new ( void  )

Create new Completion Data.

Return values
ptrNew Completion Data

Definition at line 71 of file data.c.

72{
73 struct CompletionData *cd = mutt_mem_calloc(1, sizeof(struct CompletionData));
74
75 cd->match_list_len = 512;
76 cd->match_list = mutt_mem_calloc(cd->match_list_len, sizeof(char *));
77
78 return cd;
79}
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
int match_list_len
Enough space for all of the config items.
Definition: data.h:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ completion_data_reset()

void completion_data_reset ( struct CompletionData cd)

Wipe the stored Completion Data.

Parameters
cdCompletion Data

Definition at line 85 of file data.c.

86{
87 if (!cd)
88 return;
89
91
92 memset(cd->user_typed, 0, sizeof(cd->user_typed));
93 memset(cd->completed, 0, sizeof(cd->completed));
94 memset(cd->match_list, 0, cd->match_list_len * sizeof(char *));
95 cd->num_matched = 0;
96 cd->free_match_strings = false;
97}
char user_typed[1024]
Initial string that starts completion.
Definition: data.h:34
char completed[256]
Completed string (command or variable)
Definition: data.h:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function: