Skip to content
Browse files

New stuff from master merged into threading branch.

  • Loading branch information...
2 parents c2a5704 + c3e3fb0 commit a20aac74c4cf6fe604703cf6904945ee65e6eac4 Jonas Kramer committed
Showing with 241 additions and 47 deletions.
  1. +8 −2 manual/shell-fm.1
  2. +9 −1 source/bookmark.c
  3. +22 −2 source/feeds.c
  4. +3 −1 source/getln.c
  5. +10 −0 source/http.c
  6. +3 −0 source/include/interface.h
  7. +59 −24 source/interface.c
  8. +19 −8 source/main.c
  9. +49 −3 source/play.c
  10. +2 −1 source/playlist.c
  11. +5 −1 source/radio.c
  12. +6 −1 source/service.c
  13. +4 −0 source/split.c
  14. +10 −0 source/strary.c
  15. +2 −0 source/submit.c
  16. +13 −3 source/tag.c
  17. +9 −0 source/util.c
  18. +8 −0 source/xmlrpc.c
View
10 manual/shell-fm.1
@@ -251,7 +251,9 @@ specified in the scrobbling protocol version 1.2.
.B delay-change = something
If this is set to anything, and you change the station with 'r', 's' or 'f',
the station-change will be delayed until the currently played track finishes or
-is skipped.
+is skipped. Also they key 'q' will initialize a delayed quit, so after the
+currently played track shell-fm will exit. 'Q' (uppercase) still quits
+immediately.
.TP
.B screen-format = format-string
If this is set, shell-fm will check if the terminal it's running in is a screen
@@ -264,6 +266,10 @@ Works like screen-format, but sets the x-terminals window title.
.B download = format-string
If this is set to a valid path (may contain format flags), and the played track
is free, it is saved at the given place.
+.TP
+.B gap = seconds
+If this is set to a number, shell-fm will wait that amount of seconds between
+tracks.
.SH FORMAT FLAGS
There are several format flags allowed for some options. Here is the list.
.TP
@@ -452,5 +458,5 @@ Includes examples of using the network interface plus a color printing script to
.SH BUGS
No bugs known at the moment. Please send bug reports to <shell-fm@nex.scrapping.cc>.
.SH COPYRIGHT
-Copyright (C) 2006-2008 by Jonas Kramer.
+Copyright (C) 2006-2009 by Jonas Kramer.
Published under the terms of the GNU General Public License.
View
10 source/bookmark.c
@@ -10,6 +10,7 @@
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
+#include <assert.h>
#include "settings.h"
#include "bookmark.h"
@@ -31,8 +32,11 @@ void setmark(const char * streamURL, int n) {
length = getln(& line, & size, fd);
if(line && length > 4) {
- if(sscanf(line, "%d = ", & x) == 1 && !bookmarks[x])
+ if(sscanf(line, "%d = ", & x) == 1 && !bookmarks[x]) {
bookmarks[x] = strdup(line + 4);
+ assert(bookmarks[x] != NULL);
+ }
+
free(line);
}
}
@@ -41,6 +45,7 @@ void setmark(const char * streamURL, int n) {
}
bookmarks[n] = strdup(streamURL);
+ assert(bookmarks[n] != NULL);
if((fd = fopen(rcpath("bookmarks"), "w"))) {
int i;
@@ -73,9 +78,12 @@ char * getmark(int n) {
if(line && length > 4)
if(sscanf(line, "%d = ", & x) == 1 && x == n) {
char * ptr = strchr(line, 10);
+
if(ptr != NULL)
* ptr = 0;
+
streamURL = strdup(line + 4);
+ assert(streamURL != NULL);
}
if(size && line)
View
24 source/feeds.c
@@ -42,6 +42,7 @@ char ** neighbors(const char * user) {
memmove(names[i], ptr + 1, length);
names[i][length] = 0;
names[i] = realloc(names[i], sizeof(char) * (length + 1));
+ assert(names[i] != NULL);
}
}
@@ -78,6 +79,7 @@ char ** topartists(const char * user) {
memmove(names[i], ptr + 1, length);
names[i][length] = 0;
names[i] = realloc(names[i], sizeof(char) * (length + 1));
+ assert(names[i] != NULL);
}
}
}
@@ -152,6 +154,9 @@ char ** toptags(char key, struct hash track) {
++count;
tags = calloc(count + 1, sizeof(char *));
+
+ assert(tags != NULL);
+
tags[count] = NULL;
/* Search tag names in XML document and copy them into our list. */
@@ -159,8 +164,11 @@ char ** toptags(char key, struct hash track) {
char * pbeg = strstr(resp[x], "<name>");
if(pbeg) {
char * pend = strstr(pbeg += 6, "</name>");
- if(pend)
+
+ if(pend) {
tags[idx++] = strndup(pbeg, pend - pbeg);
+ assert(tags[idx - 1] != NULL);
+ }
}
free(resp[x]);
@@ -185,14 +193,20 @@ char ** overalltags(void) {
++count;
tags = calloc(count + 1, sizeof(char *));
+
+ assert(tags != NULL);
+
tags[count] = NULL;
for(x = 0, idx = 0; resp[x]; ++x) {
char * pbeg = strstr(resp[x], "<tag name=\""), * pend;
if(pbeg) {
pend = strstr(pbeg += 11, "\"");
- if(pend)
+
+ if(pend) {
tags[idx++] = strndup(pbeg, pend - pbeg);
+ assert(tags[idx - 1] != NULL);
+ }
}
}
@@ -229,7 +243,13 @@ char ** usertags(const char * user) {
* end = 0;
tags = realloc(tags, sizeof(char *) * (ntag + 2));
+
+ assert(tags != NULL);
+
tags[ntag++] = strdup(begin);
+
+ assert(tags[ntag - 1] != NULL);
+
tags[ntag] = NULL;
}
}
View
4 source/getln.c
@@ -37,7 +37,7 @@ unsigned getln(char ** ptr, unsigned * size, FILE * fd) {
if(length + 2 > * size) {
* ptr = realloc(* ptr, (* size += 1024));
- assert(* ptr);
+ assert(* ptr != NULL);
}
(* ptr)[length++] = (char) ch;
@@ -47,5 +47,7 @@ unsigned getln(char ** ptr, unsigned * size, FILE * fd) {
* size = length + 1;
* ptr = realloc(* ptr, * size);
+ assert(* ptr != NULL);
+
return length;
}
View
10 source/http.c
@@ -188,7 +188,11 @@ char ** fetch(const char * url, FILE ** pHandle, const char * post, const char *
unsigned encode(const char * orig, char ** encoded) {
register unsigned i = 0, x = 0;
+
* encoded = calloc((strlen(orig) * 3) + 1, sizeof(char));
+
+ assert(* encoded != NULL);
+
while(i < strlen(orig)) {
if(isalnum(orig[i]) || orig[i] == ' ')
(* encoded)[x++] = orig[i];
@@ -214,7 +218,11 @@ unsigned encode(const char * orig, char ** encoded) {
unsigned decode(const char * orig, char ** decoded) {
register unsigned i = 0, x = 0;
const unsigned len = strlen(orig);
+
* decoded = calloc(len + 1, sizeof(char));
+
+ assert(decoded != NULL);
+
while(i < len) {
if(orig[i] != '%')
(* decoded)[x] = orig[i];
@@ -233,6 +241,8 @@ unsigned decode(const char * orig, char ** decoded) {
}
* decoded = realloc(* decoded, (x + 1) * sizeof(char));
+
+ assert(decoded != NULL);
for(i = 0; i < x; ++i)
if((* decoded)[i] == '+')
View
3 source/include/interface.h
@@ -7,6 +7,9 @@
#include "hash.h"
+#define M_COLORED 0x1
+#define M_RELAXPATH 0x2
+
extern const char * meta(const char *, int, struct hash *);
extern void interface();
extern void run(const char *);
View
83 source/interface.c
@@ -18,6 +18,7 @@
#include <ctype.h>
#include <time.h>
#include <pthread.h>
+#include <assert.h>
#include "service.h"
#include "hash.h"
@@ -38,6 +39,8 @@
#include "globals.h"
+extern time_t pausetime;
+extern int delayquit;
/* Main user input function. */
@@ -91,6 +94,16 @@ void interface() {
unlink(rcpath("session"));
exit(EXIT_SUCCESS);
+ case 'q':
+ if(haskey(& rc, "delay-change")) {
+ delayquit = !delayquit;
+ if(delayquit)
+ fputs("Going to quit soon.\n", stderr);
+ else
+ fputs("Delayed quit cancelled.\n", stderr);
+ }
+ break;
+
case 'i':
if(playthread) {
const char * path = rcpath("i-template");
@@ -106,10 +119,10 @@ void interface() {
}
}
else {
- puts(meta("Track: \"%t\" (%T)", !0, & playlist.track->track));
- puts(meta("Artist: \"%a\" (%A)", !0, & playlist.track->track));
- puts(meta("Album: \"%l\" (%L)", !0, & playlist.track->track));
- puts(meta("Station: %s", !0, & playlist.track->track));
+ puts(meta("Track: \"%t\" (%T)", M_COLORED, & playlist.track->track));
+ puts(meta("Artist: \"%a\" (%A)", M_COLORED, & playlist.track->track));
+ puts(meta("Album: \"%l\" (%L)", M_COLORED, & playlist.track->track));
+ puts(meta("Station: %s", M_COLORED, & playlist.track->track));
}
}
break;
@@ -162,6 +175,7 @@ void interface() {
if(haskey(& rc, "delay-change")) {
puts("\rDelayed.");
nextstation = strdup(uri);
+ assert(nextstation != NULL);
}
else {
station(uri);
@@ -175,6 +189,7 @@ void interface() {
if(haskey(& rc, "delay-change")) {
puts("\rDelayed.");
nextstation = strdup(uri);
+ assert(nextstation != NULL);
}
else {
station(uri);
@@ -316,12 +331,13 @@ int fetchkey(unsigned nsec) {
#define remn (sizeof(string) - length - 1)
-const char * meta(const char * fmt, int colored, struct hash * track) {
+const char * meta(const char * fmt, int flags, struct hash * track) {
static char string[4096];
unsigned length = 0, x = 0;
/* Switch off coloring when in batch mode */
- colored = (colored && !(batch));
+ if (batch)
+ flags &= ~M_COLORED;
if(!fmt)
return NULL;
@@ -351,7 +367,8 @@ const char * meta(const char * fmt, int colored, struct hash * track) {
while(i--) {
if(fmt[x] == keys[i][0]) {
const char * val = value(track, keys[i] + 1), * color = NULL;
- if(colored) {
+ char *val2;
+ if(flags & M_COLORED) {
char colorkey[64] = { 0 };
snprintf(colorkey, sizeof(colorkey), "%c-color", keys[i][0]);
color = value(& rc, colorkey);
@@ -359,6 +376,9 @@ const char * meta(const char * fmt, int colored, struct hash * track) {
/* Strip leading spaces from end of color (Author: Ondrej Novy) */
char * color_st = strdup(color);
size_t len = strlen(color_st) - 1;
+
+ assert(color_st != NULL);
+
while(isspace(color_st[len]) && len > 0) {
color_st[len] = 0;
len--;
@@ -368,7 +388,20 @@ const char * meta(const char * fmt, int colored, struct hash * track) {
}
}
- length = strlen(strncat(string, val ? val : "(unknown)", remn));
+ if((flags & M_RELAXPATH) && val) {
+ unsigned j;
+ size_t l = strlen(val);
+
+ val2 = malloc(l+1);
+ if(val2) {
+ for(j = 0; j <= l; j++)
+ val2[j] = (val[j] == '/') ? '|' : val[j];
+ }
+ } else
+ val2 = (char *)val;
+ length = strlen(strncat(string, val2 ? val2 : "(unknown)", remn));
+ if(flags & M_RELAXPATH)
+ free(val2);
if(color)
length = strlen(strncat(string, "\x1B[0m", remn));
@@ -405,33 +438,35 @@ void run(const char * cmd) {
int rate(const char * rating) {
if(playthread && rating != NULL) {
- set(& playlist.track->track, "rating", rating);
+
+ if(rating[0] != 'U')
+ set(& playlist.track->track, "rating", rating);
switch(rating[0]) {
case 'B':
pthread_kill(playthread, SIGUSR1);
return xmlrpc(
- "banTrack",
- "ss",
- value(& playlist.track->track, "creator"),
- value(& playlist.track->track, "title")
- );
+ "banTrack",
+ "ss",
+ value(& playlist.track->track, "creator"),
+ value(& playlist.track->track, "title")
+ );
case 'L':
return xmlrpc(
- "loveTrack",
- "ss",
- value(& playlist.track->track, "creator"),
- value(& playlist.track->track, "title")
- );
+ "loveTrack",
+ "ss",
+ value(& playlist.track->track, "creator"),
+ value(& playlist.track->track, "title")
+ );
case 'U':
return xmlrpc(
- "unLoveTrack",
- "ss",
- value(& playlist.track->track, "creator"),
- value(& playlist.track->track, "title")
- );
+ "unLoveTrack",
+ "ss",
+ value(& playlist.track->track, "creator"),
+ value(& playlist.track->track, "title")
+ );
case 'S':
pthread_kill(playthread, SIGUSR1);
View
27 source/main.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2006-2008 by Jonas Kramer
+ Copyright (C) 2006-2009 by Jonas Kramer
Published under the terms of the GNU General Public License (GPL).
*/
@@ -50,7 +50,7 @@ unsigned flags = RTP;
time_t changetime = 0, pausetime = 0, pauselength = 0;
char * nextstation = NULL;
-int batch = 0, error = 0;
+int batch = 0, error = 0, delayquit = 0;
static void cleanup(void);
static void forcequit(int);
@@ -392,10 +392,21 @@ int main(int argc, char ** argv) {
}
}
- /* If there's no playback thread runnong, see if we can start one. */
+ /* If there's no playback thread runnoig, see if we can start one. */
if(!playthread) {
- /* Try to play a track from the playlist. */
+ /*
+ If there was a track played before, and there is a gap
+ configured, wait that many seconds before playing the next
+ track.
+ */
+ if(playnext && haskey(& rc, "gap")) {
+ int gap = atoi(value(& rc, "gap"));
+
+ if(gap > 0)
+ sleep(gap);
+ }
+
if(play(& playlist)) {
time(& changetime);
pauselength = 0;
@@ -405,14 +416,14 @@ int main(int argc, char ** argv) {
/* Print what's currently played. (Ondrej Novy) */
if(!background) {
if(enabled(CHANGED) && playlist.left > 0) {
- puts(meta("Receiving %s.", !0, & playlist.track->track));
+ puts(meta("Receiving %s.", M_COLORED, & playlist.track->track));
disable(CHANGED);
}
if(haskey(& rc, "title-format"))
- printf("%s\n", meta(value(& rc, "title-format"), !0, & playlist.track->track));
+ printf("%s\n", meta(value(& rc, "title-format"), M_COLORED, & playlist.track->track));
else
- printf("%s\n", meta("Now playing \"%t\" by %a.", !0, & playlist.track->track));
+ printf("%s\n", meta("Now playing \"%t\" by %a.", M_COLORED, & playlist.track->track));
}
@@ -468,7 +479,7 @@ int main(int argc, char ** argv) {
/* Automatically ban tracks from banned artists. */
if(banned(value(& playlist.track->track, "creator"))) {
- puts(meta("%a is banned.", !0, & playlist.track->track));
+ puts(meta("%a is banned.", M_COLORED, & playlist.track->track));
rate("B");
fflush(stdout);
}
View
52 source/play.c
@@ -17,9 +17,12 @@
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
+#include <libgen.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <pthread.h>
+#include <sys/stat.h>
+#include <assert.h>
#ifdef LIBAO
#include <ao/ao.h>
@@ -70,6 +73,39 @@ int killed = 0;
static void sighand(int);
+/*
+ * Taken from *BSD code
+ * (usr.bin/patch/mkpath.c)
+ */
+int
+mkpath(char *path)
+{
+ struct stat sb;
+ char *slash;
+ int done = 0;
+
+ slash = path;
+
+ while (!done) {
+ slash += strspn(slash, "/");
+ slash += strcspn(slash, "/");
+
+ done = (*slash == '\0');
+ *slash = '\0';
+
+ if (stat(path, &sb)) {
+ if (errno != ENOENT || (mkdir(path, 0777) &&
+ errno != EEXIST))
+ return (-1);
+ } else if (!S_ISDIR(sb.st_mode))
+ return (-1);
+
+ *slash = '/';
+ }
+
+ return (0);
+}
+
int playback(FILE * streamfd) {
killed = 0;
signal(SIGUSR1, sighand);
@@ -128,8 +164,17 @@ int playback(FILE * streamfd) {
#endif
if(haskey(& playlist.track->track, "freeTrackURL") && haskey(& rc, "download")) {
- data.path = strdup(meta(value(& rc, "download"), 0, & playlist.track->track));
- data.dump = fopen(data.path, "w");
+ char *dnam;
+ int rv;
+
+ data.path = strdup(meta(value(& rc, "download"), M_RELAXPATH, & playlist.track->track));
+ assert(data.path != NULL);
+
+ dnam = strdup(data.path);
+ rv = dnam ? mkpath(dirname(dnam)) : -1;
+ free(dnam);
+
+ data.dump = (rv == 0) ? fopen(data.path, "w") : NULL;
if(!data.dump)
fprintf(stderr, "Can't write download to %s.\n", data.path);
@@ -233,7 +278,6 @@ static enum mad_flow input(void * data, struct mad_stream * stream) {
mad_stream_buffer(stream, (unsigned char *) buf, nbyte);
-
if(killed)
return MAD_FLOW_STOP;
@@ -272,6 +316,8 @@ static enum mad_flow output(
}
stream_ptr = stream = malloc(pcm->length * (pcm->channels == 2 ? 4 : 2));
+
+ assert(stream != NULL);
while(nsample--) {
signed int sample;
View
3 source/playlist.c
@@ -76,6 +76,7 @@ int parsexspf(struct playlist * list, const char * xml) {
char * track, * radio = NULL;
radio = strndup(ptr + 7, strcasestr(xml, "</title>") - ptr - 7);
+ assert(radio != NULL);
if(list->title != NULL) {
free(list->title);
@@ -222,7 +223,7 @@ void preview(struct playlist list) {
? value(& rc, "preview-format")
: "%a - %t";
- printf("%2d %s\n", n++, meta(format, !0, & node->track));
+ printf("%2d %s\n", n++, meta(format, M_COLORED, & node->track));
node = node->next;
}
View
6 source/radio.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2006-2008 by Jonas Kramer.
+ Copyright (C) 2006-2009 by Jonas Kramer.
Published under the terms of the GNU General Public License (GPL).
*/
@@ -16,6 +16,7 @@
#include <sys/time.h>
#include <signal.h>
#include <stdarg.h>
+#include <assert.h>
#include "completion.h"
#include "http.h"
@@ -30,6 +31,7 @@
#include "globals.h"
+extern int delayquit;
extern char ** popular;
static int radiocomplete(char *, const unsigned, int);
@@ -82,7 +84,9 @@ void radioprompt(const char * prompt) {
as the current track stops.
*/
if(playthread && haskey(& rc, "delay-change")) {
+ delayquit = 0;
nextstation = strdup(decoded);
+ assert(nextstation != NULL);
puts("\rDelayed.");
}
else {
View
7 source/service.c
@@ -180,6 +180,7 @@ int station(const char * stationURL) {
free(currentstation);
currentstation = strdup(stationURL);
+ assert(currentstation != NULL);
if(retval && playthread)
pthread_kill(playthread, SIGUSR1);
@@ -188,7 +189,11 @@ int station(const char * stationURL) {
}
-/* Play the next track from the given playlist. */
+/*
+ Takes pointer to a playlist, forks off a playback process and tries to play
+ the next track in the playlist. If there's already a playback process, it's
+ killed first (which means the currently played track is skipped).
+*/
int play(struct playlist * list) {
FILE * fd = NULL;
const char * location;
View
4 source/split.c
@@ -27,12 +27,16 @@ char ** split(char * string, const char * del, unsigned * pnsplt) {
++ptr;
if(* ptr) {
register unsigned length = 0;
+
splt = realloc(splt, sizeof(char *) * (nsplt + 2));
assert(splt != NULL);
+
splt[nsplt] = calloc(strlen(ptr) + 1, sizeof(char));
assert(splt[nsplt] != NULL);
+
while(* ptr && !strchr(del, * ptr))
splt[nsplt][length++] = * (ptr++);
+
splt[nsplt] = realloc(splt[nsplt], length + 1);
splt[++nsplt] = NULL;
}
View
10 source/strary.c
@@ -38,7 +38,11 @@ char ** append(char ** list, const char * string) {
list = realloc(list, sizeof(char *) * (size + 2));
+ assert(list != NULL);
+
list[size++] = strdup(string);
+ assert(list[size - 1] != NULL);
+
list[size] = NULL;
return list;
@@ -53,7 +57,11 @@ char ** merge(char ** list, char ** appendix, int keep) {
for(i = 0; appendix && appendix[i] != NULL; ++i) {
list = realloc(list, sizeof(char *) * (size + 2));
+
+ assert(list != NULL);
+
list[size++] = strdup(appendix[i]);
+ assert(list[size - 1] != NULL);
list[size] = NULL;
if(!keep)
@@ -90,6 +98,8 @@ char * join(char ** list, int keep) {
while(list[i] != NULL) {
result = realloc(result, sizeof(char) * (length + strlen(list[i]) + 1));
+ assert(result != NULL);
+
strcpy(result + length, list[i]);
length += strlen(list[i]);
result[length] = 0;
View
2 source/submit.c
@@ -186,6 +186,8 @@ static void sliceq(unsigned tracks) {
if(qlength > 0) {
memmove(queue, & queue[tracks], sizeof(struct hash) * qlength);
queue = realloc(queue, sizeof(struct hash) * qlength);
+
+ assert(queue != NULL);
} else {
free(queue);
queue = NULL;
View
16 source/tag.c
@@ -53,7 +53,7 @@ void tag(struct hash data) {
setup.line = oldtags(key, data);
- tagstring = strdup(readline(& setup));
+ assert((tagstring = strdup(readline(& setup))) != NULL);
if(setup.line) {
free(setup.line);
@@ -75,8 +75,10 @@ void tag(struct hash data) {
char * oldtags(char key, struct hash track) {
unsigned length, x;
char * tags = NULL, * url = calloc(512, sizeof(char)),
- * user = NULL, * artist = NULL, * arg = NULL,
- * file = NULL, ** resp;
+ * user = NULL, * artist = NULL, * arg = NULL,
+ * file = NULL, ** resp;
+
+ assert(url != NULL);
switch(key) {
case 'a':
@@ -129,10 +131,18 @@ char * oldtags(char key, struct hash track) {
if(pend) {
char * thistag = strndup(pbeg, pend - pbeg);
unsigned nlength = strlen(thistag) + length;
+
+ assert(thistag != NULL);
+
if(length)
++nlength;
+
tags = realloc(tags, nlength + 1);
+
+ assert(tags != NULL);
+
sprintf(tags + length, "%s%s", length ? "," : "", thistag);
+
free(thistag);
length = nlength;
}
View
9 source/util.c
@@ -35,7 +35,12 @@ char ** slurp(const char * path) {
if(strlen(line) > 0) {
content = realloc(content, sizeof(char *) * (items + 2));
+
+ assert(content != NULL);
+
content[items] = strdup(line);
+ assert(content[items] != NULL);
+
content[++items] = NULL;
}
}
@@ -64,7 +69,9 @@ char ** uniq(char ** list) {
list[n] = NULL;
} else {
uniqlist = realloc(uniqlist, (sizeof(char *)) * (size + 2));
+
assert(uniqlist != NULL);
+
uniqlist[size++] = list[n];
uniqlist[size] = NULL;
}
@@ -103,10 +110,12 @@ int grep(char ** list, char * needle) {
/* Our own implementation of strndup(), for non-gnu systems. */
char * strndup(const char * src, size_t len) {
char * tmp = (char *) malloc(len + 1);
+
if(tmp != NULL) {
strncpy(tmp, src, len);
tmp[len] = 0;
}
+
return tmp;
}
View
8 source/xmlrpc.c
@@ -8,6 +8,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
+#include <assert.h>
#include "md5.h"
#include "settings.h"
@@ -32,6 +33,8 @@ int xmlrpc(const char * method, const char * fmt, ...) {
** resp, * url = "http://ws.audioscrobbler.com/1.0/rw/xmlrpc.php",
md5hex[32 + 1] = { 0 }, tmp[32 + 8 + 1] = { 0 };
+ assert(xml != NULL);
+
const char
* challenge = "Shell.FM",
* xmlhead =
@@ -96,6 +99,8 @@ static void append(char ** string, unsigned * size, const char * appendix) {
* size = strlen(* string) + strlen(appendix) + 1;
copy = realloc(* string, * size);
+ assert(copy != NULL);
+
if(!copy)
fputs("Out of memory!\n", stderr);
else {
@@ -139,6 +144,9 @@ static void aparam(char ** xml, unsigned * size, const char ** param) {
char * xmlize(const char * orig) {
register unsigned i = 0, x = 0;
char * encoded = calloc((strlen(orig) * 6) + 1, sizeof(char));
+
+ assert(encoded != NULL);
+
while(i < strlen(orig)) {
if(strchr("&<>'\"", orig[i])) {
snprintf(

0 comments on commit a20aac7

Please sign in to comment.
Something went wrong with that request. Please try again.