The line log_finer("Random bytes: %s", rand);
tries to print "rand" as if it were a null-terminated string, which it isn't. Anyway, since rand might contain non-printable characters, a better method of printing would be:
log_finer("Random bytes: %0X %0X %0X %0X", rand[0], rand[1], rand[2], rand[3] );
Regards, Thilo Stapff Axton wrote:
I know this is not the right forum, but you are the people I know. I am working on an arfilter plug-in and have a question about C. The plug-in I am writing randomly returns true or false based on a probability (e.g., 1 in 10 chance T is returned). The output from the plug-in shows the following: <ARSWIKI.ARF.PRNG> <INFO> ARFilterApiCall called by user Demo <ARSWIKI.ARF.PRNG> <FINER> Random bytes: i{¤ïÓÅ <ARSWIKI.ARF.PRNG> <FINEST> character 0: <ARSWIKI.ARF.PRNG> <FINER> int val of char 0: 134 <ARSWIKI.ARF.PRNG> <FINEST> bit offset: 0 <ARSWIKI.ARF.PRNG> <FINEST> after bit offset: 134 <ARSWIKI.ARF.PRNG> <FINEST> character 1: i <ARSWIKI.ARF.PRNG> <FINER> int val of char 1: 105 <ARSWIKI.ARF.PRNG> <FINEST> bit offset: 8 <ARSWIKI.ARF.PRNG> <FINEST> after bit offset: 26880 <ARSWIKI.ARF.PRNG> <FINEST> character 2: { <ARSWIKI.ARF.PRNG> <FINER> int val of char 2: 123 <ARSWIKI.ARF.PRNG> <FINEST> bit offset: 16 <ARSWIKI.ARF.PRNG> <FINEST> after bit offset: 8060928 <ARSWIKI.ARF.PRNG> <FINEST> character 3: ¤ <ARSWIKI.ARF.PRNG> <FINER> int val of char 3: 164 <ARSWIKI.ARF.PRNG> <FINEST> bit offset: 24 <ARSWIKI.ARF.PRNG> <FINEST> after bit offset: 2751463424 <ARSWIKI.ARF.PRNG> <FINE> Random 32-bit int: 2894948742 <ARSWIKI.ARF.PRNG> <INFO> Received value: 2 <ARSWIKI.ARF.PRNG> <INFO> Return Value: 1 The Random bytes line should contain 4 bytes of data, but for some reason it returns between 4 and 8 bytes. The sources that retrive and log the value are available at: http://arswiki.org/projects/arfprng/browser/trunk/lib/arfprng.c#L241 The program seems to work fine, but it worries me that I seem to be reading memory I shouldn't be. Any help is appreciated. fwiw, the plug-in functions properly on linux, though there are a few things I need to clean up before I consider it production worthy (e.g., handling text values, handling zero as an input value, breaking the code into functions, etc.). Main Page: http://arswiki.org/projects/arfprng As a partial side note, I installed the Doxygen plug-in for Trac; the doxygen docs are available within the project web page. As another side note; there seem to be some undocumented functions available that are exposed through ARPluginSetProperties: AR_PLUGIN_PROP_LOG_FUNCTION AR_PLUGIN_PROP_INSTALL_DIR AR_PLUGIN_PROP_CONFIG_FILE AR_PLUGIN_PROP_GETUSER_FUNCTION AR_PLUGIN_PROP_GETAUTHSTRING_FUNCTION AR_PLUGIN_PROP_GETUSERAUTHINFO_FUNCTION AR_PLUGIN_PROP_REGISTERSIGNALHANDLER_FUNCTION AR_PLUGIN_PROP_INITTLS_FUNCTION Wondering if anyone had experimented with these and could share their comments. Axton Grams _______________________________________________________________________________ UNSUBSCRIBE or access ARSlist Archives at www.arslist.org ARSlist:"Where the Answers Are"
_______________________________________________________________________________ UNSUBSCRIBE or access ARSlist Archives at www.arslist.org ARSlist:"Where the Answers Are"