This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' This is file libzib-0.9.3_TJF.bi. | |
' | |
' FreeBasic-Header file for libzip, translated with help of h_2_bi.bas by | |
' [email protected]. | |
' | |
' Licence: | |
' | |
' libzib-0.9.3_TJF.bi is free software: you can redistribute it and/or modify | |
' it under the terms of the GNU General Public License as published by the | |
' Free Software Foundation, either version 3 of the License, or (at your |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include once "crt.bi" | |
#undef Rem | |
#define Rem | |
Dim Shared As Integer CHAR_DBLQUOTE = 34 | |
Dim Shared As Integer SYM_BAD = 0 | |
Dim Shared As Integer SYM_DATATYPE = 1 | |
Dim Shared As Integer SYM_VAR = 2 | |
Dim Shared As Integer SYM_PROC = 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'' Simple prime sieve written in FreeBASIC. Compiles a table of all the primes under 2^32 (configurable). | |
'' It outputs the number of primes found (should be 203280221 under 2^32), and the time it took (roughly 2-3 mins on my old-ish PC). | |
'' It uses around 512 MB of memory (one bit for each odd number in the range). | |
#define MAX 4294967295 | |
type LUT_INT as uinteger | |
#ASSERT cast(LUT_INT, MAX) = MAX |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ext2scan: | |
* Scans an input stream, sector by sector, for something that looks like an ext{2,3,4} partition. | |
* It does this by looking for a magic WORD, 0xEF53, at a known offset into the sector. | |
* For random data, this will occur by chance around once per 32MB of data, so we also | |
* check whether the first two sectors are all zeros, which is commonly true for ext partitions. | |
* | |
* Compile with: | |
* gcc ./ext2scan.c -o ./ext2scan | |
* | |
* Example usage: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'' FreeBASIC has a number of pseudorandom algorithms: set the QB algorithm (4) | |
randomize 0, 4 | |
function unrnd(byval r as double) as long | |
#define SEED2R(seed) ( ((seed) + ((seed) shr 24)) and &HFFFFFF ) | |
'' accept [0,1) or [0,16777215] | |
if r > 0.0 and r < 1.0 then | |
r = int(r * 16777216) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'' FT = full type (doesn't always exist) | |
'' HT = half type (make up the two halves of the number) | |
'' QT = quarter type (used for multiplication) | |
'' 32 / 16 / 8 | |
'type FT as ulong | |
'type HT as ushort | |
'type QT as ubyte | |
'' 64 / 32 / 16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h3>This article has been tested for the following Ubuntu versions:</h3> | |
<p> </p> | |
<ul> | |
<li> | |
<p><a href="https://wiki.ubuntuusers.de/Trusty_Tahr/">Ubuntu 14.04</a> Trusty Tahr</p> | |
</li> | |
<li> | |
<p><a href="https://wiki.ubuntuusers.de/Precise_Pangolin/">Ubuntu 12.04</a> Precise Pangolin</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "inflate.h" | |
int inflate(char *output, int *output_length, const char *input, int input_length) { | |
final_block = 0; | |
do { | |
get_block_type(); | |
switch(block_type) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void lngcpy(unsigned char *dst, int dst_length, unsigned char *const src, int src_length) { | |
if (dst_length <= src_length) { | |
memcpy(dst, src, dst_length); | |
} else { | |
/* src_length < dst_length */ | |
memcpy(dst, src, src_length); | |
memset(dst + src_length, 0, dst_length - src_length); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Game: given four different items, try to put them in order. | |
With each try, a number is returned indicating how many items are in their correct position. (As in a recent Crystal Maze game) | |
Challenge: find a strategy that minimises the (worst-case) number of moves needed to guess the order. | |
*/ | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
typedef unsigned char move_count; |
OlderNewer