RSS view

 

Sample code is good. It's often more useful to read some sample code that page endlessly through documentation. We're hoping to build up a repository of code that may be fully fledged applications or just a short function, all available for use in your projects with no ties!

Presently we have the following pieces of sample code available...

 

Title Description Options
binimg Shows any binary file as 8 or 32 bpp picture, you can change the picture size, byte offset, page up/down... View
Download ( 3793 bytes)
connect_test.c Simple little test app that tries to connect to www.google.com on port 80 to test if the internet is still switched on. Written in response to questions and a request on irc #beclan :-) View
Download ( 1480 bytes)
dpms CLI roster This is a simple CLI tool to use the DPMS API to force monitor shutdown or query the DPMS capabilities. View
Download ( 1482 bytes)
DrawCentredText.cpp Draws centred text into a BRect on a BView using DrawString, resizing or chopping the text as required. View
Download ( 2583 bytes)
keep_module.c This is a small kernel driver who's aim is to keep a module referenced and therefore kept loaded, even if the B_KEEP_LOADED flag isn't specified for that module.
It's mainly of interest to developers who are working on kernel modules :)
NB don't add the code to open this in the std_ops function or you'll end up in an endless loop!
View
Download ( 3924 bytes)
listfonts This CLI tool list installed fonts and their properties. Also demonstrates how to get a BApplication object Run()ed while leaving the main thread for other purposes. View
Download ( 1826 bytes)
list_test.cpp A small app that shows how to sort an stl::list on a member of a user defined class. View
Download ( 1502 bytes)
signal_test A question came up on #beclan about using a -ve thread id to change how signals are delivered. This looked like an attempt to copy the unix behaviour where using a -pid will deliver the signal to all other processes in the group. Being a little unsure I wrote this simple test app and added a function that mimics that behaviour. View
Download ( 2224 bytes)
stat.c stat() a file and print the result. This code shows what kind of information you can find about files using the stat() call. View
Download ( 2661 bytes)
test-getaddrinfo.c getaddrinfo is a resolving function that is usable over a wide range of protocols (it should supports IPv6) that is being introduced. Be thoughfully included it in their BONE networking but there are a couple of problems with the actual implenetation as this small app shows. (Should build on most unix's) View
Download ( 2457 bytes)
test-getservbyname.c Simple test app that allows the implementation of getservbyname to be checked. View
Download ( 2122 bytes)
testfork.c fork() on BeOS doesn't work with the concept of areas for shared memory. This illustrates the problem. View
Download ( 1931 bytes)