2 * ========================================================================
3 * Copyright 2013-2022 Eduardo Chappa
4 * Copyright 2006-2007 University of Washington
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * ========================================================================
15 #include "../pith/headers.h"
16 #include "../pith/handle.h"
17 #include "../pith/mailview.h"
21 get_handle(HANDLE_S
*handles
, int key
)
25 if((h
= handles
) != NULL
){
26 for( ; h
; h
= h
->next
)
30 for(h
= handles
->prev
; h
; h
= h
->prev
)
40 init_handles(HANDLE_S
**handlesp
)
45 (void) url_external_specific_handler(NULL
, 0);
51 new_handle(HANDLE_S
**handlesp
)
53 HANDLE_S
*hp
, *h
= NULL
;
56 h
= (HANDLE_S
*) fs_get(sizeof(HANDLE_S
));
57 memset(h
, 0, sizeof(HANDLE_S
));
59 /* Put it in the list */
60 if((hp
= *handlesp
) != NULL
){
69 /* Assumption #2,340: There are NO ZERO KEY HANDLES */
80 * Normally we ignore the is_used bit in HANDLE_S. However, if we are
81 * using the delete_quotes filter, we pay attention to it. All of the is_used
82 * bits are off by default, and the delete_quotes filter turns them on
83 * if it is including lines with those handles.
85 * This is a bit of a crock, since it depends heavily on the order of the
86 * filters. Notice that the charset_editorial filter, which comes after
87 * delete_quotes and adds a handle, has to explicitly set the is_used bit!
90 delete_unused_handles(HANDLE_S
**handlesp
)
94 if(handlesp
&& *handlesp
&& (*handlesp
)->using_is_used
){
95 for(h
= *handlesp
; h
&& h
->prev
; h
= h
->prev
)
112 free_handle(HANDLE_S
**h
)
115 if((*h
)->next
) /* clip from list */
116 (*h
)->next
->prev
= (*h
)->prev
;
119 (*h
)->prev
->next
= (*h
)->next
;
121 if((*h
)->type
== URL
){ /* destroy malloc'd data */
123 fs_give((void **) &(*h
)->h
.url
.path
);
126 fs_give((void **) &(*h
)->h
.url
.tool
);
129 fs_give((void **) &(*h
)->h
.url
.name
);
132 if((*h
)->type
== imgData
){ /* destroy malloc'd data */
134 fs_give((void **) &(*h
)->h
.img
.src
);
137 fs_give((void **) &(*h
)->h
.img
.alt
);
140 fs_give((void **) &(*h
)->h
.url
.tool
);
143 free_handle_locations(&(*h
)->loc
);
145 fs_give((void **) h
);
151 free_handles(HANDLE_S
**handlesp
)
155 if(handlesp
&& *handlesp
){
156 while((h
= (*handlesp
)->next
) != NULL
)
159 while((h
= (*handlesp
)->prev
) != NULL
)
162 free_handle(handlesp
);
168 free_handle_locations(POSLIST_S
**l
)
171 free_handle_locations(&(*l
)->next
);
172 fs_give((void **) l
);