1 #if !defined(lint) && !defined(DOS)
2 static char rcsid
[] = "$Id: handle.c 769 2007-10-24 00:15:40Z hubert@u.washington.edu $";
6 * ========================================================================
7 * Copyright 2006-2007 University of Washington
8 * Copyright 2013-2016 Eduardo Chappa
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
19 #include "../pith/headers.h"
20 #include "../pith/handle.h"
21 #include "../pith/mailview.h"
25 get_handle(HANDLE_S
*handles
, int key
)
29 if((h
= handles
) != NULL
){
30 for( ; h
; h
= h
->next
)
34 for(h
= handles
->prev
; h
; h
= h
->prev
)
44 init_handles(HANDLE_S
**handlesp
)
49 (void) url_external_specific_handler(NULL
, 0);
55 new_handle(HANDLE_S
**handlesp
)
57 HANDLE_S
*hp
, *h
= NULL
;
60 h
= (HANDLE_S
*) fs_get(sizeof(HANDLE_S
));
61 memset(h
, 0, sizeof(HANDLE_S
));
63 /* Put it in the list */
64 if((hp
= *handlesp
) != NULL
){
73 /* Assumption #2,340: There are NO ZERO KEY HANDLES */
84 * Normally we ignore the is_used bit in HANDLE_S. However, if we are
85 * using the delete_quotes filter, we pay attention to it. All of the is_used
86 * bits are off by default, and the delete_quotes filter turns them on
87 * if it is including lines with those handles.
89 * This is a bit of a crock, since it depends heavily on the order of the
90 * filters. Notice that the charset_editorial filter, which comes after
91 * delete_quotes and adds a handle, has to explicitly set the is_used bit!
94 delete_unused_handles(HANDLE_S
**handlesp
)
98 if(handlesp
&& *handlesp
&& (*handlesp
)->using_is_used
){
99 for(h
= *handlesp
; h
&& h
->prev
; h
= h
->prev
)
116 free_handle(HANDLE_S
**h
)
119 if((*h
)->next
) /* clip from list */
120 (*h
)->next
->prev
= (*h
)->prev
;
123 (*h
)->prev
->next
= (*h
)->next
;
125 if((*h
)->type
== URL
){ /* destroy malloc'd data */
127 fs_give((void **) &(*h
)->h
.url
.path
);
130 fs_give((void **) &(*h
)->h
.url
.tool
);
133 fs_give((void **) &(*h
)->h
.url
.name
);
136 free_handle_locations(&(*h
)->loc
);
138 fs_give((void **) h
);
144 free_handles(HANDLE_S
**handlesp
)
148 if(handlesp
&& *handlesp
){
149 while((h
= (*handlesp
)->next
) != NULL
)
152 while((h
= (*handlesp
)->prev
) != NULL
)
155 free_handle(handlesp
);
161 free_handle_locations(POSLIST_S
**l
)
164 free_handle_locations(&(*l
)->next
);
165 fs_give((void **) l
);