From 043b12b15a661a98f63726b1819c9bd3a589abf3 Mon Sep 17 00:00:00 2001 From: Nikolas Garofil Date: Tue, 9 Feb 2010 13:11:56 +0100 Subject: [PATCH] cpp-ify a lot of files --- src/CMakeLists.txt | 30 +++---- src/{algebra.c => algebra.cc} | 10 +-- src/{apcupsd.c => apcupsd.cc} | 4 +- src/{bmpx.c => bmpx.cc} | 4 +- src/{bsdapm.c => bsdapm.cc} | 4 +- src/{eve.c => eve.cc} | 4 +- src/{fonts.c => fonts.cc} | 6 +- src/{freebsd.c => freebsd.cc} | 4 +- src/{iconv_tools.c => iconv_tools.cc} | 4 +- src/{libmpdclient.c => libmpdclient.cc} | 114 ++++++++++++------------ src/{netbsd.c => netbsd.cc} | 4 +- src/{openbsd.c => openbsd.cc} | 4 +- src/{proc.c => proc.cc} | 8 +- src/{prss.c => prss.cc} | 4 +- src/{solaris.c => solaris.cc} | 4 +- src/{sony.c => sony.cc} | 4 +- src/{user.c => user.cc} | 4 +- src/user.h | 8 -- src/{xmms2.c => xmms2.cc} | 4 +- 19 files changed, 110 insertions(+), 118 deletions(-) rename src/{algebra.c => algebra.cc} (94%) rename src/{apcupsd.c => apcupsd.cc} (98%) rename src/{bmpx.c => bmpx.cc} (97%) rename src/{bsdapm.c => bsdapm.cc} (97%) rename src/{eve.c => eve.cc} (98%) rename src/{fonts.c => fonts.cc} (95%) rename src/{freebsd.c => freebsd.cc} (99%) rename src/{iconv_tools.c => iconv_tools.cc} (97%) rename src/{libmpdclient.c => libmpdclient.cc} (95%) rename src/{netbsd.c => netbsd.cc} (98%) rename src/{openbsd.c => openbsd.cc} (99%) rename src/{proc.c => proc.cc} (98%) rename src/{prss.c => prss.cc} (97%) rename src/{solaris.c => solaris.cc} (94%) rename src/{sony.c => sony.cc} (95%) rename src/{user.c => user.cc} (94%) rename src/{xmms2.c => xmms2.cc} (98%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5d78c609..971a83ba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -37,8 +37,8 @@ endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/build.h) set(conky_sources colours.cc combine.cc common.cc conky.cc core.cc diskio.cc entropy.cc exec.cc fs.cc mail.cc mixer.cc net_stat.cc template.cc mboxscan.cc read_tcp.cc scroll.cc specials.cc tailhead.cc - temphelper.cc text_object.cc timeinfo.cc top.cc algebra.c prioqueue.c proc.c - user.c) + temphelper.cc text_object.cc timeinfo.cc top.cc algebra.cc prioqueue.c proc.cc + user.cc) # add timed thread library add_library(timed-thread timed-thread.cc) @@ -46,28 +46,28 @@ set(conky_libs ${conky_libs} timed-thread) # Platform specific sources if(OS_LINUX) - set(linux linux.cc users.cc sony.c i8k.cc) + set(linux linux.cc users.cc sony.cc i8k.cc) set(optional_sources ${optional_sources} ${linux}) endif(OS_LINUX) if(OS_FREEBSD) - set(freebsd freebsd.c bsdapm.c) + set(freebsd freebsd.cc bsdapm.cc) set(optional_sources ${optional_sources} ${freebsd}) endif(OS_FREEBSD) if(OS_OPENBSD) - set(openbsd openbsd.c bsdapm.c) + set(openbsd openbsd.cc bsdapm.cc) set(optional_sources ${optional_sources} ${openbsd}) endif(OS_OPENBSD) # These below are not actually supported. No idea what their status is. if(OS_SOLARIS) - set(solaris solaris.c) + set(solaris solaris.cc) set(optional_sources ${optional_sources} ${solaris}) endif(OS_SOLARIS) if(OS_NETBSD) - set(netbsd netbsd.c) + set(netbsd netbsd.cc) set(optional_sources ${optional_sources} ${netbsd}) endif(OS_NETBSD) @@ -79,7 +79,7 @@ if(BUILD_AUDACIOUS) endif(BUILD_AUDACIOUS) if(BUILD_BMPX) - set(bmpx bmpx.c) + set(bmpx bmpx.cc) set(optional_sources ${optional_sources} ${bmpx}) endif(BUILD_BMPX) @@ -89,7 +89,7 @@ if(BUILD_IBM) endif(BUILD_IBM) if(BUILD_MPD) - set(mpd mpd.cc libmpdclient.c) + set(mpd mpd.cc libmpdclient.cc) set(optional_sources ${optional_sources} ${mpd}) endif(BUILD_MPD) @@ -99,7 +99,7 @@ if(BUILD_MOC) endif(BUILD_MOC) if(BUILD_XMMS2) - set(xmms2 xmms2.c) + set(xmms2 xmms2.cc) set(optional_sources ${optional_sources} ${xmms2}) endif(BUILD_XMMS2) @@ -111,7 +111,7 @@ if(BUILD_PORT_MONITORS) endif(BUILD_PORT_MONITORS) if(BUILD_X11) - set(x11 x11.cc fonts.c) + set(x11 x11.cc fonts.cc) set(optional_sources ${optional_sources} ${x11}) endif(BUILD_X11) @@ -121,7 +121,7 @@ if(BUILD_HDDTEMP) endif(BUILD_HDDTEMP) if(BUILD_EVE) - set(eve eve.c) + set(eve eve.cc) set(optional_sources ${optional_sources} ${eve}) endif(BUILD_EVE) @@ -131,7 +131,7 @@ if(BUILD_CURL) endif(BUILD_CURL) if(BUILD_RSS) - set(rss rss.cc prss.c) + set(rss rss.cc prss.cc) set(optional_sources ${optional_sources} ${rss}) endif(BUILD_RSS) @@ -156,12 +156,12 @@ if(BUILD_IMLIB2) endif(BUILD_IMLIB2) if(BUILD_APCUPSD) - set(apcupsd apcupsd.c) + set(apcupsd apcupsd.cc) set(optional_sources ${optional_sources} ${apcupsd}) endif(BUILD_APCUPSD) if(BUILD_ICONV) - set(iconv iconv_tools.c) + set(iconv iconv_tools.cc) set(optional_sources ${optional_sources} ${iconv}) endif(BUILD_ICONV) diff --git a/src/algebra.c b/src/algebra.cc similarity index 94% rename from src/algebra.c rename to src/algebra.cc index 047ac97f..fa1cf9e3 100644 --- a/src/algebra.c +++ b/src/algebra.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * Conky, a system monitor, based on torsmo * @@ -227,16 +227,16 @@ int compare(const char *expr) char *a, *b; a = arg_to_string(expr_dup); b = arg_to_string(expr_dup + idx + 1); - idx = scompare(a, mtype, b); + idx = scompare(a, (enum match_type) mtype, b); free(a); free(b); return idx; } case ARG_LONG: - return lcompare(arg_to_long(expr_dup), mtype, + return lcompare(arg_to_long(expr_dup), (enum match_type) mtype, arg_to_long(expr_dup + idx + 1)); case ARG_DOUBLE: - return dcompare(arg_to_double(expr_dup), mtype, + return dcompare(arg_to_double(expr_dup), (enum match_type) mtype, arg_to_double(expr_dup + idx + 1)); } /* not reached */ diff --git a/src/apcupsd.c b/src/apcupsd.cc similarity index 98% rename from src/apcupsd.c rename to src/apcupsd.cc index d7678d2c..2e3564d1 100644 --- a/src/apcupsd.c +++ b/src/apcupsd.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * apcupsd.c: conky module for APC UPS daemon monitoring * diff --git a/src/bmpx.c b/src/bmpx.cc similarity index 97% rename from src/bmpx.c rename to src/bmpx.cc index 63e0cd63..b9d6066d 100644 --- a/src/bmpx.c +++ b/src/bmpx.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * Conky, a system monitor, based on torsmo * diff --git a/src/bsdapm.c b/src/bsdapm.cc similarity index 97% rename from src/bsdapm.c rename to src/bsdapm.cc index 1278354e..830ed32d 100644 --- a/src/bsdapm.c +++ b/src/bsdapm.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * Conky, a system monitor, based on torsmo * diff --git a/src/eve.c b/src/eve.cc similarity index 98% rename from src/eve.c rename to src/eve.cc index 6dcba02b..94d981d3 100644 --- a/src/eve.c +++ b/src/eve.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * Conky, a system monitor, based on torsmo * diff --git a/src/fonts.c b/src/fonts.cc similarity index 95% rename from src/fonts.c rename to src/fonts.cc index 450bae8c..b5c48c1e 100644 --- a/src/fonts.c +++ b/src/fonts.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * Conky, a system monitor, based on torsmo * @@ -83,7 +83,7 @@ int add_font(const char *data_in) } memset(fonts, 0, sizeof(struct font_list)); } - fonts = realloc(fonts, (sizeof(struct font_list) * (font_count + 1))); + fonts = (font_list*) realloc(fonts, (sizeof(struct font_list) * (font_count + 1))); memset(&fonts[font_count], 0, sizeof(struct font_list)); if (fonts == NULL) { CRIT_ERR(NULL, NULL, "realloc in add_font"); diff --git a/src/freebsd.c b/src/freebsd.cc similarity index 99% rename from src/freebsd.c rename to src/freebsd.cc index 9edc8cd1..9cef5856 100644 --- a/src/freebsd.c +++ b/src/freebsd.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * Conky, a system monitor, based on torsmo * diff --git a/src/iconv_tools.c b/src/iconv_tools.cc similarity index 97% rename from src/iconv_tools.c rename to src/iconv_tools.cc index 22ec891d..0c548f85 100644 --- a/src/iconv_tools.c +++ b/src/iconv_tools.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * Conky, a system monitor, based on torsmo * diff --git a/src/libmpdclient.c b/src/libmpdclient.cc similarity index 95% rename from src/libmpdclient.c rename to src/libmpdclient.cc index 4e789aa3..df7a16a3 100644 --- a/src/libmpdclient.c +++ b/src/libmpdclient.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * libmpdclient * (c)2003-2006 by Warren Dukes (warren.dukes@gmail.com) @@ -283,7 +283,7 @@ static char *mpd_sanitizeArg(const char *arg) /* instead of counting in that loop above, * just use a bit more memory and halve running time */ - ret = malloc(strlen(arg) * 2 + 1); + ret = (char*) malloc(strlen(arg) * 2 + 1); c = arg; rc = ret; @@ -300,7 +300,7 @@ static char *mpd_sanitizeArg(const char *arg) static mpd_ReturnElement *mpd_newReturnElement(const char *name, const char *value) { - mpd_ReturnElement *ret = malloc(sizeof(mpd_ReturnElement)); + mpd_ReturnElement *ret = (mpd_ReturnElement*) malloc(sizeof(mpd_ReturnElement)); ret->name = strndup(name, text_buffer_size); ret->value = strndup(value, text_buffer_size); @@ -361,7 +361,7 @@ mpd_Connection *mpd_newConnection(const char *host, int port, float timeout) int err; char *rt; char *output = NULL; - mpd_Connection *connection = malloc(sizeof(mpd_Connection)); + mpd_Connection *connection = (mpd_Connection*) malloc(sizeof(mpd_Connection)); struct timeval tv; fd_set fds; @@ -715,7 +715,7 @@ mpd_Status *mpd_getStatus(mpd_Connection *connection) mpd_getNextReturnElement(connection); } - status = malloc(sizeof(mpd_Status)); + status = (mpd_Status *) malloc(sizeof(mpd_Status)); status->volume = -1; status->repeat = 0; status->random = 0; @@ -846,7 +846,7 @@ mpd_Stats *mpd_getStats(mpd_Connection *connection) mpd_getNextReturnElement(connection); } - stats = malloc(sizeof(mpd_Stats)); + stats = (mpd_Stats *) malloc(sizeof(mpd_Stats)); stats->numberOfArtists = 0; stats->numberOfAlbums = 0; stats->numberOfSongs = 0; @@ -916,7 +916,7 @@ mpd_SearchStats *mpd_getSearchStats(mpd_Connection *connection) return NULL; } - stats = malloc(sizeof(mpd_SearchStats)); + stats = (mpd_SearchStats *) malloc(sizeof(mpd_SearchStats)); stats->numberOfSongs = 0; stats->playTime = 0; @@ -1009,7 +1009,7 @@ static void mpd_finishSong(mpd_Song *song) mpd_Song *mpd_newSong(void) { - mpd_Song *ret = malloc(sizeof(mpd_Song)); + mpd_Song *ret = (mpd_Song *) malloc(sizeof(mpd_Song)); mpd_initSong(ret); @@ -1080,7 +1080,7 @@ static void mpd_finishDirectory(mpd_Directory *directory) mpd_Directory *mpd_newDirectory(void) { - mpd_Directory *directory = malloc(sizeof(mpd_Directory)); + mpd_Directory *directory = (mpd_Directory *) malloc(sizeof(mpd_Directory)); mpd_initDirectory(directory); @@ -1119,7 +1119,7 @@ static void mpd_finishPlaylistFile(mpd_PlaylistFile *playlist) mpd_PlaylistFile *mpd_newPlaylistFile(void) { - mpd_PlaylistFile *playlist = malloc(sizeof(mpd_PlaylistFile)); + mpd_PlaylistFile *playlist = (mpd_PlaylistFile *) malloc(sizeof(mpd_PlaylistFile)); mpd_initPlaylistFile(playlist); @@ -1163,7 +1163,7 @@ static void mpd_finishInfoEntity(mpd_InfoEntity *entity) mpd_InfoEntity *mpd_newInfoEntity(void) { - mpd_InfoEntity *entity = malloc(sizeof(mpd_InfoEntity)); + mpd_InfoEntity *entity = (mpd_InfoEntity *) malloc(sizeof(mpd_InfoEntity)); mpd_initInfoEntity(entity); @@ -1340,7 +1340,7 @@ char *mpd_getNextAlbum(mpd_Connection *connection) void mpd_sendPlaylistInfoCommand(mpd_Connection *connection, int songPos) { int len = strlen("playlistinfo") + 2 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "playlistinfo \"%i\"\n", songPos); mpd_sendInfoCommand(connection, string); @@ -1350,7 +1350,7 @@ void mpd_sendPlaylistInfoCommand(mpd_Connection *connection, int songPos) void mpd_sendPlaylistIdCommand(mpd_Connection *connection, int id) { int len = strlen("playlistid") + 2 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "playlistid \"%i\"\n", id); mpd_sendInfoCommand(connection, string); @@ -1360,7 +1360,7 @@ void mpd_sendPlaylistIdCommand(mpd_Connection *connection, int id) void mpd_sendPlChangesCommand(mpd_Connection *connection, long long playlist) { int len = strlen("plchanges") + 2 + LONGLONGLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "plchanges \"%lld\"\n", playlist); mpd_sendInfoCommand(connection, string); @@ -1371,7 +1371,7 @@ void mpd_sendPlChangesPosIdCommand(mpd_Connection *connection, long long playlist) { int len = strlen("plchangesposid") + 2 + LONGLONGLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "plchangesposid \"%lld\"\n", playlist); mpd_sendInfoCommand(connection, string); @@ -1382,7 +1382,7 @@ void mpd_sendListallCommand(mpd_Connection *connection, const char *dir) { char *sDir = mpd_sanitizeArg(dir); int len = strlen("listall") + 2 + strlen(sDir) + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "listall \"%s\"\n", sDir); mpd_sendInfoCommand(connection, string); @@ -1394,7 +1394,7 @@ void mpd_sendListallInfoCommand(mpd_Connection *connection, const char *dir) { char *sDir = mpd_sanitizeArg(dir); int len = strlen("listallinfo") + 2 + strlen(sDir) + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "listallinfo \"%s\"\n", sDir); mpd_sendInfoCommand(connection, string); @@ -1406,7 +1406,7 @@ void mpd_sendLsInfoCommand(mpd_Connection *connection, const char *dir) { char *sDir = mpd_sanitizeArg(dir); int len = strlen("lsinfo") + 2 + strlen(sDir) + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "lsinfo \"%s\"\n", sDir); mpd_sendInfoCommand(connection, string); @@ -1455,12 +1455,12 @@ void mpd_sendListCommand(mpd_Connection *connection, int table, char *sanitArg1 = mpd_sanitizeArg(arg1); len = strlen("list") + 1 + strlen(sanitArg1) + 2 + strlen(st) + 3; - string = malloc(len); + string = (char*) malloc(len); snprintf(string, len, "list %s \"%s\"\n", st, sanitArg1); free(sanitArg1); } else { len = strlen("list") + 1 + strlen(st) + 2; - string = malloc(len); + string = (char*) malloc(len); snprintf(string, len, "list %s\n", st); } mpd_sendInfoCommand(connection, string); @@ -1471,7 +1471,7 @@ void mpd_sendAddCommand(mpd_Connection *connection, const char *file) { char *sFile = mpd_sanitizeArg(file); int len = strlen("add") + 2 + strlen(sFile) + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "add \"%s\"\n", sFile); mpd_executeCommand(connection, string); @@ -1484,7 +1484,7 @@ int mpd_sendAddIdCommand(mpd_Connection *connection, const char *file) int retval = -1; char *sFile = mpd_sanitizeArg(file); int len = strlen("addid") + 2 + strlen(sFile) + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "addid \"%s\"\n", sFile); mpd_sendInfoCommand(connection, string); @@ -1503,7 +1503,7 @@ int mpd_sendAddIdCommand(mpd_Connection *connection, const char *file) void mpd_sendDeleteCommand(mpd_Connection *connection, int songPos) { int len = strlen("delete") + 2 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "delete \"%i\"\n", songPos); mpd_sendInfoCommand(connection, string); @@ -1513,7 +1513,7 @@ void mpd_sendDeleteCommand(mpd_Connection *connection, int songPos) void mpd_sendDeleteIdCommand(mpd_Connection *connection, int id) { int len = strlen("deleteid") + 2 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "deleteid \"%i\"\n", id); mpd_sendInfoCommand(connection, string); @@ -1524,7 +1524,7 @@ void mpd_sendSaveCommand(mpd_Connection *connection, const char *name) { char *sName = mpd_sanitizeArg(name); int len = strlen("save") + 2 + strlen(sName) + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "save \"%s\"\n", sName); mpd_executeCommand(connection, string); @@ -1536,7 +1536,7 @@ void mpd_sendLoadCommand(mpd_Connection *connection, const char *name) { char *sName = mpd_sanitizeArg(name); int len = strlen("load") + 2 + strlen(sName) + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "load \"%s\"\n", sName); mpd_executeCommand(connection, string); @@ -1548,7 +1548,7 @@ void mpd_sendRmCommand(mpd_Connection *connection, const char *name) { char *sName = mpd_sanitizeArg(name); int len = strlen("rm") + 2 + strlen(sName) + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "rm \"%s\"\n", sName); mpd_executeCommand(connection, string); @@ -1562,7 +1562,7 @@ void mpd_sendRenameCommand(mpd_Connection *connection, const char *from, char *sFrom = mpd_sanitizeArg(from); char *sTo = mpd_sanitizeArg(to); int len = strlen("rename") + 2 + strlen(sFrom) + 3 + strlen(sTo) + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "rename \"%s\" \"%s\"\n", sFrom, sTo); mpd_executeCommand(connection, string); @@ -1584,7 +1584,7 @@ void mpd_sendClearCommand(mpd_Connection *connection) void mpd_sendPlayCommand(mpd_Connection *connection, int songPos) { int len = strlen("play") + 2 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "play \"%i\"\n", songPos); mpd_sendInfoCommand(connection, string); @@ -1594,7 +1594,7 @@ void mpd_sendPlayCommand(mpd_Connection *connection, int songPos) void mpd_sendPlayIdCommand(mpd_Connection *connection, int id) { int len = strlen("playid") + 2 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "playid \"%i\"\n", id); mpd_sendInfoCommand(connection, string); @@ -1609,7 +1609,7 @@ void mpd_sendStopCommand(mpd_Connection *connection) void mpd_sendPauseCommand(mpd_Connection *connection, int pauseMode) { int len = strlen("pause") + 2 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "pause \"%i\"\n", pauseMode); mpd_executeCommand(connection, string); @@ -1624,7 +1624,7 @@ void mpd_sendNextCommand(mpd_Connection *connection) void mpd_sendMoveCommand(mpd_Connection *connection, int from, int to) { int len = strlen("move") + 2 + INTLEN + 3 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "move \"%i\" \"%i\"\n", from, to); mpd_sendInfoCommand(connection, string); @@ -1634,7 +1634,7 @@ void mpd_sendMoveCommand(mpd_Connection *connection, int from, int to) void mpd_sendMoveIdCommand(mpd_Connection *connection, int id, int to) { int len = strlen("moveid") + 2 + INTLEN + 3 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "moveid \"%i\" \"%i\"\n", id, to); mpd_sendInfoCommand(connection, string); @@ -1644,7 +1644,7 @@ void mpd_sendMoveIdCommand(mpd_Connection *connection, int id, int to) void mpd_sendSwapCommand(mpd_Connection *connection, int song1, int song2) { int len = strlen("swap") + 2 + INTLEN + 3 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "swap \"%i\" \"%i\"\n", song1, song2); mpd_sendInfoCommand(connection, string); @@ -1654,7 +1654,7 @@ void mpd_sendSwapCommand(mpd_Connection *connection, int song1, int song2) void mpd_sendSwapIdCommand(mpd_Connection *connection, int id1, int id2) { int len = strlen("swapid") + 2 + INTLEN + 3 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "swapid \"%i\" \"%i\"\n", id1, id2); mpd_sendInfoCommand(connection, string); @@ -1664,7 +1664,7 @@ void mpd_sendSwapIdCommand(mpd_Connection *connection, int id1, int id2) void mpd_sendSeekCommand(mpd_Connection *connection, int song, int seek_time) { int len = strlen("seek") + 2 + INTLEN + 3 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "seek \"%i\" \"%i\"\n", song, seek_time); mpd_sendInfoCommand(connection, string); @@ -1674,7 +1674,7 @@ void mpd_sendSeekCommand(mpd_Connection *connection, int song, int seek_time) void mpd_sendSeekIdCommand(mpd_Connection *connection, int id, int seek_time) { int len = strlen("seekid") + 2 + INTLEN + 3 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "seekid \"%i\" \"%i\"\n", id, seek_time); mpd_sendInfoCommand(connection, string); @@ -1685,7 +1685,7 @@ void mpd_sendUpdateCommand(mpd_Connection *connection, char *path) { char *sPath = mpd_sanitizeArg(path); int len = strlen("update") + 2 + strlen(sPath) + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "update \"%s\"\n", sPath); mpd_sendInfoCommand(connection, string); @@ -1715,7 +1715,7 @@ void mpd_sendPrevCommand(mpd_Connection *connection) void mpd_sendRepeatCommand(mpd_Connection *connection, int repeatMode) { int len = strlen("repeat") + 2 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "repeat \"%i\"\n", repeatMode); mpd_executeCommand(connection, string); @@ -1725,7 +1725,7 @@ void mpd_sendRepeatCommand(mpd_Connection *connection, int repeatMode) void mpd_sendRandomCommand(mpd_Connection *connection, int randomMode) { int len = strlen("random") + 2 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "random \"%i\"\n", randomMode); mpd_executeCommand(connection, string); @@ -1735,7 +1735,7 @@ void mpd_sendRandomCommand(mpd_Connection *connection, int randomMode) void mpd_sendSetvolCommand(mpd_Connection *connection, int volumeChange) { int len = strlen("setvol") + 2 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "setvol \"%i\"\n", volumeChange); mpd_executeCommand(connection, string); @@ -1745,7 +1745,7 @@ void mpd_sendSetvolCommand(mpd_Connection *connection, int volumeChange) void mpd_sendVolumeCommand(mpd_Connection *connection, int volumeChange) { int len = strlen("volume") + 2 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "volume \"%i\"\n", volumeChange); mpd_executeCommand(connection, string); @@ -1755,7 +1755,7 @@ void mpd_sendVolumeCommand(mpd_Connection *connection, int volumeChange) void mpd_sendCrossfadeCommand(mpd_Connection *connection, int seconds) { int len = strlen("crossfade") + 2 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "crossfade \"%i\"\n", seconds); mpd_executeCommand(connection, string); @@ -1766,7 +1766,7 @@ void mpd_sendPasswordCommand(mpd_Connection *connection, const char *pass) { char *sPass = mpd_sanitizeArg(pass); int len = strlen("password") + 2 + strlen(sPass) + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "password \"%s\"\n", sPass); mpd_executeCommand(connection, string); @@ -1826,7 +1826,7 @@ mpd_OutputEntity *mpd_getNextOutput(mpd_Connection *connection) return NULL; } - output = malloc(sizeof(mpd_OutputEntity)); + output = (mpd_OutputEntity*) malloc(sizeof(mpd_OutputEntity)); output->id = -10; output->name = NULL; output->enabled = 0; @@ -1862,7 +1862,7 @@ mpd_OutputEntity *mpd_getNextOutput(mpd_Connection *connection) void mpd_sendEnableOutputCommand(mpd_Connection *connection, int outputId) { int len = strlen("enableoutput") + 2 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "enableoutput \"%i\"\n", outputId); mpd_executeCommand(connection, string); @@ -1872,7 +1872,7 @@ void mpd_sendEnableOutputCommand(mpd_Connection *connection, int outputId) void mpd_sendDisableOutputCommand(mpd_Connection *connection, int outputId) { int len = strlen("disableoutput") + 2 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "disableoutput \"%i\"\n", outputId); mpd_executeCommand(connection, string); @@ -1984,7 +1984,7 @@ void mpd_startFieldSearch(mpd_Connection *connection, int type) strtype = mpdTagItemKeys[type]; len = 5 + strlen(strtype) + 1; - connection->request = malloc(len); + connection->request = (char*) malloc(len); snprintf(connection->request, len, "list %c%s", tolower(strtype[0]), strtype + 1); @@ -2021,7 +2021,7 @@ void mpd_addConstraintSearch(mpd_Connection *connection, int type, arg = mpd_sanitizeArg(name); len = strlen(string) + 1 + strlen(strtype) + 2 + strlen(arg) + 2; - connection->request = realloc(connection->request, len); + connection->request = (char*) realloc(connection->request, len); snprintf(connection->request, len, "%s %c%s \"%s\"", string, tolower(strtype[0]), strtype + 1, arg); @@ -2040,7 +2040,7 @@ void mpd_commitSearch(mpd_Connection *connection) } len = strlen(connection->request) + 2; - connection->request = realloc(connection->request, len); + connection->request = (char*) realloc(connection->request, len); connection->request[len - 2] = '\n'; connection->request[len - 1] = '\0'; mpd_sendInfoCommand(connection, connection->request); @@ -2058,7 +2058,7 @@ void mpd_sendListPlaylistInfoCommand(mpd_Connection *connection, char *path) { char *arg = mpd_sanitizeArg(path); int len = strlen("listplaylistinfo") + 2 + strlen(arg) + 3; - char *query = malloc(len); + char *query = (char*) malloc(len); snprintf(query, len, "listplaylistinfo \"%s\"\n", arg); mpd_sendInfoCommand(connection, query); @@ -2075,7 +2075,7 @@ void mpd_sendListPlaylistCommand(mpd_Connection *connection, char *path) { char *arg = mpd_sanitizeArg(path); int len = strlen("listplaylist") + 2 + strlen(arg) + 3; - char *query = malloc(len); + char *query = (char*) malloc(len); snprintf(query, len, "listplaylist \"%s\"\n", arg); mpd_sendInfoCommand(connection, query); @@ -2087,7 +2087,7 @@ void mpd_sendPlaylistClearCommand(mpd_Connection *connection, char *path) { char *sPath = mpd_sanitizeArg(path); int len = strlen("playlistclear") + 2 + strlen(sPath) + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "playlistclear \"%s\"\n", sPath); mpd_executeCommand(connection, string); @@ -2102,7 +2102,7 @@ void mpd_sendPlaylistAddCommand(mpd_Connection *connection, char *playlist, char *sPath = mpd_sanitizeArg(path); int len = strlen("playlistadd") + 2 + strlen(sPlaylist) + 3 + strlen(sPath) + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "playlistadd \"%s\" \"%s\"\n", sPlaylist, sPath); mpd_executeCommand(connection, string); @@ -2117,7 +2117,7 @@ void mpd_sendPlaylistMoveCommand(mpd_Connection *connection, char *playlist, char *sPlaylist = mpd_sanitizeArg(playlist); int len = strlen("playlistmove") + 2 + strlen(sPlaylist) + 3 + INTLEN + 3 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "playlistmove \"%s\" \"%i\" \"%i\"\n", sPlaylist, from, to); @@ -2132,7 +2132,7 @@ void mpd_sendPlaylistDeleteCommand(mpd_Connection *connection, char *playlist, char *sPlaylist = mpd_sanitizeArg(playlist); int len = strlen("playlistdelete") + 2 + strlen(sPlaylist) + 3 + INTLEN + 3; - char *string = malloc(len); + char *string = (char*) malloc(len); snprintf(string, len, "playlistdelete \"%s\" \"%i\"\n", sPlaylist, pos); mpd_executeCommand(connection, string); diff --git a/src/netbsd.c b/src/netbsd.cc similarity index 98% rename from src/netbsd.c rename to src/netbsd.cc index 5645df1a..909c622d 100644 --- a/src/netbsd.c +++ b/src/netbsd.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * Conky, a system monitor, based on torsmo * diff --git a/src/openbsd.c b/src/openbsd.cc similarity index 99% rename from src/openbsd.c rename to src/openbsd.cc index 77bf5dde..e9bb8189 100644 --- a/src/openbsd.c +++ b/src/openbsd.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * Conky, a system monitor, based on torsmo * diff --git a/src/proc.c b/src/proc.cc similarity index 98% rename from src/proc.c rename to src/proc.cc index 30a589a3..aa8d26fd 100644 --- a/src/proc.c +++ b/src/proc.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * Conky, a system monitor, based on torsmo * @@ -45,7 +45,7 @@ char* readfile(char* filename, int* total_read, char showerror) { file = fopen(filename, "r"); if(file) { do { - buf = realloc(buf, *total_read + READSIZE + 1); + buf = (char *) realloc(buf, *total_read + READSIZE + 1); bytes_read = fread(buf + *total_read, 1, READSIZE, file); *total_read += bytes_read; buf[*total_read] = 0; @@ -75,7 +75,7 @@ struct ll_string { }; struct ll_string* addnode(struct ll_string* end, char* string) { - struct ll_string* current = malloc(sizeof(struct ll_string)); + struct ll_string* current = (struct ll_string*) malloc(sizeof(struct ll_string)); current->string = strdup(string); current->next = NULL; if(end != NULL) end->next = current; diff --git a/src/prss.c b/src/prss.cc similarity index 97% rename from src/prss.c rename to src/prss.cc index e562506f..fe8a5af9 100644 --- a/src/prss.c +++ b/src/prss.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * Copyright (c) 2007 Mikko Sysikaski * Toni Spets diff --git a/src/solaris.c b/src/solaris.cc similarity index 94% rename from src/solaris.c rename to src/solaris.cc index 0bbf249d..5c965e6b 100644 --- a/src/solaris.c +++ b/src/solaris.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * Conky, a system monitor, based on torsmo * diff --git a/src/sony.c b/src/sony.cc similarity index 95% rename from src/sony.c rename to src/sony.cc index 9e9914d0..a16004eb 100644 --- a/src/sony.c +++ b/src/sony.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * Conky, a system monitor, based on torsmo * diff --git a/src/user.c b/src/user.cc similarity index 94% rename from src/user.c rename to src/user.cc index 11ee384e..f657228f 100644 --- a/src/user.c +++ b/src/user.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * Conky, a system monitor, based on torsmo * diff --git a/src/user.h b/src/user.h index 2a1339e6..fa0971c1 100644 --- a/src/user.h +++ b/src/user.h @@ -31,15 +31,7 @@ #ifndef _USER_H #define _USER_H -#ifdef __cplusplus -extern "C" { -#endif - void print_gid_name(struct text_object *obj, char *p, int p_max_size); void print_uid_name(struct text_object *obj, char *p, int p_max_size); -#ifdef __cplusplus -} -#endif - #endif /* _USER_H */ diff --git a/src/xmms2.c b/src/xmms2.cc similarity index 98% rename from src/xmms2.c rename to src/xmms2.cc index d7a7428b..5a12e234 100644 --- a/src/xmms2.c +++ b/src/xmms2.cc @@ -1,5 +1,5 @@ -/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- - * vim: ts=4 sw=4 noet ai cindent syntax=c +/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=cpp * * Conky, a system monitor, based on torsmo *