Use glib for allocations in all plugins

Continuation of 83032b1aa
This commit is contained in:
TingPing 2014-12-28 06:08:20 -05:00
parent 83032b1aa3
commit 3f855f07f5
26 changed files with 118 additions and 257 deletions

View File

@ -3,6 +3,6 @@ libdir = $(hexchatlibdir)
lib_LTLIBRARIES = doat.la lib_LTLIBRARIES = doat.la
doat_la_SOURCES = doat.c doat_la_SOURCES = doat.c
doat_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module doat_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
doat_la_LIBADD = doat_la_LIBADD = $(GLIB_LIBS)
doat_la_CFLAGS = -I$(top_srcdir)/src/common doat_la_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)/src/common

View File

@ -10,6 +10,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <glib.h>
#include "hexchat-plugin.h" #include "hexchat-plugin.h"
static hexchat_plugin *ph; static hexchat_plugin *ph;
@ -33,7 +34,7 @@ parse_command( char *word[], char *word_eol[], void *userdata ) {
break; break;
} }
channel = strdup( token ); channel = g_strdup( token );
delimiter = strchr( channel, '/' ); delimiter = strchr( channel, '/' );
@ -42,13 +43,13 @@ parse_command( char *word[], char *word_eol[], void *userdata ) {
*delimiter = '\0'; *delimiter = '\0';
if( strlen( delimiter + 1 ) > 0 ) { if( strlen( delimiter + 1 ) > 0 ) {
server = strdup( delimiter + 1 ); server = g_strdup( delimiter + 1 );
} }
} }
/* /Network form */ /* /Network form */
if( strlen( channel ) == 0 ) { if( strlen( channel ) == 0 ) {
free( channel ); g_free( channel );
channel = NULL; channel = NULL;
} }
@ -60,13 +61,8 @@ parse_command( char *word[], char *word_eol[], void *userdata ) {
} }
} }
if( channel != NULL ) { g_free( channel );
free( channel ); g_free( server );
}
if( server != NULL ) {
free( server );
}
} }
} }
return HEXCHAT_EAT_HEXCHAT; return HEXCHAT_EAT_HEXCHAT;

View File

@ -62,7 +62,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DOAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DOAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\src\common;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile> </ClCompile>
<Link> <Link>
@ -70,6 +70,8 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>doat.def</ModuleDefinitionFile> <ModuleDefinitionFile>doat.def</ModuleDefinitionFile>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
@ -80,7 +82,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;DOAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;DOAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\src\common;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile> </ClCompile>
<Link> <Link>
@ -88,6 +90,8 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>doat.def</ModuleDefinitionFile> <ModuleDefinitionFile>doat.def</ModuleDefinitionFile>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>

View File

@ -3,7 +3,7 @@ EXTRA_DIST = INSTALL LICENSE
libdir = $(hexchatlibdir) libdir = $(hexchatlibdir)
lib_LTLIBRARIES = fishlim.la lib_LTLIBRARIES = fishlim.la
fishlim_la_SOURCES = fish.c irc.c keystore.c misc.c plugin_hexchat.c fishlim_la_SOURCES = fish.c irc.c keystore.c plugin_hexchat.c
fishlim_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module fishlim_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
fishlim_la_LIBADD = $(GLIB_LIBS) $(OPENSSL_LIBS) fishlim_la_LIBADD = $(GLIB_LIBS) $(OPENSSL_LIBS)
fishlim_la_CFLAGS = $(GLIB_CFLAGS) $(OPENSSL_CFLAGS) -I$(top_srcdir)/src/common fishlim_la_CFLAGS = $(GLIB_CFLAGS) $(OPENSSL_CFLAGS) -I$(top_srcdir)/src/common

View File

@ -75,9 +75,8 @@ char *fish_encrypt(const char *key, size_t keylen, const char *message) {
messagelen = strlen(message); messagelen = strlen(message);
if (messagelen == 0) return NULL; if (messagelen == 0) return NULL;
encrypted = malloc(((messagelen-1)/8)*12 + 12 + 1); // each 8-byte block becomes 12 bytes encrypted = g_malloc(((messagelen - 1) / 8) * 12 + 12 + 1); // each 8-byte block becomes 12 bytes
end = encrypted; end = encrypted;
if (!encrypted) return NULL;
while (*message) { while (*message) {
// Read 8 bytes (a Blowfish block) // Read 8 bytes (a Blowfish block)
@ -124,9 +123,8 @@ char *fish_decrypt(const char *key, size_t keylen, const char *data) {
unsigned char d; unsigned char d;
BF_set_key(&bfkey, keylen, (const unsigned char*)key); BF_set_key(&bfkey, keylen, (const unsigned char*)key);
decrypted = malloc(strlen(data)+1); decrypted = g_malloc(strlen(data) + 1);
end = decrypted; end = decrypted;
if (!decrypted) return NULL;
while (*data) { while (*data) {
// Convert from FiSH-BASE64 // Convert from FiSH-BASE64
@ -172,7 +170,7 @@ char *fish_encrypt_for_nick(const char *nick, const char *data) {
// Encrypt // Encrypt
encrypted = fish_encrypt(key, strlen(key), data); encrypted = fish_encrypt(key, strlen(key), data);
free(key); g_free(key);
return encrypted; return encrypted;
} }
@ -190,7 +188,7 @@ char *fish_decrypt_from_nick(const char *nick, const char *data) {
// Decrypt // Decrypt
decrypted = fish_decrypt(key, strlen(key), data); decrypted = fish_decrypt(key, strlen(key), data);
free(key); g_free(key);
return decrypted; return decrypted;
} }

View File

@ -28,6 +28,8 @@
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <glib.h>
char *fish_encrypt(const char *key, size_t keylen, const char *message); char *fish_encrypt(const char *key, size_t keylen, const char *message);
char *fish_decrypt(const char *key, size_t keylen, const char *data); char *fish_decrypt(const char *key, size_t keylen, const char *data);
char *fish_encrypt_for_nick(const char *nick, const char *data); char *fish_encrypt_for_nick(const char *nick, const char *data);

View File

@ -103,14 +103,12 @@
<ClInclude Include="fish.h" /> <ClInclude Include="fish.h" />
<ClInclude Include="irc.h" /> <ClInclude Include="irc.h" />
<ClInclude Include="keystore.h" /> <ClInclude Include="keystore.h" />
<ClInclude Include="misc.h" />
<ClInclude Include="plugin_hexchat.h" /> <ClInclude Include="plugin_hexchat.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="fish.c" /> <ClCompile Include="fish.c" />
<ClCompile Include="irc.c" /> <ClCompile Include="irc.c" />
<ClCompile Include="keystore.c" /> <ClCompile Include="keystore.c" />
<ClCompile Include="misc.c" />
<ClCompile Include="plugin_hexchat.c" /> <ClCompile Include="plugin_hexchat.c" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -32,9 +32,6 @@
<ClInclude Include="keystore.h"> <ClInclude Include="keystore.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="misc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="plugin_hexchat.h"> <ClInclude Include="plugin_hexchat.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -49,9 +46,6 @@
<ClCompile Include="keystore.c"> <ClCompile Include="keystore.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="misc.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="plugin_hexchat.c"> <ClCompile Include="plugin_hexchat.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>

View File

@ -28,6 +28,8 @@
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <glib.h>
bool irc_parse_message(const char *words[], bool irc_parse_message(const char *words[],
const char **prefix, const char **command, const char **prefix, const char **command,
size_t *parameters_offset); size_t *parameters_offset);

View File

@ -29,7 +29,6 @@
#include <string.h> #include <string.h>
#include "irc.h" #include "irc.h"
#include "fish.h" #include "fish.h"
#include "misc.h"
#include "keystore.h" #include "keystore.h"
#include "plugin_hexchat.h" #include "plugin_hexchat.h"
@ -97,7 +96,7 @@ char *keystore_get_key(const char *nick) {
if (strncmp(value, "+OK ", 4) != 0) { if (strncmp(value, "+OK ", 4) != 0) {
// Key is stored in plaintext // Key is stored in plaintext
return import_glib_string(value); return value;
} else { } else {
// Key is encrypted // Key is encrypted
const char *encrypted = value+4; const char *encrypted = value+4;
@ -191,7 +190,7 @@ bool keystore_store_key(const char *nick, const char *key) {
// Store encrypted in file // Store encrypted in file
g_key_file_set_string(keyfile, nick, "key", wrapped); g_key_file_set_string(keyfile, nick, "key", wrapped);
free(wrapped); g_free(wrapped);
} else { } else {
// Store unencrypted in file // Store unencrypted in file
g_key_file_set_string(keyfile, nick, "key", key); g_key_file_set_string(keyfile, nick, "key", key);
@ -220,11 +219,3 @@ bool keystore_delete_nick(const char *nick) {
g_key_file_free(keyfile); g_key_file_free(keyfile);
return ok; return ok;
} }
void keystore_secure_free(void *ptr, size_t size) {
secure_erase(ptr, size);
free(ptr);
}

View File

@ -28,11 +28,11 @@
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <glib.h>
char *keystore_get_key(const char *nick); char *keystore_get_key(const char *nick);
bool keystore_store_key(const char *nick, const char *key); bool keystore_store_key(const char *nick, const char *key);
bool keystore_delete_nick(const char *nick); bool keystore_delete_nick(const char *nick);
void keystore_secure_free(void *ptr, size_t size);
#endif #endif

View File

@ -1,54 +0,0 @@
/*
Copyright (c) 2010 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include "misc.h"
void secure_erase(void *ptr, size_t size) {
// "volatile" prevents this code from being optimized away
volatile char* volptr = ptr;
while (size--) *volptr++ = 0;
}
/**
* Re-allocates a string with the native allocator.
*/
char *import_glib_string(gchar *gstr) {
size_t size;
char *native;
if (g_mem_is_system_malloc()) return gstr;
size = strlen(gstr)+1;
native = malloc(size);
memcpy(native, gstr, size);
secure_erase(gstr, size);
g_free(gstr);
return native;
}

View File

@ -1,36 +0,0 @@
/*
Copyright (c) 2010 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef MISC_H
#define MISC_H
void secure_erase(void *ptr, size_t size);
#ifdef __G_LIB_H__
char *import_glib_string(gchar *gstr);
#endif
#endif

View File

@ -93,7 +93,7 @@ static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
// Send message // Send message
hexchat_commandf(ph, "PRIVMSG %s :+OK %s", channel, encrypted); hexchat_commandf(ph, "PRIVMSG %s :+OK %s", channel, encrypted);
free(encrypted); g_free(encrypted);
return HEXCHAT_EAT_HEXCHAT; return HEXCHAT_EAT_HEXCHAT;
} }
@ -180,7 +180,7 @@ static int handle_incoming(char *word[], char *word_eol[], hexchat_event_attrs *
g_string_append (message, peice); g_string_append (message, peice);
} }
free(decrypted); g_free(decrypted);
// Simulate unencrypted message // Simulate unencrypted message
//hexchat_printf(ph, "simulating: %s\n", message->str); //hexchat_printf(ph, "simulating: %s\n", message->str);
@ -191,8 +191,8 @@ static int handle_incoming(char *word[], char *word_eol[], hexchat_event_attrs *
return HEXCHAT_EAT_HEXCHAT; return HEXCHAT_EAT_HEXCHAT;
decrypt_error: decrypt_error:
free(decrypted); g_free(decrypted);
free(sender_nick); g_free(sender_nick);
return HEXCHAT_EAT_NONE; return HEXCHAT_EAT_NONE;
} }

View File

@ -47,7 +47,7 @@ static int decrypt(int nick_count, char *nicks[]) {
return 1; return 1;
success: success:
fprintf(stderr, "Decrypted text >>>%s<<<\n", msg); fprintf(stderr, "Decrypted text >>>%s<<<\n", msg);
free(msg); g_free(msg);
} }
return 0; return 0;
} }
@ -64,7 +64,7 @@ static int encrypt(int nick_count, char *nicks[]) {
char *encrypted = fish_encrypt_for_nick(nicks[i], message); char *encrypted = fish_encrypt_for_nick(nicks[i], message);
if (encrypted) { if (encrypted) {
fprintf(stderr, "Encrypted [%s]: >>>%s<<<\n", nicks[i], encrypted); fprintf(stderr, "Encrypted [%s]: >>>%s<<<\n", nicks[i], encrypted);
free(encrypted); g_free(encrypted);
} else { } else {
error = true; error = true;
} }

View File

@ -14,6 +14,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <glib.h>
char *split(char *text, char separator) char *split(char *text, char separator)
{ {
int pos = -1; int pos = -1;
@ -67,7 +69,7 @@ int inStr(char *s1, size_t sl1, char *s2)
static char *subString(char *text, int first, int length, int spcKill){ static char *subString(char *text, int first, int length, int spcKill){
//if (DEBUG==1) putlog("creating substring"); //if (DEBUG==1) putlog("creating substring");
char *ret=(char*) calloc (length+1,sizeof(char)); //malloc(sizeof(char)*(length+1)); char *ret = g_new (char, length + 1);
int i; int i;
ret[length]=0; ret[length]=0;
for (i=0;i<length;i++){ for (i=0;i<length;i++){
@ -89,7 +91,7 @@ static char *substring(char *text, int first, int length){return subString(text,
char *readLine(FILE *f){ char *readLine(FILE *f){
//if (DEBUG==1) putlog("reading line from file"); //if (DEBUG==1) putlog("reading line from file");
char *buffer=(char*)calloc(1024,sizeof(char)); //malloc(sizeof(char)*1024); char *buffer = g_new (char, 1024);
int pos=0; int pos=0;
int cc=0; int cc=0;
while((cc!=EOF)&&(pos<1024)&&(cc!=10)){ while((cc!=EOF)&&(pos<1024)&&(cc!=10)){

View File

@ -48,11 +48,19 @@ static int mpc_tell(char *word[], char *word_eol[], void *userdata){
HWND hwnd = FindWindow("MediaPlayerClassicW",NULL); HWND hwnd = FindWindow("MediaPlayerClassicW",NULL);
if (hwnd==0) {hexchat_print(ph, randomLine(notRunTheme));return HEXCHAT_EAT_ALL;} if (hwnd==0) {hexchat_print(ph, randomLine(notRunTheme));return HEXCHAT_EAT_ALL;}
tTitle=(char*)malloc(sizeof(char)*1024); tTitle = g_new(char, 1024);
GetWindowText(hwnd, tTitle, 1024); GetWindowText(hwnd, tTitle, 1024);
zero = strstr (tTitle, " - Media Player Classic"); zero = strstr (tTitle, " - Media Player Classic");
if (zero!=NULL) zero[0]=0; if (zero != NULL)
else hexchat_print(ph,"pattern not found"); {
zero[0] = 0;
}
else
{
g_free(tTitle);
hexchat_print(ph, "pattern not found");
return HEXCHAT_EAT_ALL;
}
if ((tTitle[1]==':')&&(tTitle[2]=='\\')){ if ((tTitle[1]==':')&&(tTitle[2]=='\\')){
//hexchat_print(ph,"seams to be full path"); //hexchat_print(ph,"seams to be full path");
@ -82,6 +90,7 @@ static int mpc_tell(char *word[], char *word_eol[], void *userdata){
//mp3Line=intReplace(mp3Line,"%perc",perc); //mp3Line=intReplace(mp3Line,"%perc",perc);
//mp3Line=replace(mp3Line,"%plTitle",title); //mp3Line=replace(mp3Line,"%plTitle",title);
mp3Line=replace(mp3Line,"%file",tTitle); mp3Line=replace(mp3Line,"%file",tTitle);
g_free(tTitle);
hexchat_command(ph, mp3Line); hexchat_command(ph, mp3Line);
return HEXCHAT_EAT_ALL; return HEXCHAT_EAT_ALL;
} }
@ -111,6 +120,7 @@ static int mpc_tell(char *word[], char *word_eol[], void *userdata){
//oggLine=intReplace(oggLine,"%perc",perc); //oggLine=intReplace(oggLine,"%perc",perc);
//oggLine=replace(oggLine,"%plTitle",title); //oggLine=replace(oggLine,"%plTitle",title);
oggLine=replace(oggLine,"%file",tTitle); oggLine=replace(oggLine,"%file",tTitle);
g_free(tTitle);
hexchat_command(ph, oggLine); hexchat_command(ph, oggLine);
return HEXCHAT_EAT_ALL; return HEXCHAT_EAT_ALL;
} }
@ -118,6 +128,7 @@ static int mpc_tell(char *word[], char *word_eol[], void *userdata){
} }
line=randomLine(titleTheme); line=randomLine(titleTheme);
line=replace(line,"%title", tTitle); line=replace(line,"%title", tTitle);
g_free(tTitle);
hexchat_command(ph, line); hexchat_command(ph, line);
return HEXCHAT_EAT_ALL; return HEXCHAT_EAT_ALL;
} }

View File

@ -63,13 +63,15 @@
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MPCINFO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MPCINFO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\src\common;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>mpcinfo.def</ModuleDefinitionFile> <ModuleDefinitionFile>mpcinfo.def</ModuleDefinitionFile>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
@ -81,13 +83,15 @@
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;MPCINFO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;MPCINFO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\src\common;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>mpcinfo.def</ModuleDefinitionFile> <ModuleDefinitionFile>mpcinfo.def</ModuleDefinitionFile>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>

View File

@ -7,8 +7,8 @@ libdir = $(hexchatlibdir)
lib_LTLIBRARIES = perl.la lib_LTLIBRARIES = perl.la
perl_la_SOURCES = perl.c perl_la_SOURCES = perl.c
perl_la_LDFLAGS = $(PERL_LDFLAGS) $(PLUGIN_LDFLAGS) -module perl_la_LDFLAGS = $(PERL_LDFLAGS) $(PLUGIN_LDFLAGS) -module
perl_la_LIBADD = $(PERL_LIBS) perl_la_LIBADD = $(PERL_LIBS) $(GLIB_LIBS)
perl_la_CFLAGS = $(PERL_CFLAGS) -I$(top_srcdir)/src/common perl_la_CFLAGS = $(PERL_CFLAGS) $(GLIB_CFLAGS) -I$(top_srcdir)/src/common
BUILT_SOURCES = hexchat.pm.h irc.pm.h BUILT_SOURCES = hexchat.pm.h irc.pm.h
CLEANFILES = $(BUILT_SOURCES) CLEANFILES = $(BUILT_SOURCES)

View File

@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -31,8 +33,9 @@
#include <dirent.h> #include <dirent.h>
#endif #endif
#include <glib.h>
#undef PACKAGE #undef PACKAGE
#include "config.h"
#include "hexchat-plugin.h" #include "hexchat-plugin.h"
@ -75,37 +78,26 @@ thread_mbox (char *str)
static void static void
perl_auto_load_from_path (const char *path) perl_auto_load_from_path (const char *path)
{ {
WIN32_FIND_DATA find_data; char *search_path = g_build_filename (path, "*.pl", NULL);
HANDLE find_handle; WIN32_FIND_DATAA find_data;
char *search_path; HANDLE find_handle = FindFirstFileA (search_path, &find_data);
int path_len = strlen (path);
/* +6 for \*.pl and \0 */
search_path = malloc(path_len + 6);
sprintf (search_path, "%s\\*.pl", path);
find_handle = FindFirstFile (search_path, &find_data);
if (find_handle != INVALID_HANDLE_VALUE) if (find_handle != INVALID_HANDLE_VALUE)
{ {
do do
{ {
if (!(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0 && (find_data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0)
||find_data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
{ {
char *full_path = char *full_path = g_build_filename (path, find_data.cFileName, NULL);
malloc (path_len + strlen (find_data.cFileName) + 2);
sprintf (full_path, "%s\\%s", path, find_data.cFileName);
perl_load_file (full_path); perl_load_file (full_path);
free (full_path); g_free (full_path);
} }
} }
while (FindNextFile (find_handle, &find_data) != 0); while (FindNextFileA (find_handle, &find_data) != 0);
FindClose (find_handle); FindClose (find_handle);
} }
free (search_path); g_free (search_path);
} }
#else #else
static void static void
@ -115,14 +107,16 @@ perl_auto_load_from_path (const char *path)
struct dirent *ent; struct dirent *ent;
dir = opendir (path); dir = opendir (path);
if (dir) { if (dir)
while ((ent = readdir (dir))) { {
while ((ent = readdir (dir)))
{
int len = strlen (ent->d_name); int len = strlen (ent->d_name);
if (len > 3 && strcasecmp (".pl", ent->d_name + len - 3) == 0) { if (len > 3 && strcasecmp (".pl", ent->d_name + len - 3) == 0)
char *file = malloc (len + strlen (path) + 2); {
sprintf (file, "%s/%s", path, ent->d_name); char *file = g_build_filename (path, ent->d_name, NULL);
perl_load_file (file); perl_load_file (file);
free (file); g_free (file);
} }
} }
closedir (dir); closedir (dir);
@ -145,31 +139,10 @@ perl_auto_load (void *unused)
/* don't pollute the filesystem with script files, this only causes misuse of the folders /* don't pollute the filesystem with script files, this only causes misuse of the folders
* only use ~/.config/hexchat/addons/ and %APPDATA%\HexChat\addons */ * only use ~/.config/hexchat/addons/ and %APPDATA%\HexChat\addons */
#if 0 sub_dir = g_build_filename (xdir, "addons", NULL);
/* autoload from ~/.config/hexchat/ or %APPDATA%\HexChat\ on win32 */
perl_auto_load_from_path (xdir);
#endif
sub_dir = malloc (strlen (xdir) + 8);
strcpy (sub_dir, xdir);
strcat (sub_dir, "/addons");
perl_auto_load_from_path (sub_dir); perl_auto_load_from_path (sub_dir);
free (sub_dir); g_free (sub_dir);
#if 0
#ifdef WIN32
/* autoload from C:\Program Files\HexChat\plugins\ */
sub_dir = malloc (1025 + 9);
copied = GetModuleFileName( 0, sub_dir, 1024 );
sub_dir[copied] = '\0';
slash = strrchr( sub_dir, '\\' );
if( slash != NULL ) {
*slash = '\0';
}
perl_auto_load_from_path ( strncat (sub_dir, "\\plugins", 9));
free (sub_dir);
#endif
#endif
return 0; return 0;
} }
@ -384,7 +357,7 @@ fd_cb (int fd, int flags, void *userdata)
if (data->userdata) { if (data->userdata) {
SvREFCNT_dec (data->userdata); SvREFCNT_dec (data->userdata);
} }
free (data); g_free (data);
} }
} }
@ -748,7 +721,7 @@ XS (XS_HexChat_send_modes)
if (SvROK (ST (0))) { if (SvROK (ST (0))) {
p_targets = (AV*) SvRV (ST (0)); p_targets = (AV*) SvRV (ST (0));
target_count = av_len (p_targets) + 1; target_count = av_len (p_targets) + 1;
targets = malloc (target_count * sizeof (char *)); targets = g_new (const char *, target_count);
for (i = 0; i < target_count; i++ ) { for (i = 0; i < target_count; i++ ) {
elem = av_fetch (p_targets, i, 0); elem = av_fetch (p_targets, i, 0);
@ -759,13 +732,13 @@ XS (XS_HexChat_send_modes)
} }
} }
} else{ } else{
targets = malloc (sizeof (char *)); targets = g_new (const char *, 1);
targets[0] = SvPV_nolen (ST (0)); targets[0] = SvPV_nolen (ST (0));
target_count = 1; target_count = 1;
} }
if (target_count == 0) { if (target_count == 0) {
free ((char**) targets); g_free ((char**) targets);
XSRETURN_EMPTY; XSRETURN_EMPTY;
} }
@ -777,7 +750,7 @@ XS (XS_HexChat_send_modes)
} }
hexchat_send_modes (ph, targets, target_count, modes_per_line, sign, mode); hexchat_send_modes (ph, targets, target_count, modes_per_line, sign, mode);
free ((char**) targets); g_free ((char**) targets);
} }
} }
static static
@ -895,11 +868,7 @@ XS (XS_HexChat_hook_server)
userdata = ST (3); userdata = ST (3);
package = ST (4); package = ST (4);
data = NULL; data = NULL;
data = malloc (sizeof (HookData)); data = g_new (HookData, 1);
if (data == NULL) {
XSRETURN_UNDEF;
}
data->callback = newSVsv (callback); data->callback = newSVsv (callback);
data->userdata = newSVsv (userdata); data->userdata = newSVsv (userdata);
data->depth = 0; data->depth = 0;
@ -944,11 +913,7 @@ XS (XS_HexChat_hook_command)
package = ST (5); package = ST (5);
data = NULL; data = NULL;
data = malloc (sizeof (HookData)); data = g_new (HookData, 1);
if (data == NULL) {
XSRETURN_UNDEF;
}
data->callback = newSVsv (callback); data->callback = newSVsv (callback);
data->userdata = newSVsv (userdata); data->userdata = newSVsv (userdata);
data->depth = 0; data->depth = 0;
@ -984,11 +949,7 @@ XS (XS_HexChat_hook_print)
userdata = ST (3); userdata = ST (3);
package = ST (4); package = ST (4);
data = malloc (sizeof (HookData)); data = g_new (HookData, 1);
if (data == NULL) {
XSRETURN_UNDEF;
}
data->callback = newSVsv (callback); data->callback = newSVsv (callback);
data->userdata = newSVsv (userdata); data->userdata = newSVsv (userdata);
data->depth = 0; data->depth = 0;
@ -1022,11 +983,7 @@ XS (XS_HexChat_hook_timer)
userdata = ST (2); userdata = ST (2);
package = ST (3); package = ST (3);
data = malloc (sizeof (HookData)); data = g_new (HookData, 1);
if (data == NULL) {
XSRETURN_UNDEF;
}
data->callback = newSVsv (callback); data->callback = newSVsv (callback);
data->userdata = newSVsv (userdata); data->userdata = newSVsv (userdata);
data->ctx = hexchat_get_context (ph); data->ctx = hexchat_get_context (ph);
@ -1076,11 +1033,7 @@ XS (XS_HexChat_hook_fd)
} }
#endif #endif
data = malloc (sizeof (HookData)); data = g_new (HookData, 1);
if (data == NULL) {
XSRETURN_UNDEF;
}
data->callback = newSVsv (callback); data->callback = newSVsv (callback);
data->userdata = newSVsv (userdata); data->userdata = newSVsv (userdata);
data->depth = 0; data->depth = 0;
@ -1120,7 +1073,7 @@ XS (XS_HexChat_unhook)
SvREFCNT_dec (userdata->package); SvREFCNT_dec (userdata->package);
} }
free (userdata); g_free (userdata);
} }
XSRETURN (retCount); XSRETURN (retCount);
} }

View File

@ -62,7 +62,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PERL520_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PERL520_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)..;$(PerlPath)\lib\CORE;$(IntDir);..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)..;$(PerlPath)\lib\CORE;$(IntDir);..\..\src\common;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile> </ClCompile>
<Link> <Link>
@ -70,8 +70,8 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OutDir);$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(PerlLib).lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>$(PerlLib).lib;$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>perl.def</ModuleDefinitionFile> <ModuleDefinitionFile>perl.def</ModuleDefinitionFile>
<DelayLoadDLLs>$(PerlLib).dll;%(DelayLoadDLLs)</DelayLoadDLLs> <DelayLoadDLLs>$(PerlLib).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link> </Link>
@ -91,7 +91,7 @@ move hexchat.pm.h "$(IntDir)"</Command>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;PERL520_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;PERL520_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)..;$(PerlPath)\lib\CORE;$(IntDir);..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)..;$(PerlPath)\lib\CORE;$(IntDir);..\..\src\common;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile> </ClCompile>
<Link> <Link>
@ -99,8 +99,8 @@ move hexchat.pm.h "$(IntDir)"</Command>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OutDir);$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(PerlLib).lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>$(PerlLib).lib;$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>perl.def</ModuleDefinitionFile> <ModuleDefinitionFile>perl.def</ModuleDefinitionFile>
<DelayLoadDLLs>$(PerlLib).dll;%(DelayLoadDLLs)</DelayLoadDLLs> <DelayLoadDLLs>$(PerlLib).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link> </Link>

View File

@ -1407,11 +1407,7 @@ static Hook *
Plugin_AddHook(int type, PyObject *plugin, PyObject *callback, Plugin_AddHook(int type, PyObject *plugin, PyObject *callback,
PyObject *userdata, char *name, void *data) PyObject *userdata, char *name, void *data)
{ {
Hook *hook = (Hook *) g_malloc(sizeof(Hook)); Hook *hook = g_new(Hook, 1);
if (hook == NULL) {
PyErr_NoMemory();
return NULL;
}
hook->type = type; hook->type = type;
hook->plugin = plugin; hook->plugin = plugin;
Py_INCREF(callback); Py_INCREF(callback);
@ -2532,11 +2528,8 @@ IInterp_Exec(char *command)
} }
d = PyModule_GetDict(m); d = PyModule_GetDict(m);
len = strlen(command); len = strlen(command);
buffer = (char *) g_malloc(len+2);
if (buffer == NULL) { buffer = g_malloc(len + 2);
hexchat_print(ph, "Not enough memory for command buffer");
goto fail;
}
memcpy(buffer, command, len); memcpy(buffer, command, len);
buffer[len] = '\n'; buffer[len] = '\n';
buffer[len+1] = 0; buffer[len+1] = 0;

View File

@ -22,6 +22,7 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <unistd.h> #include <unistd.h>
#include <glib.h>
#include "xsys.h" #include "xsys.h"
float percentage(unsigned long long *free, unsigned long long *total) float percentage(unsigned long long *free, unsigned long long *total)
@ -37,7 +38,7 @@ char *pretty_freespace(const char *desc, unsigned long long *free_k, unsigned lo
double free_space, total_space; double free_space, total_space;
free_space = *free_k; free_space = *free_k;
total_space = *total_k; total_space = *total_k;
result = malloc(bsize * sizeof(char)); result = g_new(char, bsize);
if (total_space == 0) if (total_space == 0)
{ {
snprintf(result, bsize, "%s: none", desc); snprintf(result, bsize, "%s: none", desc);

View File

@ -29,6 +29,7 @@
#include <dirent.h> #include <dirent.h>
#include <sys/types.h> #include <sys/types.h>
#include <pci/header.h> #include <pci/header.h>
#include <glib.h>
#include "pci.h" #include "pci.h"
#include "match.h" #include "match.h"
@ -317,13 +318,13 @@ int xs_parse_df(const char *mount_point, char *result)
char *tmp_buf = pretty_freespace(pos, &free_k, &total_k); char *tmp_buf = pretty_freespace(pos, &free_k, &total_k);
strcat(tmp_buf, " | "); strcat(tmp_buf, " | ");
strcat(result, tmp_buf); strcat(result, tmp_buf);
free(tmp_buf); g_free(tmp_buf);
} }
else if(strncmp(mount_point, pos, strlen(mount_point)) == 0) else if(strncmp(mount_point, pos, strlen(mount_point)) == 0)
{ {
char *tmp_buf = pretty_freespace(mount_point, &free_k, &total_k); char *tmp_buf = pretty_freespace(mount_point, &free_k, &total_k);
strncpy(result, tmp_buf, bsize); strncpy(result, tmp_buf, bsize);
free(tmp_buf); g_free(tmp_buf);
break; break;
} }
else snprintf(result, bsize, "Mount point %s not found!", mount_point); else snprintf(result, bsize, "Mount point %s not found!", mount_point);
@ -336,7 +337,7 @@ int xs_parse_df(const char *mount_point, char *result)
{ {
char *tmp_buf = pretty_freespace("Total", &free_k, &total_k); char *tmp_buf = pretty_freespace("Total", &free_k, &total_k);
strncpy(result, tmp_buf, bsize); strncpy(result, tmp_buf, bsize);
free(tmp_buf); g_free(tmp_buf);
} }
pclose(pipe); pclose(pipe);
return 0; return 0;

View File

@ -25,6 +25,8 @@
#include <ctype.h> #include <ctype.h>
#include <unistd.h> #include <unistd.h>
#include <pci/pci.h> #include <pci/pci.h>
#include <glib.h>
#include "xsys.h" #include "xsys.h"
static struct pci_filter filter; /* Device filter */ static struct pci_filter filter; /* Device filter */
@ -47,8 +49,7 @@ static struct device *scan_device(struct pci_dev *p)
if (!pci_filter_match(&filter, p)) if (!pci_filter_match(&filter, p))
return NULL; return NULL;
d = malloc(sizeof(struct device)); d = g_new0 (struct device, 1);
bzero(d, sizeof(*d));
d->dev = p; d->dev = p;
if (!pci_read_block(p, 0, d->config, how_much)) if (!pci_read_block(p, 0, d->config, how_much))
exit(1); exit(1);

View File

@ -162,7 +162,7 @@ print_summary (int announce, char* format)
free_space = pretty_freespace ("Physical", &mem_free, &mem_total); free_space = pretty_freespace ("Physical", &mem_free, &mem_total);
snprintf (buffer, bsize, "%s", free_space); snprintf (buffer, bsize, "%s", free_space);
free (free_space); g_free (free_space);
format_output ("RAM", buffer, format); format_output ("RAM", buffer, format);
strcat (sysinfo, "\017 "); strcat (sysinfo, "\017 ");
strncat (sysinfo, buffer, bsize - strlen (sysinfo)); strncat (sysinfo, buffer, bsize - strlen (sysinfo));