2009年7月13日月曜日

プロジェクター

昨夜はうちの学生を全員招いてミーティングをしました。

そのための準備がとても忙しく、遊んでいる暇はなかったのですが、どうにかホールも完成しました。ホールには、うちのサーバにアップした画像を連続して映写できる、プロジェクター(というより、スクリーンです)も備え付けました。

以下がサーバ側のCGIプログラムのソースになります。
/*
** projector.c
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <time.h>
 
int main(int argc, char* argv[])
{
char filename[BUFSIZ];
int imgNum = 0;
 
memset(filename, (char) 0x00, sizeof(filename));
 
printf("Content-type: text/html\n\n");
printf("<!DOCTYPE html PUBLIC \"-//w3c//dtd html 4.0 transitional//en\">\n");
printf("<html>\n");
printf("<head>\n");
printf("<title>secondlife view test</title>\n");
printf("</head>\n");
printf("<body bgcolor=\"#ffffcc\">\n");
printf("<center>\n");
if (2 < argc) {
strncpy(filename, argv[1], BUFSIZ - 1);
imgNum = atoi(argv[2]);
printf("<img alt=\"testImage\" src=\"/projecter/%s/img%03d.png\" "
"height=\"100%%\" width=\"100%%\">\n", filename, imgNum);
} else {
printf("ERROR: %s, %d\n", filename, imgNum);
}
printf("</center>\n");
printf("</body>\n");
printf("</html>\n");
 
return 0;
}

すみません。ソースの色付けにLSL用の物を使ってしまいました
それから、これ見て試そうという人はそれなりのプロでしょうからあんまり人に見せられた品質のプログラムじゃないです。
そして、目一杯のセキュリティー・ホールがあります



このCGIプログラムを、セカンドライフ側から叩けば、していたディレクトリに格納されているimgxxx.png(xxxは数字)を表示するWebページを戻します。それをセカンドライフ側から表示してやれば、うちのサーバにある画像をセカンドライフ内で表示することができます。

試して見たところ結果は比較的良好で、問題はセカンドライフ側のスクリーンに仕込むスクリプトに焦点が絞られそうです。

0 件のコメント:

コメントを投稿