annotate src/streambrowser/bookmarks.c @ 3150:062f42c3737e

Fix possible crash in scrobbler plugin
author Tomasz Mon <desowin@gmail.com>
date Tue, 12 May 2009 08:30:43 +0200
parents 3134a0987162
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2891
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
1 /*
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
2 * Audacious Streambrowser Plugin
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
3 *
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
4 * Copyright (c) 2008 Calin Crisan <ccrisan@gmail.com>
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
5 *
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
8 * the Free Software Foundation; under version 3 of the License.
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
9 *
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
13 * GNU General Public License for more details.
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
14 *
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses>.
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
17 */
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
18
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
19
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
20 #include <string.h>
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
21 #include <glib.h>
2971
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2913
diff changeset
22 #include <audlegacy/plugin.h>
2891
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
23
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
24 #include "streambrowser.h"
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
25 #include "bookmarks.h"
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
26
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
27
2913
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
28 static bookmark_t **bookmarks;
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
29 static int *bookmarks_count;
2891
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
30
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
31 gboolean bookmarks_streaminfo_fetch(category_t *category, streaminfo_t *streaminfo)
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
32 {
2913
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
33 // todo: implement and make use of this
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
34
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
35 return FALSE;
2891
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
36 }
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
37
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
38 gboolean bookmarks_category_fetch(streamdir_t *streamdir, category_t *category)
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
39 {
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
40 debug("bookmarks: filling category '%s'\n", category->name);
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
41
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
42 /* free/remove any existing streaminfos in this category */
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
43 while (streaminfo_get_count(category) > 0)
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
44 streaminfo_remove(category, streaminfo_get_by_index(category, 0));
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
45
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
46 int i;
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
47 /* find bookmarks that match this category */
2913
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
48 for (i = 0; i < *bookmarks_count; i++)
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
49 if (strcmp((*bookmarks)[i].streamdir_name, category->name) == 0) {
2891
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
50 debug("bookmarks: adding stream info for '%s/%d'\n", streamdir->name, category->name);
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
51
2913
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
52 streaminfo_t *streaminfo = streaminfo_new((*bookmarks)[i].name, (*bookmarks)[i].playlist_url, (*bookmarks)[i].url, "");
2891
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
53 streaminfo_add(category, streaminfo);
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
54
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
55 debug("bookmarks: stream info added\n");
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
56 }
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
57
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
58 return TRUE;
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
59 }
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
60
2913
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
61 streamdir_t* bookmarks_streamdir_fetch(bookmark_t **p_bookmarks, int *p_bookmarks_count)
2891
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
62 {
2913
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
63 bookmarks = p_bookmarks;
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
64 bookmarks_count = p_bookmarks_count;
2891
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
65
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
66 streamdir_t *streamdir = streamdir_new(BOOKMARKS_NAME);
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
67
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
68 debug("bookmarks: creating streaming directory for bookmarks\n");
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
69
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
70 category_t *category = category_new("Shoutcast");
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
71 category_add(streamdir, category);
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
72
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
73 category = category_new("Xiph");
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
74 category_add(streamdir, category);
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
75
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
76 debug("bookmarks: streaming directory successfuly created\n");
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
77
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
78 return streamdir;
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
79 }
c27da2c06805 initial code for bookmarks
Calin Crisan ccrisan@gmail.com
parents:
diff changeset
80
2913
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
81 void bookmark_add(bookmark_t *bookmark)
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
82 {
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
83 debug("bookmarks: adding bookmark with streamdir = '%s', name = '%s', playlist_url = '%s', url = '%s'\n",
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
84 bookmark->streamdir_name, bookmark->name, bookmark->playlist_url, bookmark->url);
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
85
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
86 int i;
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
87 for (i = 0; i < *bookmarks_count; i++)
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
88 if (strcmp((*bookmarks)[i].name, bookmark->name) == 0) {
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
89 debug("bookmarks: bookmark with name = '%s' already exists, skipping\n", bookmark->name);
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
90 return;
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
91 }
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
92
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
93 *bookmarks = realloc(*bookmarks, sizeof(bookmark_t) * ((*bookmarks_count) + 1));
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
94
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
95 strncpy((*bookmarks)[*bookmarks_count].streamdir_name, bookmark->streamdir_name, DEF_STRING_LEN);
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
96 strncpy((*bookmarks)[*bookmarks_count].name, bookmark->name, DEF_STRING_LEN);
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
97 strncpy((*bookmarks)[*bookmarks_count].playlist_url, bookmark->playlist_url, DEF_STRING_LEN);
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
98 strncpy((*bookmarks)[*bookmarks_count].url, bookmark->url, DEF_STRING_LEN);
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
99
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
100 (*bookmarks_count)++;
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
101
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
102 debug("bookmarks: bookmark added, there are now %d bookmarks\n", *bookmarks_count);
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
103
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
104 /* issue a configuration save for immediately saving the new added bookmark */
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
105 config_save();
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
106 }
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
107
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
108 void bookmark_remove(gchar *name)
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
109 {
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
110 debug("bookmarks: searching for bookmark with name = '%s'\n", name);
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
111
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
112 int pos = -1, i;
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
113
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
114 for (i = 0; i < *bookmarks_count; i++)
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
115 if (strcmp((*bookmarks)[i].name, name) == 0) {
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
116 pos = i;
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
117 break;
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
118 }
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
119
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
120 if (pos != -1) {
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
121 debug("bookmarks: removing bookmark with streamdir = '%s', name = '%s', playlist_url = '%s', url = '%s'\n",
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
122 (*bookmarks)[i].streamdir_name, (*bookmarks)[i].name, (*bookmarks)[i].playlist_url, (*bookmarks)[i].url);
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
123
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
124 for (i = pos; i < (*bookmarks_count) - 1; i++) {
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
125 /* bookmarks[i] = bookmarks[i + 1] */
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
126
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
127 strncpy((*bookmarks)[i].streamdir_name, (*bookmarks)[i + 1].streamdir_name, DEF_STRING_LEN);
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
128 strncpy((*bookmarks)[i].name, (*bookmarks)[i + 1].name, DEF_STRING_LEN);
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
129 strncpy((*bookmarks)[i].playlist_url, (*bookmarks)[i + 1].playlist_url, DEF_STRING_LEN);
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
130 strncpy((*bookmarks)[i].url, (*bookmarks)[i + 1].url, DEF_STRING_LEN);
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
131 }
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
132
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
133 (*bookmarks_count)--;
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
134 if (*bookmarks_count > 0)
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
135 *bookmarks = realloc(*bookmarks, sizeof(bookmark_t) * (*bookmarks_count));
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
136 else
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
137 *bookmarks = NULL;
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
138
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
139 debug("bookmarks: bookmark removed, there are now %d bookmarks\n", *bookmarks_count);
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
140 }
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
141 else
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
142 failure("bookmarks: cannot find a bookmark with name = '%s'\n", name);
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
143
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
144 /* issue a configuration save for immediately saving the remaining bookmarks */
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
145 config_save();
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
146 }
113454baecf8 lots of changes: most important - bookmarks code almost finished, fixed bold-text gui bug, and others...
Calin Crisan ccrisan@gmail.com
parents: 2891
diff changeset
147