Back to index

php5  5.3.10
uint32.c
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2010 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | Author: Marcus Boerger <helly@php.net>                               |
00016    +----------------------------------------------------------------------+
00017  */
00018 
00019 /* $Id: uint32.c 293036 2010-01-03 09:23:27Z sebastian $ */
00020 
00021 /* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include "config.h"
00025 #endif
00026 
00027 #include "php.h"
00028 
00029 #include "uint32.h"
00030 
00031 /* {{{ uint32_pack */
00032 void uint32_pack(char *out, uint32 in)
00033 {
00034        out[0] = in&0xff; in>>=8;
00035        out[1] = in&0xff; in>>=8;
00036        out[2] = in&0xff; in>>=8;
00037        out[3] = in&0xff;
00038 }
00039 /* }}} */
00040 
00041 /* {{{ uint32_unpack */
00042 void uint32_unpack(const char *in, uint32 *out)
00043 {
00044        *out = (((uint32)(unsigned char)in[3])<<24) |
00045               (((uint32)(unsigned char)in[2])<<16) |
00046               (((uint32)(unsigned char)in[1])<<8) |
00047               (((uint32)(unsigned char)in[0]));
00048 }
00049 /* }}} */