2007-07-26 20:07:39 -04:00
|
|
|
/** Locations handling
|
|
|
|
* @file */
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "elinks.h"
|
|
|
|
|
|
|
|
#include "session/location.h"
|
|
|
|
#include "session/session.h"
|
|
|
|
#include "util/memory.h"
|
|
|
|
#include "util/string.h"
|
|
|
|
|
2007-07-27 07:14:00 -04:00
|
|
|
/** @relates location */
|
2005-09-15 09:58:31 -04:00
|
|
|
void
|
|
|
|
copy_location(struct location *dst, struct location *src)
|
|
|
|
{
|
|
|
|
struct frame *frame, *new_frame;
|
2021-07-25 17:07:05 -04:00
|
|
|
struct frame *iframe, *new_iframe;
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
init_list(dst->frames);
|
2021-07-26 15:28:19 -04:00
|
|
|
init_list(dst->iframes);
|
2005-09-15 09:58:31 -04:00
|
|
|
foreachback (frame, src->frames) {
|
2022-01-16 15:08:50 -05:00
|
|
|
new_frame = (struct frame *)mem_calloc(1, sizeof(*new_frame));
|
2005-09-15 09:58:31 -04:00
|
|
|
if (new_frame) {
|
|
|
|
new_frame->name = stracpy(frame->name);
|
|
|
|
if (!new_frame->name) {
|
|
|
|
mem_free(new_frame);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
new_frame->redirect_cnt = 0;
|
|
|
|
copy_vs(&new_frame->vs, &frame->vs);
|
|
|
|
add_to_list(dst->frames, new_frame);
|
|
|
|
}
|
|
|
|
}
|
2021-07-25 17:07:05 -04:00
|
|
|
|
|
|
|
foreachback (iframe, src->iframes) {
|
2022-01-16 15:08:50 -05:00
|
|
|
new_iframe = (struct frame *)mem_calloc(1, sizeof(*new_iframe));
|
2021-07-25 17:07:05 -04:00
|
|
|
if (new_iframe) {
|
|
|
|
new_iframe->name = stracpy(iframe->name);
|
|
|
|
if (!new_iframe->name) {
|
|
|
|
mem_free(new_iframe);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
new_iframe->redirect_cnt = 0;
|
|
|
|
copy_vs(&new_iframe->vs, &iframe->vs);
|
|
|
|
add_to_list(dst->iframes, new_iframe);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
copy_vs(&dst->vs, &src->vs);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
destroy_location(struct location *loc)
|
|
|
|
{
|
|
|
|
struct frame *frame;
|
2021-07-25 17:07:05 -04:00
|
|
|
struct frame *iframe;
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
foreach (frame, loc->frames) {
|
|
|
|
destroy_vs(&frame->vs, 1);
|
|
|
|
mem_free(frame->name);
|
|
|
|
}
|
2021-07-25 17:07:05 -04:00
|
|
|
|
|
|
|
foreach (iframe, loc->iframes) {
|
|
|
|
destroy_vs(&iframe->vs, 1);
|
|
|
|
mem_free(iframe->name);
|
|
|
|
}
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
free_list(loc->frames);
|
2021-07-25 17:07:05 -04:00
|
|
|
free_list(loc->iframes);
|
2005-09-15 09:58:31 -04:00
|
|
|
destroy_vs(&loc->vs, 1);
|
|
|
|
mem_free(loc);
|
|
|
|
}
|