Skip to content

Instantly share code, notes, and snippets.

View sajattack's full-sized avatar

Paul Sajna sajattack

View GitHub Profile
@sajattack
sajattack / rlb.rs
Last active November 22, 2017 19:05
extern crate libc;
extern crate core;
use core::mem;
use core::ptr;
use core::ptr::null_mut;
use core::str;
/// Implements an `Iterator` which returns on either newline or EOF.
pub struct RawLineBuffer {
libc_fn!(unsafe gethostent() -> Result<*const hostent> {
if hostdb == 0 {
hostdb = syscall::open("/etc/hosts", syscall::O_RDONLY).unwrap();
}
let mut line = RawLineBuffer::new(hostdb);
let mut host_aliases: [*const u8; MAXALIASES] = [0 as *const u8; MAXALIASES];
let hostaddr: [usize; (MAXADDRS+mem::size_of::<u64>()-1)/mem::size_of::<u64>()] = [0; (MAXADDRS+mem::size_of::<u64>()-1)/mem::size_of::<u64>()];
let mut host_addrs: [*mut libc::c_char;2] = [0 as *mut libc::c_char; 2];
libc_fn!(unsafe getprotoent() -> Result <*const protoent> {
if protodb == 0 {
protodb = syscall::open("/etc/protocols", syscall::O_RDONLY).unwrap();
LINE = RawLineBuffer::new(protodb);
}
let mut r = match LINE.next() {
Some(Ok(s)) => s,
Some(Err(_)) => panic!(),
None => panic!()
unsafe fn lookup_addr(addr: *const in_addr) -> Result<LookupAddr> {
// XXX better error handling
let ip_string = String::from_utf8(::file_read_all("/etc/net/ip")?).or(Err(
Error::new(syscall::EIO),
))?;
let ip: Vec<u8> = ip_string
.trim()
.split(".")
.map(|part| part.parse::<u8>().unwrap_or(0))
.collect();
.C:0810 00 BRK
.C:0811 28 PLP
.C:0812 50 78 BVC $088C
.C:0814 A0 C8 LDY #$C8
.C:0816 F0 18 BEQ $0830
.C:0818 40 RTI
.C:0819 68 PLA
.C:081a 90 B8 BCC $07D4
.C:081c E0 08 CPX #$08
.C:081e 30 58 BMI $0878
extern "C" {
pub fn access(arg1: *const libc::c_char,
arg2: libc::c_int) -> libc::c_int;
}
extern "C" {
pub fn alarm(arg1: libc::c_uint) -> libc::c_uint;
}
extern "C" {
pub fn brk(arg1: *mut libc::c_void) -> libc::c_int;
}
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by TiMidity++ configure 2.14.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure --host=x86_64-unknown-redox --prefix=
## --------- ##
## Platform. ##
@sajattack
sajattack / swap.sh
Last active October 15, 2018 06:25
fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstab
@sajattack
sajattack / dma.c
Last active November 5, 2018 19:16
ASF4 DMA Library for SAM0
/*
* \file
*
* \brief SAM Direct Memory Access Controller Driver
*
* Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
*
* \asf_license_start
*
* \page License
#[path = "../../utils.rs"]
mod utils;
use crate::utils::*;
use std::boxed::Box;
use std::collections::HashMap;
fn main() {
let input: String = get_input(6).expect("Failed to retrieve input");