Skip to content

Instantly share code, notes, and snippets.

View madx's full-sized avatar

François Vaux madx

View GitHub Profile
@madx
madx / dexp.rb
Created January 5, 2011 15:13
Dice rolling expressions in Ruby w/ Treetop
require 'forwardable'
module Dexp
class Roll
attr_reader :count, :sides, :modifier
def initialize(count, sides, modifier)
@count, @sides, @modifier = count, sides, modifier
end
void ui_run_algorithm (Ui *u) {
GPtrArray *A = u->polys[0],
*B = u->polys[1],
*Conv;
GdkPoint *a, *b, *c, *ap, *bp,
p, q;
guint i, j;
reorder (A);
reorder (B);
#ifndef NETKIT_H_
#define NETKIT_H_
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
void print_fat() {
TBLOCK b,ib;
int adr;
int i, k;
read_block(ADR_BLOCK_DEF, &b.data);
adr = b.super.adr_dir;
read_block(adr, &b.data);
if (!fat.in_memory)
/* 1ère exécution */
== Listing du disque
34 essai.txt 156o
=> 987 blocs libres
== essai.txt:
"Ceci est un petit texte qui occupe
void sgf_remove(int inode) {
TBLOCK b;
int adr, i;
read_block (inode, &b.data);
/* Effacement en chaîne si le fichier est sur plusieurs blocs */
if (b.inode.first != FAT_EOF) {
int cur, next;
cur = get_fat(b.inode.first);
void sgf_read_bloc(OFILE* file, int nubloc) {
int adr = file->first,
nb_bloc, init, i;
nb_bloc = ((file->length + BLOCK_SIZE - 1) / BLOCK_SIZE);
if (nubloc < 0) panic ("Numéro de bloc <= 0");
if (nubloc > nb_bloc) panic ("Numéro de block > nb de blocs");
adr = (file->memo != -1) ? file->memo : file->first;
void sgf_append_block(OFILE* file) {
TBLOCK b;
int adr;
adr = alloc_block ();
if (adr <= 0) panic ("Disque plein");
set_fat (adr, FAT_EOF);
080495b0 <sgf_remove>:
80495b0: 55 push %ebp
80495b1: 89 e5 mov %esp,%ebp
80495b3: 81 ec 98 00 00 00 sub $0x98,%esp
80495b9: 8d 85 78 ff ff ff lea -0x88(%ebp),%eax
80495bf: 89 44 24 04 mov %eax,0x4(%esp)
80495c3: 8b 45 08 mov 0x8(%ebp),%eax
80495c6: 89 04 24 mov %eax,(%esp)
80495c9: e8 6e f4 ff ff call 8048a3c <read_block>
80495ce: c7 44 24 04 ff ff ff movl $0xffffffff,0x4(%esp)
void sgf_putc(OFILE* file, char c) {
assert (file->mode == WRITE_MODE);
if ((file->ptr != 0) && ((file->ptr % BLOCK_SIZE) == 0)) {
sgf_append_block (file);
}
file->buffer[ (file->ptr % BLOCK_SIZE) ] = c;
file->ptr++;
}