These pages are written by only Japanese.
|
Namazu for hns による簡易全文検索です。 詳細は 詳細指定/ヘルプをご参照下さい。 |
|||||||||||||||||||||||||||||||||||||||||||||
% php get_ftyp_brand.phps test.3g2 MajorBrand: kddi MinorVersion: 0 CompatibleBrand: kddi 3g2a 3gp5 3gp4
% php set_ftyp_brand.phps test.3g2 yoya 1 yoya yoyo yaya yayo \ | fdmp - addr : 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF 0x00000: 0000 0020 6674 7970 796f 7961 0000 0001 ftypyoya 0x00010: 796f 7961 796f 796f 7961 7961 7961 796f yoyayoyoyayayayo 0x00020: 0000 0024 7575 6964 6d76 6d6c a88c 11d4 $uuidmvml需要があるかは分かりませんけど。(´д`)
% png_dump kuriboo4.png png_filename=kuriboo4.png png_buff.data_len=166321 (width, height)=(192,224) bpp=8 color_type=6(RGB_ALPHA) y=0: ffffff(ff) ffffff(ff) ffffff(ff) ffffff(ff) ffffff(ff) <略> e4d23d(3d) e4d23e(3e) e5d13e(3e) e5d23e(3e) e6d23e(3e) e7d33e(3e)ん? ff(ff), 3e(3e)… あーーっ…
case PNG_COLOR_TYPE_RGB_ALPHA: printf("%02x%02x%02x(%02x) ", image_data[y][4*x], image_data[y][4*x+1], image_data[y][4*x+2], image_data[y][4*x+2]);あほでした… 修正っと
% png_dump kuriboo4.png png_filename=kuriboo4.png png_buff.data_len=166321 (width, height)=(192,224) bpp=8 color_type=6(RGB_ALPHA) y=0: ffffff(00) ffffff(00) ffffff(00) ffffff(00) ffffff(00) ffffff(00) fff fff(00) ffffff(00) ffffff(00) ffffff(00) ffffff(00) ffffff(00) ffffff(00)入れ替えたデータ
% png_dump game-78.png png_filename=game-78.png png_buff.data_len=46616 (width, height)=(192,224) bpp=8 color_type=6(RGB_ALPHA) (width, height)=(192,224) bpp=8 color_type=6(RGB_ALPHA) y=0: 9cffff(78) ffffff(00) ffffff(00) ffffff(00) ffffff(00) ffffff(00) fff fff(00) ffffff(00) ffffff(00) ffffff(00) ffffff(00) ffffff(00) ffffff(00)1つ目のpixelだけデータが壊れてました。これがヒントになれば良いのですが…
% wget http://www.skype.com/go/getskype-linux-centos % wget http://gd.tuwien.ac.at/infosys/phone/skype/rpm-public-key.asc % su Password: # rpm --import rpm-public-key.asc # yum -y install skype-2.0.0.72-centos.i586.rpmあとは、xterm 上で
% skype
% su # yum install dbus-devel
% wget http://labs.gree.jp/data/source/php-dbus-0.1.0.tgz % tar xvfz php-dbus-0.1.0.tgz % cd php-dbus-0.1.0 % cd % phpize % ./configure % make % su # make install # vi /etc/php.d/dbus.ini
wget http://labs.gree.jp/data/source/php-skype-0.1.0.tgz tar xvfz php-skype-0.1.0.tgz cd php-skype-0.1.0 cp -r Skype.php Skype /usr/share/pear/.
require_once 'Skype.php'; $skype = new Skype("skype_api_client", Skype::default_protocol, true); for (;;) { $skype->poll(86400); }結果 (X の通信を利用するので Skype を動かした画面上 で xterm を起動して実行。又は、適当な端末上で env DISPLAY=<skype を動かしたホスト>:<skype を動かした画面の番号> としても大丈夫)
% php skype_test.php poll: timeout=86400 PHP Fatal error: Call to a member function poll() on a non-object in /usr/share/pear/Skype.php on line 126クラスインスタンスの $dbus_connection が未定義なのが原因らしい。 見たところ connect がそれっぽい。
require_once 'Skype.php'; $skype = new Skype("skype_api_client", Skype::default_protocol, true); $skype->connect(); for (;;) { $skype->poll(86400); }再チャレンジ (Skype 側に「接続されてます」的なダイアログが出るので、OK を選択する事)
% php skype_test2.php invoke: NAME skype_api_client reply: OK invoke: PROTOCOL 7 reply: PROTOCOL 7 poll: timeout=86400 notify: CONNSTATUS ONLINE notify: CURRENTUSERHANDLE (ログインする時のユーザ名が表示される) notify: USERSTATUS ONLINE poll: timeout=86400それっぽく動いてる感じ。
でDBusConnectionオブジェクトを取得します。$typeには DBUS_BUS_SESSION DBUS_BUS_SYSETM ←☆ SYSTEM ☆ DBUS_BUS_STARTERあと、 ↑これの
require_once 'Skype.php'; $skype = new Skype("skype_api_client", Skype::default_protocol, true); for (;;) { $skype->poll(86400); }このサンプルは、
require_once 'Skype.php'; $skype = new Skype("skype_api_client", Skype::default_protocol, true); $skype->connect(); for (;;) { $skype->poll(86400); }とすれば、そのまま動かせるのでいい感じ。
old_buff = bitstream_buffer(bs2, 0); bitstream_close(bs2); old_size = bitstream_length(bs2); compsize = old_size; // too enough size tmp_buff = malloc(compsize); compress(tmp_buff, &compsize, old_buff, old_size);bitstream_buffer は bitstream の中のデータを覗き見る関数なので、 このタイミングで close しちゃダメです。
old_buff_ref = bitstream_buffer(bs2, 0); old_size = bitstream_length(bs2); compsize = old_size; // too enough size tmp_buff = malloc(compsize); compress(tmp_buff, &compsize, old_buff_ref, old_size); bitstream_putstring(bs, tmp_buff, compsize); bitstream_close(bs2);bitstream_close(bs2) はあと1行上でも良いので、後で書き換えよう。
Lossless 画像データを bitmap 形式 PNG で差し替える際に、 画像データ部にゴミの値が混ざる不具合を修正しました。ごめんなさい。ごめんなさい。ごめんなさい。
* History: * 6 May 94 - Version 1.0 by Eric Raymond.あの 有名な人 かな。同姓同名だよね。きっと。と思ったら、
"Gif compiler,\t\tEric S. Raymond\n\ (C) Copyright 1992 Eric S. Raymond, all rights reserved.\n";ホンモノか。(;゜д゜)
* 26 Jun 96 - Version 3.0 by Eric S. Raymond (Full GIF89 support)なるほど。PNG でかなり貢献してる人ってイメージがあったけど、GIF もそうだったのね。
/******************************************************************* * GifFileType constructor with user supplied input function (TVT) ******************************************************************/ GifFileType * DGifOpen(void *userData, InputFunc readFunc) {
int readFunc(GifFileType* GifFile, GifByteType* buf, int count) { char* ptr = GifFile->UserData; memcpy(buf, ptr, count); GifFile->UserData = ptr + count; return count; }の関数を用意して、
u8 *userData; /* u8 = unsigned char */ GifFileType * GifFile = DGifOpen(userData, readFunc);のように使ってました。
% gcc -W -Wall gif_dump.c -lgif % ./a.out aria.gif gif_filename=aria.gif gif_buff.data_len=24207 (SWidth, SHeight)=(200, 150) SColorResolution=8 SBackGroundColor=0 ColorMapObject: ColorCount=256 BitsPerPixel=8 Colors= (00,00,00) (ff,ff,ff) (96,53,58) (29,1b,1c) (e6,b0,b8) (b2,69,76) (37,26,29) (d6,96,a1) image_count=1 # image no=0 (Left, Top) = (0, 0) (Width, Height) = (200, 150) Interlace=0 No ColorMapそれっぽく dump 出来ました。
GENERAL FILE FORMAT +-----------------------+ | +-------------------+ | | | GIF Signature | | | +-------------------+ | | +-------------------+ | | | Screen Descriptor | | | +-------------------+ | | +-------------------+ | | | Global Color Map | | | +-------------------+ | . . . . . . | +-------------------+ | ---+ | | Image Descriptor | | | | +-------------------+ | | | +-------------------+ | | | | Local Color Map | | |- Repeated 1 to n times | +-------------------+ | | | +-------------------+ | | | | Raster Data | | | | +-------------------+ | ---+ . . . . . . |- GIF Terminator -| +-----------------------+
SCREEN DESCRIPTOR bits 7 6 5 4 3 2 1 0 Byte # +---------------+ | | 1 +-Screen Width -+ Raster width in pixels (LSB first) | | 2 +---------------+ | | 3 +-Screen Height-+ Raster height in pixels (LSB first) | | 4 +-+-----+-+-----+ M = 1, Global color map follows Descriptor |M| cr |0|pixel| 5 cr+1 = # bits of color resolution +-+-----+-+-----+ pixel+1 = # bits/pixel in image | background | 6 background=Color index of screen background +---------------+ (color is defined from the Global color |0 0 0 0 0 0 0 0| 7 map or default map if none specified) +---------------+といった構造になっていて、
SBackGroundColor; /* I hope you understand this one... */となっています。これは何かの挑戦状かと思い調べてみました。
iii) Global Color Table Flag - Flag indicating the presence of a Global Color Table; if the flag is set, the Global Color Table will immediately follow the Logical Screen Descriptor. This flag also selects the interpretation of the Background Color Index; if the flag is set, the value of the Background Color Index field should be used as the table index of the background color. (This field is the most significant bit of the byte.) Values : 0 - No Global Color Table follows, the Background Color Index field is meaningless. 1 - A Global Color Table will immediately follow, the Background Color Index field is meaningful.つまり BackGroundIndexColor のフィールドと別に、 そのフィールドの値が意味のあるものかを示すフラグが Global Color Table Flag に入っています。
DGifGetScreenDesc(GifFileType * GifFile) { <↓特に if 文とか無しで> GifFile->SBackGroundColor = Buf[1];ダメじゃん… ('A`)
<Packed Fields> = Global Color Table Flag 1 Bit Color Resolution 3 Bits Sort Flag 1 Bit Size of Global Color Table 3 Bits <略> 3 x 2^(Size of Global Color Table+1).2 のべき乗で表現しているので、例えば 33 個色を使う場合は 64 個の表を作って そのうちの33個を実際に利用し、残り31個はダミーを埋めて置くしかない。
% cd example % php skype_bot.php PHP Fatal error: Uncaught exception 'Exception' with message 'plugin file not found [Skype/Bot/Plugin/Log.php]' in /usr/share/pear/Skype/Bot.php:54 Stack trace: #0 /home/yoya/src/php/php-skype-0.1.0/example/skype_bot.php(14): Skype_Bot->loadPlugin('log', Array) #1 {main} thrown in /usr/share/pear/Skype/Bot.php on line 54えーっと…
51 if (class_exists($klass) == false) { 52 $path = sprintf("Skype/Bot/Plugin/%s.php", ucfirst(strtolower($plugin_id))); 53 if (is_readable($path) == false) { 54 throw new Exception(sprintf("plugin file not found [%s]", $path)); 55 } 56 require_once($path); 57 }あー。Skype.php と同じディレクトリ上で実行する前提なのね。
% php skype_bot.php invoke: NAME skype_bot動いt…
% php skype_bot.php invoke: NAME skype_bot PHP Warning: dbusconnection::sendwithreplyandblock(): dbus_connection_send_with_reply_and_block() failed (Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.) in /usr/share/pear/Skype.php on line 106 PHP Fatal error: Uncaught exception 'Exception' with message 'dbus_connection_send_with_reply_and_block() failed' in /usr/share/pear/Skype.php:108 Stack trace: #0 /usr/share/pear/Skype.php(85): Skype->invoke('NAME skype_bot', -1) #1 /usr/share/pear/Skype/Bot.php(89): Skype->connect() #2 /usr/share/pear/Skype/Bot.php(32): Skype_Bot->_startup() #3 /home/yoya/src/php/php-skype-0.1.0/example/skype_bot.php(16): Skype_Bot->run() #4 {main} thrown in /usr/share/pear/Skype.php on line 108試しに、"skype_bot" を "skype_api_client" に変えたら
% php skype_bot.php invoke: NAME skype_api_client reply: OK invoke: PROTOCOL 7 reply: PROTOCOL 7 <色々沢山>あ…
他のプログラムが Skype の使用を希望しています プログラム "skype_bot" が Skype への接続を試みています。 許可しますか? [ ] この選択を記憶する [ はい ] [ いいえ ]といったプロンプトが出るので、これに OK しないと接続失敗します。(当たり前)
$bot = new Skype_Bot("skype_bot", false);でも、今まで通り debug っぽいメッセージが沢山出てきます。
class Skype_Bot { public function __construct($id, $debug = false) { $this->debug = $debug; $this->skype = new Skype($id, Skype::default_protocol, $debug); }ふむ。
class Skype { public function __construct($id, $protocol = self::default_protocol, $debug = false) { $this->id = $id; $this->protocol = intval($protocol); $this->debug = $debug;ふむふむ。
public function invoke($s) { <略> $this->_debug("invoke: %s\n", $s);ふむふむふむ。
protected function _debug($format) { $args = func_get_args(); array_shift($args); vprintf($format, $args); }… (゜Д゜)!
protected function _debug($format) { if (! $this->debug) { return ; } $args = func_get_args(); array_shift($args); vprintf($format, $args);↑こんな感じに書き換えとこっ。(実際は行数を変えないように汚い書き方してるけど)
% php skype_bot.php exception 'Exception' with message 'unsupported property [DIALOG_PARTNER]' in /usr/share/pear/Skype/Object.php:68 Stack trace: #0 /usr/share/pear/Skype.php(226): Skype_Object->set('DIALOG_PARTNER', 'yoya_test') #1 /usr/share/pear/Skype.php(139): Skype->handleChat('#yoya_test/$y...') #2 [internal function]: Skype->callback(Object(dbusmessage)) #3 /usr/share/pear/Skype.php(126): dbusconnection->poll(86400) #4 /usr/share/pear/Skype/Bot.php(36): Skype->poll(86400) #5 /home/yoya/lang/php/skype_bot.php(16): Skype_Bot->run() #6 {main}(⊃д⊂)
2008/09/17 02:51:52 [SAID] よや@test(yoya_test) テスト知らないメッセージも(利用できるかは別として)とりあえず受け取れるようにはして、 更に、そのメッセージの対処コードを追加すると良さそうですが、 もう眠いので、今日はここまでで… Zzz
protected $property_def_list = array( <略> // and more... 'DIALOG_PARTNER' => array( 'default' => true, 'type' => Skype::property_type_string, ),
% php skype_bot.php exception 'Exception' with message 'unsupported property [MYROLE]' in /usr/share/pear/Skype/Object.php:68 Stack trace: #0 /usr/share/pear/Skype.php(226): Skype_Object->set('MYROLE', 'USER') #1 /usr/share/pear/Skype.php(139): Skype->handleChat('#yoya_test/$y...') #2 [internal function]: Skype->callback(Object(dbusmessage)) #3 /usr/share/pear/Skype.php(126): dbusconnection->poll(86400) #4 /usr/share/pear/Skype/Bot.php(36): Skype->poll(86400) #5 /home/yoya/lang/php/skype_bot.php(16): Skype_Bot->run() #6 {main}ふむ。MYROLL も追加と。
// and more... 'DIALOG_PARTNER' => array( 'default' => true, 'type' => Skype::property_type_string, ), 'MYROLE' => array( 'default' => true, 'type' => Skype::property_type_string, ), );とりあえず、安定して動くようになりました。(*'ω'*)
(php skype_bot.php >& ~/log/skype/log.txt ) & [1]+ Exit 255 ( php skype_bot.php >&~/log/skype/log.txt )あれれ…
PHP Fatal error: Uncaught exception 'Exception' with message 'parameter [dir] s eems to be invalid or not set' in /usr/share/pear/Skype/Bot/Plugin/Log.php:26 Stack trace: #0 /usr/share/pear/Skype/Bot.php(62): Skype_Bot_Plugin_Log->__construct(Object(S kype_Bot), Array) #1 home/yoya/lang/php/skype_bot.php(15): Skype_Bot->loadPlugin('log', Array ) #2 {main} thrown in /usr/share/pear/Skype/Bot/Plugin/Log.php on line 26うわーぃ。~/log/skype を指定したけど ~ はダメか。
$bot->loadPlugin( "log", array( 'dir' => '~/log/skype', 'chat_topic_filter' => null, 'chat_id_filter' => null, ));/home/yoya/log/skype のように絶対パス指定にしとこう。
'dir' => '/home/yoya/log/skype',常駐成功と♪