These pages are written by only Japanese.
|
Namazu for hns による簡易全文検索です。 詳細は 詳細指定/ヘルプをご参照下さい。 |
|||||||||||||||||||||||||||||||||||||||||||||
<?php $width = 8; $height = 8; $im = imagecreatetruecolor($width, $height); /* bitmap */ // $im = imagecreate($width, $height); /* palette */ $colors = array(); $colors []= imagecolorallocate($im, 255, 0, 0); // red $colors []= imagecolorallocate($im, 0, 255, 0); // green $colors []= imagecolorallocate($im, 0, 0, 255); // blue $colors []= imagecolorallocate($im, 255,255,0); // yellow for ($y=0 ; $y < $height ; $y++) { for ($x=0 ; $x < $width ; $x++) { $i = ($x + $y * $width) % 4; imagesetpixel($im, $x, $y, $colors[$i]); } } header("Content-type: image/png"); imagepng($im);
% ./a.out ~/lang/php/16x16palette.png png_filename=/home/yoya/lang/php/16x16palette.png png_buff.data_len=94 (width, height)=(8,8) bpp=2 color_type=3(PALETTE) palette_num=4 y=0: 1b 1b 24 00 80 11 24 00 y=1: 1b 1b 00 00 00 00 00 00 y=2: 1b 1b 00 00 00 00 00 00 y=3: 1b 1b 00 00 00 00 00 00 y=4: 1b 1b 00 00 00 00 00 00 y=5: 1b 1b 00 00 00 00 00 00 y=6: 1b 1b 00 00 00 00 00 00 y=7: 1b 1b 00 00 00 00 00 00ナルホド。
1b = 00011011 = 00 01 10 11 = 0 1 2 3って事か。
for (y=0; y < png_height; y++) { unsigned char *linedata = image_data[y]; bitstream_t *bs = bitstream_open(); bitstream_input(bs, linedata, png_get_rowbytes(png_ptr, png_info)); printf("y=%lu: ", y); for (x=0; x < png_width; x++) { int colorindex = bitstream_getbits(bs, bpp); printf("%02x ", colorindex); } bitstream_close(bs); printf("\n"); }実行結果
% ./a.out 16x16palette.png png_filename=16x16palette.png png_buff.data_len=94 (width, height)=(8,8) bpp=2 color_type=3(PALETTE) palette_num=4 y=0: 00 01 02 03 00 01 02 03 y=1: 00 01 02 03 00 01 02 03 y=2: 00 01 02 03 00 01 02 03 y=3: 00 01 02 03 00 01 02 03 y=4: 00 01 02 03 00 01 02 03 y=5: 00 01 02 03 00 01 02 03 y=6: 00 01 02 03 00 01 02 03 y=7: 00 01 02 03 00 01 02 03よし、完璧。(゜∇゜) コンパイル方法
% gcc -Wall -W png_dump.c -lpng bitstream.c使い方は上の通り。
% php sample/swfdump.phps bitmap.swf magic=FWS version=4 file_length=209 rect=(0, 0)-(240, 350) (f_size=14) frame_rate=12.0 frame_count=1 [0] tag=SetBackgroundColor(9) length=3 [1] tag=DefineBitsLossless(20) length=30 swf_tag_lossless_create_detail: indices_len != origsize - 4 * swf_tag_lossless->colormap_count at line(62) can't create tag detail (tag=20) swf_tag_lossless_print_detail: detail == NULL [2] tag=DefineBitsLossless(20) length=29 image_id=2 format=5 width=8 height=8 xrgb bitmap exists [3] tag=DefineShape2(22) length=95 [4] tag=PlaceObject2(26) length=6 [5] tag=ShowFrame(1) [6] tag=End(0)
% php sample/swfdump.phps bitmap.swf magic=FWS version=4 file_length=209 rect=(0, 0)-(240, 350) (f_size=14) frame_rate=12.0 frame_count=1 [0] tag=SetBackgroundColor(9) length=3 [1] tag=DefineBitsLossless(20) length=30 image_id=1 format=3 width=8 height=8 colormap_count=4 rgb colormap exists indices exists [2] tag=DefineBitsLossless(20) length=29 image_id=2 format=5 width=8 height=8 xrgb bitmap exists [3] tag=DefineShape2(22) length=95 [4] tag=PlaceObject2(26) length=6 [5] tag=ShowFrame(1) [6] tag=End(0)
% php sample/swfgetpngdata.phps bitmap.swf 1 > 1.png % php sample/swfgetpngdata.phps bitmap.swf 2 > 2.png % png_dump 1.png png_filename=1.png png_buff.data_len=119 (width, height)=(8,8) bpp=8 color_type=3(PALETTE) palette_num=4 y=0: 00 01 02 03 00 01 02 03 y=1: 00 01 02 03 00 01 02 03 y=2: 00 01 02 03 00 01 02 03 y=3: 00 01 02 03 00 01 02 03 y=4: 00 01 02 03 00 01 02 03 y=5: 00 01 02 03 00 01 02 03 y=6: 00 01 02 03 00 01 02 03 y=7: 00 01 02 03 00 01 02 03 % png_dump 2.png png_filename=2.png png_buff.data_len=103 (width, height)=(8,8) bpp=8 color_type=2(RGB) y=0: ff0000 00ff00 0000ff ffff00 ff0000 00ff00 0000ff ffff00 y=1: ff0000 00ff00 0000ff ffff00 ff0000 00ff00 0000ff ffff00 y=2: ff0000 00ff00 0000ff ffff00 ff0000 00ff00 0000ff ffff00 y=3: ff0000 00ff00 0000ff ffff00 ff0000 00ff00 0000ff ffff00 y=4: ff0000 00ff00 0000ff ffff00 ff0000 00ff00 0000ff ffff00 y=5: ff0000 00ff00 0000ff ffff00 ff0000 00ff00 0000ff ffff00 y=6: ff0000 00ff00 0000ff ffff00 ff0000 00ff00 0000ff ffff00 y=7: ff0000 00ff00 0000ff ffff00 ff0000 00ff00 0000ff ffff00問題なし。
[4] tag=DefineSound(14) length=2505 sound_id=1 format=2(MP3) rate=1 is_16bits=1 is_stereo=0 samples_count=11019 sound_data(length=2498)
mp3_filename=../game-1.mp3 mp3_data_len=2498 sync_word=0x7ff version=0 layer=1 no_protection=1 bit_rate=2 sample_rate=0 padding=0 reserved=0 channel_mode=3 mode_extension=0 copyright=0 original=0 emphasis=0 ---- sync_word=0x7ff version=2 layer=2 <略>試しに sync word を scan してみたところ、 一個目の header は正しく抽出されてそう *1 ですが、2つ目以降はボロボロ。
while (mp3_dump_frame(bs)) { // bitstream_incrpos(bs, 97, 0); // NG bitstream_incrpos(bs, 98, 0); // OK // bitstream_incrpos(bs, 100, 0); // OK }実行結果
% ./a.out ../game-1.mp3 | grep version=0 | wc bitstream_getbit: bs->data_len(2498) <= bs->byte_offset(2498) 24 24 240bitstream_getbit の警告は bitstream.c 側の問題なのでご容赦を。(⊃д⊂)
witch(fr->lay) case 1: fr->framesize = (long) tabsel_123[fr->lsf][0][fr->bitrate_index] * 12000; fr->framesize /= freqs[fr->sampling_frequency]; fr->framesize = ((fr->framesize+fr->padding)<<2)-4; fr->down_sample=0; fr->down_sample_sblimit = SBLIMIT>>(fr->down_sample); break; case 2: fr->framesize = (long) tabsel_123[fr->lsf][1][fr->bitrate_index] * 144000; fr->framesize /= freqs[fr->sampling_frequency]; fr->framesize += fr->padding - 4; fr->down_sample=0; fr->down_sample_sblimit = SBLIMIT>>(fr->down_sample); break; case 3: <略>なんだか、面倒そうなのでやっぱり自前はやめて mpglib を利用する事にします。(´Д`;)
struct buf { unsigned char *pnt; long size; long pos; struct buf *next; struct buf *prev; }; struct framebuf { struct buf *buf; long pos; struct frame *next; struct frame *prev; };あれ?
typedef struct mpstr_tag { <略> struct frame fr; /* holds the parameters decoded from the header */むむむ…
struct frame { int stereo; int jsbound; int single; <略> int bitrate_index; <略> int framesize; /* computed framesize */まさしく欲しいデータ構造がそのまま定義されてます。
% gcc lame_test.c -L/usr/local/lib -lmp3lame $ env LD_LIBRARY_PATH=/usr/local/lib ./a.out game-1.mp3何となく使い方は分かってきたけど、残念ながら frame header chain を作る API が見つからず。うーむ。
sql> CREATE DATABASE pxidb
% cat pxidb.sql | mysql -h <秘密のIP> pxidb -u pxi -p
127.0.0.1 ffxi00.pol.com
127.0.0.1 ffxi00.pol.com
問題が発生したため、pXI-Server-0.6.1.exe を終了します。 ご不便をおかけして申し訳ありません。○rz
WTF?? Did not find a match?!?!やっぱりダメか… ○rz
if((CGlobal::connectList.size() > 0)) { for(i = (CGlobal::connectList.size()-1); i >= 0; i--) { //Does the IP match and is the RecvKey free? if ((r.ip == CGlobal::connectList.at(i).ip) && (CGlobal::connectList.at(i).s == 0)) { //We found the RecvKey we were looking for!! CConsole::outTime("Found it"); break; } } } else { //We don't have a list........ CConsole::outTime("WTF??"); } //Confirm we are within range and it is valid if (i < CGlobal::connectList.size()){ //Store the newly made socket into the connectList CGlobal::connectList.at(i).s = r.s; CGlobal::connectList.at(i).out = ListenSocket2; mysql_thread_init(); //Run the PolLobbyComm thread CreateThread(0,0,PolLobbyComm,&CGlobal::connectList.at(i),0,0); } else { //How did we not find a match? :( CConsole::outTime("Did not find a match?!?!"); }この connectList に追加する部分は
DWORD WINAPI LobbyServ(LPVOID lpParam) { <略> while(1) { size = sizeof(ip); r->out = 0; //Listens for our client to connect r->s1 = accept(ListenSocket, (struct sockaddr *)&ip, &size); if (r->s1 == INVALID_SOCKET) { closesocket(ListenSocket); CConsole::outErr("accept failed: %d\n", WSAGetLastError()); WSACleanup(); return 1; } //Find the IP address of the client that connected to us r->ip = ip.sin_addr.S_un.S_addr; r->s = 0; //Push the client onto our list CGlobal::connectList.push_back(*r); }どうも、 54001 の前に 54230 のメッセージを受け取らないといけないのに、 54230 のメッセージが届いてないので、そんなの知らないって言われてそう。 きっと、54230 の thread が落ちてるんだろうなぁ… *1
o @zone - instantly zone yourself to a specified location (e.g. "@zone 0xZZ"). o @additem - puts an item of your choice in your inventory (e.g. "@additem 0xZZZZ"). o @pos - teleport your character to a given position (e.g. "@pos 1 2 3"). o @posr- changes your position relative to your current position (e.g. "@posr 0 2 0"). o @inject - load a packet to be sent to the client (e.g. "@inject packet.dat"). o @debug - print your characters charid and targid to the server o @gm - toggle GM flag o @changejob - change your job, the first parameter is the job, the second is the level (e.g. "@changejob 0xA 75") o @where - echos your current position to the server console. o @npc - echos the closest npc to you to the server console. o @zoneR - reloads a zone (e.g @zoneR 0xf5 (reloads lower jeuno)). o @hp - changes your hp, if it sinks to 0, you die. (e.g @hp 0x00 (you die)). o @mobani - change the animation of the selected mob (e.g @mobani 0x03 (it dies)). o @animation - change your character animation (e.g @animation 0x05 (mount a choco)). o @cs - play a cutscene in the current zone (e.g. @cs 0x01).自分以外いないけどねw
230 :既にその名前は使われています:2008/09/05(金) 02:02:50 ID:9PMMttxt WTHが出るのは同意画面に入る前にClientv動かした場合。 俺はすくなくともそうなった。README にもやり方が書いてあるのに。アホでした。
Launch FFXI and wait at the screen where you get to accept or decline the terms of agreement (which occurs after the POL version check, and before the character selection screen). Now launch the pXI-client.exeとはいえ、少し動かしてるとすぐ落ちるのは変わらず。
@pos -20 -20 -20 @pos -60 -60 -40
@pos 0 -200 140
% mkdir ming % cd ming % cvs -d:pserver:anonymous@ming.cvs.sourceforge.net:/cvsroot/ming login % cvs -z3 -d:pserver:anonymous@ming.cvs.sourceforge.net:/cvsroot/ming co -P .ming が PNG を処理するファイルは、ming/util/png2dbl.c,dbl2png.c の2つ。
png2dbl.c の中身 struct pngdata readPNG(FILE *fp) { <略> png_read_image(png_ptr, row_pointers);普通に libpng 経由で zlib 圧縮/伸張してるっぽいです。残念。
phpize ./configure --enable-qr --enable-qr-gd make make install vi /etc/php.d/qr.iniチェック
% php -v PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/qr.so' - /usr/lib/php/modules/qr.so: undefined symbol: php_input_from_zval in Unknown on line 0 PHP 5.1.6 (cli) (built: Jul 16 2008 19:53:00) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies怒られてる…
<?php $data = 'http://pwiki.awm.jp/~yoya/'; $options = array( 'format' => QR_FMT_JPEG, 'magnify' => 4, ); header('Content-Type: image/jpeg'); qr_output_symbol(null, $data, $options);
% 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',常駐成功と♪
GifFileType *GifFileIn, *GifFileOut; GifFileIn = DGifOpen(...); GifFileOut = EGifOpen(...); <データ入力 → GifFileIn の画像データを GifGileOut にコピー →データ出力> DGifCloseFile(GifFileIn); EGifCloseFile(GifFileOut);仮に、Open と Close が共通であれば 必要な部分だけデータを書き換えるだけですが、 ↑これらを見ると、カラーマップとかピクセルとか Extension ブロック 等を明示的に一つ一つコピーする処理をかいてるので、手間をかけないとダメそう。
while ((DGifGetRecordType(&GifFile, &RecordType)) && (RecordType != TERMINATE_RECORD_TYPE)) { switch(RecordType) { case SCREEN_DESC_RECORD_TYPE: DGifGetScreenDesc(&GifFile); break; case IMAGE_DESC_RECORD_TYPE: DGifGetImageDesc(&GifFile); break; case EXTENSION_RECORD_TYPE: DGifGetExtension(&GifFile, &GifExtCode, &GifExtension); while ((GifExtension != NULL) && (DGifGetExtensionNext(&GifFile, &GifExtension) == GIF_ERROR)) ; break; default: break; }こんな感じ。
DGifSlurp(&GifFile);出力(Encode)は
EGifSpew(&GifFile);どちらもその関数の中で順次読み出し/書き出しをしてるだけです。
% ./a.out 6 8 gcd(6, 8) => 2 lcm(6, 8) => 24ふと、ユークリッドの互助法を思い出し google の検索で以下のページを発見。 なるほど。余りを使ってもよいですね。 これで多分、OK
582 DGifCloseFile(GifFileType * GifFile) { <略> 600 if (GifFile->Image.ColorMap) { 601 FreeMapObject(GifFile->Image.ColorMap); 602 GifFile->Image.ColorMap = NULL; 603 } 604 605 if (GifFile->SColorMap) { 606 FreeMapObject(GifFile->SColorMap); 607 GifFile->SColorMap = NULL; 608 }多分、正しくは↓このはず。
for ( i = 0 ; i < GifFile->ImageCount ; i++ ) { GifImageDesc *ImageDesc = & GifFile->SavedImages[i].ImageDesc; if (ImageDesc->ColorMap) { FreeMapObject(ImageDesc->ColorMap); ImageDesc->ColorMap = NULL; } } if (GifFile->SColorMap) { FreeMapObject(GifFile->SColorMap); GifFile->SColorMap = NULL; }でも、何か勘違いしてるのかなぁ…
git clone git://github.com/yoya/php-skype.git適当にいじって動かすのは簡単ですが、 commit を意識するなら真面目にいじらないとです。
$x_axis = $world->createObject('cube', array(128, 4, 4)); $x_axis->setColor(new Image_3D_Color(255, 100, 100)); $x_axis->transform($world->createMatrix('Move', array(64, 0, 0))); $y_axis = $world->createObject('cube', array(4, 128, 4)); $y_axis->setColor(new Image_3D_Color(100, 255, 100)); $y_axis->transform($world->createMatrix('Move', array(0, 64, 0))); $z_axis = $world->createObject('cube', array(4, 4, 128)); $z_axis->setColor(new Image_3D_Color(100, 100, 255)); $z_axis->transform($world->createMatrix('Move', array(0, 0, 64)));うーん。とりあえず軸を書いてみたのですが、使うのめんどいし、 スケールが把握できないです。。(64 の値は探って見つけた値。。)
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 31651 yoya 16 0 782m 652m 3164 R 0.7 65.2 194:34.40 skypeえーっと… メモリ1G で 65% 食ってるのって、幾らなんでも太りすぎ。(´Д`;)
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 25343 yoya 15 0 80376 33m 11m S 1.0 3.3 0:02.03 skypeとりあえず、原因を切り分ける為に Skype bot を止めました。
90 :水先案名無い人 :2008/09/25(木) 16:41:54 ID:32KaDK9t0 ガイドライン来て判ったこと。 さんざん馬鹿にしておきながら 原作を超えてない点…確かにある意味才能だよね。 共感は出来ないけど。^^;
% php colordist.php chara-298.GIF > chara-298.PNG
[2008/09/27:12:06:31 +0900] dor18184.kaist.ac.kr "20020627-2-S1" "" "Mozilla/5.0 (compatible; MJ12bot/v1.2.2; http://www.majestic12.co.uk/bot.php?+)"サーバが貧弱なうちとしては困るので、ブロックする設定を入れました。
どうも去年の10月ぐらいから、ウイルスによって拡大するニセモノのMJ12botが 跋扈しているようで ^^;; ちなみにホンモノのボットの最新版はv1.2.1らしいです。 majestic12のなかのひともたいへんですね。よくよく調べてみると、ホンモノの MJ12bot (v1.2.1でした)もときどきアクセスにきているようです。そっちは大変 お行儀がよく、4, 5ページクロールしたらすぐいなくなってるようでした。なるほど?
ただし今回の実装は排他制御を行っていないのでそのままでは使えませんが…。アプリケーション全体でのデータ共有が目的なので、 そのレベルのロック処理を自分で入れて使って下さい。
パフォーマンスは悪くないのでオブジェクトに限らず画像やテキストなど キャッシュさせれば負荷を軽減させるのに役立つのではないでしょうか。 slashdotやmixiも使っているようですし。この文章の前には、 MySQL やファイルI/O との比較が載ってますし、 「...に限らず...画像やテキストなど...ようですし」という流れなので、 「slashdot や mixi も memcached を使っているようですし」であって、 PHP クラスのインスタンスとして使っているとは言ってないはず。
ExtensionBlockCount=1 Function=0xf9 ByteCount=4 Bytes: 01 00 00 00 Graphic Control Transparent=0 (= #ffffff) Dispose=0↑こんな感じで表示されます。 こちらにも反映済み。
* [GIF]GIF画像の色分布表示 ↑1文字空白検索パターン (窓に表示されるので分かりやすい)
*[GIF]なるほど…
*[GIF]GIF画像の色分布表示編集して気づいたけど * と [ の間の空白は表示にも影響するのね。 どのみち詰めた方が良いみたい。
giftransmask foo.gif baa.alpha > baz.gifとすると、baa.alpha αチャネル情報を元に goo.gif に透明pixelを上書きした baz.gif が生成されます。
php swfgetjpegdata.phps chara.swf 298 > chara-298.jpg php swfgetjpegalphadata.phps chara.swf 298 > chara-298.alphaそれから、適当なツール *3 で chara-298.jpg を変換して chara-298.gif にします。 あと、何とかして 透明=on で保存してください… *4 ごめんなさい。ごめんなさい。 そして giftransmask を実行。
giftransmask chara-298.gif chara-298.alpha > chara-298-trans.gifやったーっ!
gcc -O2 -o giftransmask giftransmask.c -lgif
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 11222 apache 22 0 53708 21m 5720 D 11.3 2.2 1:58.63 httpd 27944 yoya 15 0 91388 42m 13m R 0.7 4.2 4:02.70 skypeとりあえず動かしっぱなしでも問題はなさそうなので、次は、 Windows Skype から同じアカウントでつないで様子を見ます。