CUIで使えるIP Messengerをとりあえず使えるようにしてみた
モバイルノートをLinuxにしたので、いろいろな環境とデータのやりとりできるように
したいよねってことで、その際Sambaとかいらんのですよ!!簡単にデータを送るには
LAN内ならIPMSGだよね!!ってことで、いろいろ試して、CUIでも使えるものが
あったので、それを動かせるようにしてみました。
ちなみに、X環境が完全にないところでは試していないので、それは別ということで。。。
使用したプログラム ipmsg4linux http://code.google.com/p/ipmsg4linux/
環境:Scientific Linux 6 x86_64
X環境:GNOME
まずは、SVNからチェックアウト revは2でした。
svn checkout http://ipmsg4linux.googlecode.com/svn/trunk/
で、普通にmakeしたら。。。
$ make cc -g -rdynamic -c `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` ipmessage.c -o ipmessage.o In file included from ipmessage.c:11: util.h:15: error: 配列の型が不完全要素型を持っています ipmessage.c: In function ‘ipmNew’: ipmessage.c:57: 警告: incompatible implicit declaration of built-in function ‘malloc’ ipmessage.c: In function ‘ipmNewFromBytes’: ipmessage.c:128: 警告: incompatible implicit declaration of built-in function ‘malloc’ ipmessage.c:182: 警告: assignment makes pointer from integer without a cast make: *** [ipmessage.o] エラー 1
おぃおぃ。。。コンパイルできねぇじゃねぇか。。。ということで、久しく触っていないC言語を。。。
まずは、「警告: incompatible implicit declaration of built-in function ‘malloc’」
ということで、malloc.hがどうやら明示的に示されていなので、あろうと、
ipmessage.cに malloc.hを追加
# vim ipmessage.c #include "util.h" #include "const.h" >#include "malloc.h"
でmakeする。
$ make cc -g -rdynamic -c `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` ipmessage.c -o ipmessage.o In file included from ipmessage.c:11: util.h:15: error: 配列の型が不完全要素型を持っています ipmessage.c: In function ‘ipmNewFromBytes’: ipmessage.c:182: 警告: assignment makes pointer from integer without a cast make: *** [ipmessage.o] エラー 1
残るは、こいつだけ。。。どうやら、util.hの配列がよろしくないということは分かるので、
#vim util.h /*parse console input args*/ int argsParse(char *cmdstring, char *parrten, int limit, char arr[][]);
あれ、char型って配列サイズ指定しなくてもよかったけ??とか思いながら、
argsParseさんがきっと問題なんだろうと。。。
util.cの101行目くらいに
int argsParse(char *cmdstring, char *pattern,int limit, char arr[][1024]) { int index = 0; char *p = NULL; char *last = NULL; ...
ということで、
#vim util.h /*parse console input args*/ >int argsParse(char *cmdstring, char *parrten, int limit, char arr[][1024]);
とりあえず、makeしてみる。一応64対応でmakeもしてみるwww
#make CFLAGS='-m64' LDFLAGS='-m64' CPPFLAGS='-m64' CXXFLAGS='-m64' cc -g -rdynamic -c `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` ipmessage.c -o ipmessage.o ipmessage.c: In function ‘ipmNewFromBytes’: ipmessage.c:182: 警告: assignment makes pointer from integer without a cast cc -g -rdynamic -c `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` util.c -o util.o cc -g -rdynamic -c `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` receiver.c -o receiver.o receiver.c: In function ‘receiverRun’: receiver.c:72: 警告: キャストによってポインタから異なるサイズの整数となります cc -g -rdynamic -c `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` messager.c -o messager.o messager.c: In function ‘sendfile’: messager.c:114: 警告: キャストによってポインタから異なるサイズの整数となります messager.c:114: 警告: キャストによってポインタから異なるサイズの整数となります cc -g -rdynamic -c `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` user.c -o user.o cc -g -rdynamic -c `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` console.c -o console.o console.c: In function ‘getCmd’: console.c:52: 警告: 関数がローカル変数のアドレスを返しています cc -g -rdynamic -c `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` functions.c -o functions.o cc -g -rdynamic -c `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` sendfile.c -o sendfile.o cc -g -rdynamic -c `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` filelist.c -o filelist.o filelist.c: In function ‘fileListGetSendFiles’: filelist.c:42: 警告: initialization makes integer from pointer without a cast cc -g -rdynamic -c `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` filesender.c -o filesender.o cc -g -rdynamic -c `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` filereceiver.c -o filereceiver.o cc -lpthread `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` -o messager ipmessage.o util.o receiver.o messager.o user.o console.o functions.o sendfile.o filelist.o filesender.o filereceiver.o
おぉ、通った!!
で、できた、messagerを起動。使い方はヘルプ参照
./messager >File Send thread start... user 192.168.11.30 login ! user 192.168.11.27 login ! help ========= you can use alias too!...eg: list use ls to replace! func alias usage list ls list refresh rf refresh send send send user(or host,ip) message sendall sa sa message sendfile sf sf user(or host,ip) filename listfile lf lf accept ac accept file name(or msgNo:fileNo) cancel ca cancel file name(or MsgNo ,or cancel all pwd pwd pwd cd cd cd dir dir dir dir ! ! !command args... exit quit exit help ? help
ちなみに、sendでメッセージを送るのと、sendfileでファイルを遅れることを確認しました。(WindowsVista相手)
Vistaからはメッセージの受信はできました!!でも日本語はダメです。。。化ける。。。
ファイルをVistaから送ると「セグメンテーション違反です」ということで、落ちた。。。orz
で、GUI使ってるなら、G2IPMSGが一番いいじゃん!!ってことになると思うんですが、Vistaからメッセージがどうしても
受信できなくて、(ファイアウォールとかSELinuxは対策済みです)やりたいことができなかったので、現在休眠中。
プログラムも小さいので、ちょっとリハビリがてらに、これからイジッテいこうかと思います。
なんか、CUIのIPMSGっていいしwww
でも、とりあえず、使えるようにしたいので、ファイルの受信部等対応して頂ける方がいると幸せですm(_ _)m