Rserve/0000755000176000001440000000000013455133430011551 5ustar ripleyusersRserve/inst/0000755000176000001440000000000012205226222012520 5ustar ripleyusersRserve/inst/java/0000755000176000001440000000000012205226222013441 5ustar ripleyusersRserve/inst/java/Rserve.jar0000644000176000001440000007211412205226221015411 0ustar ripleyusersPK2C META-INF/PKPK2CMETA-INF/MANIFEST.MFMLK-. K-*ϳR03r.JM,IMu )h)f&W+x%irrPK'GGPK 2Corg/PK 2C org/rosuda/PK 2Corg/rosuda/REngine/PK 2Corg/rosuda/REngine/Rserve/PK2C0org/rosuda/REngine/Rserve/RFileInputStream.classUrV=O-(qb!B+1hPB*0IMڐ.*q$W~@w]tM,&΀3S:+鲟oԽ9&d{s9 c>Ź0c",.%"§|oM)>\#W0j3wJs5+Ss*U=wn-S(Y)`65vA\uiYLr*UTrAul<ܸg{%^"E*߲b-Tq!:]拄&-JN55vOxD$LhXĒH򧂆"J 1a: 6'ܺpW_Pޚ^v3]Kv^.I0x@F&#*h>6hI$jIZ/[DYԊMRXiT7u0仯HoJ1dQ'Ws us5^I}(F#M#yL 'py䶱fB2@D[/N+EueZbP Z [8!?"QRb*# c*cI,)ڽ CAEŇ*N8AtNAgCnJ%})֩H,$cGH)9a!]_ . t!6U*7MNQsx~.V4*xC^C:4ФW^P\Žqe[c'vI˗Óx%†B K`,<h,M< fK?ο!5ABD*yb!Pfl:\p?QC8q}6FHnE8DQ !=ʥ0ݔ_2/􉲿kH>EK/R{G x0XngP"w 5A8]XBr7ҢPKMZP PK2C1org/rosuda/REngine/Rserve/RFileOutputStream.classTsUnvM-mCR4ʲ4665H.׆ݰـ<;##3C<&4-NI:sso<p(Nb:Q+ P0|Y>Q1^Ru _{&,"\k߻cyY7|j6Z_QPPCtmi1zOdJ E@g4hn۫Z6lRo}g8Z)dT$q.W1tU1nP Eq*_}7ݫDIѩv'Koۍ1$Ӟ=']̤UlC&>n8 3riv\?6-Ggnѕ<gƫ:a_AEQEI}w7vp#HDr+5EH# W WB%/z_^ ޠ7$Hj$}ɍΐ,Lct e!@  =B G:?ԁK17Mzn0Aqd),#G&QQVpN +PL0Eb!A If&ѨʿW$w0A2ОY an ~IbFtC2 }E~Y*S?LPOTP2 Cɐ#$C}>N!{\#|c(6VqkJ^ =OQ|"<,d T.'8+u1~'|1^A~WsYdc#x {3_p>=-td ` .CI,HUkz賄 IA== ܿPKPK2C+org/rosuda/REngine/Rserve/RConnection.classZ |Tՙܛ̓ P#`(#CrIF8@ZQ|UaUW| $ZVkv۵mnEs4s9^;o~g,Oo7U 7E|zK5T۪j~ߨn4w4exSU7JG'7J"/yW1E5jsռS'9"nqH.N] )T\hnT"]ܪ/Х-RF~)e.LեR.t*xe.'e.'2[-s)2GD/2On.Pպ,ԥFZ76M6RzMhF]WZD-{ZFGO(٧f.9SͽҥIn\*+4YFe8[sTZf]r[Zd.tYK.t٨&]66MIdr2]mtr.ە.BMvhK8 *6]7=ۢ@g@")mcF9^ ͮM =q@58R'#i-hE{+z0)UP"s8* 4CX%3ڪ/17z> t 4)(Mkr^1eD%݌ P\s]>]c \u94)[P?a^'že1mߐrnb& R36ɪRG&W5"W#"b6C@=vR;S"ͱ݌mO97(uXSj-P7{zU_G@dM*CM{S\Aޔz#-˶P,EkrWSE-q' 4,$q&byOJR/fQ9C. ˆneNJdtI!6pn4Gz ܄yڲi _ X٤'Vhr!{? r^*6 GJ`w׿gr%]CQ35x^led鬝Ղ!WuԬOh,l&׫Em\}d/ڄ7h1$*aV]?VjGg%_,Bp|/!_d茜Qy.ΩX06 (IP)IՌuV_:}C>%H \>X!1&} ɕS-ImsHűerϱΐAYq+C\# bW>3E %Æ\+逩.EB̖̐u51}QVŋHtw(-"">4wEC!C 9 7$]@6Ff%`}PvEiZ2&orGhxy2~dȭxzLbq.CO+0ʴ5L>*Dԟ;[Jn$j;UcꑤTGSpD; |GU$JX $z"9,+ssZ2v}\) ."el<gJhPq-y8"񅢽 VjiXg( Kq3Gy9 r~3 | 1_I9ex٪[Ҵ$0iL|3SGP|^"/q%tގйfHRbgsg/#iflUf7KJnrdjrdGVlVwʙխTgQVQ$+bmZuk~F2F[QG;UPVqa!G}̵GDiR [6ݰa!ٲGɤĿ}KMRFO#؅*R,ͥC's]_'g*(a[~b ^\ͧIj_Gum2=QɑCOpľNX߮rsI[dXԗ[_Ǟx;Dr6z)(oB[X=/EV :a*Ym6/LV~5_^|OفOOp>//f;ȷ(;ன)UF8b}N'5F+^>99^jqGnESTS48=>TzMLAA6 hX ޟx6o3yd>u̹"5#pQK5jt5VwSpcu0P!krC鎚c(1)è:10*G9^J´Ml=G%3Gp)9!5q dqQƲ `.7WT{For:)rB%ϕ!oʐ),_|N{ 9^6m5è2m ix.\'h>j=4чanvD%!RYPYcٔÚ_N(#9X3QLw?M!e{ <ݎ~J79rMz FN㤒3SQ/faWYEY\M؀ b3І^lE?CDdxvLUN<2/7(R]R.1`tnYe H'er%Br/'Èʗ1(^ErLÕr,uڱ:c\hVIZ?n6nv-ns܄wce|>xw9^f2}J۳F4|V4< ϧV텪et4<{{9xeY'P 'W6k84bh]LqlUrX tSr R~J IH% Y=dsY}Ib*V)_!/Us>Ia88ǞQ{#' dPTJvH3*ώ0\놱8YFu4|xH/}1lq} 4Kӓ>KnK+_<>:Bweqs-pвOk,NX%D,W9c3n!/380iA3`%akrlX/8}?T~HJ Li"}̸+럝0Volrz36Vؒ!qKchGIf7}-DO6U SwW~^'׿3|=!(~Ⱥ?-Ք>ZGkxj~eqn]{^˺7lyjطm4 &}8oc-~u7m#MneqQYG!t49uv.+:Uk4{\wWZթuL هP/+ E/eDޢ no@'O,.<tCxJ7^OāPzO)Q\e meP>JǬX<^_1K dG9 qeqvz; Td\5uz ;,Yʶ^89^=f0'l@D8Zѷo}+X J R9RjR%ƒR{ċC,Ix2 o̶ eڔX2(c!DF@3AIiMlJeO\cTn^z.;y(˂$q}?!3g69+9+ӠKie8U"93=Mˎ%/ar4BwTK$Hks YI$/Ktt$HG2h"o`q}9l D KdK:l4/$mmn#2eI0~̓]X,]`gy1y)#H>P#WݻI>OE$ ݰY7,/yraU|I]>΢KI?N Jd DpDq We^!(Kܕ'joU{} K|êZ߇n1.]^M֠|Z٪AjPNNrhp܈V)̪A[~pe4vIe~Kx9iav4o'F[Qm.X H~_ÿdXChd7͜ ֟L4V?M~:~БL.gV$PKRLv\_/PK 2C#org/rosuda/REngine/Rserve/protocol/PK2C/org/rosuda/REngine/Rserve/protocol/jcrypt.classmZ |\E՟{wIfdIvhMmW6J6mIMSh!P ꧨP*E@B >?A$}ȯg̙sΝsW}@)j6ō5qSn:rA+#J:~BjRM!J*"uONNHe1IjE}'nfY\U/]s 5]sZ\Uӡ}zV΄l5ZKE(sRJ6pIhuE+d\R*-- .Z]h %2d%,JJʅ_P PR1bD@@@"DJJbT@*P(AVʁJzPAJ@=PP+J~=s`X8x04x 7 lEMGڳ}-GTkF6\9#KHwO! +[d94˶|-GyZz冾UZn9g{1qb)2gÞ ;ˣ,y҆eg,]nƎ uq6 o!]760#wSh s+v \4вk`h[˚ёC:((j!lvnUz̓'o `0Y3-ajLmԙ 3 `fLJj@ɓ9ۜ;]w-# 7a֛x֭DlipxKœo6$FCALE49 3״&,3;a2Bm-#{nhYlhM{G.l=2<:yxWˎ6̳pkQkph:|ܛPU,t`b._JҢ([~"#$fӀQ _Vf߄өU 7ܭmTx{ &͊j;xӰU׫haV'x ^qt13NGWT\Dshg]P}P{+ZwĉUj% B|\R]=Nal)ۄ7f]TWKٺcV+^*j}jWERoyߠ*3V} ;^W™}:Si'T՗vVR1^Z0ߧRjUQ2aBl6"޲@f*{ ؁R'ת}<+f=C=*%;Ls=*L6wS]GEBw6x뵲bDŽ]bJfD+DKG&3^xW ܔk!]q*KmתLx,chdcYT!a5 ݷPk.oCXd3_:sW"S*?MtF%g9WmթNַUjPY ;~}^Q7M6uuzH[=V_Gӗ_YRߩ_sg3>bQU&h%KLGq.UfȦTܔ3Nh*J#s@:i>rHH*}4U+iEPt2๨cU"VrV,Q>3 =#{&jqE7gU~R4Z_Ti7SߡP !Uܭ+Bwi ai eRӛh *6cA RNst_]tCԏqq]m$TucʅR1gբDv7)=fcd:qZgc(-JBDRMJS%Z* 29zRξBy:JJǯU1LPk3FJS%{7Jn˛'cNWNӧ4w̙sza֩I:0ZblԾЕfIFF5[y&3ϴIՅ5l>+`>ЂFseBeT4{T1K^R޿is͂GFEɓ ؑPoCao~]X,Wc8 H<H*S4 P iPfffrz@h80Ak%gQo!(XHB'\dK!`NVbnV\̊=kKl)R[Fx-'\f-6IxO>r;4"l`3`gn 7[O8hFm;pm&a[w<.;BJ8d[mp. cE{m;EbIv݄ń1eqB}w#M~NFץ_E Mc@P (Peֽ_Z=G=GhL\C0$QC&]y+P()BNyg"*o GVyg!*ldw[EZyVyH+-H+5486@ a$lb63 [@3 d0[mLLv`(H: -:$b.da&a7l{+8H9LIe2 1 3 L%L¥Lp0$I`.g0 og2 W0 W2 `$I&L{2 c$\$\$|I !&DB8 #࣠ZPpSp=S1PU68p &LCLaFs| p#Y&0p` gp3y&& L[/113w0_fdbfaag`d| : &Lo33a| x >" rB<,М?$ ޏ@ARAZ!CR "t 3``db~< lǒZa=ڈGX kq H],O/vwۘw7.ĽM.qo qWpW )aJa܍;w ssIO0na=U{ s> }P0aa#Gk넹녹 sn>!}̝J״G6l.m㾾QHF;,$a/}}y!g)C}Ax@e2/ o o8dAveN-.w ow o8*%]#}EW)I#BBMɜ* #?u!Bn-!!!\ =,}GcF2W+}O{D~ߚ;Tk^~|0H`׏28uGL%~",b* c,>&,Tg"+rm -/υDž_HPH|LH$:%¬&nl!aI39Yjh@XmWMs$fHy3W:M'1_$n!GHEC/]Oij{[+N"")@Jᗐ.n'~%tZ(Ӆ%"ɯ& `xGTrZd52e$65]|s u1S4f! bkb6JMVh3-U^VicBϓBύ^bs;ho`'Jf=%x-tRv|4!=o9~㵒Pz~/ s L%$=#=+I2 crгO[frPH焤?ItˌD#ttix f:4S%vfɍtmӍI簏fE\5Dc{/PBJI*=+I%'X0qy&^Ga/ R~K_I"aoTI1!a 7e|/g Sx6 Q^dpWUA<ñbՃi/~=*DAV#}kY6CW3,xW=8U(zUL6Qs׭mm懅#]$q)vnw1{Ic/ƾ'gԿxKa$[BTTndiPŖeUr.iaZ::_77X^7F5fv.,˒Vl㧙:#-G9)EΚI'kvIlz1?RNRM9?7p\Xyc>#|[ZpmO*s%>?' _ᕉ\'v>(~b8~f8W|rN6\ 'eEay VTfHuL0K:X/$b Hy4ϕ"j|qXG] ʓ,vQ]-*_|\x:%ou`38qD|#{'~3g7q o7%XBSt-TRT<1ZpJ:W:6\^]%f9^: a:9[jVluL*$~rb^\4HXdƛE"y1;=ʃybxx,Kmqv*l-0 mhDXnGUttRYrxouQ-ecu]0$6oZ/lNP3+X*FPE i0[Sn]XQy+8p[Cb@5\'>2=^U3['Yrw-{gz37[y>u-iFBǍFrIyXf_L~R#a qE:!D:c|7Jd4= #xN wg%09NvStlCS=+dix-4g|g21̞gr6n6b &>%;O<ΑA?L<'LjemȼOJf㋿Oc3OԆJQf =; ddd܀@PK+7]%PK2C.org/rosuda/REngine/Rserve/protocol/RTalk.classWkp>zZ QC !$AJc;&NM Ԗ#"i$@M@)ohRBi `Rȸs-E~j%oMI~νy9ŷ!t$@ad=-yLȃʯi> rgy iRZ!H =/$ =У }E`o@H j̢6|ɀ-$)ѵ#ŰNP=ຍWut3S!}: tD_EJ5T ӑZ/Юuyk$g |eylehȩ\)(YkWu5fzM=nYIsdH5XdW̜}ofA.+kiF@z84mn$3{!R#IIGv$B_6%mVdđ8lL,Qxb#5Rj`P2I. #XʦS&ў*q}`Vʷ6.FpV#㣂.dNXpjsuDH;^sbt~*e̽ 5\ΖHdXnBЍAiҝt(xF_aJ'$}EOV4r6ݻ3Ƙj4R o =K pv5+u,T'67<Ο l"dEioej ٞmOTHhZ[@!ݭn\#& i;kG@#zgP0{lA)ī Bt:|{K\L\x){\ls\\ /y1/}_1GJ^| _pዀ/vv5/uuN^z .܅q^>ɅNp?\x3s# _ Յt! g\8 lvswpxԅMhW厅kE1ڱΦ3$=Muy_4q\ /4N0_*^pSy⾁ M|6BY _(`-B"*%⛏IMf IzBGŽ r^3&xyeP"ޒ M8^srSrD]yzulfRXn&Gu ɑUh;$'{o4s_C5rAvb%jbgEnR2+9 XqoK`HŠ^wY4|h- ..jKgɭ<>^YՃԀ|!ڇ^o;cw,\̂bmMByDNĭ"\if4Ʃc@19$r ')IfiԜ<%#(oG8ȧǩV&1KB껧Rv:7~C_I&Ugto 7ӽߓ>t_;JM}_ӎpHAuHQԄvBT1Y~-\VF"OH jM05B:O&嫠ԅiiy*B]}>* }F`k'ԃz!45'1oJ'/?G-[P3:U VY1ùIEI\92 B໸ۿyܑGqO}i?D|?'3 p\K~K?a|~G8Ax8E E,WWHkE8-x#2F'K* :MzHWuQKsropZ'$6M 3!d׏vԽ͡ Ebu$?>sZC>ݯ uHWu=@+tOwE|%F!WS_r&\ #%gSA*?q+ 5:L[u_v[_ɿ-c|i1{z9LY?ximzD;=ιU⎱qicg]E 'TT]=- UڿPKU PK2C4org/rosuda/REngine/Rserve/protocol/REXPFactory.class: \Uu`PbjX((`2&Dq |IJKmBKm^kޭ629fϯ9{9{9^=~;@sLp3hp 6qBР :q R 'LGECUCv 5 u :5tih805LpM-&'?N'!$'q(4'0!Չ>LqqN`#$y$srG8FDZNPPj1uqJqqB.N4' 'g*=?Ni,rggrwk8 gp:ѳXasac1x kx:! KXL;!Ku,c7,<',r'$`J, -O??KpGCxą̲j0VǀXJu\jt\cPFtXf[t تZ^ :n/qY6 /GЖT./]XRqs-!0PhXK+C\-[XXR$WT3J JbTU²F6&NeD3.*SY&%-IrDSRVh\Z0_L[K* \Nc}|->|Bˋ,Δ~ͩuTݔsVF45|;ǾYGss(ӡ2gAcfa鹥eKgyan6=byAE 5#L*ilinliꃁ@@NSsc, 56oN#k!#XPI} 4!99sB Yhh !c &kV7ɱX3|%s"_fL-K5P=# 7[-̥(\a?'# j!kHyCI XZ)9$_hj!?OFPs}n`Pd?1yPP y̓Y<,dPEcksM`^=ـ7-^7hNf>b64x 0Xx-p -z,UȴVY2*Y`fQfV1aX Zq0  s[&E7} 5+Š֮ߠހ7Ҷ:y [jYQYYYQNo I5דʹBބ7o4;N 2fgyޣ­ލhxp; M^+}^Ao oYլtNq'b BFdƆ>XAocԁK.:e HqGUg1=;YGV*epNJ v'XғY@;p>t 'n$J VYhG+fA.ZQb)GiF^--goYlimjjlj54qOmo%@з[hHuKo;` -Y\6j͓Ge_aU}0Mo l%Y,j~!Ҭs eWMvȑѳR v3L%.>`03Jf6j,yVUGȌMb\zI׶L3H3 M} _.? !BzJ;t)zf:O \?b-OůpPAM59@E1V䛽߰13/X˩^I#kWnu74rvjl w猣 0"sܟ !Ʀ YxbsL4 Ny[j\oh9i[|<<~Ry%0hkh4eg թpT [?wiP@ (i&V'[X5Ћ,R 5;#ȻuNcCuS>Y7;F>fTMV*3B`E9+D!KZh/~J] z#≌̟>j[ 7-|qx,+;rkɏ}lsAfN4x(&Ϟ]K{@,.埜1R#0]}-SɣQtY:f[H}X׹봖p2ϑ t_! pI]Qx[ ' mQv;_~_~?D( ?B(Q?F(qŸŸ$(i»݄Ÿ!(|/?O Q: /E%@~W ^G_*l+lR-[ ^>ҨE~hz p|#?*RfNX8vA4PvƞWP󖠌ȜA}<2\*,N = j7ݠ~pH zxD`W48=B8]Y{15d-NHC4X`dBx5_J[o kbzl#4afȫ!&I?􀗖<j'|Kkۿ}Kb P _#H,mپ=0,?7%.MUU=1>\]/:Wr+ᴓG0z69>}Ǿe.ꆌ@+ytuV UmtCNҤn8-&3fx] k,$M; %oynf*{soεS"-t|ا;aJlqU^xؠ0vHf0!uV0 a\^=|rX520{ҷfnx ̧fSh UWw0^ۑO1 ٢z̉ZD:  \|8Ͳy檹&3lwCQ.~Y&Q!uWifZ4G4y%v a˔.HbSz x[ޚ+ rIq{,R<]1$tqWs]Nޛ<Fydge^ tԺx%a>jcsPTri hWKSxqϫL{G δXSՔ*##+|D'љv=:S~ӮNG<ݣoKMF&[NLZMcE2J$qԪOݰ(""|F%4OuPP꽉eRdGWuO/ =EG?Zk 糉:éW8a PZ!J= rlNaYt `R> ' cr,IMsHu6NDR8HAl݅d) |( Ó:G˫d4U0 G%l+(aػ|;A;P8f,׾ҎR&S92ra\cZȁ`%iyp=̂a!D͔B ٭mT]MmTIEٽT=HC=C^*~MTlCETd&/:J\B@ x Saq:<%$SeЍ؍+\{b؇9l/+k> ^#b(ND6!N7E>%%𶨆wD Q=u+#q=|,n?;q|*.LIBo—s8"z+ Q[e8[Q&I +2~P*GY'Kv(܁6eڕ)ON01Vc:i8H=pZCUbz!:LSpczPoǑ8JǨ/XS,l:N9qm(NeTX<6 smg4[!a+3mbag6l&,݈;qmε=EGq _OaCm =Hx T|=$H hpx8Kאa~ l񸑲4Ɲ!PPsSO@F}42͑t QJER, pEOauT$!'`IDrdIZ@K3= {g8!+#' &+zaTkU)8̙L qo} =HG<䶯u&$Xǐ4Qy@`m1P'++?ͲRK}.*_WfLD@i|+Nu::aDT)]XPgs$ϔ`TSzTEl;@m`S(J墳jgvpqǣ{~i@?,7><G Jrvd֎jЎz^ 쯮jlRSUUfuyBV8/H :+դV2c+u1䎸̚%E:ٕ\ͣy.v yzW'4ҋ3 NJє\ɹ{TSNjWxvR{d>V:L@<;L-;ݰ`]I30O"}ϳG7ZNZ[lҟ(G9p?_2=_%tkЂ:|.7q<|Owp:=lI6ďD :%/ G$1i_)xTb.KK{D! W !*١m&:_!N0 -^I(>Naj F)>!ls)`Q1v 1d0p'x; I0-]iR&!An~&PMFaGתЉ[Ҿ tiN16?ELɵd<ڊ4vJTM&ONY! qccN偭Ɗ{MjYꪞܑLCFEG!=BgI i^<7xxNR=b%.3=f5u8x4sOK`E9]\|>݅=l7ԮVxsr+bK%x>`CϖcI1FeO(mM!7W8y\:poSORgi8kn]E4buvA(*du/ɃGAHVЋQ덓AE󐒢pUVG&'fx[$w$$× _.~o`:% .)s GwB6AuiKt&rS^Eftu'myc-8dhC%f*iM IG T1t'F1QZXxTd^*^YpWKL_PS1q:FL |SD>~(fb6 f (cb(/ yBQ.E]"bX"DJ/nKIe/\<.3/~+VE-U'j# U ZCA!6(بx%JTI2eج6L\,W(ŕ&Ѯ)W-MF_ 9Q lՊp<)t` 8O桼V<&iQ !J&%O=R*,2~x^</{<| ^:ޥ?]iX6}PK( 4PK2C/org/rosuda/REngine/Rserve/RserveException.classV sE}Y2e10 B%& 4  9; ^HIaiaZC IgigiOXe|=9HQLutu}Y\lbӯa@àC4 k8ሆ G50aLq '4pJCNø) gel^͹⼆WdW5&|ބBE:Kf1RvTȇU39_,O8FŮX2w+2Um:N[AZ7\LI4vJ7oN aF@+[9 miTЧ进_ʶ/ZRl} G3>wK 7#5ޱePMV^ymK] Z Zs58fV`#($6%^"kŶ_i!e\!x56Q5WJ4Opu ?8QG &1H|H">& 0)q&Fψ1kb#''S/z]'#}YGZ7Dz*җGz:WDS+#}UX}n-z4֬X+Zv юwc>[lml>CQ/)7;~D3O7%z(9Sbbf$F,qms4ّM,W_Q-8u BŮY)*oIC\-YJ-՝#zwco cF.XEfby.zlKN}`̫ ,?b)q=q"bҵ)5qilK,,qH2MS{YIyx6N]H]~ۃqPKLW PK2C(org/rosuda/REngine/Rserve/RSession.classTmsU=7M{ yF$]D^ԖVBD>m;a۰w7'A2Cz68s=Qq.ףztA.%>ħ&h` e|fs|!l0`EG]V%$J:M~v0/H^:3_k0Nfkޮt4ڋ+02wL/Iֽ^kGqR qosAS']t0 [aǩfΩ(v&O.3Ujp%R35XTцJR@f\|21ߠ^7J,JZdZdF Ԛ5 k &Nb8nkl*dBڽ&Pv]o#wUCfͭo{*N4jM⺉u0LMPIN0&ZjZ?f&C:Ե/ ȶJHU],y^[|v5uw-/ilʼn/k]^ ۪ZE\MP3#y_33k='L-Lmm[zҞb6z:?!Sٌ 1-<`;ͳ b Y<~8ׁƋ8c}du?DzϘ~;cUS}vdj"?V(>T&)Ge9J-Q9J*)Ӈ-QHT)<;3)11aj#RRWjq4YS/0%|_PKSRhPK2C META-INF/PK2C'GG=META-INF/MANIFEST.MFPK 2Corg/PK 2C org/rosuda/PK 2Corg/rosuda/REngine/PK 2CBorg/rosuda/REngine/Rserve/PK2CMZP 0zorg/rosuda/REngine/Rserve/RFileInputStream.classPK2C1org/rosuda/REngine/Rserve/RFileOutputStream.classPK2CRLv\_/+n org/rosuda/REngine/Rserve/RConnection.classPK 2C##org/rosuda/REngine/Rserve/protocol/PK2Cꐈ6/dorg/rosuda/REngine/Rserve/protocol/jcrypt.classPK2C+7]%0f<org/rosuda/REngine/Rserve/protocol/RPacket.classPK2CU .!?org/rosuda/REngine/Rserve/protocol/RTalk.classPK2C( 44hIorg/rosuda/REngine/Rserve/protocol/REXPFactory.classPK2CLW /eorg/rosuda/REngine/Rserve/RserveException.classPK2CSRh(korg/rosuda/REngine/Rserve/RSession.classPK2oRserve/inst/java/REngine.jar0000644000176000001440000007713412205226220015500 0ustar ripleyusersPK2C META-INF/PKPK2CMETA-INF/MANIFEST.MFMLK-. K-*ϳR03r.JM,IMu )h)f&W+x%irrPK'GGPK 2Corg/PK 2C org/rosuda/PK 2Corg/rosuda/REngine/PK2Corg/rosuda/REngine/REXP.classWS\NB ,pO P(8ŔUf`;M\jrm];Mmv8U Pө~wn~}ONZyNXO؂=hCn|O^()xD SBO O +cANz)g'^4nMœr^-sڛ 'Q*z詸l-Δ5DDPcF:$xnU?zLpݞ:gҩ FT+AG¬U!)΂ЂJs1·o" N. !pI(Dhc 5!'8fzk{ӇaG\k>}Ub@%|C,Z(`RlH8& G9KAi)16Ԅn r]6S\_&h$,,V iyDRޓ04,'A B],xHY0e`$ͫD?,ca`.ZG,M3RF6h*Ղ geeܤ/+]ݼbs;G>|,Jf>9S\bs{2-Xćl/ L [ʞZmϰ*UԮvgNMdK5-ŴqZOB4ۍb|(k)# 3M / ڑՏkiXCdPʘa4,]f 8Up7H*a7GΧ3<e$ujSt%ʪĵI_CU\[䯵TWɧK]-$U\-iwrHwW tOrHV 9[+k&դ*[K Ho@n=ivHz_@n;)OV[Y㐣ac 7K8H*dxC]6[k 4 o(t N _fZlS4'wsoI\-E,E jLn&d[Ul9 "pj5 )Hg"ӳ:BrC2a04S+]O 2aRys}0j['1f/< ,3nE0 >2zNvvvFTFg tҔD ׼̼Tm퓕X\Rn)_Z 2R 33$(-19UAm'e&120201# #3 $PK[I;SPK2C)org/rosuda/REngine/REngineCallbacks.class;o>vvVv6FҢT̜TF ׼̼TĜbIJDFtҔD}}t  9yIY%@ H21PK F;kPK2C-org/rosuda/REngine/REXPExpressionVector.class}J@ƿMbbcl՛ ?bsO㟕gjybeQ(vN 62gOY, 9s U7K|\CP.w{SWz ,rND0ۘO4 ޠȮԸ&i,PKMPPK2C*org/rosuda/REngine/REXPGenericVector.classUSg-dòxI KHjBEklFKL3S2uڗvO}?%mLNz ALi 5"3tVs ΋[\c ƽ UxpI(OI bL δ WuF6!k5o\wT"]/tq.$s^$e^1XIIɢ%7%(Y}9%3d4zt"f%MˈNM4-=%A>7$l=O\M kJbW/nt{\w[9~anH8vKGS UIYXCOVY vjtdF" N^I:NfəV:2N1O>SS'3\8m\ǝ1,#g&u&+ 4vTZB[=z`aPB&)#)ǩ!= ۪_%mi kS^-K^;f*zVt ˸ iϰKzkxj#ҷpBP+ga'$HDiHhV)k􁄽u*O3y|̴ӺXRs[Ui,Zj5Lk[ ׁ:&81Ε#ɶy ۔XnZycY<ha9'3Zs:]՗`_ NMz(R.Bo7IPnh7zgIsܥΊ[x_RrWTXmݿ;ew xTkknn Sutdkt_`={e"]]ΤKFe6V(:T6+XT !2z cX%٥Zz5PK ӁF PK2C.org/rosuda/REngine/REXPMismatchException.class}SmoP~`t2/X ͗O]'6/vıD?x.lrӞs{o?kt\Wn▎*s*yP2RuEPjI%q:r~cj/Ҕj(2 @UQ(24 Վ{qW0Zw8wDwzB*N?T糩u\h/BsY´ϥa/21l̲EbBR@2'&iÎ]QljPRԇ&.`b  FPS6W5ߪr_tUs: @ tGnJu DEnb/"{UM6zysB X3d0m>|XO9:ݱt׍oT@$M > (rC}ҭ3s4@u2C8`lHk f>'Y>FfVG>V8*9)s'RU'Sr 'uK~SHOdpQ-r@#\ɧ]zCzIFkl!c? ]s2#},Z~MY$+~uޓoOIv1\e?|3 w@3_4TZNg8z$侾}Y],' I&x>Af(o%ܠ*5i >PK8kPK2Corg/rosuda/REngine/REXPS4.class;o>.fYb✟WZQ/J//.MIrK>% \Eɩn `IJDV6 Ô`Fqr @7#0 iF ͪq#$ `Pr@L 9- LjA$xnPK2>G -PK2C org/rosuda/REngine/REXPRaw.classPKKQ=w5e,Z٢VF  \]uiQPn~TQZ"=9ޟ1}dCa-/RZ#{&o3H2|sS\{b5HE7jY7٣*)ZobUEؖ{q._6ZaJbdZb]}‹"DyO@_T̜:ɘkޱ.x*g}B*C\Ϗo=_gx ܽ0ex(+A2ҾMwG,th6RfZGvIL)VRWIaLq>:$1BL=$PK?TPK2C&org/rosuda/REngine/REXPReference.class}WGƿf7Th%Fcc -if6C7-f;ﯾAωpN<'yC|桿[oݮ?~afЍHVCWb"#fpu1QiOL""WE\!rS5["!["o#{"| G:>3ҹ-oD񩴟Ey_m_JCd4&|'igb؎j͚N:gihN^1͞dzNO_RgV[)3W$gQ۱cZe:4D47&g9-alLl H ky3gMhu\L3á ]KYs:_s.򶤐E uvYy;忏:n|a3幥]|0fz0yיO)$J]vK~0a^ s9뚆uR|O{3VrRՙA ❗V$4.i0b'!4 E&<''$Uf.jzgYɱ$QZs< ߶`tRdH꣞-g[̧a7$r n؏ NoD08w^CT*PFWlSǫ.*;vT*;^,Zyv띡#kx Ue*y&/b6?Jě;KP.Kuz?PKd:)@l PK2C$org/rosuda/REngine/REXPLogical.classV[sSUN'!%KZiIrjMh)^0Жҋ ! I9aDǑQt_^'^bu{^E*K*ZTPƃF#XM iT̨ b.ye^&/)(1F>g( j粖gi=S06σ}ԥ(&<0-$8-16ef#?/dh 1+ӎ?'|8Ks\>ݙY%sB6M(3SeNs:2F6mR'xirisQܖJ֘nw]}|ᶱh+'RtcQ֭Q&+m-!=1OĠn ܳ tk0Wm]Ӡ4My32lRNDkZ2)/J4ƢnKιhsB!@U/'s1d:$9$Z/I^ZpP7s`+ 7oq!:F v ,FML~{GW)hy^ uj~4:rQ KЗ,Nbu^2+aHߖ;Z>ij/!Ʒ̵GZ[biֲ}Qϯ!DaZҦp4A |o[s ȳ: $݈.jU(Iߚ:9<ߕwB<jl-HE9ԕl1RnwO0VDhWk*h[  pVqUDzWTBh{6?BS{xbZx߸؟&C# A0cyQvC\i!j:erqIuRU.S`jgdeڥ̫"tlS0Olwο@ Q~)?]Ȭ[E ?_;6Z v"Z bc_"ErMۮ5" CeH#MmL ?طޟ&>]|F!34PK+@ PK2C#org/rosuda/REngine/REXPVector.classQmO`=w/2D GL4!iCT⇎=ԚْWl?xo[B22bs{>響?~xx(a6tl2!#[ <lH"wf APv@%_z*z̬Ny(&}eq׎?2[?R8Rkã v󔿌8<#?U|vx@<La۾妽0lfNjC!Wg[cwNŌL[MZ=FLYKɍ%,smBq-FQ*F9ˉU>"3|Hyj~(W 2Bbr>ˉݲu6!?bPKZJPK2C org/rosuda/REngine/RFactor.classuVksU~6tY@ imPv7m"` (`I MQ//00#^3 *qf?@gA}޳KRB=gy'GDxLִ2ƀa#"TvO1&b}&tSavN{p ێq+Mu<@v+N^X`;I&+kM@<&;x.&>.P7~V\1 MdW ൺ?Q>W*uo*βT`VP1#${\F?S>5]PK 5u0 PK2C)org/rosuda/REngine/REngineStdOutput.classRn@=8qb^ҦЖĄ-З T)P"7&uq^~gJ |b hJ9gfw?la׀ nXӱn 46Tq_E%3wsDtȠՂ`x"|˛Ew+E-@w amn7^]b1m]ۑwJl8GW"x4SCId{^zbN-*x~qd XVT3axG(먘Űxq#B*˲Llcc<1T7&AX&o}JWa?Eϑ=rW:c ޫRVt Id_[<f(OH52F8Bg=A} YLӻѮ@OZ`h#: jDZ! |L}E bAH#.Srib `\0Dm3ĭ*34arPKPPK2C*org/rosuda/REngine/REXPJavaReference.classRN@=ȣV"[R]FƦ[SߥBG.,Ms9gΝz ,D cQ% i2a #'b:vΫ.Rz[F+i.CB_2gM+ܹ+ l1m(:vUӋgAWe[-bp_ϴV7u|G4 똖dS処-)63~nUȈa]$.׺#Cc`7leȍ8߯R#d ~Ut!٨CA<`zu,lY]?D?̖'sιΙs7}H+i֑@Q-ʊUR*PWX\ Dx3vDG yI/|Ŝi2]O:&}'8#ffn+/'t)!za[kEfS Ob_٭-}-IyY<|1v6[ N``O hԙ"''\!Q=;r 4.?1yvQ嫦ʂ?3&ȳxĘ㪆?@fV:ϘH_TljVs? 21/(U <#o|.m!q:c )\AUOɧXHM"/PK1ߜPK2C+org/rosuda/REngine/REngineUIInterface.class;o>nvNv.F ĒTF tҔD ׼̼Tm䜑_ꖙ`WCOVbY~Nb^~pIQf^5ҢdPy%Eiɩz = FR ?)+5XX4+P$PK< PK2C7org/rosuda/REngine/REngineConsoleHistoryInterface.classu 0Eojm8.;PZpm )%4-k~%6`u[.=ޏ' SYeml6]7^ xqRъ)A3kfe19?Ȋ,՝VzIYnn,k΁"Zx>>ew PKe1PK2C-org/rosuda/REngine/REngineEvalException.classQJ@=4w.D] Aj@n%mCĤIr#(~U wΝsν36}yp-OL9"e SZ ¡ffu@H;ǚK?3%;oFiaJiFohd*%4A6'Aڍb<5y%D9VT"Nr<aPnm,%"v6)LJ}腒7 qfV,99k_(h]_Hi*oLqݽ&^VlenQ'K2z'.x%#e%QNfˌ6fuYu|gN@]gNex2D]_fNvvvFǒ̤ҒTF= IJDļt`p^O~Q~Q~qiJ~k^zf^* cd /-JNu--ILIadâIP>6FF&`dad`f`X$PKNBLnPK2C!org/rosuda/REngine/REXPNull.classNPå,x &ֽƍх!huwRۤʅH4|(L骱=\|Ϝ~||8F M6:Zeֱ#*Wgy P8@m\{m^CϟYDSi^3"? UpQ8sr{fOXA. ¾ y=iPϜrˑZ["b_*ޭk#& Xc.'ZUPȟȖ('/Kw hB > z ȥY$kc?8l  ץF?-QxKѬzZU*- PK=fPK2C#org/rosuda/REngine/REXPSymbol.classR]OA=neiqK"U @D|0JH|e%[/>hmWN KMxسws;ϷTE HbI-*bXPqEIJ`E !cM]-A>ghr2jg;V!v`!S]' qjvjU7=^o~}6["1LK 3|q^p\C}aps|E(gFm|iRS[ovŮ\ :1@0L` SǦ'c]}sS!A&Iwq~zj: q|w[A\ CD"biiZ+A# "'&%T!a3џ.(?cWyD?Ru9\.AդBP +2# A;"^@@ Aha/yU^C.&/i$z8OxS PK?#&PK2C#org/rosuda/REngine/REXPString.classTKOQnghecE(SZS`*!(S!h;WlظP4Ѹ#3sgP9s{2?~}\ b>h C|0An8pXˆQ c}oK{35 m[K|6h|v;m k!=-351mfF/,iy1\+6 T,ִ,^(Z6˛Y)3HFaڎG V\,c[Mw3u㥢K.b5 -&e3lHETXo<'X!L24hA+@hZi}]/ȸK21^Ș2*P'$^2tj'ŗAf)+zh[[z'Qk>rP27gvs-}^ͣUQgO{*li=6`q<+ {tl! A~֥C6]G@ ]j $xD+1F<'Oh|;!om9ZGN۶ #u=o[tqu\h/nl/.;^Gf"jej{"CTvTxqv+/[_Qo'@BD>@X $) trvZ߫k^: CYCb Ʊ 1I>,PK&LPK2C$org/rosuda/REngine/REXPWrapper.class}W xT{3^^Y  ,e b6!L( 0I'3q2!*-*[ nH⊊-Ҫ(""VTD^fKo?w93G<`8~< hAkO  ݱE[}G<y p1Bœ Rء!pNM vi|[Qah֐n߫b06>9'_TOe>yE_Sp RWSpgvOVp; Nrw9C)?_ SqHK*8⤊S*W*>T3*>Vo'18OU+\bQ57$!hc#VeO8rb}@;# ~<>oU$sy OP[q9Ҁr- ׭pUAjQx)1#cEJLLAiCjWdHTzFͤ:u"$eH)wLl^w`"6teo  CH[Z̴g;bZWe}u%UKx z6#.àpG#89v'H+)n? D9ԺYM:RT})z ڀG)Ui~_ǝXΰ?k岸\:yą֋Oz%wpy]u5a]t|K\;fbH3r2m:Dɸ}aK4oc.lai =Oe\2!$1L:G(x:"_Dltq^tɘQ)]m}=!:s=IuuY|.Q'v׆xR=,:|jP䏛5@G=#c>]by V"'KA#Zu4t(k bi<)"nʹMǢ!'(~9CoXN0W$'qǣD7R 5`iљ Su4Z4jRjBvhS)RD-t),Vg:fdFxD!cP*}bGKUw`gܙ~_/57d[ z:+1rx]W1XfR3-PH+X{R>_NZ+k|-NAN^*@yo%J4p6pFEuW v霓 e/{w9jmjj\~F47C-1 ޮEll,ciUeDԛm~ĕe h?{3z 9KW3z>Gx4y?5xp^f h@KA/URCb8oK4Ka͠fr^e,jD~ -I Waǭch82ƴmx<ښdI-I֌$H~+ls\t߈QC[̶цse+3s~-3NaF:cz{T*=0dݙF!|٫ ShhܾŽ 1JZhĝJkX%qÜBp Z܈ dN$W M<ږd[5tfR&2l:dT U?#teoтn-5ILi.-ibM텄@ \VDT*dQK7m9UZ7VPE]CIJ y%,f1X`9U,^Vlֱ[Al`m&Ylf(xc4Y x}U<-)!ixFJN7Að[쓦U*R9ڤ98 9qPp K^㈴ K )!܇8&qޖNt HgpR"ޕd@ sr!>\[p^&₼_KqQpI~[pYގݸ"H=('"a|_2]ȺɗY-=Y?KA ~1P"k**teX`&RBEd`}^oiƲ7 2Er3^kEXok+pW  ۑ0z׼p+QK䳈n̾=s= HE/ _ 1C0iG8(@&n\l80n#Ik>X:|/iJPKS[ PK2C org/rosuda/REngine/REngine.classWV*~#n&m:k:wcA#YEQd9iVP`=al4Z~Ňs%9Qd>4+{ϑ8 h2Dʖ*x&?͖+ZL=v<~ YǏZďy\eO@s ]_x^_k%=x+<~ xQ@?^M5 <Nw&1 aQIs/[ -Kz,SKlZX&֩UZP,U/3b/:.jm4mV/9ďj=!CtԘ#vk8ҬF}a9K{p4ol0vIV,<]qPfI 7>;JUPz %,`aMŨ,i&ҡ< q|sx$@O/\ahv Nmtkn~L6I#)mD|_Qi(t8iTh6;EL UOi(Y'G}Nzʙܜ̓Cv֙:Rh2[JI#R^-; NX밻qnpl 8j).\2z}a `*iZ0%婺qMSJvB[d7YLe^ɏˆ,iɤ sBZie?*UXyi/-=cҒ4omӽA[IGt_ަ;RA 1agJH?[D=tqrLXڙ[nBfu'eO}鐱G M93CҏGO aߎ{zZ7_n)ˬ!~(fmb8X/ JHBZGKq|q dkBW5w]bGOhd칾!gb dF{HvU i-81x6c(mIg4#ڋ v%~b5ĉ2UDw:1Uā)2`(`1%ؽn:nwC:D~<{Jn{ Pt>HtcB>p)qBC/h:&h,h:8WG+iF3͍<ҖF84tFsU4 |̌ ]Gr*R~7iOI׹K.6y5Ē: _j%ZVL^,{ O]'O;cM!qIRܬlژ-ӑqF Z*PK!yVPK2C#org/rosuda/REngine/REXPDouble.classTMWe~L20jK&B@B):iLOpItڕ+.ذqbtΝ3Ç9}}s?Ϗ\ĊkxǿB+UèƄ6 `BEAL 8#mJ"#,7E`6 f@yfݜyKP֍ϊ*n9#;*AdG v_SBE\TŸjJhJf3FHK`P*\ #;)3V9?P*Uc`vg,Lb @,%≴Qv9e<4s[B$<@(\됄Uraʼn&ŐQIYU2 QjT%̛eϖvr)Jp>RfwT+E d²9Z^1' AbXVa5N Іv-IhŗRk޿o%@,㮆pEC5+C 9 !tO_ 4:ʼ5k|HY(ܩWX_7Kdx 'mk2qÚ3m7]i*z[Dk|ãvVt1V>I.kzҫgRuCoț}RB%pg/^EZ}M}ɻʒw?Dr[ IBD'7Z$8/v&_JY@d%~ .HБ )Ea<-W5{m_~_sq]yur-s:亦Q鮚uͺNC? 3 $J.vM[2"`/;X?#x[6p47pjIDW_C0S D=.Yљ$O~PHSo[nzA#}j"izbѼo]!*<\`=$Izb@d؄D =撾=Egvp ι ȇ:~AaOPKEPK2Corg/rosuda/REngine/RList.classWkp~Nl.K.KIv7 !" Y%AE YjdF[o^JkQ7ⴝmg:љZgcJ|'ˆG;߹y9Wo0 Q;dt>E\+#M.=2r^2yC yăGe1<.# L xO yZ632z@v#B'zM<8ZB~ x/_Nj|Ƀan/W cx8&'}Ń؞xou}taK|W:}BD2*nQV: x[M]\ m[lNv6Iv+/PZou()S]]H%5s`luŒ ݉d>n 'ɓi{:RȋrOB\WR+ӗ,SZr[fG 0::.ӕu9im>:GT3kӽ+TyRQ7w( I틏Afp%z\]_OD'ޝ6 cE4M22FYu1 ŻRIѬlK{8ˇ]% QΥCN1˵tIs_ڗAnrfDbkA G%Ny̆lmLv_Re6/5^juyʜmK6/֋7obȋKaEl9℈zxDU^|ۅjHhb'vy!gN]=doq{_F &ȈMkc=2в^/ҸE/7ũݻRzF8ŭŋ6gwD ?έ %# 'qs\7,WTO&;7=A`a|~yp/O5 N jv`!?5H0JC'*+c@}d!43 =K]j4,P8h9sy8y,'rk#'`"rV FhvEuE}.Քі. 2(G3╞B+I[ VjS&hϳvװ2̠ܨdkwg/# FLM})p39q?ukZxf>"xF/@1nޝMg$,7Ṳ [mT{Li[vz$nޛDktH0 RË m&p Re=0 cG J8{av'F-\SFFp.Vg=bЎkNGXϠ O:DpWg|hT@3z +}-OjkH8jgLʷ9Δ,i5L״`U"28}u<յyzAyCϬZ< vbJmJjٍ0M1j!+d0@sFE.ST]F=}!9YQOO>Jy:޶Z]QZ` * faVn~6Y,O+#ʴ gԼ&gc+ j}9/_b:~ k7olMuS/ߓvZ:͔'`\f;?%M,]v'H$ݓ͎ZÜ/3ğHYވ5=3('B-e{q1>wEj7`2xdrA6۲Zm'j樊*Ҙ_>7(طivsYFOUَ|v 3|ɍ_4Ae2~{ O7K?<+9*BTqA*  t ~Uj5,ۏEDu]UԮ1"52y-6<ej]'X0_mqT#m` y$AwJ28%R2TrvQ*0KU)WSHUaZf*_|j:v@:_A5[{c Q 7>'ʾ FBգR5FGP5bjBX-"2u\J={&t~$U-GjOEtEW|YΒRg\KO`R}dWR~|dQ[^*[q9m" PK W 3PK2C#org/rosuda/REngine/REXPFactor.classT[sT%[6m.M⤗uhzbJiPqZ;c)! ~]IuH.ǻGoϞ_K|`%()- 2>m*ஂ{N`U5U|!T}_Xȱࡆ`#^mR#O|)hf8]0bh7Uk+3N+0Stn>56kq%m9&3rHngPw;fwizxL莫O7*x 2ÊbDi(2m2}l&;%IPs2 {pC0[ :?nϦU;݆fqSG_XS81/0EG ^ױKCF]ϛgF˰m7:GnGGLgYU, rsgvl긁:@u^<ųJ/i Nã߷:Ʈ@^DܙL}" YH a ǡCo΋vRr +amJ!ڿLѾӔ%KOyzh*$wd~T"m.D4%b?A.AC~C$HA!Z;F &C$z&WꤋSUjRjѪ\pWL Grq'IF6AyP  egS}owHy3H MR9/{!~=qL0ø$:O_ {[^RSsK)0ٿ2H*4,SӮas i-܏Ix$~K8D^z. ab}5&arz u̳lTt34 nfSsùLI~PK]MPK2C!org/rosuda/REngine/REXPList.classUKsd=-G"&M8[ 8! }%5%;K0X0nEa= ,aU1v& {=H<2U9,q=d\WU /Yq]EYF]N›{_A^-|Xc3_?T1 weܓQwG;5cK`<_W222vŲzre[d?lzC@Z2)ڨC,[밦{d!xhdv )uˮxY5\yK̲+0彲Z5ۑͺc@0>pޑVuܨ;t'B>2J7:DLŭ[n@ ֮FL-bҤRëw? >#& }*Y`4Hj3ٮ4M½9 s o fBQ5094A@R`b*ǒL!!ɶ߲wl=z2U ;FoufoJg]ӦڊUd 8ҫn{rYuH92u ekr= 0<z9fnZ_-[CҟAɫz\-F,><8{&l!tSach>%(^65 ү(]b0YhA&qS%@̖G;ybH-yr~)IO/Cbt%Ca&;^u|>zGn\7cE:NN7B.hVz}5~0=c$&N$8D;(SE)H72^h|p1kџq rq\}sD }dS|& %/_"1`S^%iic dGoI,Kd/PKPK2C/org/rosuda/REngine/REngineOutputInterface.class;o>^vnvFޠ̒TTF# tҔD ׼̼Tm퓕X\Rn_Z\4ÐD3@Fg! ҢTLriiIAig^IjQZbr.FMFi`d@8?)+5YX4+fg02pI&.PKD\bPK2C%org/rosuda/REngine/REXPLanguage.class;o>!.> fYb ___\䚗Y\b✟+MJ- ILXшU5"n*WfOb^zib:$f (Pp~iQr[&pAj IJDV6 xx `f` $ف<9& d``bd4PH-'T

G -org/rosuda/REngine/REXPS4.classPK2C?T org/rosuda/REngine/REXPRaw.classPK2Cd:)@l &org/rosuda/REngine/REXPReference.classPK2C+@ $>#org/rosuda/REngine/REXPLogical.classPK2CZJ#(org/rosuda/REngine/REXPVector.classPK2C 5u0 *org/rosuda/REngine/RFactor.classPK2CP)b1org/rosuda/REngine/REngineStdOutput.classPK2C4B|*3org/rosuda/REngine/REXPJavaReference.classPK2C1ߜ$5org/rosuda/REngine/REXPUnknown.classPK2C< +7org/rosuda/REngine/REngineUIInterface.classPK2Ce178org/rosuda/REngine/REngineConsoleHistoryInterface.classPK2C|kU-9org/rosuda/REngine/REngineEvalException.classPK2C"(;org/rosuda/REngine/REXPEnvironment.classPK2CNBLn$>org/rosuda/REngine/MutableREXP.classPK2C=f!?org/rosuda/REngine/REXPNull.classPK2C?#&#SAorg/rosuda/REngine/REXPSymbol.classPK2C&L#Corg/rosuda/REngine/REXPString.classPK2CS[ $Gorg/rosuda/REngine/REXPWrapper.classPK2C!yV Porg/rosuda/REngine/REngine.classPK2CE#Xorg/rosuda/REngine/REXPDouble.classPK2C W 3]org/rosuda/REngine/RList.classPK2C]M#gorg/rosuda/REngine/REXPFactor.classPK2C!korg/rosuda/REngine/REXPList.classPK2CD\b/oorg/rosuda/REngine/REngineOutputInterface.classPK2C$5%porg/rosuda/REngine/REXPLanguage.classPK&& GrRserve/configure.ac0000644000176000001440000001434713442515504014052 0ustar ripleyusers# Process this file with autoconf to produce a configure script. AC_INIT([Rserve],[1.7],[Simon.Urbanek@r-project.org]) AC_CONFIG_SRCDIR([src/Rserv.c]) AC_CONFIG_HEADER([src/config.h]) # find R home and set CC/CFLAGS : ${R_HOME=`R RHOME`} if test -z "${R_HOME}"; then echo "could not determine R_HOME" exit 1 fi AC_ARG_WITH([server], AS_HELP_STRING(--with-server,[compile Rserve server (default is @<:@yes@:>@). Given that this is the main functionality of Rserve, the only reason to disable the server is to configure R or C++ client separately.]), [with_server=$withval], [with_server=yes]) AC_ARG_WITH([client], AS_HELP_STRING(--with-client,[compile additional C/C++ Rserve client (default is @<:@no@:>@). The client can be always compiled manually regardless of this setting.]), [with_client=$withval], [with_client=no]) AC_ARG_ENABLE([ipv6], [AC_HELP_STRING([--enable-ipv6], [enable the use of IPv6 protocol. @<:@no@:>@])], [want_ipv6="${enableval}"], [want_ipv6=no]) RLD=`${R_HOME}/bin/R CMD config --ldflags 2>/dev/null` has_R_shlib=no if test -n "$RLD"; then has_R_shlib=yes fi AC_MSG_CHECKING([whether to compile the server]) if test "${with_server}" = yes; then AC_MSG_RESULT(yes) if test "${has_R_shlib}" = no; then AC_MSG_ERROR([R was configured without --enable-R-shlib or --enable-R-static-lib *** Rserve requires R (shared or static) library. *** *** Please install R library or compile R with either --enable-R-shlib *** *** or --enable-R-static-lib support *** Alternatively use --without-server if you wish to build only Rserve client. ]) fi else AC_MSG_RESULT(no) fi AC_MSG_CHECKING([whether to compile the client]) if test "${with_client}" = yes; then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi AM_CONDITIONAL(WITH_SERVER, [test "x${with_server}" = xyes]) AM_CONDITIONAL(WITH_CLIENT, [test "x${with_client}" = xyes]) AC_LANG(C) CC=`${R_HOME}/bin/R CMD config CC`; CXX=`${R_HOME}/bin/R CMD config CXX`; CPPFLAGS="${CPPFLAGS} ${PKG_CPPFLAGS}" CFLAGS=`${R_HOME}/bin/R CMD config CFLAGS` CXXFLAGS=`${R_HOME}/bin/R CMD config CXXFLAGS` RINC=`${R_HOME}/bin/R CMD config --cppflags` LIBS="${LIBS} ${PKG_LIBS}" AC_SUBST(R_HOME) AC_SUBST(RINC) AC_SUBST(RLD) AC_ARG_VAR([OPENSSL_INCLUDES],[optional path to the include directory for OpenSSL headers]) AC_ARG_VAR([PKG_CPPFLAGS],[additional pre-processor flags]) AC_ARG_VAR([PKG_LIBS],[additional linker library flags]) if test "x${OPENSSL_INCLUDES}" != x; then CPPFLAGS="${CPPFLAGS} -I${OPENSSL_INCLUDES}" fi # Checks for programs. AC_PROG_CC # Checks for libraries. # Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([string.h memory.h sys/time.h unistd.h]) AC_CHECK_HEADERS([sys/stat.h sys/types.h sys/socket.h sys/un.h netinet/in.h netinet/tcp.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_BIGENDIAN(AC_DEFINE(BS_BIG_ENDIAN, 1, [Defined if the platform is big-endian]), AC_DEFINE(BS_LITTLE_ENDIAN, 1, [Defined if the platform is little-endian]), [ AC_MSG_RESULT(endianness unknown - will rely solely on compiler macros) AC_MSG_CHECKING([whether compiler sets endianness macros]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #if defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN_ || defined __BIG_ENDIAN__ || defined _BIG_ENDIAN_ #define BS_OK 1 #else cannot determine compiler's endianness #endif ])],[AC_MSG_RESULT(yes)],[ AC_MSG_RESULT(no) AC_MSG_ERROR([Cannot determine endianness neither from the compiler nor using a test. Try adding -D_BIG_ENDIAN_ or -D_LITTLE_ENDIAN_ to PKG_CPPFLAGS. ])]) ]) AC_HEADER_TIME # Checks for library functions. AC_FUNC_FORK AC_TYPE_SIGNAL AC_CHECK_FUNCS([memset mkdir rmdir select socket srandomdev]) # Check whether we can use crypt (and if we do if it's in the crypt library) AC_SEARCH_LIBS(crypt, crypt, [AC_DEFINE(HAS_CRYPT, 1, [If defined Rserve supports unix crypt password encryption.])]) AC_CHECK_HEADERS([crypt.h]) # socket related stuff - indroduced first due to Solaris # socklen_t - note that we don't try to find an equivalent! # we'll use BSD-style int in case this one isn't defined. # that should be fine for all major platforms. AC_CHECK_TYPE(socklen_t,, AC_DEFINE(socklen_t, int, [Define to `int' if neither nor define.]), [ #include #include ]) # connect may need -lsocket and/or -lnsl (e.g. on Solaris) AC_CHECK_FUNCS(connect) if test x"$ac_cv_func_connect" = x"no"; then case "$LIBS" in *-lnsl*) ;; *) AC_CHECK_LIB(nsl_s, printf) ;; esac case "$LIBS" in *-lnsl*) ;; *) AC_CHECK_LIB(nsl, printf) ;; esac case "$LIBS" in *-lsocket*) ;; *) AC_CHECK_LIB(socket, connect) ;; esac case "$LIBS" in *-linet*) ;; *) AC_CHECK_LIB(inet, connect) ;; esac dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value dnl has been cached. if test x"$ac_cv_lib_socket_connect" = x"yes" || test x"$ac_cv_lib_inet_connect" = x"yes"; then # ac_cv_func_connect=yes # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run AC_DEFINE(HAVE_CONNECT, 1, [ ]) fi fi # IPv6 have_ipv6=no AC_MSG_CHECKING([whether to enable IPv6]) if test "$want_ipv6" = yes; then AC_MSG_RESULT([yes]) AC_MSG_CHECKING([for working IPv6 sockets]) AC_LINK_IFELSE([AC_LANG_SOURCE([ #include #include int main(void) { struct sockaddr_in6 sin; int i = socket(PF_INET6, SOCK_STREAM, 0); sin.sin6_family = AF_INET6; sin.sin6_addr = in6addr_any; return 0; } ])],[AC_MSG_RESULT(yes) have_ipv6=yes],[AC_MSG_RESULT(no)]) else AC_MSG_RESULT([no]) fi if test "$have_ipv6" = yes; then AC_DEFINE(HAVE_IPV6, 1, [IPv6 support present and enabled]) fi # on some platforms libR expects dl code in the binary AC_CHECK_LIB(dl, dlopen) # check RSA/crypto AC_CHECK_HEADER([openssl/rsa.h], [AC_SEARCH_LIBS(RSA_generate_key, [crypto ssl openssl], [AC_DEFINE(HAVE_RSA, 1, [RSA crypto support])])]) # check SSL support AC_CHECK_HEADER([openssl/ssl.h], [AC_SEARCH_LIBS(SSL_CTX_load_verify_locations, [ssl openssl], [AC_DEFINE(HAVE_TLS, 1, [TLS/SSL support])])]) AC_CONFIG_FILES([src/Makevars]) AC_CONFIG_FILES([src/client/cxx/Makefile]) AC_OUTPUT Rserve/aclocal.m40000644000176000001440000000437613442515520013423 0ustar ripleyusers# generated automatically by aclocal 1.16.1 -*- Autoconf -*- # Copyright (C) 1996-2018 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 2006-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) Rserve/src/0000755000176000001440000000000012205226216012335 5ustar ripleyusersRserve/src/oc.h0000644000176000001440000000022412205226215013104 0ustar ripleyusers#ifndef OC_H__ #define OC_H__ #include SEXP oc_resolve(const char *ref); char *oc_register(SEXP what, char *dst, int len); #endif Rserve/src/base64.c0000644000176000001440000000324012205226215013563 0ustar ripleyusersvoid base64encode(const unsigned char *src, int len, char *dst); int base64decode(const char *src, void *dst, int max_len); static const char *b64tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /* dst must be at least (len + 2) / 3 * 4 + 1 bytes long and will be NUL terminated when done */ void base64encode(const unsigned char *src, int len, char *dst) { while (len > 0) { *(dst++) = b64tab[src[0] >> 2]; *(dst++) = b64tab[((src[0] & 0x03) << 4) | ((src[1] & 0xf0) >> 4)]; *(dst++) = (len > 1) ? b64tab[((src[1] & 0x0f) << 2) | ((src[2] & 0xc0) >> 6)] : '='; *(dst++) = (len > 2) ? b64tab[src[2] & 0x3f] : '='; src += 3; len -= 3; } *dst = 0; } static unsigned int val(const char **src) { while (1) { char c = **src; if (c) src[0]++; else return 0x10000; if (c >= 'A' && c <= 'Z') return c - 'A'; if (c >= 'a' && c <= 'z') return c - 'a' + 26; if (c >= '0' && c <= '9') return c - '0' + 52; if (c == '+') return 62; if (c == '/') return 63; if (c == '=') return 0x10000; /* we loop as to skip any blanks, newlines etc. */ } } /* returns the decoded length or -1 if max_len was not enough */ int base64decode(const char *src, void *dst, int max_len) { unsigned char *t = (unsigned char*) dst, *end = t + max_len; while (*src && t < end) { unsigned int v = val(&src); if (v > 64) break; *t = v << 2; v = val(&src); *t |= v >> 4; if (v < 64) { if (++t == end) return -1; *t = v << 4; v = val(&src); *t |= v >> 2; if (v < 64) { if (++t == end) return -1; *t = v << 6; v = val(&src); *t |= v & 0x3f; if (v < 64) t++; } } } return (int) (t - (unsigned char*) dst); } Rserve/src/http.c0000644000176000001440000007412412205226215013467 0ustar ripleyusers#include "RSserver.h" #include "tls.h" #include "http.h" #include "websockets.h" /* for connection upgrade */ #include "rserr.h" #include #include #include /* size of the line buffer for each worker (request and header only) * requests that have longer headers will be rejected with 413 * Note that cookies can be quite big and some browsers send them * in one line, so this should not be too small */ #define LINE_BUF_SIZE 32768 /* debug output - change the DBG(X) X to enable debugging output */ #ifdef RSERV_DEBUG #define DBG(X) X #else #define DBG(X) #endif /* --- httpd --- */ #define PART_REQUEST 0 #define PART_HEADER 1 #define PART_BODY 2 #define METHOD_POST 1 #define METHOD_GET 2 #define METHOD_HEAD 3 #define METHOD_OTHER 8 /* for custom requests only */ /* attributes of a connection/worker */ #define CONNECTION_CLOSE 0x0001 /* Connection: close response behavior is requested */ #define HOST_HEADER 0x0002 /* headers contained Host: header (required for HTTP/1.1) */ #define HTTP_1_0 0x0004 /* the client requested HTTP/1.0 */ #define CONTENT_LENGTH 0x0008 /* Content-length: was specified in the headers */ #define THREAD_OWNED 0x0010 /* the worker is owned by a thread and cannot removed */ #define THREAD_DISPOSE 0x0020 /* the thread should dispose of the worker */ #define CONTENT_TYPE 0x0040 /* message has a specific content type set */ #define CONTENT_FORM_UENC 0x0080 /* message content type is application/x-www-form-urlencoded */ #define WS_UPGRADE 0x0100 /* upgrade to WebSockets protocol */ struct buffer { struct buffer *next, *prev; int size, length; char data[1]; }; #ifdef unix #include /* needed for unix sockets */ #endif struct args { server_t *srv; /* server that instantiated this connection */ SOCKET s; SOCKET ss; void *res1, *res2; /* the following entries are not populated by Rserve but can be used by server implemetations */ char *buf, *sbuf; int ver, bp, bl, sp, sl, flags; long l1, l2; /* The following fields are informational, populated by Rserve */ SAIN sa; int ucix; #ifdef unix struct sockaddr_un su; #endif char *line_buf; /* line buffer (used for request and headers) */ char *url, *body; /* URL and request body */ char *content_type; /* content type (if set) */ unsigned int line_pos, body_pos; /* positions in the buffers */ long content_length; /* desired content length */ char part, method; /* request part, method */ int attr; /* connection attributes */ char *ws_protocol, *ws_version, *ws_key; struct buffer *headers; /* buffer holding header lines */ }; #define IS_HTTP_1_1(C) (((C)->attr & HTTP_1_0) == 0) /* returns the HTTP/x.x string for a given connection - we support 1.0 and 1.1 only */ #define HTTP_SIG(C) (IS_HTTP_1_1(C) ? "HTTP/1.1" : "HTTP/1.0") #ifndef USE_RINTERNALS #define USE_RINTERNALS #include #endif /* free buffers starting from the tail(!!) */ static void free_buffer(struct buffer *buf) { if (!buf) return; if (buf->prev) free_buffer(buf->prev); free(buf); } /* allocate a new buffer */ static struct buffer *alloc_buffer(int size, struct buffer *parent) { struct buffer *buf = (struct buffer*) malloc(sizeof(struct buffer) + size); if (!buf) return buf; buf->next = 0; buf->prev = parent; if (parent) parent->next = buf; buf->size = size; buf->length = 0; return buf; } /* convert doubly-linked buffers into one big raw vector */ static SEXP collect_buffers(struct buffer *buf) { SEXP res; char *dst; int len = 0; if (!buf) return allocVector(RAWSXP, 0); while (buf->prev) { /* count the total length and find the root */ len += buf->length; buf = buf->prev; } res = allocVector(RAWSXP, len + buf->length); dst = (char*) RAW(res); while (buf) { memcpy(dst, buf->data, buf->length); dst += buf->length; buf = buf->next; } return res; } static void free_args(args_t *c) { DBG(printf("finalizing worker %p\n", (void*) c)); if (c->url) { free(c->url); c->url = NULL; } if (c->line_buf) { free(c->line_buf); c->line_buf = NULL; } if (c->body) { free(c->body); c->body = NULL; } if (c->content_type) { free(c->content_type); c->content_type = NULL; } if (c->headers) { free_buffer(c->headers); c->headers = NULL; } if (c->ws_key) { free(c->ws_key); c->ws_key = NULL; } if (c->ws_protocol) { free(c->ws_protocol); c->ws_protocol = NULL; } if (c->ws_version) { free(c->ws_version); c->ws_version = NULL; } if (c->s != INVALID_SOCKET) { closesocket(c->s); c->s = INVALID_SOCKET; } } static int send_response(args_t *c, const char *buf, unsigned int len) { server_t *srv = c->srv; unsigned int i = 0; /* we have to tell R to ignore SIGPIPE otherwise it can raise an error and get us into deep trouble */ while (i < len) { int n = srv->send(c, buf + i, len - i); if (n < 1) { return -1; } i += n; } return 0; } /* sends HTTP/x.x plus the text (which should be of the form " XXX ...") */ static int send_http_response(args_t *c, const char *text) { char buf[96]; server_t *srv = c->srv; const char *s = HTTP_SIG(c); int l = strlen(text), res; /* reduce the number of packets by sending the payload en-block from buf */ if (l < sizeof(buf) - 10) { strcpy(buf, s); strcpy(buf + 8, text); return send_response(c, buf, l + 8); } res = srv->send(c, s, 8); if (res < 8) return -1; return send_response(c, text, strlen(text)); } /* decode URI in place (decoding never expands) */ static void uri_decode(char *s) { char *t = s; while (*s) { if (*s == '+') { /* + -> SPC */ *(t++) = ' '; s++; } else if (*s == '%') { unsigned char ec = 0; s++; if (*s >= '0' && *s <= '9') ec |= ((unsigned char)(*s - '0')) << 4; else if (*s >= 'a' && *s <= 'f') ec |= ((unsigned char)(*s - 'a' + 10)) << 4; else if (*s >= 'A' && *s <= 'F') ec |= ((unsigned char)(*s - 'A' + 10)) << 4; if (*s) s++; if (*s >= '0' && *s <= '9') ec |= (unsigned char)(*s - '0'); else if (*s >= 'a' && *s <= 'f') ec |= (unsigned char)(*s - 'a' + 10); else if (*s >= 'A' && *s <= 'F') ec |= (unsigned char)(*s - 'A' + 10); if (*s) s++; *(t++) = (char) ec; } else *(t++) = *(s++); } *t = 0; } /* parse a query string into a named character vector - must NOT be * URI decoded */ static SEXP parse_query(char *query) { int parts = 0; SEXP res, names; char *s = query, *key = 0, *value = query, *t = query; while (*s) { if (*s == '&') parts++; s++; } parts++; res = PROTECT(allocVector(STRSXP, parts)); names = PROTECT(allocVector(STRSXP, parts)); s = query; parts = 0; while (1) { if (*s == '=' && !key) { /* first '=' in a part */ key = value; *(t++) = 0; value = t; s++; } else if (*s == '&' || !*s) { /* next part */ int last_entry = !*s; *(t++) = 0; if (!key) key = ""; SET_STRING_ELT(names, parts, mkChar(key)); SET_STRING_ELT(res, parts, mkChar(value)); parts++; if (last_entry) break; key = 0; value = t; s++; } else if (*s == '+') { /* + -> SPC */ *(t++) = ' '; s++; } else if (*s == '%') { /* we cannot use uri_decode becasue we need &/= *before* decoding */ unsigned char ec = 0; s++; if (*s >= '0' && *s <= '9') ec |= ((unsigned char)(*s - '0')) << 4; else if (*s >= 'a' && *s <= 'f') ec |= ((unsigned char)(*s - 'a' + 10)) << 4; else if (*s >= 'A' && *s <= 'F') ec |= ((unsigned char)(*s - 'A' + 10)) << 4; if (*s) s++; if (*s >= '0' && *s <= '9') ec |= (unsigned char)(*s - '0'); else if (*s >= 'a' && *s <= 'f') ec |= (unsigned char)(*s - 'a' + 10); else if (*s >= 'A' && *s <= 'F') ec |= (unsigned char)(*s - 'A' + 10); if (*s) s++; *(t++) = (char) ec; } else *(t++) = *(s++); } setAttrib(res, R_NamesSymbol, names); UNPROTECT(2); return res; } static SEXP R_ContentTypeName; /* create an object representing the request body. It is NULL if the body is empty (or zero length). * In the case of a URL encoded form it will have the same shape as the query string (named string vector). * In all other cases it will be a raw vector with a "content-type" attribute (if specified in the headers) */ static SEXP parse_request_body(args_t *c) { if (!c || !c->body) return R_NilValue; if ((c->attr & CONTENT_FORM_UENC) && !(c->srv->flags & HTTP_RAW_BODY)) { /* URL encoded form - return parsed form */ c->body[c->content_length] = 0; /* the body is guaranteed to have an extra byte for the termination */ return parse_query(c->body); } else { /* something else - pass it as a raw vector */ SEXP res = PROTECT(Rf_allocVector(RAWSXP, c->content_length)); if (c->content_length) memcpy(RAW(res), c->body, c->content_length); if (c->content_type) { /* attach the content type so it can be interpreted */ if (!R_ContentTypeName) R_ContentTypeName = install("content-type"); setAttrib(res, R_ContentTypeName, mkString(c->content_type)); } UNPROTECT(1); return res; } } /* finalize a request - essentially for HTTP/1.0 it means that * we have to close the connection */ static void fin_request(args_t *c) { if (!IS_HTTP_1_1(c)) c->attr |= CONNECTION_CLOSE; } /* process a request by calling the httpd() function in R */ static void process_request(args_t *c) { const char *ct = "text/html"; char *query = 0, *s; SEXP sHeaders = R_NilValue; int code = 200; DBG(Rprintf("process request for %p\n", (void*) c)); if (!c || !c->url) return; /* if there is not enough to process, bail out */ if ((c->attr & WS_UPGRADE) && (c->srv->flags & HTTP_WS_UPGRADE)) { WS13_upgrade(c, c->ws_key, c->ws_protocol, c->ws_version); /* the WS swtich messes up args since it replaces it with its own version so we can't go back to serving - just bail out (NOTE: only works when forked!) */ exit(0); } s = c->url; while (*s && *s != '?') s++; /* find the query part */ if (*s) { *(s++) = 0; query = s; } uri_decode(c->url); /* decode the path part */ { /* construct "try(httpd(url, query, body, headers), silent=TRUE)" */ SEXP sTrue = PROTECT(ScalarLogical(TRUE)); SEXP sBody = PROTECT(parse_request_body(c)); SEXP sQuery = PROTECT(query ? parse_query(query) : R_NilValue); SEXP sReqHeaders = PROTECT(c->headers ? collect_buffers(c->headers) : R_NilValue); SEXP sArgs = PROTECT(list4(mkString(c->url), sQuery, sBody, sReqHeaders)); SEXP sTry = install("try"); SEXP y, x = PROTECT(lang3(sTry, LCONS(install(".http.request"), sArgs), sTrue)); SET_TAG(CDR(CDR(x)), install("silent")); DBG(Rprintf("eval(try(.http.request('%s'),silent=TRUE))\n", c->url)); /* evaluate the above in the global namespace */ x = PROTECT(eval(x, R_GlobalEnv)); /* the result is expected to have one of the following forms: a) character vector of length 1 => error (possibly from try), will create 500 response b) list(payload[, content-type[, headers[, status code]]]) payload: can be a character vector of length one or a raw vector. if the character vector is named "file" then the content of a file of that name is the payload content-type: must be a character vector of length one or NULL (if present, else default is "text/html") headers: must be a character vector - the elements will have CRLF appended and neither Content-type nor Content-length may be used status code: must be an integer if present (default is 200) */ if (TYPEOF(x) == STRSXP && LENGTH(x) > 0) { /* string means there was an error */ const char *s = CHAR(STRING_ELT(x, 0)); send_http_response(c, " 500 Evaluation error\r\nConnection: close\r\nContent-type: text/plain\r\n\r\n"); DBG(Rprintf("respond with 500 and content: %s\n", s)); if (c->method != METHOD_HEAD) send_response(c, s, strlen(s)); c->attr |= CONNECTION_CLOSE; /* force close */ UNPROTECT(7); return; } if (TYPEOF(x) == VECSXP && LENGTH(x) > 0) { /* a list (generic vector) can be a real payload */ SEXP xNames = getAttrib(x, R_NamesSymbol); if (LENGTH(x) > 1) { SEXP sCT = VECTOR_ELT(x, 1); /* second element is content type if present */ if (TYPEOF(sCT) == STRSXP && LENGTH(sCT) > 0) ct = CHAR(STRING_ELT(sCT, 0)); if (LENGTH(x) > 2) { /* third element is headers vector */ sHeaders = VECTOR_ELT(x, 2); if (TYPEOF(sHeaders) != STRSXP) sHeaders = R_NilValue; if (LENGTH(x) > 3) /* fourth element is HTTP code */ code = asInteger(VECTOR_ELT(x, 3)); } } y = VECTOR_ELT(x, 0); if (TYPEOF(y) == STRSXP && LENGTH(y) > 0) { char buf[64]; int is_tmp = 0; const char *cs = CHAR(STRING_ELT(y, 0)), *fn = 0; if (code == 200) send_http_response(c, " 200 OK\r\nContent-type: "); else { sprintf(buf, "%s %d Code %d\r\nContent-type: ", HTTP_SIG(c), code, code); send_response(c, buf, strlen(buf)); } send_response(c, ct, strlen(ct)); if (sHeaders != R_NilValue) { unsigned int i = 0, n = LENGTH(sHeaders); for (; i < n; i++) { const char *hs = CHAR(STRING_ELT(sHeaders, i)); if (*hs) { /* headers must be non-empty */ send_response(c, "\r\n", 2); send_response(c, hs, strlen(hs)); } } } /* special content - a file: either list(file="") or list(tmpfile="") the latter will be deleted once served */ if (TYPEOF(xNames) == STRSXP && LENGTH(xNames) > 0 && (!strcmp(CHAR(STRING_ELT(xNames, 0)), "file") || (is_tmp = !strcmp(CHAR(STRING_ELT(xNames, 0)), "tmpfile")))) fn = cs; if (fn) { char *fbuf; FILE *f = fopen(fn, "rb"); long fsz = 0; if (!f) { send_response(c, "\r\nContent-length: 0\r\n\r\n", 23); UNPROTECT(7); fin_request(c); return; } fseek(f, 0, SEEK_END); fsz = ftell(f); fseek(f, 0, SEEK_SET); sprintf(buf, "\r\nContent-length: %ld\r\n\r\n", fsz); send_response(c, buf, strlen(buf)); if (c->method != METHOD_HEAD) { fbuf = (char*) malloc(32768); if (fbuf) { while (fsz > 0 && !feof(f)) { int rd = (fsz > 32768) ? 32768 : fsz; if (fread(fbuf, 1, rd, f) != rd) { free(fbuf); UNPROTECT(7); c->attr |= CONNECTION_CLOSE; fclose(f); if (is_tmp) unlink(fn); return; } send_response(c, fbuf, rd); fsz -= rd; } free(fbuf); } else { /* allocation error - get out */ UNPROTECT(7); c->attr |= CONNECTION_CLOSE; fclose(f); if (is_tmp) unlink(fn); return; } } fclose(f); if (is_tmp) unlink(fn); UNPROTECT(7); fin_request(c); return; } sprintf(buf, "\r\nContent-length: %u\r\n\r\n", (unsigned int) strlen(cs)); send_response(c, buf, strlen(buf)); if (c->method != METHOD_HEAD) send_response(c, cs, strlen(cs)); UNPROTECT(7); fin_request(c); return; } if (TYPEOF(y) == RAWSXP) { char buf[64]; Rbyte *cs = RAW(y); if (code == 200) send_http_response(c, " 200 OK\r\nContent-type: "); else { sprintf(buf, "%s %d Code %d\r\nContent-type: ", HTTP_SIG(c), code, code); send_response(c, buf, strlen(buf)); } send_response(c, ct, strlen(ct)); if (sHeaders != R_NilValue) { unsigned int i = 0, n = LENGTH(sHeaders); for (; i < n; i++) { const char *hs = CHAR(STRING_ELT(sHeaders, i)); send_response(c, "\r\n", 2); send_response(c, hs, strlen(hs)); } } sprintf(buf, "\r\nContent-length: %u\r\n\r\n", LENGTH(y)); send_response(c, buf, strlen(buf)); if (c->method != METHOD_HEAD) send_response(c, (char*) cs, LENGTH(y)); UNPROTECT(7); fin_request(c); return; } } UNPROTECT(7); } send_http_response(c, " 500 Invalid response from R\r\nConnection: close\r\nContent-type: text/plain\r\n\r\nServer error: invalid response from R\r\n"); c->attr |= CONNECTION_CLOSE; /* force close */ } static void http_close(args_t *arg) { closesocket(arg->s); arg->s = -1; } /* this function is called to fetch new data from the client * connection socket and process it */ static void http_input_iteration(args_t *c) { int n; server_t *srv = c->srv; DBG(printf("worker_input_handler, data=%p\n", (void*) c)); if (!c) return; DBG(printf("input handler for worker %p (sock=%d, part=%d, method=%d, line_pos=%d)\n", (void*) c, (int)c->s, (int)c->part, (int)c->method, (int)c->line_pos)); /* FIXME: there is one edge case that is not caught on unix: if * recv reads two or more full requests into the line buffer then * this function exits after the first one, but input handlers may * not trigger, because there may be no further data. It is not * trivial to fix, because just checking for a full line at the * beginning and not calling recv won't trigger a new input * handler. However, under normal circumstance this should not * happen, because clients should wait for the response and even * if they don't it's unlikely that both requests get combined * into one packet. */ if (c->part < PART_BODY) { char *s = c->line_buf; n = srv->recv(c, c->line_buf + c->line_pos, LINE_BUF_SIZE - c->line_pos - 1); DBG(printf("[recv n=%d, line_pos=%d, part=%d]\n", n, c->line_pos, (int)c->part)); if (n < 0) { /* error, scrape this worker */ http_close(c); return; } if (n == 0) { /* connection closed -> try to process and then remove */ process_request(c); http_close(c); return; } c->line_pos += n; c->line_buf[c->line_pos] = 0; DBG(printf("in buffer: {%s}\n", c->line_buf)); while (*s) { /* ok, we have genuine data in the line buffer */ if (s[0] == '\n' || (s[0] == '\r' && s[1] == '\n')) { /* single, empty line - end of headers */ /* --- check request validity --- */ DBG(printf(" end of request, moving to body\n")); if (!(c->attr & HTTP_1_0) && !(c->attr & HOST_HEADER)) { /* HTTP/1.1 mandates Host: header */ send_http_response(c, " 400 Bad Request (Host: missing)\r\nConnection: close\r\n\r\n"); http_close(c); return; } if (c->attr & CONTENT_LENGTH && c->content_length) { if (c->content_length < 0 || /* we are parsing signed so negative numbers are bad */ c->content_length > 2147483640 || /* R will currently have issues with body around 2Gb or more, so better to not go there */ !(c->body = (char*) malloc(c->content_length + 1 /* allocate an extra termination byte */ ))) { send_http_response(c, " 413 Request Entity Too Large (request body too big)\r\nConnection: close\r\n\r\n"); http_close(c); return; } } c->body_pos = 0; c->part = PART_BODY; if (s[0] == '\r') s++; s++; /* move the body part to the beginning of the buffer */ c->line_pos -= s - c->line_buf; memmove(c->line_buf, s, c->line_pos); /* GET/HEAD or no content length mean no body */ if (c->method == METHOD_GET || c->method == METHOD_HEAD || !(c->attr & CONTENT_LENGTH) || c->content_length == 0) { if ((c->attr & CONTENT_LENGTH) && c->content_length > 0) { send_http_response(c, " 400 Bad Request (GET/HEAD with body)\r\n\r\n"); http_close(c); return; } process_request(c); if (c->attr & CONNECTION_CLOSE) { http_close(c); return; } /* keep-alive - reset the worker so it can process a new request */ if (c->url) { free(c->url); c->url = NULL; } if (c->body) { free(c->body); c->body = NULL; } if (c->content_type) { free(c->content_type); c->content_type = NULL; } if (c->headers) { free_buffer(c->headers); c->headers = NULL; } if (c->ws_key) { free(c->ws_key); c->ws_key = NULL; } if (c->ws_protocol) { free(c->ws_protocol); c->ws_protocol = NULL; } if (c->ws_version) { free(c->ws_version); c->ws_version = NULL; } c->body_pos = 0; c->method = 0; c->part = PART_REQUEST; c->attr = 0; c->content_length = 0; return; } /* copy body content (as far as available) */ c->body_pos = (c->content_length < c->line_pos) ? c->content_length : c->line_pos; if (c->body_pos) { memcpy(c->body, c->line_buf, c->body_pos); c->line_pos -= c->body_pos; /* NOTE: we are NOT moving the buffer since non-zero left-over causes connection close */ } /* POST will continue into the BODY part */ break; } { char *bol = s; while (*s && *s != '\r' && *s != '\n') s++; if (!*s) { /* incomplete line */ if (bol == c->line_buf) { if (c->line_pos < LINE_BUF_SIZE) /* one, incomplete line, but the buffer is not full yet, just return */ return; /* the buffer is full yet the line is incomplete - we're in trouble */ send_http_response(c, " 413 Request entity too large\r\nConnection: close\r\n\r\n"); http_close(c); return; } /* move the line to the begining of the buffer for later requests */ c->line_pos -= bol - c->line_buf; memmove(c->line_buf, bol, c->line_pos); return; } else { /* complete line, great! */ if (*s == '\r') *(s++) = 0; if (*s == '\n') *(s++) = 0; DBG(printf("complete line: {%s}\n", bol)); if (c->part == PART_REQUEST) { /* --- process request line --- */ unsigned int rll = strlen(bol); /* request line length */ char *url = strchr(bol, ' '); if (!url || rll < 14 || strncmp(bol + rll - 9, " HTTP/1.", 8)) { /* each request must have at least 14 characters [GET / HTTP/1.0] and have HTTP/1.x */ send_response(c, "HTTP/1.0 400 Bad Request\r\n\r\n", 28); http_close(c); return; } url++; if (!strncmp(bol + rll - 3, "1.0", 3)) c->attr |= HTTP_1_0; if (!strncmp(bol, "GET ", 4)) c->method = METHOD_GET; if (!strncmp(bol, "POST ", 5)) c->method = METHOD_POST; if (!strncmp(bol, "HEAD ", 5)) c->method = METHOD_HEAD; { char *mend = url - 1; /* we generate a header with the method so it can be passed to the handler */ if (!c->headers) c->headers = alloc_buffer(1024, NULL); /* make sure it fits */ if (c->headers->size - c->headers->length >= 18 + (mend - bol)) { if (!c->method) c->method = METHOD_OTHER; /* add "Request-Method: xxx" */ memcpy(c->headers->data + c->headers->length, "Request-Method: ", 16); c->headers->length += 16; memcpy(c->headers->data + c->headers->length, bol, mend - bol); c->headers->length += mend - bol; c->headers->data[c->headers->length++] = '\n'; } } if (!c->method) { send_http_response(c, " 501 Invalid or unimplemented method\r\n\r\n"); http_close(c); return; } bol[strlen(bol) - 9] = 0; c->url = strdup(url); c->part = PART_HEADER; DBG(printf("parsed request, method=%d, URL='%s'\n", (int)c->method, c->url)); } else if (c->part == PART_HEADER) { /* --- process headers --- */ char *k = bol; if (!c->headers) c->headers = alloc_buffer(1024, NULL); if (c->headers) { /* record the header line in the buffer */ int l = strlen(bol); if (l) { /* this should be really always true */ if (c->headers->length + l + 1 > c->headers->size) { /* not enough space? */ int fits = c->headers->size - c->headers->length; int needs = 2048; if (fits) { memcpy(c->headers->data + c->headers->length, bol, fits); c->headers->length += fits; } while (l + 1 - fits >= needs) needs <<= 1; if (alloc_buffer(needs, c->headers)) { c->headers = c->headers->next; memcpy(c->headers->data, bol + fits, l - fits); c->headers->length = l - fits; c->headers->data[c->headers->length++] = '\n'; } } else { memcpy(c->headers->data + c->headers->length, bol, l); c->headers->length += l; c->headers->data[c->headers->length++] = '\n'; } } } while (*k && *k != ':') { if (*k >= 'A' && *k <= 'Z') *k |= 0x20; k++; } if (*k == ':') { *(k++) = 0; while (*k == ' ' || *k == '\t') k++; DBG(printf("header '%s' => '%s'\n", bol, k)); if (!strcmp(bol, "upgrade") && !strcmp(k, "websocket")) c->attr |= WS_UPGRADE; if (!strcmp(bol, "content-length")) { c->attr |= CONTENT_LENGTH; c->content_length = atol(k); } if (!strcmp(bol, "content-type")) { char *l = k; while (*l) { if (*l >= 'A' && *l <= 'Z') *l |= 0x20; l++; } c->attr |= CONTENT_TYPE; if (c->content_type) free(c->content_type); c->content_type = strdup(k); if (!strncmp(k, "application/x-www-form-urlencoded", 33)) c->attr |= CONTENT_FORM_UENC; } if (!strcmp(bol, "host")) c->attr |= HOST_HEADER; if (!strcmp(bol, "connection")) { char *l = k; while (*l) { if (*l >= 'A' && *l <= 'Z') *l |= 0x20; l++; } if (!strncmp(k, "close", 5)) c->attr |= CONNECTION_CLOSE; } if (!strcmp(bol, "sec-websocket-key")) { if (c->ws_key) free(c->ws_key); c->ws_key = strdup(k); } if (!strcmp(bol, "sec-websocket-protocol")) { if (c->ws_protocol) free(c->ws_protocol); c->ws_protocol = strdup(k); } if (!strcmp(bol, "sec-websocket-version")) { if (c->ws_version) free(c->ws_version); c->ws_version = strdup(k); } DBG(Rprintf(" [attr = %x]\n", c->attr)); } } } } } if (c->part < PART_BODY) { /* we end here if we processed a buffer of exactly one line */ c->line_pos = 0; return; } } if (c->part == PART_BODY && c->body) { /* BODY - this branch always returns */ if (c->body_pos < c->content_length) { /* need to receive more ? */ DBG(printf("BODY: body_pos=%d, content_length=%ld\n", c->body_pos, c->content_length)); n = srv->recv(c, c->body + c->body_pos, c->content_length - c->body_pos); DBG(printf(" [recv n=%d - had %u of %lu]\n", n, c->body_pos, c->content_length)); c->line_pos = 0; if (n < 0) { /* error, scrap this worker */ http_close(c); return; } if (n == 0) { /* connection closed -> try to process and then remove */ process_request(c); http_close(c); return; } c->body_pos += n; } if (c->body_pos == c->content_length) { /* yay! we got the whole body */ process_request(c); if (c->attr & CONNECTION_CLOSE || c->line_pos) { /* we have to close the connection if there was a double-hit */ http_close(c); return; } /* keep-alive - reset the worker so it can process a new request */ if (c->url) { free(c->url); c->url = NULL; } if (c->body) { free(c->body); c->body = NULL; } if (c->content_type) { free(c->content_type); c->content_type = NULL; } if (c->headers) { free_buffer(c->headers); c->headers = NULL; } if (c->ws_key) { free(c->ws_key); c->ws_key = NULL; } if (c->ws_protocol) { free(c->ws_protocol); c->ws_protocol = NULL; } if (c->ws_version) { free(c->ws_version); c->ws_version = NULL; } c->line_pos = 0; c->body_pos = 0; c->method = 0; c->part = PART_REQUEST; c->attr = 0; c->content_length = 0; return; } } /* we enter here only if recv was used to leave the headers with no body */ if (c->part == PART_BODY && !c->body) { char *s = c->line_buf; if (c->line_pos > 0) { if ((s[0] != '\r' || s[1] != '\n') && (s[0] != '\n')) { send_http_response(c, " 411 length is required for non-empty body\r\nConnection: close\r\n\r\n"); http_close(c); return; } /* empty body, good */ process_request(c); if (c->attr & CONNECTION_CLOSE) { http_close(c); return; } else { /* keep-alive */ int sh = 1; if (s[0] == '\r') sh++; if (c->line_pos <= sh) c->line_pos = 0; else { /* shift the remaining buffer */ memmove(c->line_buf, c->line_buf + sh, c->line_pos - sh); c->line_pos -= sh; } /* keep-alive - reset the worker so it can process a new request */ if (c->url) { free(c->url); c->url = NULL; } if (c->body) { free(c->body); c->body = NULL; } if (c->content_type) { free(c->content_type); c->content_type = NULL; } if (c->headers) { free_buffer(c->headers); c->headers = NULL; } if (c->ws_key) { free(c->ws_key); c->ws_key = NULL; } if (c->ws_protocol) { free(c->ws_protocol); c->ws_protocol = NULL; } if (c->ws_version) { free(c->ws_version); c->ws_version = NULL; } c->body_pos = 0; c->method = 0; c->part = PART_REQUEST; c->attr = 0; c->content_length = 0; return; } } n = srv->recv(c, c->line_buf + c->line_pos, LINE_BUF_SIZE - c->line_pos - 1); if (n < 0) { /* error, scrap this worker */ http_close(c); return; } if (n == 0) { /* connection closed -> try to process and then remove */ process_request(c); http_close(c); return; } if ((s[0] != '\r' || s[1] != '\n') && (s[0] != '\n')) { send_http_response(c, " 411 length is required for non-empty body\r\nConnection: close\r\n\r\n"); http_close(c); return; } } } static void HTTP_connected(void *parg) { args_t *arg = (args_t*) parg; if (Rserve_prepare_child(arg) != 0) { /* parent or error */ free(arg); return; } if (!(arg->line_buf = (char*) malloc(LINE_BUF_SIZE))) { RSEprintf("ERROR: unable to allocate line buffer\n"); free(arg); return; } if ((arg->srv->flags & SRV_TLS) && shared_tls(0)) add_tls(arg, shared_tls(0), 1); while (arg->s != -1) http_input_iteration(arg); free_args(arg); } server_t *create_HTTP_server(int port, int flags) { server_t *srv = create_server(port, 0, 0, flags); #ifdef RSERV_DEBUG fprintf(stderr, "create_HTTP_server(port = %d, flags=0x%x)\n", port, flags); #endif if (srv) { srv->connected = HTTP_connected; /* srv->send_resp = */ srv->recv = server_recv; srv->send = server_send; srv->fin = server_fin; add_server(srv); return srv; } return 0; } /*--- The following makes the indenting behavior of emacs compatible with Xcode's 4/4 setting ---*/ /* Local Variables: */ /* indent-tabs-mode: t */ /* tab-width: 4 */ /* c-basic-offset: 4 */ /* End: */ Rserve/src/rsio.c0000644000176000001440000002221112205226215013452 0ustar ripleyusers/* small IPC framework that allows bi-directional communication between parent/child processes including the ability to pass fds/sockets (C)Copyright 2013 Simon Urbanek License: 2-clause BSD Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rsio.h" /* --- non-API --- */ #ifdef WIN32 /* we could emulate socketpair() on Windows, but it's pointless since there is no fork() -- so just plug in empty stubs for now. */ rsio_t *rsio_new() { return 0; } void rsio_free(rsio_t *io) {} void rsio_close(rsio_t *io) {} void rsio_set_child(rsio_t *io) {} void rsio_set_parent(rsio_t *io) {} void rsmsg_free(rsmsg_t *msg) {} rsmsg_t *rsio_read_msg(rsio_t *io) { return 0; } int rsio_write(rsio_t *io, const void *buf, rsmsglen_t len, int cmd, int fd) { return -1; } int rsio_write_msg(rsio_t *io, rsmsg_t *msg) { return -1; } int rsio_select_fd(rsio_t *io) { return -1; } #else /* real implementation using socketpair() on unix */ #include #include #include #define MAX_IO_PIPES 2048 #define MAX_CHUNK (1024*1024) /* max send size */ /* internal flags inside rsio */ #define RSIO_IN_USE 0x02 #define RSIO_CHILD 0x01 /* it *must* be 1 since we use fd[flags & RSIO_CHILD] */ struct rsio { int fd[2]; unsigned int flags, location; }; /* we keep a static pool to avoid allocations */ static rsio_t io_pool[MAX_IO_PIPES]; static int io_pool_max, io_pool_count; #ifdef RSIO_DEBUG #include #endif rsio_t *rsio_new() { rsio_t *io; unsigned int i = io_pool_max; if (io_pool_count < io_pool_max) /* there is a hole - find it */ for (i = 0; i < io_pool_max; i++) if (!(io_pool[i].flags & RSIO_IN_USE)) break; if (i >= MAX_IO_PIPES) return 0; io = io_pool + i; if (socketpair(AF_UNIX, SOCK_STREAM, 0, io->fd)) return 0; io->flags = RSIO_IN_USE; io->location = i; io_pool_count++; if (io_pool_max == i) io_pool_max++; return io; } void rsio_close(rsio_t *io) { if (io) { close(io->fd[0]); io->fd[0] = -1; close(io->fd[1]); io->fd[1] = -1; } } void rsio_free(rsio_t *io) { if (io) { rsio_close(io); io->flags = 0; if (io->location < io_pool_max) { io_pool_count--; /* shrink as much as possible */ while (io_pool_max && ((io_pool[io_pool_max - 1].flags & RSIO_IN_USE) == 0)) io_pool_max--; } } } void rsio_set_child(rsio_t *io) { if (io) { io->flags |= RSIO_CHILD; close(io->fd[0]); } } void rsio_set_parent(rsio_t *io) { if (io) { close(io->fd[1]); } } void rsmsg_free(rsmsg_t *msg) { free(msg); } #define CMD_HAS_FD 0x010000 #define CMD_LONG 0x020000 #define CMD_MASK 0x00ffff typedef struct { int cmd; unsigned int len1, len2; } iohdr_t; /* global buffers for the control - their size is not a constant so we can't allocate them at compile time */ static struct cmsghdr *cmsg_send, *cmsg_recv; rsmsg_t *rsio_read_msg(rsio_t *io) { struct msghdr msg; struct iovec iov; rsmsg_t *res; int n, clen = CMSG_LEN(sizeof(int)); /* for the FD */ int fd; iohdr_t hdr; rsmsglen_t len; unsigned char *ptr; if (!io) return 0; fd = io->fd[io->flags & RSIO_CHILD]; if (!cmsg_recv) cmsg_recv = malloc(clen); if (!cmsg_recv) return 0; cmsg_recv->cmsg_level = SOL_SOCKET; cmsg_recv->cmsg_type = SCM_RIGHTS; cmsg_recv->cmsg_len = clen; *(int*)CMSG_DATA(cmsg_recv) = -1; /* initialize recv FD to -1 */ iov.iov_base = &hdr; iov.iov_len = 8; /* first 8 bytes are mandatory */ msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_name = 0; msg.msg_namelen = 0; msg.msg_control = cmsg_recv; msg.msg_controllen = clen; n = (int) recvmsg(fd, &msg, MSG_WAITALL); if (n < 8) { /* we need at least 8 bytes */ #ifdef RSIO_DEBUG fprintf(stderr, "ERROR: rsio(%p)read: recvmsg got %d, expected 8\n", io, n); #endif rsio_close(io); return 0; } len = hdr.len1; if (hdr.cmd & CMD_LONG) { if (recv(fd, &(hdr.len2), sizeof(hdr.len2), 0) != sizeof(hdr.len2)) { #ifdef RSIO_DEBUG fprintf(stderr, "ERROR: rsio(%p)read: cmd=0x%x -> LONG but receiving len2 failed\n", io, hdr.cmd); #endif rsio_close(io); return 0; } #ifdef __LP64__ len |= (((rsmsglen_t) hdr.len2) << 32); #else if (hdr.len2) { /* 64-bit size requested, but we can't do that */ #ifdef RSIO_DEBUG fprintf(stderr, "ERROR: rsio(%p)read: cmd=0x%x, 64-bit length on 32-bit system\n", io, hdr.cmd); #endif rsio_close(io); return 0; } #endif } /* guarantee one extra byte */ res = malloc(sizeof(rsmsg_t) + len + 1); if (!res) { #ifdef RSIO_DEBUG fprintf(stderr, "ERROR: rsio(%p)read: cannot allocate %lu bytes\n", io, (unsigned long) (sizeof(rsmsg_t) + len)); #endif rsio_close(io); return 0; } res->cmd = hdr.cmd & CMD_MASK; res->flags = (hdr.cmd & CMD_HAS_FD) ? RSMSG_HAS_FD : 0; res->fd = *(int*)CMSG_DATA(cmsg_recv); res->len = len; ptr = res->data; while (len) { unsigned int chunk = (unsigned int) ((len > MAX_CHUNK) ? MAX_CHUNK : len); n = (int) recv(fd, ptr, chunk, 0); if (n < 1) { free(res); #ifdef RSIO_DEBUG fprintf(stderr, "ERROR: rsio(%p)read: cmd=0x%x, len=%lu, recv=%d (expected %d) with %lu bytes to go\n", io, hdr.cmd, res->len, n, chunk, len); #endif rsio_close(io); return 0; } len -= n; ptr += n; } return res; } int rsio_write(rsio_t *io, const void *buf, rsmsglen_t len, int cmd, int fd) { struct msghdr msg; struct iovec iov[2]; int clen = CMSG_LEN(sizeof(int)); iohdr_t hdr; ssize_t n; if (!io) return -2; if (fd != -1) { if (!cmsg_send) cmsg_send = malloc(clen); if (!cmsg_send) return -1; cmsg_send->cmsg_level = SOL_SOCKET; cmsg_send->cmsg_type = SCM_RIGHTS; cmsg_send->cmsg_len = clen; *(int*)CMSG_DATA(cmsg_send) = fd; msg.msg_control = cmsg_send; msg.msg_controllen = clen; } else { msg.msg_control = 0; msg.msg_controllen = 0; } hdr.cmd = cmd & CMD_MASK; if (fd != -1) hdr.cmd |= CMD_HAS_FD; hdr.len1 = (unsigned int) len; #ifdef __LP64__ hdr.len2 = (unsigned int) (len << 32); if (hdr.len2) hdr.cmd |= CMD_LONG; #else hdr.len2 = 0; #endif iov[0].iov_base = &hdr; iov[0].iov_len = (hdr.cmd & CMD_LONG) ? 12 : 8; iov[1].iov_base = (void*) buf; iov[1].iov_len = len; msg.msg_iov = iov; msg.msg_iovlen = 2; msg.msg_name = 0; msg.msg_namelen = 0; if ((n = sendmsg(io->fd[io->flags & RSIO_CHILD], &msg, 0)) != (len + (rsmsglen_t) iov[0].iov_len)) { rsio_close(io); #ifdef RSIO_DEBUG fprintf(stderr, "ERROR: rsio(%p)write: cmd=0x%x, write error (%ld, expected %lu)\n", io, hdr.cmd, (long)n, (unsigned long) (len + (rsmsglen_t) iov[0].iov_len)); #endif return -1; } return 0; } int rsio_write_msg(rsio_t *io, rsmsg_t *msg) { if (!io || !msg) return -2; return rsio_write(io, msg->data, msg->len, msg->cmd, (msg->flags & RSMSG_HAS_FD) ? msg->fd : -1); } int rsio_select_fd(rsio_t *io) { return io ? io->fd[io->flags & RSIO_CHILD] : -1; } #endif /* unix implementation */ #ifdef TEST_ME #include int main(int ac, char**av) { rsio_t *io = rsio_new(); if (fork() > 0) { printf("parent: %d\n", getpid()); rsmsg_t *msg = rsio_read_msg(io); if (msg) { printf("msg: command=0x%x, has fd:%s (%d), payload '%s'\n", msg->cmd, (msg->flags & RSMSG_HAS_FD) ? "yes" : "no", msg->fd, msg->data); free(msg); msg = rsio_read_msg(io); if (msg) printf("msg: command=0x%x, has fd:%s (%d), payload '%s'\n", msg->cmd, (msg->flags & RSMSG_HAS_FD) ? "yes" : "no", msg->fd, msg->data); } else printf("read failed\n"); rsio_close(io); printf("parent done.\n"); return 0; } else { printf("child: %d\n", getpid()); rsio_set_child(io); printf("child: write = %d\n", rsio_write(io, "hello!", 7, 0x1234, 1)); printf("child: write = %d\n", rsio_write(io, "hello!", 7, 0, -1)); rsio_close(io); printf("child done\n"); return 0; } } #endif Rserve/src/winembed.c0000644000176000001440000001714112205226215014276 0ustar ripleyusers/* * R : A Computer Language for Statistical Data Analysis * Copyright (C) 1998--2002 R Development Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef WIN32 /* based on rtest.c implements Rf_initEmbeddedR which is missing in the Windows-version of R shared library */ /* 27/03/2000 win32-api needs this */ #define NONAMELESSUNION #include #include #include #include #include "Rversion.h" #if R_VERSION < 0x2010 #include "Startup.h" #else #include #endif /* flag governing interactivity - from Rserv.c */ extern int Rsrv_interactive; /* I didn't actually check if 2.10.x is really the point where initEmbedded was introduced but it makes pretty much all this file obsolete */ #if R_VERSION > R_Version(2,10,0) __declspec(dllimport) int R_Interactive; int Rf_initEmbeddedR(int argc, char **argv) { Rf_initialize_R(argc, argv); R_Interactive = Rsrv_interactive; setup_Rmainloop(); return 0; } #else /* otherwise we have to do all this manually ... */ /* for signal-handling code */ #include "psignal.h" /* one way to allow user interrupts: called in ProcessEvents */ #if defined _MSC_VER || defined WIN64 __declspec(dllimport) int UserBreak; #else #define UserBreak (*_imp__UserBreak) extern int UserBreak; #endif /* calls into the R DLL */ extern char *getDLLVersion(); extern void R_DefParams(Rstart); extern void R_SetParams(Rstart); extern void setup_term_ui(void); extern void ProcessEvents(void); extern void end_Rmainloop(void), R_ReplDLLinit(void); extern int R_ReplDLLdo1(); extern void run_Rmainloop(void); #ifndef YES #define YES 1 #endif #ifndef NO #define NO -1 #endif #ifndef CANCEL #define CANCEL 0 #endif /* simple input, simple output */ /* This version blocks all events: a real one needs to call ProcessEvents frequently. See rterm.c and ../system.c for one approach using a separate thread for input */ int myReadConsole(const char *prompt, char *buf, int len, int addtohistory) { fputs(prompt, stdout); fflush(stdout); if(fgets(buf, len, stdin)) return 1; else return 0; } void myWriteConsole(const char *buf, int len) { printf("%s", buf); } void myCallBack() { /* called during i/o, eval, graphics in ProcessEvents */ } void myBusy(int which) { /* set a busy cursor ... if which = 1, unset if which = 0 */ } void myMessage(const char *s) { if (!s) return; myWriteConsole(s, strlen(s)); } int myYesNoCancel(const char *s) { char ss[128]; char a[3]; sprintf(ss, "%s [y/n/c]: ", s); myReadConsole(ss, a, 3, 0); switch (a[0]) { case 'y': case 'Y': return YES; case 'n': case 'N': return NO; default: return CANCEL; } } static void my_onintr(int sig) { UserBreak = 1; } static char Rversion[25], RUser[MAX_PATH], RHome[MAX_PATH]; static int dir_exists(const char* dn) { DWORD att = GetFileAttributes(dn); /* this actually needs Win2k or higher but I suppose that's ok these days ... */ return (att != INVALID_FILE_ATTRIBUTES && ((att & FILE_ATTRIBUTE_DIRECTORY) != 0 || att == FILE_ATTRIBUTE_NORMAL)); /* the last one is weird, but according to MS docs it can happen any we cannot tell whether it's a file or a directory */ } static char tmpbuf[8192]; int Rf_initEmbeddedR(int argc, char **argv) { structRstart rp; Rstart Rp = &rp; char *p; char rhb[MAX_PATH+10]; DWORD t,s=MAX_PATH; HKEY k; const char *arch = 0; const char *path_suf = 0; sprintf(Rversion, "%s.%s", R_MAJOR, R_MINOR); { char *c = Rversion, *d = Rversion; while (*c) { if (*c=='.') d=c; c++; }; *d=0; } #ifdef RSERV_DEBUG printf("Windows: Rf_initEmbeddedR; compiled as %s.%s, DLL is %s\n", R_MAJOR, R_MINOR, getDLLVersion()); #endif if(strncmp(Rversion, getDLLVersion(), strlen(Rversion)) != 0) { fprintf(stderr, "Error: R.DLL version (%s) does not match (%s.%s)\n", getDLLVersion(), R_MAJOR, R_MINOR); return -1; } R_DefParams(Rp); if(getenv("R_HOME")) { strcpy(RHome, getenv("R_HOME")); } else { /* fetch R_HOME from the registry */ /* try HKCU first such that users can override the system setting */ if (RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\R-core\\R", 0, KEY_QUERY_VALUE, &k) != ERROR_SUCCESS || RegQueryValueEx(k, "InstallPath", 0, &t, (LPVOID)RHome, &s) != ERROR_SUCCESS || !dir_exists(RHome)) { /* then try HKLM where teh system-wide installs would be */ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\R-core\\R", 0, KEY_QUERY_VALUE, &k) != ERROR_SUCCESS || RegQueryValueEx(k, "InstallPath", 0, &t, (LPVOID)RHome, &s) != ERROR_SUCCESS) { fprintf(stderr, "R_HOME must be set or R properly installed (\\Software\\R-core\\R\\InstallPath registry entry must exist).\n"); return -2; } } sprintf(rhb,"R_HOME=%s",RHome); putenv(rhb); } /* on Win32 this should set R_Home (in R_SetParams) as well */ Rp->rhome = RHome; #ifdef RSERV_DEBUG printf("R_HOME: %s\n", RHome); #endif /* check for multi-arch R */ if (!getenv("R_ARCH")) { strcpy(tmpbuf, RHome); #ifdef WIN64 strcat(tmpbuf, "\\bin\\x64\\R.dll"); arch = "R_ARCH=/x64"; #else strcat(tmpbuf, "\\bin\\i386\\R.dll"); arch = "R_ARCH=/i386"; #endif if (GetFileAttributes(tmpbuf) != -1) { /* muti-arch R, DLL found */ putenv(arch); #ifdef RSERV_DEBUG printf("Multi-architecture R found, setting %s\n", arch); #endif } else arch = 0; } if (!arch) { strcpy(tmpbuf, RHome); strcat(tmpbuf, "\\bin\\R.dll"); if (GetFileAttributes(tmpbuf) == -1) printf("WARNING: cannot find R DDL at %s\n check your R installation or make sure PATH is set accordingly\n"); } /* * try R_USER then HOME then working directory */ if (getenv("R_USER")) { strcpy(RUser, getenv("R_USER")); } else if (getenv("HOME")) { strcpy(RUser, getenv("HOME")); } else if (getenv("HOMEDIR")) { strcpy(RUser, getenv("HOMEDIR")); strcat(RUser, getenv("HOMEPATH")); } else GetCurrentDirectory(MAX_PATH, RUser); p = RUser + (strlen(RUser) - 1); if (*p == '/' || *p == '\\') *p = '\0'; Rp->home = RUser; Rp->CharacterMode = LinkDLL; Rp->ReadConsole = myReadConsole; Rp->WriteConsole = myWriteConsole; Rp->CallBack = myCallBack; #if R_VERSION < 0x2010 Rp->message = myMessage; Rp->yesnocancel = myYesNoCancel; Rp->busy = myBusy; #else Rp->ShowMessage = myMessage; Rp->YesNoCancel = myYesNoCancel; Rp->Busy = myBusy; #endif Rp->R_Quiet = TRUE; Rp->R_Interactive = Rsrv_interactive; Rp->RestoreAction = SA_RESTORE; Rp->SaveAction = SA_NOSAVE; #if R_VERSION < 0x2000 Rp->CommandLineArgs = NULL; Rp->NumCommandLineArgs = 0; #endif /* Rp->nsize = 300000; Rp->vsize = 6e6; */ R_SetParams(Rp); /* so R_ShowMessage is set */ R_SizeFromEnv(Rp); R_SetParams(Rp); FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); signal(SIGBREAK, my_onintr); setup_term_ui(); setup_Rmainloop(); return 0; } #endif #else #include #endif Rserve/src/Rsrv.h0000644000176000001440000004522212205226215013446 0ustar ripleyusers/* * Rsrv.h : constants and macros for Rserve client/server architecture * Copyright (C) 2002-13 Simon Urbanek * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; version 2.1 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Note: This header file is licensed under LGPL to allow other * programs to use it under LGPL. Rserve itself is licensed under GPL. * * $Id$ */ /* external defines: MAIN - should be defined in just one file that will contain the fn definitions and variables */ #ifndef __RSRV_H__ #define __RSRV_H__ #ifndef NO_CONFIG_H #include "config.h" #endif #define RSRV_VER 0x010703 /* Rserve v1.7-3 */ #define default_Rsrv_port 6311 /* Rserve communication is done over any reliable connection-oriented protocol (usually TCP/IP or local sockets). After the connection is established, the server sends 32 bytes of ID-string defining the capabilities of the server. Each attribute of the ID-string is 4 bytes long and is meant to be user-readable (i.e. don't use special characters), and it's a good idea to make "\r\n\r\n" the last attribute the ID string must be of the form: [0] "Rsrv" - R-server ID signature [4] "0100" - version of the R server [8] "QAP1" - protocol used for communication (here Quad Attributes Packets v1) [12] any additional attributes follow. \r\n and '-' are ignored. optional attributes (in any order; it is legitimate to put dummy attributes, like "----" or " " between attributes): "R151" - version of R (here 1.5.1) "ARpt" - authorization required (here "pt"=plain text, "uc"=unix crypt, "m5"=MD5) connection will be closed if the first packet is not CMD_login. if more AR.. methods are specified, then client is free to use the one he supports (usually the most secure) "K***" - key if encoded authentification is challenged (*** is the key) for unix crypt the first two letters of the key are the salt required by the server */ /* QAP1 transport protocol header structure all int and double entries throughout the transfer are in Intel-endianess format: int=0x12345678 -> char[4]=(0x78,0x56,x34,0x12) functions/macros for converting from native to protocol format are available below Please note also that all values muse be quad-aligned, i.e. the length must be divisible by 4. This is automatically assured for int/double etc., but care must be taken when using strings and byte streams. */ struct phdr { /* always 16 bytes */ int cmd; /* command */ int len; /* length of the packet minus header (ergo -16) */ int dof; /* data offset behind header (ergo usually 0) */ int res; /* high 32-bit of the packet length (since 0103 and supported on 64-bit platforms only) aka "lenhi", but the name was not changed to maintain compatibility */ }; /* each entry in the data section (aka parameter list) is preceded by 4 bytes: 1 byte : parameter type 3 bytes: length parameter list may be terminated by 0/0/0/0 but doesn't have to since "len" field specifies the packet length sufficiently (hint: best method for parsing is to allocate len+4 bytes, set the last 4 bytes to 0 and trverse list of parameters until (int)0 occurs since 0102: if the 7-th bit (0x40) in parameter type is set then the length is encoded in 7 bytes enlarging the header by 4 bytes. */ /* macros for handling the first int - split/combine (24-bit version only!) */ #define PAR_TYPE(X) ((X) & 255) #define PAR_LEN(X) (((unsigned int)(X)) >> 8) #define PAR_LENGTH PAR_LEN #define SET_PAR(TY,LEN) ((((unsigned int) (LEN) & 0xffffff) << 8) | ((TY) & 255)) #define CMD_STAT(X) (((X) >> 24)&127) /* returns the stat code of the response */ #define SET_STAT(X,s) ((X) | (((s) & 127) << 24)) /* sets the stat code */ #define CMD_RESP 0x10000 /* all responses have this flag set */ #define RESP_OK (CMD_RESP|0x0001) /* command succeeded; returned parameters depend on the command issued */ #define RESP_ERR (CMD_RESP|0x0002) /* command failed, check stats code attached string may describe the error */ #define CMD_OOB 0x20000 /* out-of-band data - i.e. unsolicited messages */ #define OOB_SEND (CMD_OOB | 0x1000) /* OOB send - unsolicited SEXP sent from the R instance to the client. 12 LSB are reserved for application-specific code */ #define OOB_MSG (CMD_OOB | 0x2000) /* OOB message - unsolicited message sent from the R instance to the client requiring a response. 12 LSB are reserved for application-specific code */ #define IS_OOB_SEND(X) (((X) & 0x0ffff000) == OOB_SEND) #define IS_OOB_MSG(X) (((X) & 0x0ffff000) == OOB_MSG) #define OOB_USR_CODE(X) ((X) & 0xfff) /* flag for create_server: Use QAP object-cap mode */ #define SRV_QAP_OC 0x40 /* mask of all flags that are relevant to QAP (so they can be passed through) */ #define SRV_QAP_FLAGS (SRV_QAP_OC) /* stat codes; 0-0x3f are reserved for program specific codes - e.g. for R connection they correspond to the stat of Parse command. the following codes are returned by the Rserv itself codes <0 denote Rerror as provided by R_tryEval */ #define ERR_auth_failed 0x41 /* auth.failed or auth.requested but no login came. in case of authentification failure due to name/pwd mismatch, server may send CMD_accessDenied instead */ #define ERR_conn_broken 0x42 /* connection closed or broken packet killed it */ #define ERR_inv_cmd 0x43 /* unsupported/invalid command */ #define ERR_inv_par 0x44 /* some parameters are invalid */ #define ERR_Rerror 0x45 /* R-error occured, usually followed by connection shutdown */ #define ERR_IOerror 0x46 /* I/O error */ #define ERR_notOpen 0x47 /* attempt to perform fileRead/Write on closed file */ #define ERR_accessDenied 0x48 /* this answer is also valid on CMD_login; otherwise it's sent if the server deosn;t allow the user to issue the specified command. (e.g. some server admins may block file I/O operations for some users) */ #define ERR_unsupportedCmd 0x49 /* unsupported command */ #define ERR_unknownCmd 0x4a /* unknown command - the difference between unsupported and unknown is that unsupported commands are known to the server but for some reasons (e.g. platform dependent) it's not supported. unknown commands are simply not recognized by the server at all. */ /* The following ERR_.. exist since 1.23/0.1-6 */ #define ERR_data_overflow 0x4b /* incoming packet is too big. currently there is a limit as of the size of an incoming packet. */ #define ERR_object_too_big 0x4c /* the requested object is too big to be transported in that way. If received after CMD_eval then the evaluation itself was successful. optional parameter is the size of the object */ /* since 1.29/0.1-9 */ #define ERR_out_of_mem 0x4d /* out of memory. the connection is usually closed after this error was sent */ /* since 0.6-0 */ #define ERR_ctrl_closed 0x4e /* control pipe to the master process is closed or broken */ /* since 0.4-0 */ #define ERR_session_busy 0x50 /* session is still busy */ #define ERR_detach_failed 0x51 /* unable to detach seesion (cannot determine peer IP or problems creating a listening socket for resume) */ /* since 1.7 */ #define ERR_disabled 0x61 /* feature is disabled */ #define ERR_unavailable 0x62 /* feature is not present in this build */ #define ERR_cryptError 0x63 /* crypto-system error */ #define ERR_securityClose 0x64 /* server-initiated close due to security violation (too many attempts, excessive timeout etc.) */ /* availiable commands */ #define CMD_login 0x001 /* "name\npwd" : - */ #define CMD_voidEval 0x002 /* string : - */ #define CMD_eval 0x003 /* string | encoded SEXP : encoded SEXP */ #define CMD_shutdown 0x004 /* [admin-pwd] : - */ /* security/encryption - all since 1.7-0 */ #define CMD_switch 0x005 /* string (protocol) : - */ #define CMD_keyReq 0x006 /* string (request) : bytestream (key) */ #define CMD_secLogin 0x007 /* bytestream (encrypted auth) : - */ #define CMD_OCcall 0x00f /* SEXP : SEXP -- it is the only command supported in object-capability mode and it requires that the SEXP is a language construct with OC reference in the first position */ #define CMD_OCinit 0x434f7352 /* SEXP -- 'RsOC' - command sent from the server in OC mode with the packet of initial capabilities. */ /* file I/O routines. server may answe */ #define CMD_openFile 0x010 /* fn : - */ #define CMD_createFile 0x011 /* fn : - */ #define CMD_closeFile 0x012 /* - : - */ #define CMD_readFile 0x013 /* [int size] : data... ; if size not present, server is free to choose any value - usually it uses the size of its static buffer */ #define CMD_writeFile 0x014 /* data : - */ #define CMD_removeFile 0x015 /* fn : - */ /* object manipulation */ #define CMD_setSEXP 0x020 /* string(name), REXP : - */ #define CMD_assignSEXP 0x021 /* string(name), REXP : - ; same as setSEXP except that the name is parsed */ /* session management (since 0.4-0) */ #define CMD_detachSession 0x030 /* : session key */ #define CMD_detachedVoidEval 0x031 /* string : session key; doesn't */ #define CMD_attachSession 0x032 /* session key : - */ /* control commands (since 0.6-0) - passed on to the master process */ /* Note: currently all control commands are asychronous, i.e. RESP_OK indicates that the command was enqueued in the master pipe, but there is no guarantee that it will be processed. Moreover non-forked connections (e.g. the default debug setup) don't process any control commands until the current client connection is closed so the connection issuing the control command will never see its result. */ #define CMD_ctrl 0x40 /* -- not a command - just a constant -- */ #define CMD_ctrlEval 0x42 /* string : - */ #define CMD_ctrlSource 0x45 /* string : - */ #define CMD_ctrlShutdown 0x44 /* - : - */ /* 'internal' commands (since 0.1-9) */ #define CMD_setBufferSize 0x081 /* [int sendBufSize] this commad allow clients to request bigger buffer sizes if large data is to be transported from Rserve to the client. (incoming buffer is resized automatically) */ #define CMD_setEncoding 0x082 /* string (one of "native","latin1","utf8") : -; since 0.5-3 */ /* special commands - the payload of packages with this mask does not contain defined parameters */ #define CMD_SPECIAL_MASK 0xf0 #define CMD_serEval 0xf5 /* serialized eval - the packets are raw serialized data without data header */ #define CMD_serAssign 0xf6 /* serialized assign - serialized list with [[1]]=name, [[2]]=value */ #define CMD_serEEval 0xf7 /* serialized expression eval - like serEval with one additional evaluation round */ /* data types for the transport protocol (QAP1) do NOT confuse with XT_.. values. */ #define DT_INT 1 /* int */ #define DT_CHAR 2 /* char */ #define DT_DOUBLE 3 /* double */ #define DT_STRING 4 /* 0 terminted string */ #define DT_BYTESTREAM 5 /* stream of bytes (unlike DT_STRING may contain 0) */ #define DT_SEXP 10 /* encoded SEXP */ #define DT_ARRAY 11 /* array of objects (i.e. first 4 bytes specify how many subsequent objects are part of the array; 0 is legitimate) */ #define DT_CUSTOM 32 /* custom types not defined in the protocol but used by applications */ #define DT_LARGE 64 /* new in 0102: if this flag is set then the length of the object is coded as 56-bit integer enlarging the header by 4 bytes */ /* XpressionTypes REXP - R expressions are packed in the same way as command parameters transport format of the encoded Xpressions: [0] int type/len (1 byte type, 3 bytes len - same as SET_PAR) [4] REXP attr (if bit 8 in type is set) [4/8] data .. */ #define XT_NULL 0 /* P data: [0] */ #define XT_INT 1 /* - data: [4]int */ #define XT_DOUBLE 2 /* - data: [8]double */ #define XT_STR 3 /* P data: [n]char null-term. strg. */ #define XT_LANG 4 /* - data: same as XT_LIST */ #define XT_SYM 5 /* - data: [n]char symbol name */ #define XT_BOOL 6 /* - data: [1]byte boolean (1=TRUE, 0=FALSE, 2=NA) */ #define XT_S4 7 /* P data: [0] */ #define XT_VECTOR 16 /* P data: [?]REXP,REXP,.. */ #define XT_LIST 17 /* - X head, X vals, X tag (since 0.1-5) */ #define XT_CLOS 18 /* P X formals, X body (closure; since 0.1-5) */ #define XT_SYMNAME 19 /* s same as XT_STR (since 0.5) */ #define XT_LIST_NOTAG 20 /* s same as XT_VECTOR (since 0.5) */ #define XT_LIST_TAG 21 /* P X tag, X val, Y tag, Y val, ... (since 0.5) */ #define XT_LANG_NOTAG 22 /* s same as XT_LIST_NOTAG (since 0.5) */ #define XT_LANG_TAG 23 /* s same as XT_LIST_TAG (since 0.5) */ #define XT_VECTOR_EXP 26 /* s same as XT_VECTOR (since 0.5) */ #define XT_VECTOR_STR 27 /* - same as XT_VECTOR (since 0.5 but unused, use XT_ARRAY_STR instead) */ #define XT_ARRAY_INT 32 /* P data: [n*4]int,int,.. */ #define XT_ARRAY_DOUBLE 33 /* P data: [n*8]double,double,.. */ #define XT_ARRAY_STR 34 /* P data: string,string,.. (string=byte,byte,...,0) padded with '\01' */ #define XT_ARRAY_BOOL_UA 35 /* - data: [n]byte,byte,.. (unaligned! NOT supported anymore) */ #define XT_ARRAY_BOOL 36 /* P data: int(n),byte,byte,... */ #define XT_RAW 37 /* P data: int(n),byte,byte,... */ #define XT_ARRAY_CPLX 38 /* P data: [n*16]double,double,... (Re,Im,Re,Im,...) */ #define XT_UNKNOWN 48 /* P data: [4]int - SEXP type (as from TYPEOF(x)) */ /* | +--- interesting flags for client implementations: P = primary type s = secondary type - its decoding is identical to a primary type and thus the client doesn't need to decode it separately. - = deprecated/removed. if a client doesn't need to support old Rserve versions, those can be safely skipped. Total primary: 4 trivial types (NULL, STR, S4, UNKNOWN) + 6 array types + 3 recursive types */ #define XT_LARGE 64 /* new in 0102: if this flag is set then the length of the object is coded as 56-bit integer enlarging the header by 4 bytes */ #define XT_HAS_ATTR 128 /* flag; if set, the following REXP is the attribute */ /* the use of attributes and vectors results in recursive storage of REXPs */ #define BOOL_TRUE 1 #define BOOL_FALSE 0 #define BOOL_NA 2 #define GET_XT(X) ((X)&63) #define GET_DT(X) ((X)&63) #define HAS_ATTR(X) (((X)&XT_HAS_ATTR)>0) #define IS_LARGE(X) (((X)&XT_LARGE)>0) #if defined sun && ! defined ALIGN_DOUBLES #define ALIGN_DOUBLES #endif /* this is the type used to calculate pointer distances */ /* note: we may want to use size_t or something more compatible */ typedef unsigned long rlen_t; #ifdef ULONG_MAX #define rlen_max ULONG_MAX #else #ifdef __LP64__ #define rlen_max 0xffffffffffffffffL #else #define rlen_max 0xffffffffL #endif /* __LP64__ */ #endif /* ULONG_MAX */ /* functions/macros to convert native endianess of int/double for transport currently ony PPC style and Intel style are supported */ /* Since 0.4-5 we no longer use configure-time endianness tests to allow cross-compilation. Either BS_xx_ENDIAN constant is defined by configure and thus should be relied upon only if the compiler contants don't work */ #if defined __BIG_ENDIAN__ || defined _BIG_ENDIAN_ #define SWAPEND 1 #elif defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN_ || defined BS_LITTLE_ENDIAN /* #undef SWAPEND */ #elif defined BS_BIG_ENDIAN #define SWAPEND 1 #elif __ia64__ || __i386__ || __x86_64__ /* take a guess based on the architecture (Intel-like) */ #define __LITTLE_ENDIAN__ 1 #elif __ppc__ || __ppc64__ /* any ppc */ #define __BIG_ENDIAN__ 1 #define SWAPEND 1 #elif ! defined Win32 /* Windows is little-endian is most cases, anywhere else we're stuck */ #error "Cannot determine endianness. Make sure config.h is included or __{BIG|LITTLE}_ENDIAN__ is defined ." #endif /* FIXME: all the mess below needs more efficient implementation - the current one is so messy to work around alignment problems on some platforms like Sun and HP 9000 */ #ifdef SWAPEND /* swap endianness - for PPC and co. */ #ifdef MAIN unsigned int itop(unsigned int i) { char b[4]; b[0]=((char*)&i)[3]; b[3]=((char*)&i)[0]; b[1]=((char*)&i)[2]; b[2]=((char*)&i)[1]; return *((unsigned int*)b); } double dtop(double i) { char b[8]; b[0]=((char*)&i)[7]; b[1]=((char*)&i)[6]; b[2]=((char*)&i)[5]; b[3]=((char*)&i)[4]; b[7]=((char*)&i)[0]; b[6]=((char*)&i)[1]; b[5]=((char*)&i)[2]; b[4]=((char*)&i)[3]; return *((double*)b); } void fixdcpy(void *t,void *s) { int i=0; while (i<8) { ((char*)t)[7-i]=((char*)s)[i]; i++; } } #else extern unsigned int itop(unsigned int i); extern double dtop(double i); extern void fixdcpy(void *t,void *s); #endif #define ptoi(X) itop(X) /* itop*itop=id */ #define ptod(X) dtop(X) #else #define itop(X) (X) #define ptoi(X) (X) #define dtop(X) (X) #define ptod(X) (X) #define fixdcpy(T,S) ((double*)(T))[0]=((double*)(S))[0]; #define NATIVE_COPY 1 #endif #ifndef HAVE_CONFIG_H /* this tiny function can be used to make sure that the endianess is correct (it is not included if the package was configured with autoconf since then it should be fine anyway) */ #ifdef MAIN int isByteSexOk() { int i; i=itop(0x12345678); return (*((char*)&i)==0x78); } #else extern int isByteSexOk(); #endif #else #define isByteSexOk 1 #endif /* STANDALONE_RSERVE takes precedence over RSERVE_PKG */ #if defined STANDALONE_RSERVE && defined RSERVE_PKG #undef RSERVE_PKG #endif #endif /*--- The following makes the indenting behavior of emacs compatible with Xcode's 4/4 setting ---*/ /* Local Variables: */ /* indent-tabs-mode: t */ /* tab-width: 4 */ /* c-basic-offset: 4 */ /* End: */ Rserve/src/RSserver.c0000644000176000001440000001246412205226215014262 0ustar ripleyusers#include "RSserver.h" #include "rserr.h" #define SOCK_ERRORS #define LISTENQ 16 #include #ifdef unix #include /* needed for unix sockets */ #endif #include #include /* AF_LOCAL is the POSIX version of AF_UNIX - we need this e.g. for AIX */ #ifndef AF_LOCAL #define AF_LOCAL AF_UNIX #endif /* keep track of all bound server sockets so they can be easily all closed after fork this is important for two reasons: so ports don't get stuck bound after the server has been shut down but children are still around, and so that a rogue child cannot impersonate the server after the server has been shut down (since the port may have been bound at higher privileges than the child may have at this point) */ #define MAX_SRVS 512 static int active_srv_sockets[MAX_SRVS]; static void add_active_srv_socket(int s) { int i = 0; while (active_srv_sockets[i] && i < MAX_SRVS) { if (active_srv_sockets[i] == s) return; i++; } if (i < MAX_SRVS) active_srv_sockets[i] = s; } static void rm_active_srv_socket(int s) { int i = 0; while (i < MAX_SRVS) { if (active_srv_sockets[i] == s) { active_srv_sockets[i] = 0; break; } i++; } } /* this is typically used after fork in the child process */ void close_all_srv_sockets() { int i = 0; while (i < MAX_SRVS) { if (active_srv_sockets[i]) closesocket(active_srv_sockets[i]); i++; } } /* provides client socket from accept() to the server so that it can modify the socket as needed according to the server flags */ void accepted_server(server_t *srv, int cs) { #ifdef SO_KEEPALIVE /* if keep-alive is enabled and supported - try to set it */ if (srv->flags & SRV_KEEPALIVE) { int ka = 1; setsockopt(cs, SOL_SOCKET, SO_KEEPALIVE, &ka, sizeof(ka)); } #endif } server_t *create_server(int port, const char *localSocketName, int localSocketMode, int flags) { server_t *srv; SAIN ssa; int reuse, ss; #ifdef HAVE_IPV6 struct sockaddr_in6 ssa6; #endif #ifdef unix struct sockaddr_un lusa; #endif #ifdef RSERV_DEBUG printf(" - create_server(port = %d, socket = %s, mode = %d, flags = 0x%x)\n", port, localSocketName ? localSocketName : "", localSocketMode, flags); #endif initsocks(); if (localSocketName) { #ifndef unix RSEprintf("ERROR: Local sockets are not supported on non-unix systems.\n"); return 0; #else ss = FCF("open socket", socket(AF_LOCAL, SOCK_STREAM, 0)); memset(&lusa, 0, sizeof(lusa)); lusa.sun_family = AF_LOCAL; if (strlen(localSocketName) > sizeof(lusa.sun_path) - 2) { RSEprintf("ERROR: Local socket name is too long for this system.\n"); return 0; } strcpy(lusa.sun_path, localSocketName); remove(localSocketName); /* remove existing if possible */ #endif } else #ifdef HAVE_IPV6 ss = FCF("open socket", socket((flags & SRV_IPV6) ? AF_INET6 : AF_INET, SOCK_STREAM, 0)); #else ss = FCF("open socket", socket(AF_INET, SOCK_STREAM, 0)); #endif srv = (server_t*) calloc(1, sizeof(server_t)); if (!srv) { RSEprintf("ERROR: cannot allocate memory for server structure\n"); return 0; } srv->ss = ss; srv->unix_socket = localSocketName ? 1 : 0; srv->flags = flags; srv->parent = 0; reuse = 1; /* enable socket address reusage */ setsockopt(ss, SOL_SOCKET, SO_REUSEADDR, (const char*)&reuse, sizeof(reuse)); #ifdef unix if (localSocketName) { FCF("bind", bind(ss, (SA*) &lusa, sizeof(lusa))); if (localSocketMode) chmod(localSocketName, localSocketMode); } else { #endif #ifdef HAVE_IPV6 if (flags & SRV_IPV6) { memset(&ssa6, 0, sizeof(ssa6)); ssa6.sin6_family = AF_INET6; ssa6.sin6_port = htons(port); ssa6.sin6_addr = (flags & SRV_LOCAL) ? in6addr_loopback : in6addr_any; FCF("bind", bind(ss, (struct sockaddr*) &ssa6, sizeof(ssa6))); } else { #endif memset(&ssa, 0, sizeof(ssa)); ssa.sin_family = AF_INET; ssa.sin_port = htons(port); ssa.sin_addr.s_addr = htonl((flags & SRV_LOCAL) ? INADDR_LOOPBACK : INADDR_ANY); FCF("bind", bind(ss, (struct sockaddr*) &ssa, sizeof(ssa))); #ifdef HAVE_IPV6 } /* if (flags & SRV_IPV6) else */ #endif #ifdef unix } /* if (localSocketName) else */ #endif add_active_srv_socket(ss); FCF("listen", listen(ss, LISTENQ)); return srv; } void server_fin(void *x) { server_t *srv = (server_t*) x; if (srv) { closesocket(srv->ss); if (srv->ss != -1) rm_active_srv_socket(srv->ss); } } #define NSPS 16 struct server_stack { server_stack_t *prev, *next; int ns; server_t *srv[NSPS]; }; server_stack_t* create_server_stack() { server_stack_t *s = (server_stack_t*) malloc(sizeof(server_stack_t)); s->prev = s->next = 0; s->ns = 0; return s; } void push_server(server_stack_t *s, server_t *srv) { while (s->ns >= NSPS && s->next) s = s->next; if (s->ns >= NSPS) { server_stack_t *ns = create_server_stack(); ns->prev = s; s = s->next = ns; } s->srv[s->ns++] = srv; } void release_server_stack(server_stack_t *s) { while (s && s->next) s = s->next; while (s) { int i = s->ns; while (i-- > 0) { rm_server(s->srv[i]); free(s->srv[i]); } s->ns = 0; s = s->prev; } } int server_stack_size(server_stack_t *s) { int n = 0; while (s) { n += s->ns; s = s->next; } return n; } /*--- The following makes the indenting behavior of emacs compatible with Xcode's 4/4 setting ---*/ /* Local Variables: */ /* indent-tabs-mode: t */ /* tab-width: 4 */ /* c-basic-offset: 4 */ /* End: */ Rserve/src/sha1.h0000644000176000001440000000015412205226215013341 0ustar ripleyusers#ifndef SHA1_H__ #define SHA1_H__ void sha1hash(const char *buf, int len, unsigned char hash[20]); #endif Rserve/src/config.h.in0000644000176000001440000001051712205226216014364 0ustar ripleyusers/* src/config.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* Defined if the platform is big-endian */ #undef BS_BIG_ENDIAN /* Defined if the platform is little-endian */ #undef BS_LITTLE_ENDIAN /* If defined Rserve supports unix crypt password encryption. */ #undef HAS_CRYPT /* */ #undef HAVE_CONNECT /* Define to 1 if you have the header file. */ #undef HAVE_CRYPT_H /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* IPv6 support present and enabled */ #undef HAVE_IPV6 /* Define to 1 if you have the `dl' library (-ldl). */ #undef HAVE_LIBDL /* Define to 1 if you have the `inet' library (-linet). */ #undef HAVE_LIBINET /* Define to 1 if you have the `nsl' library (-lnsl). */ #undef HAVE_LIBNSL /* Define to 1 if you have the `nsl_s' library (-lnsl_s). */ #undef HAVE_LIBNSL_S /* Define to 1 if you have the `socket' library (-lsocket). */ #undef HAVE_LIBSOCKET /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the `mkdir' function. */ #undef HAVE_MKDIR /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_TCP_H /* Define to 1 if you have the `rmdir' function. */ #undef HAVE_RMDIR /* RSA crypto support */ #undef HAVE_RSA /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT /* Define to 1 if you have the `socket' function. */ #undef HAVE_SOCKET /* Define to 1 if you have the `srandomdev' function. */ #undef HAVE_SRANDOMDEV /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_UN_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H /* TLS/SSL support */ #undef HAVE_TLS /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vfork' function. */ #undef HAVE_VFORK /* Define to 1 if you have the header file. */ #undef HAVE_VFORK_H /* Define to 1 if `fork' works. */ #undef HAVE_WORKING_FORK /* Define to 1 if `vfork' works. */ #undef HAVE_WORKING_VFORK /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `int' if does not define. */ #undef pid_t /* Define to `int' if neither nor define. */ #undef socklen_t /* Define as `fork' if `vfork' does not work. */ #undef vfork Rserve/src/oc.c0000644000176000001440000000622012205226215013101 0ustar ripleyusers#include #include "oc.h" #include "sha1.h" #ifndef NO_CONFIG_H #include "config.h" #endif #ifdef HAVE_TLS #include #endif #ifndef HAVE_SRANDOMDEV /* the fall-back is to use time and pid so we need those extra headers */ #include #include #endif static SEXP oc_env; SEXP oc_resolve(const char *ref) { SEXP val; if (!oc_env) return R_NilValue; val = findVarInFrame(oc_env, install(ref)); if (val == R_UnboundValue) val = R_NilValue; return val; } /* this is where we generate tokens. The current apporach is to generate good random 168-bits and encode them using slightly modified base-64 encoding into a string. If we can't get good random bits, we generate more pseudo-random bytes and run SHA1 on it. The result is almost a valid identifier except that it can start with a number. */ static int rand_inited; static const char b64map[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_."; /* currently we use 21 bytes = 168 bits --> 28 bytes encoded */ #define MAX_OC_TOKEN_LEN 31 static void oc_new(char *dst) { int have_hash = 0, i; unsigned char hash[21]; #ifdef HAVE_TLS if (RAND_bytes(hash, 21) || RAND_pseudo_bytes(hash, 21)) have_hash = 1; #endif if (!have_hash) { /* should only be used if TLS is not available or it fails */ unsigned char rbuf[64]; if (!rand_inited) { #ifdef HAVE_SRANDOMDEV srandomdev(); #else #ifdef Win32 srand(time(NULL) ^ (getpid() << 12)); #else /* fall back -- mix of time and pid is the best we can do ... */ srandom(time(NULL) ^ (getpid() << 12)); #endif #endif rand_inited = 1; } #ifdef Win32 for (i = 0; i < sizeof(rbuf); i++) rbuf[i] = rand(); #else for (i = 0; i < sizeof(rbuf); i++) rbuf[i] = random(); #endif /* we use random -> SHA1 .. is it an overkill? */ sha1hash(rbuf, sizeof(rbuf) - 1, hash); /* the last byte is the hold-out byte -- just because SHA gives only 160 bits */ hash[20] = rbuf[sizeof(rbuf) - 1]; } for (i = 0; i < 21; i += 3) { *(dst++) = b64map[hash[i] & 63]; *(dst++) = b64map[((hash[i] >> 6) | (hash[i + 1] << 2)) & 63]; *(dst++) = b64map[((hash[i + 1] >> 4) | (hash[i + 2] << 4)) & 63]; *(dst++) = b64map[hash[i + 2] >> 2]; } *dst = 0; } char *oc_register(SEXP what, char *dst, int len) { if (len <= MAX_OC_TOKEN_LEN) return NULL; if (!oc_env) { SEXP env = eval(PROTECT(lang3(install("new.env"), ScalarLogical(TRUE), R_EmptyEnv)), R_GlobalEnv); UNPROTECT(1); if (TYPEOF(env) != ENVSXP) return NULL; oc_env = env; R_PreserveObject(oc_env); } oc_new(dst); Rf_defineVar(install(dst), what, oc_env); return dst; } /* --- R-side API --- */ /* Note that we don't expose oc_resolve, because we don't want to facilitate unwanted discovery (although code that can poke around like that has already broken through some barriers) */ SEXP Rserve_oc_register(SEXP what) { char token[MAX_OC_TOKEN_LEN + 1]; SEXP res; if (!oc_register(what, token, sizeof(token))) Rf_error("Cannot create OC reference registry"); res = PROTECT(mkString(token)); setAttrib(res, R_ClassSymbol, mkString("OCref")); UNPROTECT(1); return res; } Rserve/src/install.libs.R0000644000176000001440000000143412205226215015057 0ustar ripleyuserslibarch <- if (nzchar(R_ARCH)) paste("libs", R_ARCH, sep='') else "libs" dest <- file.path(R_PACKAGE_DIR, libarch) ## the last two on unix are for compatibility only files <- if (WINDOWS) c("Rserve.exe", "Rserve_d.exe") else c("Rserve","Rserve.dbg") files <- c(files, paste("Rserve",SHLIB_EXT,sep='')) ## all files are optional in case the package is built without the server files <- files[file.exists(files)] if (length(files)) { dir.create(dest, recursive = TRUE, showWarnings = FALSE) file.copy(files, dest, overwrite = TRUE) if (length(grep("^darwin", R.version$os))) { message('generating debug symbols (dSYM)') dylib <- Sys.glob(paste(dest, "/*", SHLIB_EXT, sep='')) if (length(dylib)) for (file in dylib) try(system(paste("dsymutil ", file, sep='')), silent=TRUE) } } Rserve/src/tls.c0000644000176000001440000000463312205226215013310 0ustar ripleyusers#ifndef NO_CONFIG_H #include "config.h" #endif #include "tls.h" #ifdef HAVE_TLS #include #ifdef RSERV_DEBUG #include #endif struct tls { SSL_CTX *ctx; SSL_METHOD *method; }; static int first_tls = 1; static tls_t *tls; tls_t *shared_tls(tls_t *new_tls) { if (!tls) tls = new_tls; return tls; } tls_t *new_tls() { tls_t *t = (tls_t*) calloc(1, sizeof(tls_t)); if (first_tls) { SSL_library_init(); #ifdef RSERV_DEBUG SSL_load_error_strings(); #endif first_tls = 0; tls = t; } t->method = SSLv23_server_method(); t->ctx = SSL_CTX_new(t->method); return t; } int set_tls_pk(tls_t *tls, const char *fn) { return SSL_CTX_use_PrivateKey_file(tls->ctx, fn, SSL_FILETYPE_PEM); } int set_tls_cert(tls_t *tls, const char *fn) { return SSL_CTX_use_certificate_file(tls->ctx, fn, SSL_FILETYPE_PEM); } int set_tls_ca(tls_t *tls, const char *fn_ca, const char *path_ca) { return SSL_CTX_load_verify_locations(tls->ctx, fn_ca, path_ca); } struct args { server_t *srv; /* server that instantiated this connection */ int s; int ss; SSL *ssl; void *res2; }; static int tls_recv(args_t *c, void *buf, rlen_t len) { return SSL_read(c->ssl, buf, len); } static int tls_send(args_t *c, const void *buf, rlen_t len) { return SSL_write(c->ssl, buf, len); } int add_tls(args_t *c, tls_t *tls, int server) { c->ssl = SSL_new(tls->ctx); c->srv->send = tls_send; c->srv->recv = tls_recv; SSL_set_fd(c->ssl, c->s); if (server) return SSL_accept(c->ssl); else return SSL_connect(c->ssl); } void copy_tls(args_t *src, args_t *dst) { dst->ssl = src->ssl; dst->s = src->s; dst->srv->send = src->srv->send; dst->srv->recv = src->srv->recv; } void close_tls(args_t *c) { if (c->ssl) { SSL_shutdown(c->ssl); SSL_free(c->ssl); c->ssl = 0; } } void free_tls(tls_t *tls) { } #else /* no SSL/TLS support, ignore everything, fail on everything */ tls_t *shared_tls(tls_t *new_tls) { return 0; } tls_t *new_tls() { return 0; } int set_tls_pk(tls_t *tls, const char *fn) { return -1; } int set_tls_cert(tls_t *tls, const char *fn) { return -1; } int set_tls_ca(tls_t *tls, const char *fn_ca, const char *path_ca) { return -1; } void free_tls(tls_t *tls) { } int add_tls(args_t *c, tls_t *tls, int server) { return -1; } void copy_tls(args_t *src, args_t *dst) { } void close_tls(args_t *c) { } #endif Rserve/src/tls.h0000644000176000001440000000102512205226215013305 0ustar ripleyusers#ifndef TLS_H__ #define TLS_H__ #include "RSserver.h" typedef struct tls tls_t; /* in case shared tls is not set, it will be set to new_tls (which can be NULL) */ tls_t *shared_tls(tls_t *new_tls); tls_t *new_tls(); int set_tls_pk(tls_t *tls, const char *fn); int set_tls_cert(tls_t *tls, const char *fn); int set_tls_ca(tls_t *tls, const char *fn_ca, const char *path_ca); void free_tls(tls_t *tls); int add_tls(args_t *c, tls_t *tls, int server); void copy_tls(args_t *src, args_t *dst); void close_tls(args_t *c); #endif Rserve/src/session.c0000644000176000001440000000404412205226215014165 0ustar ripleyusers/* * implements a vector of session scructures accessible by a session key. * * Author : Simon Urbanek * Created: 2005/08/30 * License: GPL2 * * $Id$ */ #include "config.h" #include "session.h" #ifdef HAVE_MEMORY_H #include #else #include #endif #include static struct sSession *session=0; static int sessions=0; static int sessions_allocated=0; /* find a session */ struct sSession *find_session(char key[16]) { int i=0; while (i128 && sessions < sessions_allocated/2) { sessions_allocated = sessions_allocated/2 + 64; session = (struct sSession*) realloc(session, sessions_allocated * sizeof(struct sSession)); } return; } i++; } } int total_sessions() { return sessions; } struct sSession *first_session() { return session; } struct sSession *next_session(struct sSession* current) { if (current=session+sessions-1) return 0; return current+1; } /*--- The following makes the indenting behavior of emacs compatible with Xcode's 4/4 setting ---*/ /* Local Variables: */ /* indent-tabs-mode: t */ /* tab-width: 4 */ /* c-basic-offset: 4 */ /* End: */ Rserve/src/rserr.h0000644000176000001440000000107712205226215013647 0ustar ripleyusers/* error I/O that uses either stderr or REprintf depending on the build */ #ifndef RSERR_H__ #define RSERR_H__ #ifndef NO_CONFIG_H #include "config.h" #endif #if defined STANDALONE_RSERVE && defined RSERVE_PKG #undef RSERVE_PKG #endif #include #include #ifndef STANDALONE_RSERVE #include /* for REvprintf */ #endif static void RSEprintf(const char *format, ...) { va_list(ap); va_start(ap, format); #ifdef STANDALONE_RSERVE vfprintf(stderr, format, ap); #else REvprintf(format, ap); #endif va_end(ap); } #endif Rserve/src/qap_encode.c0000644000176000001440000002161012205226215014576 0ustar ripleyusers#include #include #include "qap_encode.h" #include /* compatibility re-mapping */ #define getStorageSize QAP_getStorageSize #define storeSEXP QAP_storeSEXP /* FIXME: we should move this to some common place ... */ /* string encoding handling */ #if (R_VERSION < R_Version(2,8,0)) || (defined DISABLE_ENCODING) #define mkRChar(X) mkChar(X) #define CHAR_FE(X) CHAR(X) #else #define USE_ENCODING 1 extern cetype_t string_encoding; #define mkRChar(X) mkCharCE((X), string_encoding) #define CHAR_FE(X) charsxp_to_current(X) static const char *charsxp_to_current(SEXP s) { if (Rf_getCharCE(s) == string_encoding) return CHAR(s); return Rf_reEnc(CHAR(s), getCharCE(s), string_encoding, 0); } #endif /* this is the representation of NAs in strings. We chose 0xff since that should never occur in UTF-8 strings. If 0xff occurs in the beginning of a string anyway, it will be doubled to avoid misrepresentation. */ static const unsigned char NaStringRepresentation[2] = { 255, 0 }; #define attrFixup if (hasAttr) buf = storeSEXP(buf, ATTRIB(x), 0); #define dist(A,B) (((rlen_t)(((char*)B)-((char*)A))) - 4L) #define align(A) (((A) + 3L) & (rlen_max ^ 3L)) rlen_t getStorageSize(SEXP x) { int t = TYPEOF(x); rlen_t tl = LENGTH(x); /* although LENGTH can only be 32-bit use rlen_t to avoid downcasting */ rlen_t len = 4; #ifdef RSERV_DEBUG printf("getStorageSize(%p,type=%d,len=%ld) ", (void*)x, t, tl); #endif if (t != CHARSXP && TYPEOF(ATTRIB(x)) == LISTSXP) { rlen_t alen = getStorageSize(ATTRIB(x)); len += alen; } switch (t) { case LISTSXP: case LANGSXP: { SEXP l = x; rlen_t tags = 0, n = 0; while (l != R_NilValue) { len += getStorageSize(CAR(l)); tags += getStorageSize(TAG(l)); n++; l = CDR(l); } if (tags > 4L * n) len += tags; /* use tagged list */ } break; case CLOSXP: len+=getStorageSize(FORMALS(x)); len+=getStorageSize(BODY(x)); break; case CPLXSXP: len += tl * 16L; break; case REALSXP: len += tl * 8L; break; case INTSXP: len += tl * 4L; break; case LGLSXP: case RAWSXP: if (tl > 1) len += 4L + align(tl); else len += 4L; break; case SYMSXP: case CHARSXP: { const char *ct = ((t==CHARSXP) ? CHAR_FE(x) : CHAR_FE(PRINTNAME(x))); if (!ct) len += 4L; else { rlen_t sl = strlen(ct) + 1L; len += align(sl); } } break; case STRSXP: { unsigned int i = 0; while (i < tl) { len += getStorageSize(STRING_ELT(x, i)); i++; } } break; case EXPRSXP: case VECSXP: { unsigned int i = 0; while(i < tl) { len += getStorageSize(VECTOR_ELT(x,i)); i++; } } break; case S4SXP: /* S4 really has the payload in attributes, so it doesn't occupy anything */ break; default: len += 4L; /* unknown types are simply stored as int */ } if (len > 0xfffff0) /* large types must be stored in the new format */ len += 4L; #ifdef RSERV_DEBUG printf("= %lu\n", len); #endif return len; } /* if storage_size is > 0 then it it used instad of a call to getStorageSize() */ unsigned int* storeSEXP(unsigned int* buf, SEXP x, rlen_t storage_size) { int t = TYPEOF(x); int hasAttr = 0; int isLarge = 0; unsigned int *preBuf = buf; rlen_t txlen; if (!x) { /* null pointer will be treated as XT_NULL */ *buf = itop(XT_NULL); buf++; goto didit; } if (t != CHARSXP && TYPEOF(ATTRIB(x)) == LISTSXP) hasAttr = XT_HAS_ATTR; if (t == NILSXP) { *buf = itop(XT_NULL | hasAttr); buf++; attrFixup; goto didit; } /* check storage size */ if (!storage_size) storage_size = getStorageSize(x); txlen = storage_size; if (txlen > 0xfffff0) { /* if the entry is too big, use large format */ isLarge = 1; buf++; } if (t==LISTSXP || t==LANGSXP) { SEXP l = x; rlen_t tags = 0; while (l != R_NilValue) { if (TAG(l) != R_NilValue) tags++; l = CDR(l); } /* note that we are using the fact that XT_LANG_xx=XT_LIST_xx+2 */ *buf = itop((((t == LISTSXP) ? 0 : 2) + (tags ? XT_LIST_TAG : XT_LIST_NOTAG)) | hasAttr); buf++; attrFixup; l = x; while (l != R_NilValue) { buf = storeSEXP(buf, CAR(l), 0); if (tags) buf = storeSEXP(buf, TAG(l), 0); l = CDR(l); } goto didit; } if (t==CLOSXP) { /* closures (send FORMALS and BODY) */ *buf=itop(XT_CLOS|hasAttr); buf++; attrFixup; buf=storeSEXP(buf, FORMALS(x), 0); buf=storeSEXP(buf, BODY(x), 0); goto didit; } if (t==REALSXP) { R_len_t i = 0; *buf=itop(XT_ARRAY_DOUBLE|hasAttr); buf++; attrFixup; #ifdef NATIVE_COPY memcpy(buf, REAL(x), sizeof(double) * LENGTH(x)); buf += LENGTH(x) * sizeof(double) / sizeof(*buf); #else while(i < LENGTH(x)) { fixdcpy(buf, REAL(x) + i); buf += 2; /* sizeof(double)=2*sizeof(int) */ i++; } #endif goto didit; } if (t==CPLXSXP) { R_len_t i = 0; *buf = itop(XT_ARRAY_CPLX|hasAttr); buf++; attrFixup; #ifdef NATIVE_COPY memcpy(buf, COMPLEX(x), LENGTH(x) * sizeof(*COMPLEX(x))); buf += LENGTH(x) * sizeof(*COMPLEX(x)) / sizeof(*buf); #else while(i < LENGTH(x)) { fixdcpy(buf, &(COMPLEX(x)[i].r)); buf += 2; /* sizeof(double)=2*sizeof(int) */ fixdcpy(buf, &(COMPLEX(x)[i].i)); buf += 2; /* sizeof(double)=2*sizeof(int) */ i++; } #endif goto didit; } if (t==RAWSXP) { R_len_t ll = LENGTH(x); *buf = itop(XT_RAW | hasAttr); buf++; attrFixup; *buf = itop(ll); buf++; if (ll) memcpy(buf, RAW(x), ll); ll += 3; ll /= 4; buf += ll; goto didit; } if (t==LGLSXP) { R_len_t ll = LENGTH(x), i = 0; int *lgl = LOGICAL(x); *buf = itop(XT_ARRAY_BOOL | hasAttr); buf++; attrFixup; *buf = itop(ll); buf++; while(i < ll) { /* logical values are stored as bytes of values 0/1/2 */ int bv = lgl[i]; *((unsigned char*)buf) = (bv == 0) ? 0 : (bv==1) ? 1 : 2; buf = (unsigned int*)(((unsigned char*)buf) + 1); i++; } /* pad by 0xff to a multiple of 4 */ while (i & 3) { *((unsigned char*)buf) = 0xff; i++; buf=(unsigned int*)(((unsigned char*)buf) + 1); } goto didit; } if (t == STRSXP) { char *st; R_len_t nx = LENGTH(x), i; *buf = itop(XT_ARRAY_STR|hasAttr); buf++; attrFixup; /* leading int n; is not needed due to the choice of padding */ st = (char *)buf; for (i = 0; i < nx; i++) { const char *cv = CHAR_FE(STRING_ELT(x, i)); rlen_t l = strlen(cv); if (STRING_ELT(x, i) == R_NaString) { cv = (const char*) NaStringRepresentation; l = 1; } else if ((unsigned char) cv[0] == NaStringRepresentation[0]) /* we will double the leading 0xff to avoid abiguity between NA and "\0xff" */ (st++)[0] = (char) NaStringRepresentation[0]; strcpy(st, cv); st += l + 1; } /* pad with '\01' to make sure we can determine the number of elements */ while ((st - (char*)buf) & 3) *(st++) = 1; buf = (unsigned int*)st; goto didit; } if (t==EXPRSXP || t==VECSXP) { R_len_t i = 0, n = LENGTH(x); *buf = itop(((t == EXPRSXP) ? XT_VECTOR_EXP : XT_VECTOR) | hasAttr); buf++; attrFixup; while(i < n) { buf = storeSEXP(buf, VECTOR_ELT(x, i), 0); i++; } goto didit; } if (t==INTSXP) { R_len_t i = 0, n = LENGTH(x); int *iptr = INTEGER(x); *buf = itop(XT_ARRAY_INT | hasAttr); buf++; attrFixup; #ifdef NATIVE_COPY memcpy(buf, iptr, n * sizeof(int)); buf += n; #else while(i < n) { *buf = itop(iptr[i]); buf++; i++; } #endif goto didit; } if (t==S4SXP) { *buf=itop(XT_S4|hasAttr); buf++; attrFixup; goto didit; } if (t==CHARSXP||t==SYMSXP) { rlen_t sl; const char *val; if (t == CHARSXP) { *buf = itop(XT_STR | hasAttr); val = CHAR_FE(x); } else { *buf = itop(XT_SYMNAME | hasAttr); val = CHAR_FE(PRINTNAME(x)); } buf++; attrFixup; strcpy((char*)buf, val); sl = strlen((char*)buf); sl++; while (sl & 3) /* pad by 0 to a length divisible by 4 (since 0.1-10) */ ((char*)buf)[sl++] = 0; buf = (unsigned int*)(((char*)buf) + sl); goto didit; } *buf = itop(XT_UNKNOWN | hasAttr); buf++; attrFixup; *buf = itop(TYPEOF(x)); buf++; didit: if (isLarge) { txlen = dist(preBuf, buf) - 4L; preBuf[0] = itop(SET_PAR(PAR_TYPE(((unsigned char*) preBuf)[4] | XT_LARGE), txlen & 0xffffff)); preBuf[1] = itop(txlen >> 24); } else *preBuf = itop(SET_PAR(PAR_TYPE(ptoi(*preBuf)), dist(preBuf, buf))); #ifdef RSERV_DEBUG printf("stored %p at %p, %lu bytes\n", (void*)x, (void*)preBuf, (unsigned long) dist(preBuf, buf)); #endif if (dist(preBuf, buf) > storage_size) { #ifdef RSERVE_PKG REprintf("**ERROR: underestimated storage %ld / %ld SEXP type %d\n", (long) dist(preBuf, buf), (long) storage_size, TYPEOF(x)); #else fprintf(stderr, "**ERROR: underestimated storage %ld / %ld SEXP type %d\n", (long) dist(preBuf, buf), (long) storage_size, TYPEOF(x)); #endif /* R_inspect(x) // can't use this since it's hidden in R */ } return buf; } Rserve/src/RSserver.h0000644000176000001440000000554112205226215014265 0ustar ripleyusers#ifndef RS_SERVER_H__ #define RS_SERVER_H__ #include "Rsrv.h" /* this is a voluntary standart flag to request TLS support */ #define SRV_TLS 0x0800 /* these flags are global and respected by the default socket server */ #define SRV_IPV6 0x1000 /* use IPv6 */ #define SRV_LOCAL 0x4000 /* bind to local loopback interface only */ #define SRV_KEEPALIVE 0x8000 /* enable keep-alive - note that this is really a client option sice inheritance is not guaranteed */ typedef struct args args_t; typedef void (*work_fn_t)(void *par); typedef void (*send_fn_t)(args_t *arg, int rsp, rlen_t len, const void *buf); typedef int (*buf_fn_t) (args_t *arg, void *buf, rlen_t len); typedef int (*cbuf_fn_t) (args_t *arg, const void *buf, rlen_t len); typedef int (*fork_fn_t) (args_t *arg); /* definition of a server */ typedef struct server { int ss; /* server socket */ int unix_socket; /* 0 = TCP/IP, 1 = unix socket */ int flags; /* optional server-specific flags */ work_fn_t connected; /* function called for each new connection */ work_fn_t fin; /* optional finalization function */ send_fn_t send_resp; /* send response */ cbuf_fn_t send; /* direct send */ buf_fn_t recv; /* direct receive */ fork_fn_t fork; /* fork */ struct server *parent;/* parent server - used only by multi-layer servers */ } server_t; /* this flag can be passed to create_server for an IP socket to modify the behavior */ #define LSM_IP_LOCAL 1 /* bind to loopback address only */ #define LSM_IPV6 2 /* use IPv6 (if available) */ server_t *create_server(int port, const char *localSocketName, int localSocketMode, int flags); void accepted_server(server_t *srv, int cs); /* performs additional tasks on client socket (eg SO_KEEPALIVE) */ int add_server(server_t *srv); int rm_server(server_t *srv); /* server stacks */ typedef struct server_stack server_stack_t; server_stack_t* create_server_stack(); void push_server(server_stack_t *s, server_t *srv); int server_stack_size(server_stack_t *s); void release_server_stack(server_stack_t *s); /* some generic implementations */ void server_fin(void *x); int server_recv(args_t *arg, void *buf, rlen_t len); int server_send(args_t *arg, const void *buf, rlen_t len); void stop_server_loop(); void serverLoop(); /* helper function that prepares the process just like Rserve internal impleemntation - forking when desired, establishing pipes, setting see, uid/gid, cwd etc. returns 0 for the child */ int Rserve_prepare_child(args_t *arg); /* this one is called by the former to close all server sockets in the child */ void close_all_srv_sockets(); #endif /*--- The following makes the indenting behavior of emacs compatible with Xcode's 4/4 setting ---*/ /* Local Variables: */ /* indent-tabs-mode: t */ /* tab-width: 4 */ /* c-basic-offset: 4 */ /* End: */ Rserve/src/other/0000755000176000001440000000000012205226215013455 5ustar ripleyusersRserve/src/other/RSpool.c0000644000176000001440000002534112205226215015044 0ustar ripleyusers/* * RSpool : pool manager for synchronous Rserve workes instances * Part of the Rserve project. * Copyright (C) 2002-12 Simon Urbanek * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "Rsrv.h" #include "RSserver.h" #include #ifdef unix #include /* needed for unix sockets */ #endif #include #include #include #include #define default_max_pool 200 #define default_workers 20 static int active = 1, localonly = 1; typedef struct worker { #ifdef WIN32 SOCKET s; HANDLE w_in, w_out; /* worker pipe I/O handles */ #else int s; int w_in, w_out; /* worker pipe I/O handles, in = pool->worker, out = pool<-worker */ #endif long io_in_packet; long s_in_packet; } worker_t; static char **RSargv; static int RSargc; static char **allowed_ips = 0; /* spawns a new worker and returns worker structure to be used in the communication Returns only on the pool side, worker side. */ static worker_t* create_worker() { worker_t *w = (worker_t*) calloc(1, sizeof(worker_t)); if (!w) { fprintf(stderr, "ERROR: cannot allocate memory for a worker\n"); return w; } { #ifdef unix int pfd_in[2], pfd_out[2]; pid_t pid; if (pipe(pfd_in) != 0) { fprintf(stderr, "ERROR: cannot create I/O pipe 1\n"); free(w); return 0; } if (pipe(pfd_out) != 0) { fprintf(stderr, "ERROR: cannot create I/O pipe 2\n"); close(pfd_in[0]); close(pfd_in[1]); free(w); return 0; } w->w_in = pfd_in[1]; /* we write to w_in */ w->w_out = pfd_out[0];/* we read from w_out */ w->io_in_packet = -1; w->s_in_packet = -1; w->s = -1; /* all workers are unconnected first */ pid = fork(); if (pid == -1) { fprintf(stderr, "ERROR: cannot fork to exec\n"); close(pfd_in[0]); close(pfd_in[1]); close(pfd_out[0]); close(pfd_out[1]); free(w); return 0; } if (pid == 0) { /* child -> exec */ char buf[48]; /* close pool's side of the pipes */ close(pfd_in[1]); close(pfd_out[0]); /* add FD arguments for communication */ snprintf(buf, sizeof(buf), "--RS-pipe-io=%d,%d", pfd_in[0], pfd_out[1]); RSargv[RSargc++] = buf; RSargv[RSargc] = 0; /* exec */ execvp(RSargv[0], RSargv); /* should not return */ fprintf(stderr, "ERROR: cannot exec %s\n", RSargv[0]); perror("exec error"); exit(1); } /* successful fork */ #else #endif } return w; } static void remove_worker(worker_t *w) { close(w->w_out); close(w->w_in); free(w); } static int workers = default_workers, max_pool = default_max_pool; static worker_t **worker; static server_t *srv; static void connected(SOCKET s) { int i; worker_t *w = 0; for (i = 0; i < workers; i++) /* find any unconnected worker */ if (worker[i] && worker[i]->s == -1) { w = worker[i]; break; } if (!w) { /* no unconnected workers, need to spawn new one - find a slot for it*/ for (i = 0; i < max_pool; i++) if (!worker[i]) { w = worker[i] = create_worker(); if (i >= workers) workers = i + 1; break; } if (!w) { /* no slot */ fprintf(stderr, "ERROR: too many connections\n"); close(s); return; } } w->s = s; /* this should be unnecessary since the workes should be "fresh", but just in case ... */ w->s_in_packet = -1; w->io_in_packet = -1; } static char server_io_buffer[65536]; /* pool server loop - the server part is the same as Rserve, but it also has to include the workers part */ static void RSpool_serverLoop() { #ifdef unix struct timeval timv; int selRet = 0; fd_set readfds; #endif while(active) { /* main serving loop */ int i; #ifdef unix int maxfd = 0; while (waitpid(-1, 0, WNOHANG) > 0); /* 500ms (used to be 10ms) - it shouldn't really matter since it's ok for us to sleep -- the timeout will only influence how often we collect terminated children and (maybe) how quickly we react to shutdown */ timv.tv_sec = 0; timv.tv_usec = 500000; FD_ZERO(&readfds); if (srv) { int ss = srv->ss; if (ss > maxfd) maxfd = ss; FD_SET(ss, &readfds); } for (i = 0; i < workers; i++) if (worker[i]) { /* register output from workers as well as their sockets */ int fd = worker[i]->w_out; if (fd > maxfd) maxfd = fd; FD_SET(fd, &readfds); fd = worker[i]->s; if (fd > maxfd) maxfd = fd; if (fd != -1) FD_SET(fd, &readfds); } selRet = select(maxfd + 1, &readfds, 0, 0, &timv); if (selRet > 0) { /* for (i = 0; i < servers; i++) */ { socklen_t al; /* server_t *srv = server[i]; */ int ss = srv->ss; if (FD_ISSET(ss, &readfds)) { #endif SOCKET s; SAIN sa; #ifdef unix struct sockaddr_un su; if (srv->unix_socket) { al = sizeof(su); s = accept(ss, (SA*)&su, &al); } else #endif s = accept(ss, (SA*)&sa, &al); if (s != -1) { if (localonly && !srv->unix_socket) { char **laddr = allowed_ips; int allowed = 0; if (!laddr) { allowed_ips = (char**) malloc(sizeof(char*)*2); allowed_ips[0] = strdup("127.0.0.1"); allowed_ips[1] = 0; laddr = allowed_ips; } while (*laddr) if (sa.sin_addr.s_addr == inet_addr(*(laddr++))) { allowed = 1; break; }; if (allowed) { #ifdef RSERV_DEBUG printf("INFO: accepted connection for server %p, calling connected\n", (void*) srv); #endif connected(s); } else closesocket(s); } else { /* ---> remote enabled */ #ifdef RSERV_DEBUG printf("INFO: accepted connection for server %p, calling connected\n", (void*) srv); #endif connected(s); } } #ifdef unix } } /* end loop over servers */ for (i = 0; i < workers; i++) { worker_t *w = worker[i]; int remove = 0; /* socket read */ if (w && FD_ISSET(w->s, &readfds)) { remove = 1; if (w->s_in_packet <= 0) { /* new packet */ struct phdr hdr; int n = recv(w->s, &hdr, sizeof(hdr), 0); if (n == sizeof(hdr)) { n = write(w->w_in, &hdr, sizeof(hdr)); if (n == sizeof(hdr)) { long sz = hdr.len; if (hdr.res) sz |= ((long) hdr.res) << 32; remove = 0; w->s_in_packet = sz; } } } else { /* buffer IO */ int to_go = (int) (w->s_in_packet > sizeof(server_io_buffer)) ? sizeof(server_io_buffer) : w->s_in_packet; int n = recv(w->s, server_io_buffer, to_go, 0); if (n > 0 && write(w->w_in, server_io_buffer, n) == n) { remove = 0; w->s_in_packet -= to_go; } } } /* fd read */ if (w && FD_ISSET(w->w_out, &readfds)) { remove = 1; if (w->io_in_packet == -1) { /* first is the ID string */ char ids[32]; int n = read(w->w_out, ids, sizeof(ids)); if (n == sizeof(ids)) { n = send(w->s, ids, sizeof(ids), 0); if (n == sizeof(ids)) { w->io_in_packet = 0; /* done with ID, back to messages */ remove = 0; } } } else if (w->io_in_packet <= 0) { /* new packet */ struct phdr hdr; int n = read(w->w_out, &hdr, sizeof(hdr)); if (n == sizeof(hdr)) { n = send(w->s, &hdr, sizeof(hdr), 0); if (n == sizeof(hdr)) { long sz = hdr.len; if (hdr.res) sz |= ((long) hdr.res) << 32; remove = 0; w->io_in_packet = sz; } } } else { /* buffer IO */ int to_go = (int) (w->io_in_packet > sizeof(server_io_buffer)) ? sizeof(server_io_buffer) : w->io_in_packet; int n = read(w->w_out, server_io_buffer, to_go); if (n > 0 && send(w->s, server_io_buffer, n, 0) == n) { remove = 0; w->io_in_packet -= to_go; } } } if (remove) { remove_worker(w); /* FIXME: we should only create if it was not a surplus worker - but we have not recorded that number */ worker[i] = create_worker(); } } /* loop over workers */ } /* end if (selRet > 0) */ #endif } /* end while(active) */ } int main(int argc, char **argv) { int i = 0; int port = default_Rsrv_port; while (++i < argc) if (argv[i][0] == '-') switch (argv[i][1]) { case 'h': printf("\n Usage: %s [] \n\n Options: -w - specifies the number of workers (default %d)\n -p - port to listen on (default %d)\n -h - show this help\n\n Example: %s -w 30 R CMD Rserve --vanilla --no-save\n\n", argv[0], default_workers, default_Rsrv_port, argv[0]); return 0; case 'p': if (++i < argc) port = atoi(argv[i]); else { fprintf(stderr, "ERROR: missing port specification in -p \n"); return 1; }; break; case 'w': if (++i < argc) workers = atoi(argv[i]); else { fprintf(stderr, "ERROR: missing workers specification in -w \n"); return 1; }; break; default: fprintf(stderr, "ERROR: unknown option %s\n", argv[i]); return 1; } else break; if (i >= argc) { fprintf(stderr, "ERROR: missing Rserve startup command. See %s -h for usage.\n", argv[0]); return 0; } RSargv = (char**) calloc(argc - i + 3, sizeof(char*)); RSargc = argc - i; { /* Fill RSargv with startup + sentinel */ int j; for (j = 0; j < RSargc; j++) RSargv[j] = strdup(argv[i + j]); RSargv[j] = 0; } srv = create_server(port, 0, 0, 0); if (!srv) return 0; if (max_pool < workers) max_pool = workers; worker = (worker_t**) calloc(max_pool, sizeof(worker_t)); for (i = 0; i < workers; i++) worker[i] = create_worker(); RSpool_serverLoop(); return 0; } #ifdef RSERVE_PKG #include SEXP RSpool_run(SEXP args) { int argc, i, n; char **argv; if (TYPEOF(args) != STRSXP) Rf_error("Start arguments must be a character vector."); argc = LENGTH(args) + 1; argv = (char**) calloc(argc, sizeof(char*)); if (!argv) Rf_error("Cannot allocate memory for arguments"); for (i = 1; i < argc; i++) argv[i] = strdup(CHAR(STRING_ELT(args, i - 1))); argv[0] = "RSpool"; n = main(argc, argv); for (i = 1; i < argc; i++) free(argv[i]); free(argv); return ScalarLogical((n == 0) ? TRUE : FALSE); } #endif /*--- The following makes the indenting behavior of emacs compatible with Xcode's 4/4 setting ---*/ /* Local Variables: */ /* indent-tabs-mode: t */ /* tab-width: 4 */ /* c-basic-offset: 4 */ /* End: */ Rserve/src/md5.c0000644000176000001440000002110112205226215013160 0ustar ripleyusers/* * This code implements the MD5 message-digest algorithm. * The algorithm is due to Ron Rivest. This code was * written by Colin Plumb in 1993, no copyright is claimed. * This code is in the public domain; do with it what you wish. * * Equivalent code is available from RSA Data Security, Inc. * This code has been tested against that, and is equivalent, * except that you don't need to include two pages of legalese * with every copy. * * To compute the message digest of a chunk of bytes, declare an * MD5Context structure, pass it to MD5Init, call MD5Update as * needed on buffers full of bytes, and then call MD5Final, which * will fill a supplied 16-byte array with the digest. */ /* Brutally hacked by John Walker back from ANSI C to K&R (no prototypes) to maintain the tradition that Netfone will compile with Sun's original "cc". Modified to work better with autoconf and added md5hash convenience function (Simon Urbanek, 2005/09/30) $Id$ */ #ifndef NO_CONFIG_H #include "config.h" #endif #ifdef HAVE_MEMORY_H #include /* for memcpy() */ #else #include #endif #include "md5.h" #ifdef SWAPEND #define HIGHFIRST #endif #ifndef HIGHFIRST #define byteReverse(buf, len) /* Nothing */ #else /* * Note: this code is harmless on little-endian machines. */ void byteReverse(buf, longs) unsigned char *buf; unsigned longs; { uint32 t; do { t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | ((unsigned) buf[1] << 8 | buf[0]); *(uint32 *) buf = t; buf += 4; } while (--longs); } #endif /* * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious * initialization constants. */ void MD5Init(ctx) struct MD5Context *ctx; { ctx->buf[0] = 0x67452301; ctx->buf[1] = 0xefcdab89; ctx->buf[2] = 0x98badcfe; ctx->buf[3] = 0x10325476; ctx->bits[0] = 0; ctx->bits[1] = 0; } /* * Update context to reflect the concatenation of another buffer full * of bytes. */ void MD5Update(ctx, buf, len) struct MD5Context *ctx; const unsigned char *buf; unsigned len; { uint32 t; /* Update bitcount */ t = ctx->bits[0]; if ((ctx->bits[0] = t + ((uint32) len << 3)) < t) ctx->bits[1]++; /* Carry from low to high */ ctx->bits[1] += len >> 29; t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ /* Handle any leading odd-sized chunks */ if (t) { unsigned char *p = (unsigned char *) ctx->in + t; t = 64 - t; if (len < t) { memcpy(p, buf, len); return; } memcpy(p, buf, t); byteReverse(ctx->in, 16); MD5Transform(ctx->buf, (uint32 *) ctx->in); buf += t; len -= t; } /* Process data in 64-byte chunks */ while (len >= 64) { memcpy(ctx->in, buf, 64); byteReverse(ctx->in, 16); MD5Transform(ctx->buf, (uint32 *) ctx->in); buf += 64; len -= 64; } /* Handle any remaining bytes of data. */ memcpy(ctx->in, buf, len); } /* * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ void MD5Final(digest, ctx) unsigned char digest[16]; struct MD5Context *ctx; { unsigned count; unsigned char *p; /* Compute number of bytes mod 64 */ count = (ctx->bits[0] >> 3) & 0x3F; /* Set the first char of padding to 0x80. This is safe since there is always at least one byte free */ p = ctx->in + count; *p++ = 0x80; /* Bytes of padding needed to make 64 bytes */ count = 64 - 1 - count; /* Pad out to 56 mod 64 */ if (count < 8) { /* Two lots of padding: Pad the first block to 64 bytes */ memset(p, 0, count); byteReverse(ctx->in, 16); MD5Transform(ctx->buf, (uint32 *) ctx->in); /* Now fill the next block with 56 bytes */ memset(ctx->in, 0, 56); } else { /* Pad block to 56 bytes */ memset(p, 0, count - 8); } byteReverse(ctx->in, 14); /* Append length in bits and transform */ ((uint32 *) ctx->in)[14] = ctx->bits[0]; ((uint32 *) ctx->in)[15] = ctx->bits[1]; MD5Transform(ctx->buf, (uint32 *) ctx->in); byteReverse((unsigned char *) ctx->buf, 4); memcpy(digest, ctx->buf, 16); memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ } /* The four core functions - F1 is optimized somewhat */ /* #define F1(x, y, z) (x & y | ~x & z) */ #define F1(x, y, z) (z ^ (x & (y ^ z))) #define F2(x, y, z) F1(z, x, y) #define F3(x, y, z) (x ^ y ^ z) #define F4(x, y, z) (y ^ (x | ~z)) /* This is the central step in the MD5 algorithm. */ #define MD5STEP(f, w, x, y, z, data, s) \ ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) /* * The core of the MD5 algorithm, this alters an existing MD5 hash to * reflect the addition of 16 longwords of new data. MD5Update blocks * the data and converts bytes into longwords for this routine. */ void MD5Transform(buf, in) uint32 buf[4]; uint32 in[16]; { register uint32 a, b, c, d; a = buf[0]; b = buf[1]; c = buf[2]; d = buf[3]; MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); buf[0] += a; buf[1] += b; buf[2] += c; buf[3] += d; } static unsigned char m5hash[16]; /* the hash must hold 16 bytes */ unsigned char *md5hash(const void *buf, int len, unsigned char hash[16]) { struct MD5Context ctx; if (!hash) hash=m5hash; MD5Init(&ctx); MD5Update(&ctx, buf, len); MD5Final(hash, &ctx); return hash; } Rserve/src/qap_encode.h0000644000176000001440000000041212205226215014600 0ustar ripleyusers#ifndef QAP_ENCODE_H__ #define QAP_ENCODE_H__ #ifndef USE_RINTERNALS #define USE_RINTERNALS 1 #include #endif #include "Rsrv.h" rlen_t QAP_getStorageSize(SEXP x); unsigned int* QAP_storeSEXP(unsigned int* buf, SEXP x, rlen_t storage_size); #endif Rserve/src/mergefat0000755000176000001440000000160212205226215014053 0ustar ripleyusers#!/bin/sh # Usage: mergefat # # Merges into possibly fat file and places the result in . # is assumed to be single-arch only. # Checks whether /usr/bin/lipo exists and uses cp if it doesn't. # # (C)2006,8 Simon Urbanek LIPO=/usr/bin/lipo if test -e "${LIPO}" -a -e "$2"; then myarch=`${LIPO} -detailed_info "$1"| sed -n -e 's|.\{0,\}architecture:\{0,1\} ||p'` binarch=`${LIPO} -detailed_info "$2"| sed -n -e 's|.\{0,\}architecture:\{0,1\} ||p'` if test "$myarch" = "$binarch"; then # the target is a single-arch of the same type as us - just replace cp "$1" "$2" else # try to remove our arch - if it fails (it is not fat or doesn't have our arch), # take the whole thing ${LIPO} "$2" -remove "$myarch" -o liposuction || cp "$2" liposuction ${LIPO} -create liposuction "$1" -o "$2" rm -f liposuction fi else cp "$1" "$2" fi Rserve/src/sha1.c0000644000176000001440000002616712205226215013350 0ustar ripleyusers/* * sha1.c * * Description: * This file implements the Secure Hashing Algorithm 1 as * defined in FIPS PUB 180-1 published April 17, 1995. * * The SHA-1, produces a 160-bit message digest for a given * data stream. It should take about 2**n steps to find a * message with the same digest as a given message and * 2**(n/2) to find any two messages with the same digest, * when n is the digest size in bits. Therefore, this * algorithm can serve as a means of providing a * "fingerprint" for a message. * * Portability Issues: * SHA-1 is defined in terms of 32-bit "words". This code * uses (included via "sha1.h" to define 32 and 8 * bit unsigned integer types. If your C compiler does not * support 32 bit unsigned integers, this code is not * appropriate. * * Caveats: * SHA-1 is designed to work with messages less than 2^64 bits * long. Although SHA-1 allows a message digest to be generated * for messages of any number of bits less than 2^64, this * implementation only works with messages with a length that is * a multiple of the size of an 8-bit character. * */ #include enum { shaSuccess = 0, shaNull, /* Null pointer parameter */ shaInputTooLong, /* input data too long */ shaStateError /* called Input after Result */ }; #define SHA1HashSize 20 /* * This structure will hold context information for the SHA-1 * hashing operation */ typedef struct SHA1Context { uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */ uint32_t Length_Low; /* Message length in bits */ uint32_t Length_High; /* Message length in bits */ /* Index into message block array */ int_least16_t Message_Block_Index; uint8_t Message_Block[64]; /* 512-bit message blocks */ int Computed; /* Is the digest computed? */ int Corrupted; /* Is the message digest corrupted? */ } SHA1Context; /* * Define the SHA1 circular left shift macro */ #define SHA1CircularShift(bits,word) \ (((word) << (bits)) | ((word) >> (32-(bits)))) /* Local Function Prototyptes */ static void SHA1PadMessage(SHA1Context *); static void SHA1ProcessMessageBlock(SHA1Context *); /* * SHA1Reset * * Description: * This function will initialize the SHA1Context in preparation * for computing a new SHA1 message digest. * * Parameters: * context: [in/out] * The context to reset. * * Returns: * sha Error Code. * */ static int SHA1Reset(SHA1Context *context) { if (!context) { return shaNull; } context->Length_Low = 0; context->Length_High = 0; context->Message_Block_Index = 0; context->Intermediate_Hash[0] = 0x67452301; context->Intermediate_Hash[1] = 0xEFCDAB89; context->Intermediate_Hash[2] = 0x98BADCFE; context->Intermediate_Hash[3] = 0x10325476; context->Intermediate_Hash[4] = 0xC3D2E1F0; context->Computed = 0; context->Corrupted = 0; return shaSuccess; } /* * SHA1Result * * Description: * This function will return the 160-bit message digest into the * Message_Digest array provided by the caller. * NOTE: The first octet of hash is stored in the 0th element, * the last octet of hash in the 19th element. * * Parameters: * context: [in/out] * The context to use to calculate the SHA-1 hash. * Message_Digest: [out] * Where the digest is returned. * * Returns: * sha Error Code. * */ static int SHA1Result( SHA1Context *context, uint8_t Message_Digest[SHA1HashSize]) { int i; if (!context || !Message_Digest) { return shaNull; } if (context->Corrupted) { return context->Corrupted; } if (!context->Computed) { SHA1PadMessage(context); for(i=0; i<64; ++i) { /* message may be sensitive, clear it out */ context->Message_Block[i] = 0; } context->Length_Low = 0; /* and clear length */ context->Length_High = 0; context->Computed = 1; } for(i = 0; i < SHA1HashSize; ++i) { Message_Digest[i] = context->Intermediate_Hash[i>>2] >> 8 * ( 3 - ( i & 0x03 ) ); } return shaSuccess; } /* * SHA1Input * * Description: * This function accepts an array of octets as the next portion * of the message. * * Parameters: * context: [in/out] * The SHA context to update * message_array: [in] * An array of characters representing the next portion of * the message. * length: [in] * The length of the message in message_array * * Returns: * sha Error Code. * */ static int SHA1Input( SHA1Context *context, const uint8_t *message_array, unsigned length) { if (!length) { return shaSuccess; } if (!context || !message_array) { return shaNull; } if (context->Computed) { context->Corrupted = shaStateError; return shaStateError; } if (context->Corrupted) { return context->Corrupted; } while(length-- && !context->Corrupted) { context->Message_Block[context->Message_Block_Index++] = (*message_array & 0xFF); context->Length_Low += 8; if (context->Length_Low == 0) { context->Length_High++; if (context->Length_High == 0) { /* Message is too long */ context->Corrupted = 1; } } if (context->Message_Block_Index == 64) { SHA1ProcessMessageBlock(context); } message_array++; } return shaSuccess; } /* * SHA1ProcessMessageBlock * * Description: * This function will process the next 512 bits of the message * stored in the Message_Block array. * * Parameters: * None. * * Returns: * Nothing. * * Comments: * Many of the variable names in this code, especially the * single character names, were used because those were the * names used in the publication. * * */ static void SHA1ProcessMessageBlock(SHA1Context *context) { const uint32_t K[] = { /* Constants defined in SHA-1 */ 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 }; int t; /* Loop counter */ uint32_t temp; /* Temporary word value */ uint32_t W[80]; /* Word sequence */ uint32_t A, B, C, D, E; /* Word buffers */ /* * Initialize the first 16 words in the array W */ for(t = 0; t < 16; t++) { W[t] = context->Message_Block[t * 4] << 24; W[t] |= context->Message_Block[t * 4 + 1] << 16; W[t] |= context->Message_Block[t * 4 + 2] << 8; W[t] |= context->Message_Block[t * 4 + 3]; } for(t = 16; t < 80; t++) { W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]); } A = context->Intermediate_Hash[0]; B = context->Intermediate_Hash[1]; C = context->Intermediate_Hash[2]; D = context->Intermediate_Hash[3]; E = context->Intermediate_Hash[4]; for(t = 0; t < 20; t++) { temp = SHA1CircularShift(5,A) + ((B & C) | ((~B) & D)) + E + W[t] + K[0]; E = D; D = C; C = SHA1CircularShift(30,B); B = A; A = temp; } for(t = 20; t < 40; t++) { temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1]; E = D; D = C; C = SHA1CircularShift(30,B); B = A; A = temp; } for(t = 40; t < 60; t++) { temp = SHA1CircularShift(5,A) + ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2]; E = D; D = C; C = SHA1CircularShift(30,B); B = A; A = temp; } for(t = 60; t < 80; t++) { temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3]; E = D; D = C; C = SHA1CircularShift(30,B); B = A; A = temp; } context->Intermediate_Hash[0] += A; context->Intermediate_Hash[1] += B; context->Intermediate_Hash[2] += C; context->Intermediate_Hash[3] += D; context->Intermediate_Hash[4] += E; context->Message_Block_Index = 0; } /* * SHA1PadMessage * * Description: * According to the standard, the message must be padded to an even * 512 bits. The first padding bit must be a '1'. The last 64 * bits represent the length of the original message. All bits in * between should be 0. This function will pad the message * according to those rules by filling the Message_Block array * accordingly. It will also call the ProcessMessageBlock function * provided appropriately. When it returns, it can be assumed that * the message digest has been computed. * * Parameters: * context: [in/out] * The context to pad * ProcessMessageBlock: [in] * The appropriate SHA*ProcessMessageBlock function * Returns: * Nothing. * */ static void SHA1PadMessage(SHA1Context *context) { /* * Check to see if the current message block is too small to hold * the initial padding bits and length. If so, we will pad the * block, process it, and then continue padding into a second * block. */ if (context->Message_Block_Index > 55) { context->Message_Block[context->Message_Block_Index++] = 0x80; while(context->Message_Block_Index < 64) { context->Message_Block[context->Message_Block_Index++] = 0; } SHA1ProcessMessageBlock(context); while(context->Message_Block_Index < 56) { context->Message_Block[context->Message_Block_Index++] = 0; } } else { context->Message_Block[context->Message_Block_Index++] = 0x80; while(context->Message_Block_Index < 56) { context->Message_Block[context->Message_Block_Index++] = 0; } } /* * Store the message length as the last 8 octets */ context->Message_Block[56] = context->Length_High >> 24; context->Message_Block[57] = context->Length_High >> 16; context->Message_Block[58] = context->Length_High >> 8; context->Message_Block[59] = context->Length_High; context->Message_Block[60] = context->Length_Low >> 24; context->Message_Block[61] = context->Length_Low >> 16; context->Message_Block[62] = context->Length_Low >> 8; context->Message_Block[63] = context->Length_Low; SHA1ProcessMessageBlock(context); } void sha1hash(const char *buf, int len, unsigned char hash[20]) { SHA1Context sha; SHA1Reset(&sha); SHA1Input(&sha, (const unsigned char *) buf, len); SHA1Result(&sha, hash); } Rserve/src/rsdebug.h0000644000176000001440000000226412205226215014144 0ustar ripleyusers/* debugging tools such as dump */ #ifndef RSDEBUG_H__ #define RSDEBUG_H__ #ifndef NO_CONFIG_H #include "config.h" #endif #ifdef unix #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #else #define gettimeofday(X,Y) 1 #endif #include #if defined RSERV_DEBUG || defined RSERV_IOLOG #ifdef MAIN int io_log = 0; /* log all I/O operations */ int dumpLimit = 128; double first_ts = 0.0; #else extern int io_log, dumpLimit; extern double first_ts; #endif static char io_log_fn[128]; static void fprintDump(FILE *f, const void *b, int len) { int i = 0; if (len < 1) { fprintf(f, "DUMP FAILED (len=%d)\n", len); }; fprintf(f, "DUMP [%d]:",len); while(i < len) { fprintf(f, " %02x",((const unsigned char*)b)[i++]); if (dumpLimit && i > dumpLimit) { fprintf(f, " ..."); break; }; } i = 0; fprintf(f, " |"); while (i < len) { unsigned char c = ((const unsigned char*)b)[i++]; if (c < 32 || c > 127) c = '.'; fputc(c, f); if (dumpLimit && i > dumpLimit) break; } fprintf(f, "\n"); } #define printDump(B,L) fprintDump(stdout, B, L) #endif #endif Rserve/src/websockets.c0000644000176000001440000006171212205226215014660 0ustar ripleyusers#include "Rsrv.h" #include "websockets.h" #include "md5.h" #include "sha1.h" #include "tls.h" #include "rsdebug.h" #include "rserr.h" #include #include #include #include struct args { server_t *srv; /* server that instantiated this connection */ SOCKET s; SOCKET ss; void *res1; /* used by TLS */ struct args *tls_arg; /* if set it is used to wire send/recv calls */ /* the following entries are not populated by Rserve but can be used by server implemetations */ char *buf, *sbuf; int ver, bp, bl, sp, sl, flags; long l1, l2; }; static int WS_recv_data(args_t *arg, void *buf, rlen_t read_len); static void WS_send_resp(args_t *arg, int rsp, rlen_t len, const void *buf); static int WS_send_data(args_t *arg, const void *buf, rlen_t len); static int WS_wire_send(args_t *arg, const void *buf, rlen_t len) { return (arg->tls_arg) ? arg->tls_arg->srv->send(arg->tls_arg, buf, len) : send(arg->s, buf, len, 0); } static int WS_wire_recv(args_t *arg, void *buf, rlen_t len) { return (arg->tls_arg) ? arg->tls_arg->srv->recv(arg->tls_arg, buf, len) : recv(arg->s, buf, len, 0); } static void WS_wire_close(args_t *arg) { if (arg->tls_arg) { close_tls(arg->tls_arg); closesocket(arg->tls_arg->s); if (arg->s != arg->tls_arg->s) closesocket(arg->s); arg->tls_arg->s = -1; /* the server is virtual and allocated only for this instance so it's ok to free it (all other server are re-used) */ free(arg->tls_arg->srv); free(arg->tls_arg); arg->tls_arg = 0; } else closesocket(arg->s); arg->s = -1; } static int do_mask(char *msg, int len, int koff, char *key) { int i = 0; while (i < len) { msg[i] ^= key[(i + koff) & 3]; i++; } return (i + koff) & 3; } /* due to very large cookies the lines may be very long, using 128kB for now */ #define LINE_BUF_SIZE (128*1024) struct header_info { int version; char *origin; char *host; char *key; char *key1; char *key2; char *path; char *query; char *protocol; }; static void free_header(struct header_info *h) { if (h->origin) free(h->origin); if (h->host) free(h->host); if (h->key) free(h->key); if (h->key1) free(h->key1); if (h->key2) free(h->key2); if (h->path) free(h->path); if (h->query) free(h->query); if (h->protocol) free(h->protocol); } static unsigned long count_spaces(const char *c) { unsigned long n = 0; while (*c) { if (*c == ' ') n++; c++; } return n; } static unsigned long count_digits(const char *c) { unsigned long n = 0; while (*c) { if (*c >= '0' && *c <= '9') n = n * 10L + (unsigned long)(*c - '0'); c++; } return n; } /* from base64.c */ void base64encode(const unsigned char *src, int len, char *dst); /* from Rserve.c */ void Rserve_QAP1_connected(args_t *arg); void Rserve_text_connected(args_t *arg); #define FRAME_BUFFER_SIZE 65536 static void WS_connected(void *parg) { args_t *arg = (args_t*) parg; /* server_t *srv = arg->srv; */ SOCKET s = arg->s; int n, bp = 0, empty_lines = 0, request_line = 1; struct header_info h; char *buf; /* we have to perform a handshake before giving over to QAP but we have to fork() first as to not block the server on handshake */ if (Rserve_prepare_child(arg) != 0) { /* parent or error */ free(arg); return; } /* if TLS is requested then we need to synthesize arg and srv for the TLS leg. FIXME: check that disassociating arg->s and tls_arg->s has no bad side-effects. */ if (arg->srv->flags & WS_TLS) { args_t *tls_arg = calloc(1, sizeof(args_t)); tls_arg->s = arg->s; tls_arg->srv = calloc(1, sizeof(server_t)); add_tls(tls_arg, shared_tls(0), 1); arg->tls_arg = tls_arg; } else arg->tls_arg = 0; buf = (char*) malloc(LINE_BUF_SIZE); if (!buf) { char lbuf[64]; strcpy(lbuf, "HTTP/1.1 500 Out of memory\r\n\r\n"); WS_wire_send(arg, lbuf, strlen(lbuf)); WS_wire_close(arg); arg->s = -1; return; } buf[LINE_BUF_SIZE - 1] = 0; memset(&h, 0, sizeof(h)); #ifdef RSERV_DEBUG printf("INFO:WS: connection accepted for WebSockets\n"); #endif while ((n = WS_wire_recv(arg, buf + bp, LINE_BUF_SIZE - bp - 1)) > 0) { char *c = buf, *nl = c; #ifdef RSERV_DEBUG buf[bp + n] = 0; printf("INFO:WS: recv(%d, %d) = %d\n%s\n---\n", bp, LINE_BUF_SIZE - bp - 1, n, buf); #endif bp += n; while (*c) { char *dc = 0, *kc; while (*c == ' ' || *c == '\t') c++; kc = c; while (*c && *c != '\n') { if (!dc) { if (*c >= 'A' && *c <= 'Z') *c |= 0x20; /* to lower */ if (*c == ':') { *c = 0; dc = c + 1; } } c++; } if (*c) { /* next full line */ nl = c + 1; if (c > buf && *(c - 1) == '\r') *(c - 1) = 0; *c = 0; c++; if (request_line) { char *r1 = kc; request_line = 0; while (*kc && *kc != ' ') kc++; if (*kc == ' ') { r1 = ++kc; while (*kc && *kc != ' ') kc++; if (*kc == ' ') { char *r2 = r1; *kc = 0; while (*r2 && *r2 != '?') r2++; if (*r2 == '?') { /* split off query part */ *(r2++) = 0; h.query = strdup(r2); } h.path = strdup(r1); #ifdef RSERV_DEBUG printf("INFO:WS: request for '%s' (query%c%s)\n", r1, h.query ? ':' : ' ', h.query ? h.query : "not specified"); #endif } } } else if (dc) { while (*dc == ' ' || *dc == '\t') dc++; #ifdef RSERV_DEBUG printf("INFO:WS: header '%s' = '%s'\n", kc, dc); #endif if (!strcmp(kc, "origin")) h.origin = strdup(dc); if (!strcmp(kc, "host")) h.host = strdup(dc); if (!strcmp(kc, "sec-websocket-version")) h.version = atoi(dc); if (!strcmp(kc, "sec-websocket-protocol")) h.protocol = strdup(dc); if (!strcmp(kc, "sec-websocket-key1")) h.key1 = strdup(dc); if (!strcmp(kc, "sec-websocket-key2")) h.key2 = strdup(dc); if (!strcmp(kc, "sec-websocket-key")) h.key = strdup(dc); } else if (!*kc && ++empty_lines) break; } } #ifdef RSERV_DEBUG printf("INFO: bp=%d, nl=buf+%d\n", bp, (int) (nl - buf)); #endif if (nl == buf) { if (bp >= LINE_BUF_SIZE - 1) { /* no line in the entire buffer */ strcpy(buf, "HTTP/1.1 400 Bad Request (line overflow)\r\n\r\n"); WS_wire_send(arg, buf, strlen(buf)); WS_wire_close(arg); arg->s = -1; free_header(&h); free(buf); return; } /* otherwise it's fine, we will load more */ } else { if (nl >= buf + LINE_BUF_SIZE - 1 || (!empty_lines && !*nl)) /* everything was consumed */ bp = 0; else { bp -= nl - buf; memmove(buf, nl, bp); } } if (empty_lines > 0) break; } if (empty_lines < 1) { strcpy(buf, "HTTP/1.1 400 Bad Request (connection failed before EOH)\r\n\r\n"); WS_wire_send(arg, buf, strlen(buf)); WS_wire_close(arg); arg->s = -1; free(buf); free_header(&h); return; } #ifdef RSERV_DEBUG fprintf(stderr, "INFO: WebSockets version %d\n Origin: %s\n Host: %s\n Key: '%s'\n Key1: '%s'\n Key2: '%s'\n\n", h.version, h.origin ? h.origin : "", h.host ? h.host : "", h.key ? h.key : "", h.key1 ? h.key1 : "", h.key2 ? h.key2 : ""); #endif arg->ver = h.version; if (h.version < 4) { /* 00 .. 03 (in fact that was no version in the handshake before 04) */ unsigned int v[2]; unsigned char keyb[16]; unsigned char hash[16]; if (bp < 8) { n = WS_wire_recv(arg, buf + bp, 8 - bp); if (n < 8 - bp) { strcpy(buf, "HTTP/1.1 400 Bad Request (Key3 incomplete)\r\n\r\n"); WS_wire_send(arg, buf, strlen(buf)); WS_wire_close(arg); arg->s = -1; free(buf); free_header(&h); return; } } if (!h.origin || !h.key1 || !h.key2 || !h.host) { strcpy(buf, "HTTP/1.1 400 Bad Request (at least one key header is missing)\r\n\r\n"); WS_wire_send(arg, buf, strlen(buf)); WS_wire_close(arg); arg->s = -1; free(buf); free_header(&h); return; } v[0] = count_digits(h.key1) / count_spaces(h.key1); v[1] = count_digits(h.key2) / count_spaces(h.key2); keyb[3] = v[0] & 255; keyb[2] = (v[0] >> 8) & 255; keyb[1] = (v[0] >> 16) & 255; keyb[0] = (v[0] >> 24) & 255; keyb[7] = v[1] & 255; keyb[6] = (v[1] >> 8) & 255; keyb[5] = (v[1] >> 16) & 255; keyb[4] = (v[1] >> 24) & 255; memcpy(keyb + 8, buf, 8); md5hash(keyb, 16, hash); if (!h.path) h.path = strdup("/"); snprintf(buf, LINE_BUF_SIZE, "HTTP/1.1 101 Switching Protocols\r\nUpgrade: WebSocket\r\nConnection: Upgrade\r\nSec-WebSocket-Origin: %s\r\nSec-WebSocket-Location: ws://%s%s\r\n%s%s%s\r\n", h.origin, h.host, h.path, h.protocol ? "Sec-WebSocket-Protocol: " : "", h.protocol ? h.protocol : "", h.protocol ? "\r\n" : ""); bp = strlen(buf); memcpy(buf + bp, hash, 16); WS_wire_send(arg, buf, bp + 16); #ifdef RSERV_DEBUG printf("Responded with WebSockets.00 handshake\n"); #endif } else { unsigned char hash[21]; char b64[40]; strcpy(buf, h.key); strcat(buf, "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"); sha1hash(buf, strlen(buf), hash); hash[20] = 0; /* base64encode needs NUL sentinel */ base64encode(hash, sizeof(hash) - 1, b64); /* FIXME: if the client requests multiple protocols, we should be picking one but we don't */ snprintf(buf, LINE_BUF_SIZE, "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: %s\r\n%s%s%s\r\n", b64, h.protocol ? "Sec-WebSocket-Protocol: " : "", h.protocol ? h.protocol : "", h.protocol ? "\r\n" : ""); WS_wire_send(arg, buf, strlen(buf)); #ifdef RSERV_DEBUG printf("Responded with WebSockets.04+ handshake (version = %02d)\n", h.version); #endif } free(buf); arg->bl = FRAME_BUFFER_SIZE; arg->bp = 0; arg->buf = (char*) malloc(FRAME_BUFFER_SIZE); arg->sl = FRAME_BUFFER_SIZE; arg->sbuf = (char*) malloc(FRAME_BUFFER_SIZE); /* textual protocol */ if (h.protocol && strstr(h.protocol, "text")) { free_header(&h); Rserve_text_connected(arg); return; } free_header(&h); /* switch to underlying QAP1 */ Rserve_QAP1_connected(arg); } static server_t *ws_upgrade_srv, *wss_upgrade_srv; /* virtual server that represents the WS layer in HTTP/WS stack */ /* upgrade HTTP connection to WS connection, only 13+ protocol is supported this way */ /* NOTE: not included: origin, host */ /* IMPORTANT: it mangles the arg structure, so the caller should make sure it releases any obejcts from the structure that may leak */ /* FIXME: it only works on connections that have a direct socket since we don't have a stack to do TLS <-> WS <-> QAP */ void WS13_upgrade(args_t *arg, const char *key, const char *protocol, const char *version) { char buf[512]; unsigned char hash[21]; char b64[44]; server_t *srv; srv = (arg->srv->flags & WS_TLS) ? wss_upgrade_srv : ws_upgrade_srv; if (!srv) { srv = (server_t*) calloc(1, sizeof(server_t)); if (!srv) { snprintf(buf, sizeof(buf), "HTTP/1.1 511 Allocation error\r\n\r\n"); arg->srv->send(arg, buf, strlen(buf)); return; } srv->parent = arg->srv; srv->connected = WS_connected; /* this is not actually called */ srv->send_resp = WS_send_resp; srv->recv = WS_recv_data; srv->send = WS_send_data; srv->fin = server_fin; srv->flags = arg->srv->flags & SRV_QAP_FLAGS; /* pass-through QAP flags */ if (arg->srv->flags & WS_TLS) wss_upgrade_srv = srv; else ws_upgrade_srv = srv; } /* FIXME: can we just use the parent server? */ if (arg->srv->flags & SRV_TLS) { /* if this server is connected through TLS we have to create wire TLS pass-through */ args_t *tls_arg = calloc(1, sizeof(args_t)); tls_arg->srv = calloc(1, sizeof(server_t)); copy_tls(arg, tls_arg); arg->tls_arg = tls_arg; } strncpy(buf, key, sizeof(buf) - 50); strcat(buf, "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"); sha1hash(buf, strlen(buf), hash); hash[20] = 0; /* base64encode needs NUL sentinel */ base64encode(hash, sizeof(hash) - 1, b64); /* FIXME: if the client requests multiple protocols, we should be picking one but we don't */ snprintf(buf, sizeof(buf), "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: %s\r\n%s%s%s\r\n", b64, protocol ? "Sec-WebSocket-Protocol: " : "", protocol ? protocol : "", protocol ? "\r\n" : ""); arg->srv->send(arg, buf, strlen(buf)); #ifdef RSERV_DEBUG printf("Responded with WebSockets.04+ handshake (version = %02d)\n", version ? atoi(version) : 0); #endif arg->bl = FRAME_BUFFER_SIZE; arg->bp = 0; arg->buf = (char*) malloc(FRAME_BUFFER_SIZE); arg->sl = FRAME_BUFFER_SIZE; arg->sbuf = (char*) malloc(FRAME_BUFFER_SIZE); arg->srv = srv; arg->ver = version ? atoi(version) : 13; /* let's assume 13 if not present */ /* textual protocol */ if (protocol && strstr(protocol, "text")) { Rserve_text_connected(arg); return; } /* switch to underlying QAP1 */ Rserve_QAP1_connected(arg); } static void WS_send_resp(args_t *arg, int rsp, rlen_t len, const void *buf) { unsigned char *sbuf = (unsigned char*) arg->sbuf; if (arg->ver == 0) { /* FIXME: we can't really tunnel QAP1 without some encoding ... */ } else { struct phdr ph; int pl = 0; long flen = len + sizeof(ph); memset(&ph, 0, sizeof(ph)); ph.cmd = itop(rsp | ((rsp & CMD_OOB) ? 0 : CMD_RESP)); ph.len = itop(len); #ifdef __LP64__ ph.res = itop(len >> 32); #endif #ifdef RSERV_DEBUG if (io_log) { struct timeval tv; snprintf(io_log_fn, sizeof(io_log_fn), "/tmp/Rserve-io-%d.log", getpid()); FILE *f = fopen(io_log_fn, "a"); if (f) { double ts = 0; if (!gettimeofday(&tv, 0)) ts = ((double) tv.tv_sec) + ((double) tv.tv_usec) / 1000000.0; if (first_ts < 1.0) first_ts = ts; fprintf(f, "%.3f [+%4.3f] SRV --> CLI [WS_send_resp] (%x, %ld bytes)\n HEAD ", ts, ts - first_ts, rsp, (long) len); fprintDump(f, &ph, sizeof(ph)); fprintf(f, " BODY "); if (len) fprintDump(f, buf, len); else fprintf(f, "\n"); fclose(f); } } #endif sbuf[pl++] = ((arg->flags & F_OUT_BIN) ? 1 : 0) + ((arg->ver < 4) ? 0x04 : 0x81); /* text/binary, 4+ has inverted FIN bit */ if (flen < 126) /* short length */ sbuf[pl++] = flen; else if (flen < 65536) { /* 16-bit */ sbuf[pl++] = 126; sbuf[pl++] = flen >> 8; sbuf[pl++] = flen & 255; } else { /* 64-bit */ sbuf[pl++] = 127; { int i = 8; long l = flen; while (i--) { sbuf[pl + i] = l & 255; l >>= 8; } } pl += 8; } memcpy(sbuf + pl, &ph, sizeof(ph)); pl += sizeof(ph); while (len + pl) { int n, send_here = (len + pl > arg->sl) ? arg->sl : (len + pl); if (send_here > pl) memcpy(sbuf + pl, buf, send_here - pl); n = WS_wire_send(arg, sbuf, send_here); #ifdef RSERV_DEBUG if (pl) { fprintf(stderr, "WS_send_resp: sending 4+ frame (ver %02d), n = %d / %d (of total %ld)\n", arg->ver, n, send_here, flen); { int i, m = send_here; if (m > 100) m = 100; for (i = 0; i < m; i++) fprintf(stderr, " %02x", (int) sbuf[i]); fprintf(stderr,"\n"); } } else fprintf(stderr, "WS_send_resp: continuation (%d bytes)\n", n); #endif if (n != send_here) { #ifdef RSERV_DEBUG fprintf(stderr, "WS_send_resp: write failed (%d expected, got %d)\n", send_here, n); #endif return; } buf = ((char*)buf) + send_here - pl; len -= send_here - pl; pl = 0; } } } /* we use send_data only to send the ID string so we don't bother supporting frames bigger than the buffer */ static int WS_send_data(args_t *arg, const void *buf, rlen_t len) { unsigned char *sbuf = (unsigned char*) arg->sbuf; if (arg->ver == 0) { if (len < arg->sl - 2) { int n; sbuf[0] = 0; memcpy(sbuf + 1, buf, len); sbuf[len + 1] = 0xff; n = WS_wire_send(arg, sbuf, len + 2); #ifdef RSERV_DEBUG fprintf(stderr, "WS_send_data: sending 00 frame, n = %d / %d\n", n, (int) len + 2); #endif if (n == len + 2) return len; if (n < len + 2 && n >= len) return len - 1; return n; } else { #ifdef RSERV_DEBUG fprintf(stderr, "ERROR in WS_send_data: data too large\n"); #endif return -1; } } else { if (len < arg->sl - 8 && len < 65536) { int n, pl = 0; sbuf[pl++] = ((arg->flags & F_OUT_BIN) ? 1 : 0) + ((arg->ver < 4) ? 0x04 : 0x81); /* text, 4+ has inverted FIN bit */ if (len < 126) /* short length */ sbuf[pl++] = len; else if (len < 65536) { /* 16-bit */ sbuf[pl++] = 126; sbuf[pl++] = len >> 8; sbuf[pl++] = len & 255; } /* no masking or other stuff */ memcpy(sbuf + pl, buf, len); n = WS_wire_send(arg, sbuf, len + pl); #ifdef RSERV_DEBUG fprintf(stderr, "WS_send_data: sending 4+ frame (ver %02d), n = %d / %d\n", arg->ver, n, (int) len + pl); #endif if (n == len + pl) return len; if (n < len + pl && n >= len) return len - 1; return n; } else { #ifdef RSERV_DEBUG fprintf(stderr, "ERROR in WS_send_data: data too large\n"); #endif return -1; } } return 0; } static int WS_recv_data(args_t *arg, void *buf, rlen_t read_len) { #ifdef RSERV_DEBUG fprintf(stderr, "WS_recv_data for %d (bp = %d)\n", (int) read_len, arg->bp); #endif if (arg->ver == 0) { /* make sure we have at least one (in frame) or two (oof) bytes in the buffer */ int min_size = (arg->flags & F_INFRAME) ? 1 : 2; while (arg->bp < min_size) { int n = WS_wire_recv(arg, arg->buf + arg->bp, arg->bl - arg->bp); #ifdef RSERV_DEBUG fprintf(stderr, "WS_recv_data: needs ver 00 frame, reading %d bytes in addition to %d\n", n, arg->bp); { int i; fprintf(stderr, "Buffer: "); for (i = 0; i < n; i++) fprintf(stderr, " %02x", (int) (unsigned char) arg->buf[i]); fprintf(stderr,"\n"); } #endif if (n < 1) return n; arg->bp += n; } if (!(arg->flags & F_INFRAME)) { if (arg->buf[0] != 0x00) { #ifdef RSERV_DEBUG fprintf(stderr, "ERROR: WS_recv_data: ver0 yet not a text frame (0x%02x)\n", (int) (unsigned char) arg->buf[0]); #endif return -1; } /* now we're in-frame - this is silly but makes the processing easier */ arg->flags |= F_INFRAME; memmove(arg->buf, arg->buf + 1, arg->bp - 1); } /* first check if we can satify any need by using contents of the buffer */ /* NOTE: this is actually always true since we guarantee both F_INFRAME and bp > 0 above */ if ((arg->flags & F_INFRAME) && arg->bp > 0) { unsigned char *b = (unsigned char*) arg->buf; int i = 0; #ifdef RSERV_DEBUG fprintf(stderr, "WS_recv_data: have %d bytes of a frame, requested %d, returning what we have\n", arg->bp, (int) read_len); #endif while (i < arg->bp && i < read_len && b[i] != 0xff) i++; if (i >= arg->bp) { /* end of buffer, still in frame */ memcpy(buf, arg->buf, i); arg->bp = 0; return i; } if (b[i] == 0xff) { /* reached end of frame */ if (i) memcpy(buf, arg->buf, i); arg->bp -= i + 1; if (arg->bp > 0) memmove(arg->buf, arg->buf + i + 1, arg->bp); arg->flags ^= F_INFRAME; return i; } /* read_len was less than the buffer and did not even reach the end of frame */ memcpy(buf, arg->buf, i); arg->bp -= i; memmove(arg->buf, arg->buf + i, arg->bp); return i; } } /* ver 00 always returns before this */ if ((arg->flags & F_INFRAME) && arg->bp > 0) { /* do we have content of a frame what has not been picked up yet? */ #ifdef RSERV_DEBUG fprintf(stderr, "WS_recv_data: have %d bytes of a frame, requested %d, returning what we have\n", arg->bp, (int) read_len); #endif if (read_len > arg->bp) read_len = arg->bp; /* at most all buffer */ if (read_len > arg->l1) read_len = arg->l1; /* and not beyond the current frame */ memcpy(buf, arg->buf, read_len); if (arg->bp > read_len) memmove(arg->buf, arg->buf + read_len, arg->bp - read_len); arg->bp -= read_len; arg->l1 -= read_len; /* if the whole frame was consumed, flag out-of-frame for the next run */ if (arg->l1 == 0) arg->flags ^= F_INFRAME; return read_len; } /* make sure we have at least one byte in the buffer */ if (arg->bp == 0) { int n = WS_wire_recv(arg, arg->buf, arg->bl); if (n < 1) return n; arg->bp = n; #ifdef RSERV_DEBUG fprintf(stderr, "INFO: WS_recv_data: read %d bytes:\n", n); { int i; for (i = 0; i < n; i++) fprintf(stderr, " %02x", (int) (unsigned char) arg->buf[i]); fprintf(stderr,"\n"); } #endif } if (arg->flags & F_INFRAME) { /* in frame with new content */ if (read_len > arg->l1) /* we can do at most the end of the frame */ read_len = arg->l1; if (read_len > arg->bp) /* and at most what we got in the buffer */ read_len = arg->bp; memcpy(buf, arg->buf, read_len); if (arg->flags & F_MASK) SET_F_MASK(arg->flags, do_mask(buf, read_len, GET_MASK_ID(arg->flags), (char*)&arg->l2)); arg->bp -= read_len; arg->l1 -= read_len; if (arg->l1 == 0) /* was that the entire frame? */ arg->flags ^= F_INFRAME; return read_len; } else { /* not in frame - interpret a new frame */ unsigned char *fr = (unsigned char*) arg->buf; int more = (arg->ver < 4) ? ((fr[0] & 0x80) == 0x80) : ((fr[0] & 0x80) == 0), mask = 0; int need = 0, ct = fr[0] & 127, at_least, payload; long len = 0; /* set the F_IN_BIN flag according to the frame type */ if ((arg->ver < 4 && ct == 5) || (arg->ver >= 4 && ct == 2)) arg->flags |= F_IN_BIN; else arg->flags &= ~ F_IN_BIN; SET_F_FT(arg->flags, ct); if (arg->bp == 1) { int n = WS_wire_recv(arg, arg->buf + 1, arg->bl - 1); if (n < 1) return n; arg->bp = n + 1; } if (arg->ver > 6 && fr[1] & 0x80) mask = 1; len = fr[1] & 127; need = 2 + (mask ? 4 : 0) + ((len < 126) ? 0 : ((len == 126) ? 2 : 8)); while (arg->bp < need) { int n = WS_wire_recv(arg, arg->buf + arg->bp, arg->bl - arg->bp); if (n < 1) return n; arg->bp += n; } if (len == 126) len = (fr[2] << 8) | fr[3]; else if (len == 127) { if (fr[2] || fr[3]) { #ifdef RSERV_DEBUG fprintf(stderr, "WS_recv_data: requested frame length is way too big - we support only up to 256TB\n"); #endif return -1; } #define SH(X,Y) (((long)X) << Y) len = SH(fr[4], 48) | SH(fr[5], 40) | SH(fr[5], 32) | SH(fr[6], 24) | SH(fr[7], 16) | SH(fr[8], 8) | (long)fr[9]; } #ifdef RSERV_DEBUG fprintf(stderr, "INFO: WS_recv_data frame type=%02x, len=%d, more=%d, mask=%d (need=%d)\n", ct, (int) len, more, mask, need); #endif at_least = need + len; if (at_least > arg->bl) at_least = arg->bl; payload = at_least - need; while (arg->bp < at_least) { int n = WS_wire_recv(arg, arg->buf + arg->bp, at_least - arg->bp); #ifdef RSERV_DEBUG fprintf(stderr, "INFO: read extra %d bytes in addition to %d (need %d)\n", n, arg->bp, need); #endif if (n < 1) return n; arg->bp += n; } /* FIXME: more recent protocols require MASK at all times */ if (mask) { #ifdef RSERV_DEBUG { int i; for (i = 0; i < payload; i++) fprintf(stderr, " %02x", (int) (unsigned char) arg->buf[need + i]); fprintf(stderr,"\n"); } #endif SET_F_MASK(arg->flags, do_mask(arg->buf + need, payload, 0, arg->buf + need - 4)); memcpy(&arg->l2, arg->buf + need - 4, 4); #ifdef RSERV_DEBUG { int i; for (i = 0; i < payload; i++) fprintf(stderr, " %02x", (int) (unsigned char) arg->buf[need + i]); fprintf(stderr,"\n"); } #endif } else arg->flags &= ~ F_MASK; /* if the frame fits in the buffer (payload == len) and the read will read it all, we can deliver the whole frame */ if (payload == len && read_len >= payload) { #ifdef RSERV_DEBUG fprintf(stderr, "INFO: WS_recv_data frame has %d bytes, requested %d, returning entire frame\n", (int) len, (int) read_len); #endif memcpy(buf, arg->buf + need, len); if (arg->bp > at_least) { /* this is unlikely but possible if we got multiple frames in the first read */ memmove(arg->buf, arg->buf + at_least, arg->bp - at_least); arg->bp -= at_least; } else arg->bp = 0; return len; } /* left-over */ #ifdef RSERV_DEBUG fprintf(stderr, "INFO: WS_recv_data frame has %d bytes (of %ld frame), requested %d, returning partial frame\n", payload, len, (int) read_len); #endif /* we can only read all we got */ if (read_len > payload) read_len = payload; memcpy(buf, arg->buf + need, read_len); if (arg->bp > need + read_len) /* if there is any data beyond what we will deliver, we need to move it */ memmove(arg->buf, arg->buf + need + read_len, arg->bp - need - read_len); len -= read_len; /* left in the frame is total minus delivered - we only get here if the frame did not fit, so len > 0 */ arg->l1 = len; arg->flags |= F_INFRAME; arg->bp -= need + read_len; return read_len; } /* in frame */ } server_t *create_WS_server(int port, int flags) { server_t *srv = create_server(port, 0, 0, flags); if (srv) { srv->connected = WS_connected; srv->send_resp = WS_send_resp; srv->recv = WS_recv_data; srv->send = WS_send_data; srv->fin = server_fin; add_server(srv); return srv; } return 0; } #include void serverLoop(void); typedef void (*sig_fn_t)(int); #ifdef unix static void brkHandler_R(int i) { Rprintf("Caught break signal, shutting down WebSockets.\n"); stop_server_loop(); } #endif SEXP run_WSS(SEXP sPort) { server_t *srv = create_WS_server(asInteger(sPort), WS_PROT_ALL); if (srv) { sig_fn_t old; Rprintf("-- starting WebSockets server at port %d (pid=%d) --\n", asInteger(sPort), getpid()); #ifdef unix old = signal(SIGINT, brkHandler_R); #endif serverLoop(); #ifdef unix signal(SIGINT, old); #endif rm_server(srv); } return ScalarLogical(TRUE); } /*--- The following makes the indenting behavior of emacs compatible with Xcode's 4/4 setting ---*/ /* Local Variables: */ /* indent-tabs-mode: t */ /* tab-width: 4 */ /* c-basic-offset: 4 */ /* End: */ Rserve/src/client/0000755000176000001440000000000012205226215013612 5ustar ripleyusersRserve/src/client/java/0000755000176000001440000000000012205226222014531 5ustar ripleyusersRserve/src/client/java/REngineCallbacks.java0000644000176000001440000000025712205226215020531 0ustar ripleyuserspackage org.rosuda.REngine; /** REngineCallbacks is a virtual interface that poses as a superclass of all callback delegate classes. */ public interface REngineCallbacks { } Rserve/src/client/java/REngineStdOutput.java0000644000176000001440000000074212205226215020624 0ustar ripleyuserspackage org.rosuda.REngine; /** implementation of the {@link REngineOutputInterface} which uses standard output. */ public class REngineStdOutput implements REngineCallbacks, REngineOutputInterface { public synchronized void RWriteConsole(REngine eng, String text, int oType) { ((oType == 0) ? System.out : System.err).print(text); } public void RShowMessage(REngine eng, String text) { System.err.println("*** "+text); } public void RFlushConsole(REngine eng) { } } Rserve/src/client/java/Makefile0000644000176000001440000000150213442516164016202 0ustar ripleyusersRENG_SRC=$(wildcard *.java) RSRV_SRC=$(wildcard Rserve/*.java) $(wildcard Rserve/protocol/*.java) JRI_SRC=$(wildcard JRI/*.java) TARGETS=REngine.jar Rserve.jar all: $(TARGETS) JAVAC=javac JAVADOC=javadoc JDFLAGS=-author -version -breakiterator -link http://java.sun.com/j2se/1.4.2/docs/api/ JFLAGS+=-source 1.4 -target 1.4 REngine.jar: $(RENG_SRC) @rm -rf org $(JAVAC) -d . $(JFLAGS) $(RENG_SRC) jar fc $@ org rm -rf org Rserve.jar: $(RSRV_SRC) REngine.jar @rm -rf org $(JAVAC) -d . -cp REngine.jar $(RSRV_SRC) jar fc $@ org rm -rf org clean: rm -rf org *~ $(TARGETS) doc make -C Rserve clean make -C JRI clean test: make -C Rserve test rc: Rserve.jar Rserve/test/jt.java make -C Rserve/test jt doc: $(RENG_SRC) $(RSRV_SRC) $(JRI_SRC) rm -rf $@ mkdir $@ $(JAVADOC) -d $@ $(JDFLAGS) $^ .PHONY: clean all test Rserve/src/client/java/REXPGenericVector.java0000644000176000001440000000574312205226215020645 0ustar ripleyuserspackage org.rosuda.REngine; import java.util.Vector; import java.util.HashMap; /** REXPGenericVector represents a generic vector in R. Its elements can be typically of any {@link REXP} type. */ public class REXPGenericVector extends REXPVector { /** payload */ private RList payload; /** creates a new generic vector from a list. If the list is named, the "names" attribute is created automatically from it. * @param list list to create the vector from */ public REXPGenericVector(RList list) { super(); payload=(list==null)?new RList():list; // automatically generate 'names' attribute if (payload.isNamed()) attr = new REXPList( new RList(new REXP[] { new REXPString(payload.keys()) }, new String[] { "names" })); } /** creates a new generic vector from a list. Note that the names in the list are ignored as they are expected to be defined by the attributes parameter. * @param list list to create the vector from (names are ignored - use {@link #REXPGenericVector(RList)} or the "names" attribute for named lists * @param attr attributes */ public REXPGenericVector(RList list, REXPList attr) { super(attr); payload=(list==null)?new RList():list; } /* generic vectors are converted either to a Map (if it is a named vector and there are no duplicate names) or a Vector. The contained elements are converted using asNativeJavaObject recursively. */ public Object asNativeJavaObject() throws REXPMismatchException { // we need to convert the inside as well int n = payload.size(); // named list -> map but only if // a) all names are present // b) there are no duplicates in the names if (payload.isNamed()) { String[] names = payload.keys(); if (names.length == n) { HashMap map = new HashMap(); boolean valid = true; for (int i = 0; i < n; i++) { if (map.containsKey(names[i])) { valid = false; break; } Object value = payload.elementAt(i); if (value != null) value = ((REXP) value).asNativeJavaObject(); map.put(value, names[i]); } if (valid) return map; } } // otherwise drop names and use just a vector Vector v = new Vector(); for (int i = 0; i < n; i++) { Object value = payload.elementAt(i); if (value != null) value = ((REXP) value).asNativeJavaObject(); v.addElement(value); } return v; } public int length() { return payload.size(); } public boolean isList() { return true; } public boolean isRecursive() { return true; } public RList asList() { return payload; } public String toString() { return super.toString()+(asList().isNamed()?"named":""); } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.size() && i < maxDebugItems) { if (i>0) sb.append(",\n"); sb.append(payload.at(i).toDebugString()); i++; } if (i < payload.size()) sb.append(",.."); return sb.toString()+"}"; } } Rserve/src/client/java/REXPJavaReference.java0000644000176000001440000000164212205226215020600 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPJavaReference is a reference to a Java object that has been resolved from is R wrapper. Note that not all engines support references. */ public class REXPJavaReference extends REXP { /** the referenced Java object */ Object object; /** creates a new Java reference R object * @param o Java object referenced by the REXP */ public REXPJavaReference(Object o) { super(); this.object = o; } /** creates a new Java reference R object * @param o Java object referenced by the REXP * @param attr attributes (of the R wrapper) */ public REXPJavaReference(Object o, REXPList attr) { super(attr); this.object = o; } /** returns the Java object referenced by this REXP * @return Java object */ public Object getObject() { return object; } public Object asNativeJavaObject() { return object; } public String toString() { return super.toString() + "[" + object + "]"; } } Rserve/src/client/java/REXPInteger.java0000644000176000001440000000415712205226215017501 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPDouble represents a vector of integer values. */ public class REXPInteger extends REXPVector { protected int[] payload; /** NA integer value as defined in R. Unlike its real equivalent this one can be used in comparisons, although {@link #isNA(int) } is provided for consistency. */ public static final int NA = -2147483648; public static boolean isNA(int value) { return (value == NA); } /** create integer vector of the length 1 with the given value as its first (and only) element */ public REXPInteger(int load) { super(); payload=new int[] { load }; } /** create integer vector with the payload specified by load */ public REXPInteger(int[] load) { super(); payload=(load==null)?new int[0]:load; } /** create integer vector with the payload specified by load and attributes attr */ public REXPInteger(int[] load, REXPList attr) { super(attr); payload=(load==null)?new int[0]:load; } public Object asNativeJavaObject() { return payload; } public int length() { return payload.length; } public boolean isInteger() { return true; } public boolean isNumeric() { return true; } public int[] asIntegers() { return payload; } /** returns the contents of this vector as doubles */ public double[] asDoubles() { double[] d = new double[payload.length]; int i = 0; while (i < payload.length) { d[i] = (double) payload[i]; i++; } return d; } /** returns the contents of this vector as strings */ public String[] asStrings() { String[] s = new String[payload.length]; int i = 0; while (i < payload.length) { s[i] = ""+payload[i]; i++; } return s; } public boolean[] isNA() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = (payload[i]==NA); i++; } return a; } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.length && i < maxDebugItems) { if (i>0) sb.append(","); sb.append(payload[i]); i++; } if (i < payload.length) sb.append(",.."); return sb.toString()+"}"; } } Rserve/src/client/java/REXPExpressionVector.java0000644000176000001440000000137512205226215021425 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPExpressionVector represents a vector of expressions in R. It is essentially a special kind of generic vector - its elements are expected to be valid R expressions. */ public class REXPExpressionVector extends REXPGenericVector { /** create a new vector of expressions from a list of expressions. * @param list list of expressions to store in this vector */ public REXPExpressionVector(RList list) { super(list); } /** create a new vector of expressions from a list of expressions. * @param list list of expressions to store in this vector * @param attr attributes for the R object */ public REXPExpressionVector(RList list, REXPList attr) { super(list, attr); } public boolean isExpression() { return true; } } Rserve/src/client/java/REXPVector.java0000644000176000001440000000165612205226215017347 0ustar ripleyuserspackage org.rosuda.REngine; /** abstract class representing all vectors in R */ public abstract class REXPVector extends REXP { public REXPVector() { super(); } public REXPVector(REXPList attr) { super(attr); } /** returns the length of the vector (i.e. the number of elements) * @return length of the vector */ public abstract int length(); public boolean isVector() { return true; } /** returns a boolean vector of the same length as this vector with true for NA values and false for any other values * @return a boolean vector of the same length as this vector with true for NA values and false for any other values */ public boolean[] isNA() { boolean a[] = new boolean[length()]; return a; } public String toString() { return super.toString()+"["+length()+"]"; } public String toDebugString() { return super.toDebugString()+"["+length()+"]"; } } Rserve/src/client/java/JRI/0000755000176000001440000000000012205226215015157 5ustar ripleyusersRserve/src/client/java/JRI/Makefile0000644000176000001440000000130713442516164016631 0ustar ripleyusers## there are two ways to compile JRIEngine - either use ## already installed REngine and JRI and then just ## compile JRIEngine against those jars or use this ## Makefile with all org sources checked out ## in which case the JRIEngine.jar will implicitly ## contain org.rosuda.JRI classes as well ## However, that requires both: ## org/rosuda/JRI ## org/rosuda/REngine JRI_MAIN_SRC=$(wildcard ../../JRI/*.java) JRIENGINE_SRC=JRIEngine.java JAVAC=javac JAR=jar JFLAGS=-source 1.4 -target 1.4 all: JRIEngine.jar JRIEngine.jar: $(JRI_MAIN_SRC) $(JRIENGINE_SRC) rm -rf org $(JAVAC) $(JFLAGS) -classpath ../REngine.jar -d . $^ $(JAR) fc $@ org clean: rm -rf org *~ JRIEngine.jar *.class make -C test clean Rserve/src/client/java/JRI/JRIEngine.java0000644000176000001440000010136512205226215017602 0ustar ripleyusers// JRIEngine - REngine-based interface to JRI // Copyright(c) 2009 Simon Urbanek // // Currently it uses low-level calls from org.rosuda.JRI.Rengine, but // all REXP representations are created based on the org.rosuda.REngine API package org.rosuda.REngine.JRI; import org.rosuda.JRI.Rengine; import org.rosuda.JRI.Mutex; import org.rosuda.JRI.RMainLoopCallbacks; import org.rosuda.REngine.*; /** JRIEngine is a REngine implementation using JRI (Java/R Interface).

Note that at most one JRI instance can exist in a given JVM process, because R does not support multiple threads. JRIEngine itself is thread-safe, so it is possible to invoke its methods from any thread. However, this is achieved by serializing all entries into R, so be aware of possible deadlock conditions if your R code calls back into Java (JRIEngine is re-entrant from the same thread so deadlock issues can arise only with multiple threads inteacting thorugh R). */ public class JRIEngine extends REngine implements RMainLoopCallbacks { // internal R types as defined in Rinternals.h static final int NILSXP = 0; /* nil = NULL */ static final int SYMSXP = 1; /* symbols */ static final int LISTSXP = 2; /* lists of dotted pairs */ static final int CLOSXP = 3; /* closures */ static final int ENVSXP = 4; /* environments */ static final int PROMSXP = 5; /* promises: [un]evaluated closure arguments */ static final int LANGSXP = 6; /* language constructs */ static final int SPECIALSXP = 7; /* special forms */ static final int BUILTINSXP = 8; /* builtin non-special forms */ static final int CHARSXP = 9; /* "scalar" string type (internal only) */ static final int LGLSXP = 10; /* logical vectors */ static final int INTSXP = 13; /* integer vectors */ static final int REALSXP = 14; /* real variables */ static final int CPLXSXP = 15; /* complex variables */ static final int STRSXP = 16; /* string vectors */ static final int DOTSXP = 17; /* dot-dot-dot object */ static final int ANYSXP = 18; /* make "any" args work */ static final int VECSXP = 19; /* generic vectors */ static final int EXPRSXP = 20; /* expressions vectors */ static final int BCODESXP = 21; /* byte code */ static final int EXTPTRSXP = 22; /* external pointer */ static final int WEAKREFSXP = 23; /* weak reference */ static final int RAWSXP = 24; /* raw bytes */ static final int S4SXP = 25; /* S4 object */ /** minimal JRI API version that is required by this class in order to work properly (currently API 1.10, corresponding to JRI 0.5-1 or higher) */ static public final long requiredAPIversion = 0x010a; /** currently running JRIEngine - there can be only one and we store it here. Essentially if it is null then R was not initialized. */ static JRIEngine jriEngine = null; /** reference to the underlying low-level JRI (RNI) engine */ Rengine rni = null; /** event loop callbacks associated with this engine. */ REngineCallbacks callbacks = null; /** mutex synchronizing access to R through JRIEngine.

NOTE: only access through this class is synchronized. Any other access (e.g. using RNI directly) is NOT. */ Mutex rniMutex = null; // cached pointers of special objects in R long R_UnboundValue, R_NilValue; /** special, global references */ public REXPReference globalEnv, emptyEnv, baseEnv, nullValueRef; /** canonical NULL object */ public REXPNull nullValue; /** class used for wrapping raw pointers such that they are adequately protected and released according to the lifespan of the Java object */ class JRIPointer { long ptr; JRIPointer(long ptr, boolean preserve) { this.ptr = ptr; if (preserve && ptr != 0 && ptr != R_NilValue) { boolean obtainedLock = rniMutex.safeLock(); // this will inherently wait for R to become ready try { rni.rniPreserve(ptr); } finally { if (obtainedLock) rniMutex.unlock(); } } } protected void finalize() throws Throwable { try { if (ptr != 0 && ptr != R_NilValue) { boolean obtainedLock = rniMutex.safeLock(); try { rni.rniRelease(ptr); } finally { if (obtainedLock) rniMutex.unlock(); } } } finally { super.finalize(); } } long pointer() { return ptr; } } /** factory method called by engineForClass @return new or current engine (new if there is none, current otherwise since R allows only one engine at any time) */ public static REngine createEngine() throws REngineException { // there can only be one JRI engine in a process if (jriEngine == null) jriEngine = new JRIEngine(); return jriEngine; } public static REngine createEngine(String[] args, REngineCallbacks callbacks, boolean runREPL) throws REngineException { if (jriEngine != null) throw new REngineException(jriEngine, "engine already running - cannot use extended constructor on a running instance"); return jriEngine = new JRIEngine(args, callbacks, runREPL); } public Rengine getRni() { return rni; } /** default constructor - this constructor is also used via createEngine factory call and implies --no-save R argument, no callbacks and no REPL.

This is equivalent to JRIEngine(new String[] { "--no-save" }, null, false) */ public JRIEngine() throws REngineException { this(new String[] { "--no-save" }, (REngineCallbacks) null, false); } /** create JRIEngine with specified R command line arguments, no callbacks and no REPL.

This is equivalent to JRIEngine(args, null, false) */ public JRIEngine(String args[]) throws REngineException { this(args, (REngineCallbacks) null, false); } /** creates a JRI engine with specified delegate for callbacks (JRI compatibility mode ONLY!). The event loop is started if callbacks in not null. * @param args arguments to pass to R (note that R usually requires something like --no-save!) * @param callbacks delegate class to process event loop callback from R or null if no event loop is desired **/ public JRIEngine(String args[], RMainLoopCallbacks callbacks) throws REngineException { this(args, callbacks, (callbacks == null) ? false : true); } /** creates a JRI engine with specified delegate for callbacks * @param args arguments to pass to R (note that R usually requires something like --no-save!) * @param callback delegate class to process callbacks from R or null if no callbacks are desired * @param runREPL if set to true then the event loop (REPL) will be started, otherwise the engine is in direct operation mode. */ public JRIEngine(String args[], REngineCallbacks callbacks, boolean runREPL) throws REngineException { // if Rengine hasn't been able to load the native JRI library in its static // initializer, throw an exception if (!Rengine.jriLoaded) throw new REngineException (null, "Cannot load JRI native library"); if (Rengine.getVersion() < requiredAPIversion) throw new REngineException(null, "JRI API version is too old, update rJava/JRI to match the REngine API"); this.callbacks = callbacks; // the default modus operandi is without event loop and with --no-save option rni = new Rengine(args, runREPL, (callbacks == null) ? null : this); rniMutex = rni.getRsync(); boolean obtainedLock = rniMutex.safeLock(); // this will inherently wait for R to become ready try { if (!rni.waitForR()) throw(new REngineException(this, "Unable to initialize R")); if (rni.rniGetVersion() < requiredAPIversion) throw(new REngineException(this, "JRI API version is too old, update rJava/JRI to match the REngine API")); globalEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_GlobalEnv))); nullValueRef = new REXPReference(this, new Long(R_NilValue = rni.rniSpecialObject(Rengine.SO_NilValue))); emptyEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_EmptyEnv))); baseEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_BaseEnv))); nullValue = new REXPNull(); R_UnboundValue = rni.rniSpecialObject(Rengine.SO_UnboundValue); } finally { if (obtainedLock) rniMutex.unlock(); } // register ourself as the main and last engine lastEngine = this; if (jriEngine == null) jriEngine = this; } /** creates a JRI engine with specified delegate for callbacks (JRI compatibility mode ONLY! Will be deprecated soon!) * @param args arguments to pass to R (note that R usually requires something like --no-save!) * @param callback delegate class to process callbacks from R or null if no callbacks are desired * @param runREPL if set to true then the event loop (REPL) will be started, otherwise the engine is in direct operation mode. */ public JRIEngine(String args[], RMainLoopCallbacks callbacks, boolean runREPL) throws REngineException { // if Rengine hasn't been able to load the native JRI library in its static // initializer, throw an exception if (!Rengine.jriLoaded) throw new REngineException (null, "Cannot load JRI native library"); if (Rengine.getVersion() < requiredAPIversion) throw new REngineException(null, "JRI API version is too old, update rJava/JRI to match the REngine API"); // the default modus operandi is without event loop and with --no-save option rni = new Rengine(args, runREPL, callbacks); rniMutex = rni.getRsync(); boolean obtainedLock = rniMutex.safeLock(); // this will inherently wait for R to become ready try { if (!rni.waitForR()) throw(new REngineException(this, "Unable to initialize R")); if (rni.rniGetVersion() < requiredAPIversion) throw(new REngineException(this, "JRI API version is too old, update rJava/JRI to match the REngine API")); globalEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_GlobalEnv))); nullValueRef = new REXPReference(this, new Long(R_NilValue = rni.rniSpecialObject(Rengine.SO_NilValue))); emptyEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_EmptyEnv))); baseEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_BaseEnv))); nullValue = new REXPNull(); R_UnboundValue = rni.rniSpecialObject(Rengine.SO_UnboundValue); } finally { if (obtainedLock) rniMutex.unlock(); } // register ourself as the main and last engine lastEngine = this; if (jriEngine == null) jriEngine = this; } /** WARNING: legacy fallback for hooking from R into an existing Rengine - do NOT use for creating a new Rengine - it will go away eventually */ public JRIEngine(Rengine eng) throws REngineException { // if Rengine hasn't been able to load the native JRI library in its static // initializer, throw an exception if (!Rengine.jriLoaded) throw new REngineException (null, "Cannot load JRI native library"); rni = eng; if (rni.rniGetVersion() < 0x109) throw(new REngineException(this, "R JRI engine is too old - RNI API 1.9 (JRI 0.5) or newer is required")); rniMutex = rni.getRsync(); boolean obtainedLock = rniMutex.safeLock(); try { globalEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_GlobalEnv))); nullValueRef = new REXPReference(this, new Long(R_NilValue = rni.rniSpecialObject(Rengine.SO_NilValue))); emptyEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_EmptyEnv))); baseEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_BaseEnv))); nullValue = new REXPNull(); R_UnboundValue = rni.rniSpecialObject(Rengine.SO_UnboundValue); } finally { if (obtainedLock) rniMutex.unlock(); } // register ourself as the main and last engine lastEngine = this; if (jriEngine == null) jriEngine = this; } public REXP parse(String text, boolean resolve) throws REngineException { REXP ref = null; boolean obtainedLock = rniMutex.safeLock(); try { long pr = rni.rniParse(text, -1); if (pr == 0 || pr == R_NilValue) throw(new REngineException(this, "Parse error")); rni.rniPreserve(pr); ref = new REXPReference(this, new Long(pr)); if (resolve) try { ref = resolveReference(ref); } catch (REXPMismatchException me) { }; } finally { if (obtainedLock) rniMutex.unlock(); } return ref; } public REXP eval(REXP what, REXP where, boolean resolve) throws REngineException, REXPMismatchException { REXP ref = null; long rho = 0; if (where != null && !where.isReference()) { if (!where.isEnvironment() || ((REXPEnvironment)where).getHandle() == null) throw(new REXPMismatchException(where, "environment")); else rho = ((JRIPointer)((REXPEnvironment)where).getHandle()).pointer(); } else if (where != null) rho = ((Long)((REXPReference)where).getHandle()).longValue(); if (what == null) throw(new REngineException(this, "null object to evaluate")); if (!what.isReference()) { if (what.isExpression() || what.isLanguage()) what = createReference(what); else throw(new REXPMismatchException(where, "reference, expression or language")); } boolean obtainedLock = rniMutex.safeLock(); try { long pr = rni.rniEval(((Long)((REXPReference)what).getHandle()).longValue(), rho); /* handling problems */ if (pr == REngineEvalException.INVALID_INPUT){ throw new REngineEvalException(this, "Eval error (invalid input)", REngineEvalException.INVALID_INPUT ); } if (pr == REngineEvalException.ERROR) { throw new REngineEvalException( this, "error during evaluation", REngineEvalException.ERROR ) ; } rni.rniPreserve(pr); ref = new REXPReference(this, new Long(pr)); if (resolve) ref = resolveReference(ref); } finally { if (obtainedLock) rniMutex.unlock(); } return ref; } public void assign(String symbol, REXP value, REXP env) throws REngineException, REXPMismatchException { long rho = 0; if (env != null && !env.isReference()) { if (!env.isEnvironment() || ((REXPEnvironment)env).getHandle() == null) throw(new REXPMismatchException(env, "environment")); else rho = ((JRIPointer)((REXPEnvironment)env).getHandle()).pointer(); } else if (env != null) rho = ((Long)((REXPReference)env).getHandle()).longValue(); if (value == null) value = nullValueRef; if (!value.isReference()) value = createReference(value); // if value is not a reference, we have to create one boolean obtainedLock = rniMutex.safeLock(), succeeded = false; try { succeeded = rni.rniAssign(symbol, ((Long)((REXPReference)value).getHandle()).longValue(), rho); } finally { if (obtainedLock) rniMutex.unlock(); } if (!succeeded) throw new REngineException(this, "assign failed (probably locked binding"); } public REXP get(String symbol, REXP env, boolean resolve) throws REngineException, REXPMismatchException { REXP ref = null; long rho = 0; if (env != null && !env.isReference()) { if (!env.isEnvironment() || ((REXPEnvironment)env).getHandle() == null) throw(new REXPMismatchException(env, "environment")); else rho = ((JRIPointer)((REXPEnvironment)env).getHandle()).pointer(); } else if (env != null) rho = ((Long)((REXPReference)env).getHandle()).longValue(); boolean obtainedLock = rniMutex.safeLock(); try { long pr = rni.rniFindVar(symbol, rho); if (pr == R_UnboundValue || pr == 0) return null; rni.rniPreserve(pr); ref = new REXPReference(this, new Long(pr)); if (resolve) try { ref = resolveReference(ref); } catch (REXPMismatchException me) { }; } finally { if (obtainedLock) rniMutex.unlock(); } return ref; } public REXP resolveReference(REXP ref) throws REngineException, REXPMismatchException { REXP res = null; if (ref == null) throw(new REngineException(this, "resolveReference called on NULL input")); if (!ref.isReference()) throw(new REXPMismatchException(ref, "reference")); long ptr = ((Long)((REXPReference)ref).getHandle()).longValue(); if (ptr == 0) return nullValue; return resolvePointer(ptr); } /** * Turn an R pointer (long) into a REXP object. * * This is the actual implementation of resolveReference but it works directly on the long pointers to be more efficient when performing recursive de-referencing */ REXP resolvePointer(long ptr) throws REngineException, REXPMismatchException { if (ptr == 0) return nullValue; REXP res = null; boolean obtainedLock = rniMutex.safeLock(); try { int xt = rni.rniExpType(ptr); String an[] = rni.rniGetAttrNames(ptr); REXPList attrs = null; if (an != null && an.length > 0) { // are there attributes? Then we need to resolve them first // we allow special handling for Java references so we need the class and jobj long jobj = 0; String oclass = null; RList attl = new RList(); for (int i = 0; i < an.length; i++) { long aptr = rni.rniGetAttr(ptr, an[i]); if (aptr != 0 && aptr != R_NilValue) { if (an[i].equals("jobj")) jobj = aptr; REXP av = resolvePointer(aptr); if (av != null && av != nullValue) { attl.put(an[i], av); if (an[i].equals("class") && av.isString()) oclass = av.asString(); } } } if (attl.size() > 0) attrs = new REXPList(attl); // FIXME: in general, we could allow arbitrary convertors here ... // Note that the jobj hack is only needed because we don't support EXTPTRSXP conversion // (for a good reason - we can't separate the PTR from the R object so the only way it can // live is as a reference and we don't want resolvePointer to ever return REXPReference as // that could trigger infinite recursions), but if we did, we could allow post-processing // based on the class attribute on the converted REXP.. (better, we can leverage REXPUnknown // and pass the ptr to the convertor so it can pull things like EXTPTR via rni) if (jobj != 0 && oclass != null && (oclass.equals("jobjRef") || oclass.equals("jarrayRef") || oclass.equals("jrectRef"))) return new REXPJavaReference(rni.rniXrefToJava(jobj), attrs); } switch (xt) { case NILSXP: return nullValue; case STRSXP: String[] s = rni.rniGetStringArray(ptr); res = new REXPString(s, attrs); break; case INTSXP: if (rni.rniInherits(ptr, "factor")) { long levx = rni.rniGetAttr(ptr, "levels"); if (levx != 0) { String[] levels = null; // we're using low-level calls here (FIXME?) int rlt = rni.rniExpType(levx); if (rlt == STRSXP) { levels = rni.rniGetStringArray(levx); int[] ids = rni.rniGetIntArray(ptr); res = new REXPFactor(ids, levels, attrs); } } } // if it's not a factor, then we use int[] instead if (res == null) res = new REXPInteger(rni.rniGetIntArray(ptr), attrs); break; case REALSXP: res = new REXPDouble(rni.rniGetDoubleArray(ptr), attrs); break; case LGLSXP: { int ba[] = rni.rniGetBoolArrayI(ptr); byte b[] = new byte[ba.length]; for (int i = 0; i < ba.length; i++) b[i] = (ba[i] == 0 || ba[i] == 1) ? (byte) ba[i] : REXPLogical.NA; res = new REXPLogical(b, attrs); } break; case VECSXP: { long l[] = rni.rniGetVector(ptr); REXP rl[] = new REXP[l.length]; long na = rni.rniGetAttr(ptr, "names"); String[] names = null; if (na != 0 && rni.rniExpType(na) == STRSXP) names = rni.rniGetStringArray(na); for (int i = 0; i < l.length; i++) rl[i] = resolvePointer(l[i]); RList list = (names == null) ? new RList(rl) : new RList(rl, names); res = new REXPGenericVector(list, attrs); } break; case RAWSXP: res = new REXPRaw(rni.rniGetRawArray(ptr), attrs); break; case LISTSXP: case LANGSXP: { RList l = new RList(); // we need to plow through the list iteratively - the recursion occurs at the value level long cdr = ptr; while (cdr != 0 && cdr != R_NilValue) { long car = rni.rniCAR(cdr); long tag = rni.rniTAG(cdr); String name = null; if (rni.rniExpType(tag) == SYMSXP) name = rni.rniGetSymbolName(tag); REXP val = resolvePointer(car); if (name == null) l.add(val); else l.put(name, val); cdr = rni.rniCDR(cdr); } res = (xt == LANGSXP) ? new REXPLanguage(l, attrs) : new REXPList(l, attrs); } break; case SYMSXP: res = new REXPSymbol(rni.rniGetSymbolName(ptr)); break; case ENVSXP: if (ptr != 0) rni.rniPreserve(ptr); res = new REXPEnvironment(this, new JRIPointer(ptr, false)); break; case S4SXP: res = new REXPS4(attrs); break; default: res = new REXPUnknown(xt, attrs); break; } } finally { if (obtainedLock) rniMutex.unlock(); } return res; } public REXP createReference(REXP value) throws REngineException, REXPMismatchException { if (value == null) throw(new REngineException(this, "createReference from a NULL value")); if (value.isReference()) return value; long ptr = createReferencePointer(value); if (ptr == 0) return null; boolean obtainedLock = rniMutex.safeLock(); try { rni.rniPreserve(ptr); } finally { if (obtainedLock) rniMutex.unlock(); } return new REXPReference(this, new Long(ptr)); } /** * Create an R object, returning its pointer, from an REXP java object. * * @param value * @return long R pointer * @throws REngineException if any of the RNI calls fails * @throws REXPMismatchException only if some internal inconsistency happens. The internal logic should prevent invalid access to valid objects. */ long createReferencePointer(REXP value) throws REngineException, REXPMismatchException { if (value.isReference()) { // if it's reference, return the handle if it's from this engine REXPReference vref = (REXPReference) value; if (vref.getEngine() != this) throw new REXPMismatchException(value, "reference (cross-engine reference is invalid)"); return ((Long)vref.getHandle()).longValue(); } boolean obtainedLock = rniMutex.safeLock(); int upp = 0; try { long ptr = 0; if (value.isNull()) // NULL cannot have attributes, hence get out right away return R_NilValue; else if (value.isLogical()) { int v[] = value.asIntegers(); for (int i = 0; i < v.length; i++) v[i] = (v[i] < 0) ? 2 : ((v[i] == 0) ? 0 : 1); // convert to logical NAs as used by R ptr = rni.rniPutBoolArrayI(v); } else if (value.isInteger()) ptr = rni.rniPutIntArray(value.asIntegers()); else if (value.isRaw()) ptr = rni.rniPutRawArray(value.asBytes()); else if (value.isNumeric()) ptr = rni.rniPutDoubleArray(value.asDoubles()); else if (value.isString()) ptr = rni.rniPutStringArray(value.asStrings()); else if (value.isEnvironment()) { JRIPointer l = (JRIPointer) ((REXPEnvironment)value).getHandle(); if (l == null) { // no associated reference, create a new environemnt long p = rni.rniParse("new.env(parent=baseenv())", 1); ptr = rni.rniEval(p, 0); /* TODO: should we handle REngineEvalException.ERROR and REngineEvalException.INVALID_INPUT here, for completeness */ } else ptr = l.pointer(); } else if (value.isPairList()) { // LISTSXP / LANGSXP boolean lang = value.isLanguage(); RList rl = value.asList(); ptr = R_NilValue; int j = rl.size(); if (j == 0) ptr = rni.rniCons(R_NilValue, 0, 0, lang); else // we are in a somewhat unfortunate situation because we cannot append to the list (RNI has no rniSetCDR!) so we have to use Preserve and bulild the list backwards which may be a bit slower ... for (int i = j - 1; i >= 0; i--) { REXP v = rl.at(i); String n = rl.keyAt(i); long sn = 0; if (n != null) sn = rni.rniInstallSymbol(n); long vptr = createReferencePointer(v); if (vptr == 0) vptr = R_NilValue; long ent = rni.rniCons(vptr, ptr, sn, (i == 0) && lang); /* only the head should be LANGSXP I think - verify ... */ rni.rniPreserve(ent); // preserve current head rni.rniRelease(ptr); // release previous head (since it's part of the new one already) ptr = ent; } } else if (value.isList()) { // VECSXP int init_upp = upp; RList rl = value.asList(); long xl[] = new long[rl.size()]; for (int i = 0; i < xl.length; i++) { REXP rv = rl.at(i); if (rv == null || rv.isNull()) xl[i] = R_NilValue; else { long lv = createReferencePointer(rv); if (lv != 0 && lv != R_NilValue) { rni.rniProtect(lv); upp++; } else lv = R_NilValue; xl[i] = lv; } } ptr = rni.rniPutVector(xl); if (init_upp > upp) { rni.rniUnprotect(upp - init_upp); upp = init_upp; } } else if (value.isSymbol()) return rni.rniInstallSymbol(value.asString()); // symbols need no attribute handling, hence get out right away else if (value instanceof REXPJavaReference) { // we wrap Java references by calling new("jobjRef", ...) Object jval = ((REXPJavaReference)value).getObject(); long jobj = rni.rniJavaToXref(jval); rni.rniProtect(jobj); long jobj_sym = rni.rniInstallSymbol("jobj"); long jclass_sym = rni.rniInstallSymbol("jclass"); String clname = "java/lang/Object"; if (jval != null) { clname = jval.getClass().getName(); clname = clname.replace('.', '/'); } long jclass = rni.rniPutString(clname); rni.rniProtect(jclass); long jobjRef = rni.rniPutString("jobjRef"); rni.rniProtect(jobjRef); long ro = rni.rniEval(rni.rniLCons(rni.rniInstallSymbol("new"), rni.rniCons(jobjRef, rni.rniCons(jobj, rni.rniCons(jclass, R_NilValue, jclass_sym, false), jobj_sym, false)) ), 0); rni.rniUnprotect(3); ptr = ro; } if (ptr == R_NilValue) return ptr; if (ptr != 0) { REXPList att = value._attr(); if (att == null || !att.isPairList()) return ptr; // no valid attributes? the we're done RList al = att.asList(); if (al == null || al.size() < 1 || !al.isNamed()) return ptr; // again - no valid list, get out rni.rniProtect(ptr); // symbols and other exotic creatures are already out by now, so it's ok to protect upp++; for (int i = 0; i < al.size(); i++) { REXP v = al.at(i); String n = al.keyAt(i); if (n != null) { long vptr = createReferencePointer(v); if (vptr != 0 && vptr != R_NilValue) rni.rniSetAttr(ptr, n, vptr); } } return ptr; } } finally { if (upp > 0) rni.rniUnprotect(upp); if (obtainedLock) rniMutex.unlock(); } // we fall thgough here if the object cannot be handled or something went wrong return 0; } public void finalizeReference(REXP ref) throws REngineException, REXPMismatchException { if (ref != null && ref.isReference()) { long ptr = ((Long)((REXPReference)ref).getHandle()).longValue(); boolean obtainedLock = rniMutex.safeLock(); try { rni.rniRelease(ptr); } finally { if (obtainedLock) rniMutex.unlock(); } } } public REXP getParentEnvironment(REXP env, boolean resolve) throws REngineException, REXPMismatchException { REXP ref = null; long rho = 0; if (env != null && !env.isReference()) { if (!env.isEnvironment() || ((REXPEnvironment)env).getHandle() == null) throw(new REXPMismatchException(env, "environment")); else rho = ((JRIPointer)((REXPEnvironment)env).getHandle()).pointer(); } else if (env != null) rho = ((Long)((REXPReference)env).getHandle()).longValue(); boolean obtainedLock = rniMutex.safeLock(); try { long pr = rni.rniParentEnv(rho); if (pr == 0 || pr == R_NilValue) return null; // this should never happen, really rni.rniPreserve(pr); ref = new REXPReference(this, new Long(pr)); if (resolve) ref = resolveReference(ref); } finally { if (obtainedLock) rniMutex.unlock(); } return ref; } public REXP newEnvironment(REXP parent, boolean resolve) throws REXPMismatchException, REngineException { REXP ref = null; boolean obtainedLock = rniMutex.safeLock(); try { long rho = 0; if (parent != null && !parent.isReference()) { if (!parent.isEnvironment() || ((REXPEnvironment)parent).getHandle() == null) throw(new REXPMismatchException(parent, "environment")); else rho = ((JRIPointer)((REXPEnvironment)parent).getHandle()).pointer(); } else if (parent != null) rho = ((Long)((REXPReference)parent).getHandle()).longValue(); if (rho == 0) rho = ((Long)((REXPReference)globalEnv).getHandle()).longValue(); long p = rni.rniEval(rni.rniLCons(rni.rniInstallSymbol("new.env"), rni.rniCons(rho, R_NilValue, rni.rniInstallSymbol("parent"), false)), 0); /* TODO: should we handle REngineEvalException.INVALID_INPUT and REngineEvalException.ERROR here, for completeness */ if (p != 0) rni.rniPreserve(p); ref = new REXPReference(this, new Long(p)); if (resolve) ref = resolveReference(ref); } finally { if (obtainedLock) rniMutex.unlock(); } return ref; } public boolean close() { if (rni == null) return false; rni.end(); return true; } /** attempts to obtain a lock for this R engine synchronously (without waiting for it). @return 0 if the lock could not be obtained (R is busy) and some other value otherwise (1 = lock obtained, 2 = the current thread already holds a lock) -- the returned value must be used in a matching call to {@link #unlock(int)}. */ public synchronized int tryLock() { int res = rniMutex.tryLock(); return (res == 1) ? 0 : ((res == -1) ? 2 : 1); } /** obains a lock for this R engine, waiting until it becomes available. @return value that must be passed to {@link #unlock} in order to release the lock */ public synchronized int lock() { return rniMutex.safeLock() ? 1 : 2; } /** releases a lock previously obtained by {@link #lock()} or {@link #tryLock()}. @param lockValue value returned by {@link #lock()} or {@link #tryLock()}. */ public synchronized void unlock(int lockValue) { if (lockValue == 1) rniMutex.unlock(); } public boolean supportsReferences() { return true; } public boolean supportsEnvironments() { return true; } // public boolean supportsREPL() { return true; } public boolean supportsLocking() { return true; } /** * creates a jobjRef reference in R via rJava.
Important: rJava must be loaded and intialized in R (e.g. via eval("{library(rJava);.jinit()}",false), otherwise this will fail. Requires rJava 0.4-13 or higher! * * @param o object to push to R * * @return unresolved REXPReference of the newly created jobjRef object * or null upon failure */ public REXPReference createRJavaRef(Object o) throws REngineException { /* precaution */ if( o == null ){ return null ; } /* call Rengine api and make REXPReference from the result */ REXPReference ref = null ; boolean obtainedLock = rniMutex.safeLock(); try { org.rosuda.JRI.REXP rx = rni.createRJavaRef( o ); if( rx == null){ throw new REngineException( this, "Could not push java Object to R" ) ; } else{ long p = rx.xp; rni.rniPreserve(p) ; ref = new REXPReference( this, new Long(p) ) ; } } finally { if (obtainedLock) rniMutex.unlock(); } return ref ; } /** JRI callbacks forwarding */ public void rWriteConsole (Rengine re, String text, int oType) { if (callbacks != null && callbacks instanceof REngineOutputInterface) ((REngineOutputInterface)callbacks).RWriteConsole(this, text, oType); } public void rBusy (Rengine re, int which) { if (callbacks != null && callbacks instanceof REngineUIInterface) ((REngineUIInterface)callbacks).RBusyState(this, which); } public synchronized String rReadConsole (Rengine re, String prompt, int addToHistory) { if (callbacks != null && callbacks instanceof REngineInputInterface) return ((REngineInputInterface)callbacks).RReadConsole(this, prompt, addToHistory); try { wait(); } catch (Exception e) {} return ""; } public void rShowMessage (Rengine re, String message) { if (callbacks != null && callbacks instanceof REngineOutputInterface) ((REngineOutputInterface)callbacks).RShowMessage(this, message); } public String rChooseFile (Rengine re, int newFile) { if (callbacks != null && callbacks instanceof REngineUIInterface) return ((REngineUIInterface)callbacks).RChooseFile(this, (newFile == 0)); return null; } public void rFlushConsole (Rengine re) { if (callbacks != null && callbacks instanceof REngineOutputInterface) ((REngineOutputInterface)callbacks).RFlushConsole(this); } public void rSaveHistory (Rengine re, String filename) { if (callbacks != null && callbacks instanceof REngineConsoleHistoryInterface) ((REngineConsoleHistoryInterface)callbacks).RSaveHistory(this, filename); } public void rLoadHistory (Rengine re, String filename) { if (callbacks != null && callbacks instanceof REngineConsoleHistoryInterface) ((REngineConsoleHistoryInterface)callbacks).RLoadHistory(this, filename); } } Rserve/src/client/java/JRI/test/0000755000176000001440000000000012205226215016136 5ustar ripleyusersRserve/src/client/java/JRI/test/Makefile0000644000176000001440000000122013442516164017602 0ustar ripleyusers## NOTE: the tests require rJava to be installed in the current R ## since they also test the JRI/rJava connectivity CP=../../REngine.jar:../JRIEngine.jar:$(RJAVA)/java/boot:$(RJAVA)/jri/JRI.jar JFLAGS=-source 1.4 -target 1.4 RJAVA=$(shell echo "cat(system.file(package='rJava'))"|R --slave --no-save) JRI=$(shell if test -e ../../../JRI/src/JRI.jar; then echo ../../../JRI/src; else echo $(RJAVA)/jri; fi) JRT=-Djava.library.path=$(JRI):. JAVAC=javac JAVA=java all: run RTest.class: RTest.java $(JAVAC) $(JFLAGS) -classpath $(CP) $^ run: RTest.class R CMD $(JAVA) -cp $(CP):. $(JRT) RTest clean: rm -rf org *.class *~ .PHONY: run clean Rserve/src/client/java/JRI/test/RTest.java0000644000176000001440000004134412205226215020050 0ustar ripleyusersimport org.rosuda.REngine.*; class TestException extends Exception { public TestException(String msg) { super(msg); } } // This is the same test as in Rserve but it's using JRI instead public class RTest { public static void main(String[] args) { try { // the simple initialization is done using // REngine eng = REngine.engineForClass("org.rosuda.REngine.JRI.JRIEngine"); // but the one below allows us to see all output from R via REngineStdOutput() // However, it won't succeed if the engine doesn't support callbacks, so be prepared to fall back REngine eng = REngine.engineForClass("org.rosuda.REngine.JRI.JRIEngine", args, new REngineStdOutput(), false); if (args.length > 0 && args[0].equals("--debug")) { // --debug waits for so a debugger can be attached System.out.println("R Version: " + eng.parseAndEval("R.version.string").asString()); System.out.println("ok, connected, press to continue\n"); System.in.read(); } { System.out.println("* Test string and list retrieval"); RList l = eng.parseAndEval("{d=data.frame(\"huhu\",c(11:20)); lapply(d,as.character)}").asList(); int cols = l.size(); int rows = l.at(0).length(); String[][] s = new String[cols][]; for (int i=0; i { .env <- new.env(); .env$x <- 2 }" ); System.out.println( " env = eng.get(\".env\", null, false ) " ); System.out.print( " parseAndEval( \"x+1\", env, true)" ); if( !( x instanceof REXPDouble ) || x.asDouble() != 3.0 ) throw new TestException("eval within environment failed") ; System.out.println( " == 3.0 : ok" ); System.out.println("PASSED"); } /* SU: wrap() tests removed since they didn't even compile ... */ { System.out.println("* Test generation of exceptions"); /* parse exceptions */ String cmd = "rnorm(10))" ; // syntax error System.out.println(" eng.parse(\"rnorm(10))\", false ) -> REngineException( \"Parse Error\" ) " ) ; boolean ok = false; try{ eng.parse( cmd, false ) ; } catch( REngineException e){ ok = true ; } if( !ok ){ throw new TestException( "parse did not generate an exception on syntax error" ) ; } System.out.println(" eng.parseAndEval(\"rnorm(10))\" ) -> REngineException( \"Parse Error\" ) " ) ; ok = false; try{ eng.parseAndEval( cmd ) ; } catch( REngineException e){ ok = true ; } if( !ok ){ throw new TestException( "parseAndEval did not generate an exception on syntax error" ) ; } /* eval exceptions */ cmd = "rnorm(5); stop('error'); rnorm(2)" ; System.out.print(" " + cmd ) ; ok = false; try{ eng.parseAndEval( cmd ) ; } catch( REngineException e){ if( e instanceof REngineEvalException ){ ok = true ; } } if( !ok ){ throw new TestException( "error in R did not generate REngineEvalException" ) ; } System.out.println( " -> REngineEvalException : ok" ) ; System.out.println("PASSED"); } { System.out.println("* Test creation of references to java objects"); if (!((REXPLogical)eng.parseAndEval("require(rJava)")).isTRUE()[0]) { System.out.println(" - rJava is not available, skipping test\n"); } else if (!(eng instanceof org.rosuda.REngine.JRI.JRIEngine)) { System.out.println(" - the used engine is not JRIEngine, skipping test\n"); } else { /* try to use rJava before it is initialized */ System.out.print(" checking that rJava generate error if not yet loaded" ) ; boolean error = false; try{ eng.parseAndEval( "p <- .jnew( 'java/awt/Point' ) " ) ; } catch( REngineException e){ error = true ; } if( !error ){ throw new TestException( "rJava not initiliazed, but did not generate error" ) ; } System.out.println( " : ok" ) ; eng.parseAndEval(".jinit()"); REXPReference ref = ((org.rosuda.REngine.JRI.JRIEngine)eng).createRJavaRef( null ); if( ref != null ){ throw new TestException( "null object should create null REXPReference" ) ; } System.out.println(" eng.createRJavaRef(null) -> null : ok" ) ; System.out.println( " pushing a java.awt.Point to R " ) ; java.awt.Point p = new java.awt.Point( 10, 10) ; ref = ((org.rosuda.REngine.JRI.JRIEngine)eng).createRJavaRef( p ); eng.assign( "p", ref ) ; String cmd = "exists('p') && inherits( p, 'jobjRef') && .jclass(p) == 'java.awt.Point' " ; System.out.println( " test if the object was pushed correctly " ) ; boolean ok = ((REXPLogical)eng.parseAndEval( cmd )).isTRUE()[0] ; if( !ok ){ throw new TestException( "could not push java object to R" ) ; } System.out.println( " R> " + cmd + " : ok " ) ; eng.parseAndEval( ".jcall( p, 'V', 'move', 20L, 20L )" ) ; System.out.println(" manipulate the object " ) ; if( p.x != 20 || p.y != 20 ){ throw new TestException( "not modified the java object with R" ) ; } System.out.println(" R> .jcall( p, 'V', 'move', 20L, 20L ) -> p.x == 20 ,p.y == 20 : ok " ) ; /* bug #126, use of .jfield with guess of the return class using reflection */ System.out.print(" using .jfield with reflection (bug #126)" ) ; eng.parseAndEval( ".jfield( p, , 'x')" ) ; /* used to crash the jvm; (not really - the code in the bgu just forgot to init rJava) */ System.out.println(" : ok " ) ; System.out.println("PASSED"); } } /* setEncoding is Rserve's extension - with JRI you have to use UTF-8 locale so this test will fail unless run in UTF-8 { // string encoding test (will work with Rserve 0.5-3 and higher only) System.out.println("* Test string encoding support ..."); String t = "ひらがな"; // hiragana (literally, in hiragana ;)) eng.setStringEncoding("utf8"); // -- Just in case the console is not UTF-8 don't display it //System.out.println(" unicode text: "+t); eng.assign("s", t); REXP x = eng.parseAndEval("nchar(s)"); System.out.println(" nchar = " + x); if (x == null || !x.isInteger() || x.asInteger() != 4) throw new TestException("UTF-8 encoding string length test failed"); // we cannot really test any other encoding .. System.out.println("PASSED"); } */ eng.close(); // close the engine connection System.out.println("Done."); } catch (REXPMismatchException me) { // some type is different from what you (the programmer) expected System.err.println("Type mismatch: "+me); me.printStackTrace(); System.exit(1); } catch (REngineException ee) { // something went wring in the engine System.err.println("REngine exception: "+ee); ee.printStackTrace(); System.exit(1); } catch (ClassNotFoundException cnfe) { // class not found is thrown by engineForClass System.err.println("Cannot find JRIEngine class - please fix your class path!\n"+cnfe); System.exit(1); } catch (Exception e) { // some other exception ... System.err.println("Exception: "+e); e.printStackTrace(); System.exit(1); } } } Rserve/src/client/java/JRI/package-info.java0000644000176000001440000000035012205226215020344 0ustar ripleyusers/** * REngine-based interface to JRI * *

* Currently it uses low-level calls from org.rosuda.JRI.Rengine, but * all REXP representations are created based on the org.rosuda.REngine API */ package org.rosuda.REngine.JRI ; Rserve/src/client/java/REngineEvalException.java0000644000176000001440000000235012205226215021414 0ustar ripleyuserspackage org.rosuda.REngine ; /** * Exception thrown when an error occurs during eval. * *

* This class is a placeholder and should be extended when more information * can be extracted from R (call stack, etc ... ) *

*/ public class REngineEvalException extends REngineException { /** * Value returned by the rniEval native method when the input passed to eval * is invalid */ public static final int INVALID_INPUT = -1 ; /** * Value returned by the rniEval native method when an error occured during * eval (stop, ...) */ public static final int ERROR = -2 ; /** * Type of eval error */ protected int type ; /** * Constructor * * @param eng associated REngine * @param message error message * @param type type of error (ERROR or INVALID_INPUT) */ public REngineEvalException( REngine eng, String message, int type ){ super( eng, message ); this.type = type ; } /** * Constructor using ERROR type * * @param eng associated REngine * @param message error message */ public REngineEvalException( REngine eng, String message){ this( eng, message, ERROR ); } /** * @return the type of error (ERROR or INVALID_INPUT) */ public int getType(){ return type ; } } Rserve/src/client/java/REngineConsoleHistoryInterface.java0000644000176000001440000000117212205226215023454 0ustar ripleyuserspackage org.rosuda.REngine; /** interface defining delegate methods used by {@link REngine} to forward console history callbacks from R. */ public interface REngineConsoleHistoryInterface { /** called when R wants to save the history content. * @param eng calling engine * @param filename name of the file to save command history to */ public void RSaveHistory (REngine eng, String filename); /** called when R wants to load the history content. * @param eng calling engine * @param filename name of the file to load the command history from */ public void RLoadHistory (REngine eng, String filename); } Rserve/src/client/java/REngine.java0000644000176000001440000003023612205226215016731 0ustar ripleyuserspackage org.rosuda.REngine; import java.lang.reflect.Method; /** REngine is an abstract base class for all implementations of R engines. Subclasses can implement interfaces to R in many different ways. Clients should always use methods this class instead of its direct subclasses in order to maintian compatibility with any R engine implementation. The canonical way of obtaining a new engine is to call {@link #engineForClass}. All subclasses must implement createEngine() method. */ public abstract class REngine { /** last created engine or null if there is none */ protected static REngine lastEngine = null; /** this is the designated constructor for REngine classes. It uses reflection to call createEngine method on the given REngine class. @param klass fully qualified class-name of a REngine implementation @return REngine implementation or null if createEngine invokation failed */ public static REngine engineForClass(String klass) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, java.lang.reflect.InvocationTargetException { Class cl=Class.forName(klass); if (cl==null) throw(new ClassNotFoundException("can't find engine class "+klass)); Method m=cl.getMethod("createEngine",(Class[])null); Object o=m.invoke(null,(Object[])null); return lastEngine=(REngine)o; } /** This is the extended constructor for REngine classes. It uses reflection to call createEngine method on the given REngine class with some additional control over the engine. Note that not all engines may support the extended version. @param klass fully qualified class-name of a REngine implementation @param args arguments to pass to R for initialization @param callbacks delegate for REngine callbacks or null if callbacks won't be serviced (engine may not support callbacks) @param runREPL if true then REPL will be started (if supported by the engine) @return REngine implementation or null if createEngine invokation failed */ public static REngine engineForClass(String klass, String[] args, REngineCallbacks callbacks, boolean runREPL) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, java.lang.reflect.InvocationTargetException { Class cl = Class.forName(klass); if (cl == null) throw new ClassNotFoundException("can't find engine class " + klass); Method m = cl.getMethod("createEngine", new Class[] { String[].class, REngineCallbacks.class, Boolean.TYPE }); Object o = m.invoke(null, new Object[] { args, callbacks, new Boolean(runREPL) }); return lastEngine = (REngine)o; } /** retrieve the last created engine @return last created engine or null if no engine was created yet */ public static REngine getLastEngine() { return lastEngine; } /** parse a string into an expression vector @param text string to parse @param resolve resolve the resulting REXP (true) or just return a reference (false) @return parsed expression */ public abstract REXP parse(String text, boolean resolve) throws REngineException; /** evaluate an expression vector @param what an expression (or vector of such) to evaluate @param where environment to evaluate in (use null for the global environemnt and/or if environments are not supported by the engine) @param resolve resolve the resulting REXP or just return a reference @return the result of the evaluation of the last expression */ public abstract REXP eval(REXP what, REXP where, boolean resolve) throws REngineException, REXPMismatchException; /** assign into an environment @param symbol symbol name @param value value to assign @param env environment to assign to (use null for the global environemnt and/or if environments are not supported by the engine) */ public abstract void assign(String symbol, REXP value, REXP env) throws REngineException, REXPMismatchException; /** get a value from an environment @param symbol symbol name @param env environment (use null for the global environemnt and/or if environments are not supported by the engine) @param resolve resolve the resulting REXP or just return a reference @return value */ public abstract REXP get(String symbol, REXP env, boolean resolve) throws REngineException, REXPMismatchException; /** fetch the contents of the given reference. The resulting REXP may never be REXPReference. The engine should raise a {@link #REngineException} exception if {@link #supportsReferences()} returns false. @param ref reference to resolve @return resolved reference */ public abstract REXP resolveReference(REXP ref) throws REngineException, REXPMismatchException; /** create a reference by pushing local data to R and returning a reference to the data. If ref is a reference it is returned as-is. The engine should raise a {@link #REngineException} exception if {@link #supportsReferences()} returns false. @param value to create reference to @return reference to the value */ public abstract REXP createReference(REXP value) throws REngineException, REXPMismatchException; /** removes reference from the R side. This method is called automatically by the finalizer of REXPReference and should never be called directly. @param ref reference to finalize */ public abstract void finalizeReference(REXP ref) throws REngineException, REXPMismatchException; /** get the parent environemnt of an environemnt @param env environment to query @param resolve whether to resolve the resulting environment reference @return parent environemnt of env */ public abstract REXP getParentEnvironment(REXP env, boolean resolve) throws REngineException, REXPMismatchException; /** create a new environemnt @param parent parent environment @param resolve whether to resolve the reference to the environemnt (usually false since the returned environment will be empty) @return resulting environment */ public abstract REXP newEnvironment(REXP parent, boolean resolve) throws REngineException, REXPMismatchException; /** convenince method equivalent to eval(parse(text, false), where, resolve); @param text to parse (see {@link #parse}) @param where environment to evaluate in (see {@link #eval}) @param resolve whether to resolve the resulting reference or not (see {@link #eval}) @return result */ public REXP parseAndEval(String text, REXP where, boolean resolve) throws REngineException, REXPMismatchException { REXP p = parse(text, false); return eval(p, where, resolve); } /** convenince method equivalent to eval(parse(cmd, false), null, true); @param cmd expression to parse (see {@link #parse}) @return result */ public REXP parseAndEval(String cmd) throws REngineException, REXPMismatchException { return parseAndEval(cmd, null, true); }; /** performs a close operation on engines that support it. The engine may not be used after close() returned true. This operation is optional and will always return false if not implemented. @return true if the close opetaion was successful, false otherwise. */ public boolean close() { return false; } //--- capabilities --- /** check whether this engine supports references to R objects @return true if this engine supports references, false/code> otherwise */ public boolean supportsReferences() { return false; } /** check whether this engine supports handing of environments (if not, {@link #eval} and {@link #assign} only support the global environment denoted by null). @return true if this engine supports environments, false/code> otherwise */ public boolean supportsEnvironments() { return false; } /** check whether this engine supports REPL (Read-Evaluate-Print-Loop) and corresponding callbacks. @return true if this engine supports REPL, false/code> otherwise */ public boolean supportsREPL() { return false; } /** check whether this engine supports locking ({@link #lock}, {@link #tryLock} and {@link #unlock}). @return true if this engine supports REPL, false/code> otherwise */ public boolean supportsLocking() { return false; } //--- convenience methods --- (the REXPMismatchException catches should be no-ops since the value type is guaranteed in the call to assign) /** convenience method equivalent to assign(symbol, new REXPDouble(d), null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d values to assign */ public void assign(String symbol, double[] d) throws REngineException { try { assign(symbol, new REXPDouble(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,double[]): "+e)); } } /** convenience method equivalent to assign(symbol, new REXPInteger(d), null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d values to assign */ public void assign(String symbol, int[] d) throws REngineException { try { assign(symbol, new REXPInteger(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,int[]): "+e)); } } /** convenience method equivalent to assign(symbol, new REXPString(d), null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d values to assign */ public void assign(String symbol, String[] d) throws REngineException { try { assign(symbol, new REXPString(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,String[]): "+e)); } } /** convenience method equivalent to assign(symbol, new REXPRaw(d), null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d values to assign */ public void assign(String symbol, byte[] d) throws REngineException { try { assign(symbol, new REXPRaw(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,byte[]): "+e)); } } /** convenience method equivalent to assign(symbol, new REXPString(d), null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d value to assign */ public void assign(String symbol, String d) throws REngineException { try { assign(symbol, new REXPString(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,String[]): "+e)); } } /** convenience method equivalent to assign(symbol, value, null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param value values to assign */ public void assign(String symbol, REXP value) throws REngineException, REXPMismatchException { assign(symbol, value, null); } //--- locking API --- /** attempts to obtain a lock for this R engine synchronously (without waiting for it).
Note: check for {@link #supportsLocking()} before relying on this capability. If not implemented, always returns 0. @return 0 if the lock could not be obtained (R engine is busy) and some other value otherwise -- the returned value must be used in a matching call to {@link #unlock(int)}. */ public synchronized int tryLock() { return 0; } /** obtains a lock for this R engine, waiting until it becomes available.
Note: check for {@link #supportsLocking()} before relying on this capability. If not implemented, always returns 0. @return value that must be passed to {@link #unlock} in order to release the lock */ public synchronized int lock() { return 0; } /** releases a lock previously obtained by {@link #lock()} or {@link #tryLock()}.
Note: check for {@link #supportsLocking()} before relying on this capability. If not implemented, has no effect. @param lockValue value returned by {@link #lock()} or {@link #tryLock()}. */ public synchronized void unlock(int lockValue) {} public String toString() { return super.toString()+((lastEngine==this)?"{last}":""); } public REXP wrap(Object o){ return REXPWrapper.wrap(o); } } Rserve/src/client/java/REXP.java0000644000176000001440000003456412205226215016170 0ustar ripleyuserspackage org.rosuda.REngine; /** Basic class representing an object of any type in R. Each type in R in represented by a specific subclass.

This class defines basic accessor methods (asXXX), type check methods (isXXX), gives access to attributes ({@link #getAttribute}, {@link #hasAttribute}) as well as several convenience methods. If a given method is not applicable to a particular type, it will throw the {@link REXPMismatchException} exception.

This root class will throw on any accessor call and returns false for all type methods. This allows subclasses to override accessor and type methods selectively. */ public class REXP { /** attribute list. This attribute should never be accessed directly. */ protected REXPList attr; /** public root contrsuctor, same as new REXP(null) */ public REXP() { } /** public root constructor @param attr attribute list object (can be null */ public REXP(REXPList attr) { this.attr=attr; } // type checks /** check whether the REXP object is a character vector (string) @return true if the receiver is a character vector, false otherwise */ public boolean isString() { return false; } /** check whether the REXP object is a numeric vector @return true if the receiver is a numeric vector, false otherwise */ public boolean isNumeric() { return false; } /** check whether the REXP object is an integer vector @return true if the receiver is an integer vector, false otherwise */ public boolean isInteger() { return false; } /** check whether the REXP object is NULL @return true if the receiver is NULL, false otherwise */ public boolean isNull() { return false; } /** check whether the REXP object is a factor @return true if the receiver is a factor, false otherwise */ public boolean isFactor() { return false; } /** check whether the REXP object is a list (either generic vector or a pairlist - i.e. {@link #asList()} will succeed) @return true if the receiver is a generic vector or a pair-list, false otherwise */ public boolean isList() { return false; } /** check whether the REXP object is a pair-list @return true if the receiver is a pair-list, false otherwise */ public boolean isPairList() { return false; } /** check whether the REXP object is a logical vector @return true if the receiver is a logical vector, false otherwise */ public boolean isLogical() { return false; } /** check whether the REXP object is an environment @return true if the receiver is an environment, false otherwise */ public boolean isEnvironment() { return false; } /** check whether the REXP object is a language object @return true if the receiver is a language object, false otherwise */ public boolean isLanguage() { return false; } /** check whether the REXP object is an expression vector @return true if the receiver is an expression vector, false otherwise */ public boolean isExpression() { return false; } /** check whether the REXP object is a symbol @return true if the receiver is a symbol, false otherwise */ public boolean isSymbol() { return false; } /** check whether the REXP object is a vector @return true if the receiver is a vector, false otherwise */ public boolean isVector() { return false; } /** check whether the REXP object is a raw vector @return true if the receiver is a raw vector, false otherwise */ public boolean isRaw() { return false; } /** check whether the REXP object is a complex vector @return true if the receiver is a complex vector, false otherwise */ public boolean isComplex() { return false; } /** check whether the REXP object is a recursive obejct @return true if the receiver is a recursive object, false otherwise */ public boolean isRecursive() { return false; } /** check whether the REXP object is a reference to an R object @return true if the receiver is a reference, false otherwise */ public boolean isReference() { return false; } // basic accessor methods /** returns the contents as an array of Strings (if supported by the represented object) */ public String[] asStrings() throws REXPMismatchException { throw new REXPMismatchException(this, "String"); } /** returns the contents as an array of integers (if supported by the represented object) */ public int[] asIntegers() throws REXPMismatchException { throw new REXPMismatchException(this, "int"); } /** returns the contents as an array of doubles (if supported by the represented object) */ public double[] asDoubles() throws REXPMismatchException { throw new REXPMismatchException(this, "double"); } /** returns the contents as an array of bytes (if supported by the represented object) */ public byte[] asBytes() throws REXPMismatchException { throw new REXPMismatchException(this, "byte"); } /** returns the contents as a (named) list (if supported by the represented object) */ public RList asList() throws REXPMismatchException { throw new REXPMismatchException(this, "list"); } /** returns the contents as a factor (if supported by the represented object) */ public RFactor asFactor() throws REXPMismatchException { throw new REXPMismatchException(this, "factor"); } /** attempt to represent the REXP by a native Java object and return it. Note that this may lead to loss of information (e.g., factors may be returned as a string array) and attributes are ignored. Not all R types can be converted to native Java objects. Also note that R has no concept of scalars, so vectors of length 1 will always be returned as an arrays (i.e., int[1] and not Integer). */ public Object asNativeJavaObject() throws REXPMismatchException { throw new REXPMismatchException(this, "native Java Object"); } /** returns the length of a vector object. Note that we use R semantics here, i.e. a matrix will have a length of m * n since it is represented by a single vector (see {@link #dim} for retrieving matrix and multidimentional-array dimensions). * @return length (number of elements) in a vector object * @throws REXPMismatchException if this is not a vector object */ public int length() throws REXPMismatchException { throw new REXPMismatchException(this, "vector"); } /** returns a boolean vector of the same length as this vector with true for NA values and false for any other values * @return a boolean vector of the same length as this vector with true for NA values and false for any other values * @throws REXPMismatchException if this is not a vector object */ public boolean[] isNA() throws REXPMismatchException { throw new REXPMismatchException(this, "vector"); } // convenience accessor methods /** convenience method corresponding to asIntegers()[0] @return first entry returned by {@link #asInteger} */ public int asInteger() throws REXPMismatchException { int[] i = asIntegers(); return i[0]; } /** convenience method corresponding to asDoubles()[0] @return first entry returned by {@link #asDoubles} */ public double asDouble() throws REXPMismatchException { double[] d = asDoubles(); return d[0]; } /** convenience method corresponding to asStrings()[0] @return first entry returned by {@link #asStrings} */ public String asString() throws REXPMismatchException { String[] s = asStrings(); return s[0]; } // methods common to all REXPs /** retrieve an attribute of the given name from this object * @param name attribute name * @return attribute value or null if the attribute does not exist */ public REXP getAttribute(String name) { final REXPList a = _attr(); if (a==null || !a.isList()) return null; return a.asList().at(name); } /** checks whether this obejct has a given attribute * @param name attribute name * @return true if the attribute exists, false otherwise */ public boolean hasAttribute(String name) { final REXPList a = _attr(); return (a!=null && a.isList() && a.asList().at(name)!=null); } // helper methods common to all REXPs /** returns dimensions of the object (as determined by the "dim" attribute) * @return an array of integers with corresponding dimensions or null if the object has no dimension attribute */ public int[] dim() { try { return hasAttribute("dim")?_attr().asList().at("dim").asIntegers():null; } catch (REXPMismatchException me) { } return null; } /** determines whether this object inherits from a given class in the same fashion as the inherits() function in R does (i.e. ignoring S4 inheritance) * @param klass class name * @return true if this object is of the class klass, false otherwise */ public boolean inherits(String klass) { if (!hasAttribute("class")) return false; try { String c[] = getAttribute("class").asStrings(); if (c != null) { int i = 0; while (i < c.length) { if (c[i]!=null && c[i].equals(klass)) return true; i++; } } } catch (REXPMismatchException me) { } return false; } /** this method allows a limited access to object's attributes - {@link #getAttribute} should be used instead to access specific attributes!. Note that the {@link #attr} attribute should never be used directly incase the REXP implements a lazy access (e.g. via a reference) @return list of attributes or null if the object has no attributes */ public REXPList _attr() { return attr; } /** returns a string description of the object @return string describing the object - it can be of an arbitrary form and used only for debugging (do not confuse with {@link #asString()} for accessing string REXPs) */ public String toString() { return super.toString()+((attr!=null)?"+":""); } /** returns representation that it useful for debugging (e.g. it includes attributes and may include vector values -- see {@link #maxDebugItems}) @return extended description of the obejct -- it may include vector values */ public String toDebugString() { return (attr!=null)?(("<"+attr.toDebugString()+">")+super.toString()):super.toString(); } //======= complex convenience methods /** returns the content of the REXP as a matrix of doubles (2D-array: m[rows][cols]). This is the same form as used by popular math packages for Java, such as JAMA. This means that following leads to desired results:
Matrix m=new Matrix(c.eval("matrix(c(1,2,3,4,5,6),2,3)").asDoubleMatrix());
@return 2D array of doubles in the form double[rows][cols] or null if the contents is no 2-dimensional matrix of doubles */ public double[][] asDoubleMatrix() throws REXPMismatchException { double[] ct = asDoubles(); REXP dim = getAttribute("dim"); if (dim == null) throw new REXPMismatchException(this, "matrix (dim attribute missing)"); int[] ds = dim.asIntegers(); if (ds.length != 2) throw new REXPMismatchException(this, "matrix (wrong dimensionality)"); int m = ds[0], n = ds[1]; double[][] r = new double[m][n]; // R stores matrices as matrix(c(1,2,3,4),2,2) = col1:(1,2), col2:(3,4) // we need to copy everything, since we create 2d array from 1d array int k = 0; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) r[j][i] = ct[k++]; return r; } /** creates a REXP that represents a double matrix in R based on matrix of doubles (2D-array: m[rows][cols]). This is the same form as used by popular math packages for Java, such as JAMA. The result of this function can be used in {@link REngine.assign} to store a matrix in R. @param matrix array double[rows][colums] containing the matrix to convert into a REXP. If matrix is null or either of the dimensions is 0 then the resulting matrix will have the dimensions 0 x 0 (Note: Java cannot represent 0 x n matrices for n > 0, so special matrices with one dimension of 0 can only be created by setting dimensions directly). @return REXPDouble with "dim" attribute which constitutes a matrix in R */ public static REXP createDoubleMatrix(double[][] matrix) { int m = 0, n = 0; double a[]; if (matrix != null && matrix.length != 0 && matrix[0].length != 0) { m = matrix.length; n = matrix[0].length; a = new double[m * n]; int k = 0; for (int j = 0; j < n; j++) for (int i = 0; i < m; i++) a[k++] = matrix[i][j]; } else a = new double[0]; return new REXPDouble(a, new REXPList( new RList( new REXP[] { new REXPInteger(new int[] { m, n }) }, new String[] { "dim" }) ) ); } //======= tools /** creates a data frame object from a list object using integer row names * @param l a (named) list of vectors ({@link REXPVector} subclasses), each element corresponds to a column and all elements must have the same length * @return a data frame object * @throws REXPMismatchException if the list is empty or any of the elements is not a vector */ public static REXP createDataFrame(RList l) throws REXPMismatchException { if (l == null || l.size() < 1) throw new REXPMismatchException(new REXPList(l), "data frame (must have dim>0)"); if (!(l.at(0) instanceof REXPVector)) throw new REXPMismatchException(new REXPList(l), "data frame (contents must be vectors)"); REXPVector fe = (REXPVector) l.at(0); return new REXPGenericVector(l, new REXPList( new RList( new REXP[] { new REXPString("data.frame"), new REXPString(l.keys()), new REXPInteger(new int[] { REXPInteger.NA, -fe.length() }) }, new String[] { "class", "names", "row.names" }))); } /** specifies how many items of a vector or list will be displayed in {@link #toDebugString} */ public static int maxDebugItems = 32; } Rserve/src/client/java/REXPLogical.java0000644000176000001440000001251712205226215017455 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPLogical represents a vector of logical values (TRUE, FALSE or NA). Unlike Java's boolean type R's logicals support NA values therefore either of {@link #isTRUE()}, {@link #isFALSE()} or {@link #isNA()} must be used to convert logicals to boolean values. */ public class REXPLogical extends REXPVector { protected byte[] payload; /** NA integer value as defined in R. Unlike its real equivalent this one can be used in comparisons, although {@link #isNA(int) } is provided for consistency. */ static final int NA_internal = -2147483648; /** NA boolean value as used in REXPLogical implementation. This differs from the value used in R since R uses int data type and we use byte. Unlike its real equivalent this one can be used in comparisons, although {@link #isNA(byte) } is provided for consistency. */ public static final byte NA = -128; public static final byte TRUE = 1; public static final byte FALSE = 0; public static boolean isNA(byte value) { return (value == NA); } /** create logical vector of the length 1 with the given value as its first (and only) element */ public REXPLogical(boolean load) { super(); payload = new byte[] { load ? TRUE : FALSE }; } /** create logical vector of the length 1 with the given value as its first (and only) element */ public REXPLogical(byte load) { super(); payload = new byte[] { load }; } /** create logical vector with the payload specified by load */ public REXPLogical(byte[] load) { super(); payload = (load==null) ? new byte[0]:load; } /** create logical vector with the payload specified by load */ public REXPLogical(boolean[] load) { super(); payload = new byte[(load == null) ? 0 : load.length]; if (load != null) for (int i = 0; i < load.length; i++) payload[i] = load[i] ? TRUE : FALSE; } /** create integer vector with the payload specified by load and attributes attr */ public REXPLogical(byte[] load, REXPList attr) { super(attr); payload = (load==null) ? new byte[0] : load; } /** create integer vector with the payload specified by load and attributes attr */ public REXPLogical(boolean[] load, REXPList attr) { super(attr); payload = new byte[(load == null) ? 0 : load.length]; if (load != null) for (int i = 0; i < load.length; i++) payload[i] = load[i] ? TRUE : FALSE; } public int length() { return payload.length; } public boolean isLogical() { return true; } public Object asNativeJavaObject() { return payload; } public int[] asIntegers() { int p[] = new int[payload.length]; for (int i = 0; i < payload.length; i++) // map bytes to integers including NA representation p[i] = (payload[i] == NA) ? REXPInteger.NA : ((payload[i] == FALSE) ? 0 : 1); return p; } public byte[] asBytes() { return payload; } /** returns the contents of this vector as doubles */ public double[] asDoubles() { double[] d = new double[payload.length]; for (int i = 0; i < payload.length; i++) d[i] = (payload[i] == NA) ? REXPDouble.NA : ((payload[i] == FALSE) ? 0.0 : 1.0); return d; } /** returns the contents of this vector as strings */ public String[] asStrings() { String[] s = new String[payload.length]; for (int i = 0; i < payload.length; i++) s[i] = (payload[i] == NA) ? "NA" : ((payload[i] == FALSE) ? "FALSE" : "TRUE"); return s; } public boolean[] isNA() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = (payload[i] == NA); i++; } return a; } /** returns a boolean array of the same langth as the receiver with true for TRUE values and false for FALSE and NA values. @return boolean array */ public boolean[] isTRUE() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = (payload[i] != NA && payload[i] != FALSE); i++; } return a; } /** returns a boolean array of the same langth as the receiver with true for FALSE values and false for TRUE and NA values. @return boolean array */ public boolean[] isFALSE() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = (payload[i] == FALSE); i++; } return a; } /** returns a boolean array of the same langth as the receiver with true for TRUE values and false for FALSE and NA values. @return boolean array @deprecated replaced by {@link #isTRUE()} for consistency with R nomenclature. */ public boolean[] isTrue() { return isTRUE(); } /** returns a boolean array of the same langth as the receiver with true for FALSE values and false for TRUE and NA values. @return boolean array @deprecated replaced by {@link #isTRUE()} for consistency with R nomenclature. */ public boolean[] isFalse() { return isFALSE(); } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.length && i < maxDebugItems) { if (i>0) sb.append(","); sb.append((payload[i] == NA) ? "NA" : ((payload[i] == FALSE) ? "FALSE" : "TRUE")); i++; } if (i < payload.length) sb.append(",.."); return sb.toString()+"}"; } } Rserve/src/client/java/REngineOutputInterface.java0000644000176000001440000000143512205226215021772 0ustar ripleyuserspackage org.rosuda.REngine; /** interface defining delegate methods used by {@link REngine} to forward output callbacks from R. */ public interface REngineOutputInterface { /** called when R prints output to the console. * @param eng calling engine * @param text text to display in the console * @param oType output type (0=regular, 1=error/warning) */ public void RWriteConsole(REngine eng, String text, int oType); /** called when R wants to show a warning/error message box (not console-related). * @param eng calling engine * @param text text to display in the message */ public void RShowMessage(REngine eng, String text); /** called by R to flush (display) any pending console output. * @param eng calling engine */ public void RFlushConsole(REngine eng); } Rserve/src/client/java/REXPFactor.java0000644000176000001440000000455212205226215017321 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPFactor represents a factor in R. It is an integer vector with levels for each contained category. */ // FIXME: this is currently somehow screwed - the concept of RFactor and REXPFactor is duplicate - we need to remove this historical baggage public class REXPFactor extends REXPInteger { private String[] levels; private RFactor factor; /** create a new factor REXP * @param ids indices (one-based!) * @param levels levels */ public REXPFactor(int[] ids, String[] levels) { super(ids); this.levels = (levels==null)?(new String[0]):levels; factor = new RFactor(this.payload, this.levels, false, 1); attr = new REXPList( new RList( new REXP[] { new REXPString(this.levels), new REXPString("factor") }, new String[] { "levels", "class" })); } /** create a new factor REXP * @param ids indices (one-based!) * @param levels levels * @param attr attributes */ public REXPFactor(int[] ids, String[] levels, REXPList attr) { super(ids, attr); this.levels = (levels==null)?(new String[0]):levels; factor = new RFactor(this.payload, this.levels, false, 1); } /** create a new factor REXP from an existing RFactor * @param factor factor object (can be of any index base, the contents will be pulled with base 1) */ public REXPFactor(RFactor factor) { super(factor.asIntegers(1)); this.factor = factor; this.levels = factor.levels(); attr = new REXPList( new RList( new REXP[] { new REXPString(this.levels), new REXPString("factor") }, new String[] { "levels", "class" })); } /** create a new factor REXP from an existing RFactor * @param factor factor object (can be of any index base, the contents will be pulled with base 1) * @param attr attributes */ public REXPFactor(RFactor factor, REXPList attr) { super(factor.asIntegers(1), attr); this.factor = factor; this.levels = factor.levels(); } public boolean isFactor() { return true; } /** return the contents as a factor - the factor is guaranteed to have index base 1 * @return the contents as a factor */ public RFactor asFactor() { return factor; } public String[] asStrings() { return factor.asStrings(); } public Object asNativeJavaObject() { return asStrings(); } public String toString() { return super.toString()+"["+levels.length+"]"; } } Rserve/src/client/java/REXPSymbol.java0000644000176000001440000000134212205226215017342 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPSymbol represents a symbol in R. */ public class REXPSymbol extends REXP { /** name of the symbol */ private String name; /** create a new symbol of the given name */ public REXPSymbol(String name) { super(); this.name=(name==null)?"":name; } public boolean isSymbol() { return true; } /** returns the name of the symbol * @return name of the symbol */ public String asString() { return name; } public String[] asStrings() { return new String[] { name }; } public String toString() { return getClass().getName()+"["+name+"]"; } public String toDebugString() { return super.toDebugString()+"["+name+"]"; } public Object asNativeJavaObject() { return name; } } Rserve/src/client/java/REXPRaw.java0000644000176000001440000000151412205226215016627 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPRaw represents a raw vector in R - essentially a sequence of bytes. */ public class REXPRaw extends REXPVector { private byte[] payload; /** create a new raw vector with the specified payload * @param load payload of the raw vector */ public REXPRaw(byte[] load) { super(); payload=(load==null)?new byte[0]:load; } /** create a new raw vector with the specified payload and attributes * @param load payload of the raw vector * @param attr attributes for the resulting R object */ public REXPRaw(byte[] load, REXPList attr) { super(attr); payload=(load==null)?new byte[0]:load; } public int length() { return payload.length; } public boolean isRaw() { return true; } public byte[] asBytes() { return payload; } public Object asNativeJavaObject() { return payload; } } Rserve/src/client/java/REXPWrapper.java0000644000176000001440000001614412205226215017523 0ustar ripleyuserspackage org.rosuda.REngine ; /** * Utility class to wrap an Object into a REXP object. * * This facilitates wrapping native java objects and arrays * into REXP objects that can be pushed to R * * @author Romain Francois */ public class REXPWrapper { /* various classes */ private static Class byte_ARRAY ; private static Class short_ARRAY ; private static Class int_ARRAY ; private static Class long_ARRAY ; private static Class float_ARRAY ; private static Class double_ARRAY ; private static Class boolean_ARRAY ; private static Class String_ARRAY ; private static Class Byte_ARRAY ; private static Class Short_ARRAY; private static Class Integer_ARRAY ; private static Class Long_ARRAY ; private static Class Float_ARRAY ; private static Class Double_ARRAY ; private static Class Boolean_ARRAY ; static{ try{ byte_ARRAY = Class.forName("[B") ; short_ARRAY = Class.forName("[S" ); int_ARRAY = Class.forName("[I" ); long_ARRAY = (new long[1]).getClass() ; /* FIXME */ float_ARRAY = Class.forName("[F" ) ; double_ARRAY = Class.forName("[D" ); boolean_ARRAY = Class.forName("[Z" ) ; String_ARRAY = Class.forName( "[Ljava.lang.String;") ; Byte_ARRAY = Class.forName( "[Ljava.lang.Byte;" ) ; Short_ARRAY = Class.forName( "[Ljava.lang.Short;" ) ; Integer_ARRAY = Class.forName( "[Ljava.lang.Integer;" ) ; Long_ARRAY = Class.forName( "[Ljava.lang.Long;" ) ; Float_ARRAY = Class.forName( "[Ljava.lang.Float;" ) ; Double_ARRAY = Class.forName( "[Ljava.lang.Double;" ) ; Boolean_ARRAY = Class.forName( "[Ljava.lang.Boolean;" ) ; } catch( Exception e){ // should never happen e.printStackTrace(); System.err.println( "problem while initiating the classes" ) ; } } /** * Wraps an Object into a REXP * *

Conversion :

* *
    *
  • Byte (byte) : REXPRaw
  • *
  • Short (short) : REXPInteger
  • *
  • Integer (int) : REXPInteger
  • *
  • Long (long) : REXPInteger
  • *
  • Float (float) : REXPDouble
  • *
  • Double (double) : REXPDouble
  • *
  • Boolean (boolean) : REXPLogical
  • *
  • --
  • *
  • String : REXPString
  • *
  • String[] : REXPString
  • *
  • --
  • *
  • byte[] or Byte[] : REXPRaw
  • *
  • short[] or Short[] : REXPInteger
  • *
  • int[] or Integer[] : REXPInteger
  • *
  • long[] or Long[] : REXPInteger
  • *
  • float[] or Float[] : REXPDouble
  • *
  • double[] or Double[] : REXPDouble
  • *
  • boolean[] or Boolean[]: REXPLogical
  • *
  • --
  • *
  • null for anything else
  • *
* * @param o object to wrap * @return REXP object that represents o or null if the conversion is not possible */ public static REXP wrap( Object o ) { /* nothing to do in that case */ if( o instanceof REXP){ return (REXP)o; } Class clazz = o.getClass() ; /* primitives */ if( clazz == Byte.class ){ byte[] load = new byte[1]; load[0] = ((Byte)o).byteValue() ; return new REXPRaw( load ); } if( clazz == Short.class ){ return new REXPInteger( ((Short)o).intValue() ) ; } if( clazz == Integer.class ){ return new REXPInteger( ((Integer)o).intValue() ) ; } if( clazz == Long.class ){ return new REXPInteger( ((Long)o).intValue() ) ; } if( clazz == Float.class ){ return new REXPDouble( ((Float)o).doubleValue() ) ; } if( clazz == Double.class ){ return new REXPDouble( ((Double)o).doubleValue() ) ; } if( clazz == Boolean.class ){ return new REXPLogical( ((Boolean)o).booleanValue() ) ; } /* Strings -> REXPString */ if( clazz == String.class ){ return new REXPString( (String)o ) ; } if( clazz == String_ARRAY ){ /* String[] */ return new REXPString( (String[])o ); } /* array of byte or Bytes -> REXPRaw */ if( clazz == byte_ARRAY ){ /* byte[] */ return new REXPRaw( (byte[])o ) ; } if( clazz == Byte_ARRAY ){ /* Byte[] */ Byte[] b = (Byte[])o; int n = b.length ; byte[] bytes = new byte[b.length]; for( int i=0; i REXPInteger */ if( clazz == short_ARRAY ){ /* short[] */ short[] shorts = (short[])o ; int[] ints = new int[ shorts.length ]; int n = ints.length; for( int i=0; i REXPInteger */ if( clazz == int_ARRAY ){ /* int[] */ return new REXPInteger( (int[])o ) ; } if( clazz == Integer_ARRAY ){ /* Integer[] */ Integer[] integers = (Integer[])o; int n = integers.length ; int[] ints = new int[integers.length]; for( int i=0; i REXPInteger */ if( clazz == long_ARRAY ){ /* long[] */ long[] longs = (long[])o; int n = longs.length ; int[] ints = new int[longs.length]; for( int i=0; i REXPDouble */ if( clazz == float_ARRAY ){ /* float[] */ float[] floats = (float[])o; int n = floats.length ; double[] doubles = new double[floats.length]; for( int i=0; i REXPDouble */ if(clazz == double_ARRAY ) { /* double[] */ return new REXPDouble( (double[])o ) ; } if( clazz == Double_ARRAY ){ /* Double[] */ Double[] doubles = (Double[])o; double n = doubles.length ; double[] d = new double[doubles.length]; for( int i=0; i REXPLogical */ if( clazz == boolean_ARRAY ){ /* boolean[] */ return new REXPLogical( (boolean[])o ) ; } if( clazz == Boolean_ARRAY ){ /* Boolean[] */ Boolean[] booleans = (Boolean[])o; int n = booleans.length ; boolean[] b = new boolean[booleans.length]; for( int i=0; ifalse
returns a reference to the object, if false the reference is resolved * @return value corresponding to the symbol name or possibly null if the value is unbound (the latter is currently engine-specific) */ public REXP get(String name, boolean resolve) throws REngineException { try { return eng.get(name, this, resolve); } catch (REXPMismatchException e) { // this should never happen because this is always guaranteed to be REXPEnv throw(new REngineException(eng, "REXPMismatchException:"+e+" in get()")); } } /** get a value from this environment - equavalent to get(name, true). * @param name name of the value * @return value (see {@link #get(String,boolean)}) */ public REXP get(String name) throws REngineException { return get(name, true); } /** assigns a value to a given symbol name * @param name symbol name * @param value value */ public void assign(String name, REXP value) throws REngineException, REXPMismatchException { eng.assign(name, value, this); } /** returns the parent environment or a reference to it * @param resolve if true returns the environemnt, otherwise a reference. * @return parent environemnt (or a reference to it) */ public REXP parent(boolean resolve) throws REngineException { try { return eng.getParentEnvironment(this, resolve); } catch (REXPMismatchException e) { // this should never happen because this is always guaranteed to be REXPEnv throw(new REngineException(eng, "REXPMismatchException:"+e+" in parent()")); } } /** returns the parent environment. This is equivalent to parent(true). * @return parent environemnt */ public REXPEnvironment parent() throws REngineException { return (REXPEnvironment) parent(true); } } Rserve/src/client/java/REXPNull.java0000644000176000001440000000174012205226215017011 0ustar ripleyuserspackage org.rosuda.REngine; /** represents a NULL object in R.

Note: there is a slight asymmetry - in R NULL is represented by a zero-length pairlist. For this reason REXPNull returns true for {@link #isList()} and {@link #asList()} will return an empty list. Nonetheless REXPList of the length 0 will NOT return true in {@link #isNull()} (currently), becasue it is considered a different object in Java. These nuances are still subject to change, because it's not clear how it should be treated. At any rate use REXPNull instead of empty REXPList if NULL is the intended value. */ public class REXPNull extends REXP { public REXPNull() { super(); } public REXPNull(REXPList attr) { super(attr); } public boolean isNull() { return true; } public boolean isList() { return true; } // NULL is a list public RList asList() { return new RList(); } public Object asNativeJavaObject() { return null; } } Rserve/src/client/java/REXPReference.java0000644000176000001440000000727712205226215020010 0ustar ripleyuserspackage org.rosuda.REngine; /** this class represents a reference (proxy) to an R object.

The reference semantics works by calling {@link #resolve()} (which in turn uses {@link REngine#resolveReference(REXP)} on itself) whenever any methods are accessed. The implementation is not finalized yat and may change as we approach the JRI interface which is more ameanable to reference-style access. Subclasses are free to implement more efficient implementations. */ public class REXPReference extends REXP { /** engine which will be used to resolve the reference */ protected REngine eng; /** an opaque (optional) handle */ protected Object handle; /** resolved (cached) object */ protected REXP resolvedValue; /** create an external REXP reference using given engine and handle. The handle value is just an (optional) identifier not used by the implementation directly. */ public REXPReference(REngine eng, Object handle) { super(); this.eng = eng; this.handle = handle; } /** shortcut for REXPReference(eng, new Long(handle)) that is used by native code */ REXPReference(REngine eng, long handle) { this(eng, new Long(handle)); } /** resolve the external REXP reference into an actual REXP object. In addition, the value (if not null) will be cached for subsequent calls to resolve until invalidate is called. */ public REXP resolve() { if (resolvedValue != null) return resolvedValue; try { resolvedValue = eng.resolveReference(this); return resolvedValue; } catch (REXPMismatchException me) { // this should never happen since we are REXPReference } catch(REngineException ee) { // FIXME: what to we do? } return null; } /** invalidates any cached representation of the reference */ public void invalidate() { resolvedValue = null; } /** finalization that notifies the engine when a reference gets collected */ protected void finalize() throws Throwable { try { eng.finalizeReference(this); } finally { super.finalize(); } } // type checks public boolean isString() { return resolve().isString(); } public boolean isNumeric() { return resolve().isNumeric(); } public boolean isInteger() { return resolve().isInteger(); } public boolean isNull() { return resolve().isNull(); } public boolean isFactor() { return resolve().isFactor(); } public boolean isList() { return resolve().isList(); } public boolean isLogical() { return resolve().isLogical(); } public boolean isEnvironment() { return resolve().isEnvironment(); } public boolean isLanguage() { return resolve().isLanguage(); } public boolean isSymbol() { return resolve().isSymbol(); } public boolean isVector() { return resolve().isVector(); } public boolean isRaw() { return resolve().isRaw(); } public boolean isComplex() { return resolve().isComplex(); } public boolean isRecursive() { return resolve().isRecursive(); } public boolean isReference() { return true; } // basic accessor methods public String[] asStrings() throws REXPMismatchException { return resolve().asStrings(); } public int[] asIntegers() throws REXPMismatchException { return resolve().asIntegers(); } public double[] asDoubles() throws REXPMismatchException { return resolve().asDoubles(); } public RList asList() throws REXPMismatchException { return resolve().asList(); } public RFactor asFactor() throws REXPMismatchException { return resolve().asFactor(); } public int length() throws REXPMismatchException { return resolve().length(); } public REXPList _attr() { return resolve()._attr(); } public Object getHandle() { return handle; } public REngine getEngine() { return eng; } public String toString() { return super.toString()+"{eng="+eng+",h="+handle+"}"; } } Rserve/src/client/java/REXPList.java0000644000176000001440000000417012205226215017012 0ustar ripleyuserspackage org.rosuda.REngine; /** Represents a pairlist in R. Unlike the actual internal R implementation this one does not use CAR/CDR/TAG linked representation but a @link{RList} object. */ public class REXPList extends REXPVector { private RList payload; /* create a new pairlist with the contents of a named R list and no attributes. @param list named list with the contents */ public REXPList(RList list) { super(); payload=(list==null)?new RList():list; } /* create a new pairlist with the contents of a named R list and attributes. @param list named list with the contents @param attr attributes */ public REXPList(RList list, REXPList attr) { super(attr); payload=(list==null)?new RList():list; } /* create a pairlist containing just one pair comprising of one value and one name. This is a convenience constructor most commonly used to create attribute pairlists. @param value of the element in the pairlist (must not be null) @param name of the element in the pairlist (must not be null) */ public REXPList(REXP value, String name) { super(); payload = new RList(new REXP[] { value }, new String[] { name }); } public Object asNativeJavaObject() throws REXPMismatchException { // since REXPGenericVector does the hard work, we just cheat and use it in turn REXPGenericVector v = new REXPGenericVector(payload); return v.asNativeJavaObject(); } public int length() { return payload.size(); } public boolean isList() { return true; } public boolean isPairList() { return true; } public boolean isRecursive() { return true; } public RList asList() { return payload; } public String toString() { return super.toString()+(asList().isNamed()?"named":""); } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.size() && i < maxDebugItems) { if (i>0) sb.append(",\n"); String name = payload.keyAt(i); if (name!=null) sb.append(name+"="); sb.append(payload.at(i).toDebugString()); i++; } if (i < payload.size()) sb.append(",.."); return sb.toString()+"}"; } } Rserve/src/client/java/REXPString.java0000644000176000001440000000270212205226215017344 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPString represents a character vector in R. */ public class REXPString extends REXPVector { /** payload */ private String[] payload; /** create a new character vector of the length one * @param load first (and only) element of the vector */ public REXPString(String load) { super(); payload=new String[] { load }; } /** create a new character vector * @param load string elements of the vector */ public REXPString(String[] load) { super(); payload=(load==null)?new String[0]:load; } /** create a new character vector with attributes * @param load string elements of the vector * @param attr attributes */ public REXPString(String[] load, REXPList attr) { super(attr); payload=(load==null)?new String[0]:load; } public int length() { return payload.length; } public boolean isString() { return true; } public Object asNativeJavaObject() { return payload; } public String[] asStrings() { return payload; } public boolean[] isNA() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = (payload[i]==null); i++; } return a; } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.length && i < maxDebugItems) { if (i>0) sb.append(","); sb.append("\""+payload[i]+"\""); i++; } if (i < payload.length) sb.append(",.."); return sb.toString()+"}"; } } Rserve/src/client/java/RList.java0000644000176000001440000002212512205226215016435 0ustar ripleyuserspackage org.rosuda.REngine; // REngine library - Java client interface to R // Copyright (C) 2004,2007,2008 Simon Urbanek import java.util.*; /** implementation of R-lists
All lists (dotted-pair lists, language lists, expressions and vectors) are regarded as named generic vectors. Note: This implementation has changed radically in Rserve 0.5! This class inofficially implements the Map interface. Unfortunately a conflict in the Java iterface classes Map and List doesn't allow us to implement both officially. Most prominently the Map 'remove' method had to be renamed to removeByKey. @version $Id$ */ public class RList extends Vector implements List { public Vector names; /** constructs an empty list */ public RList() { super(); names=null; } /** constructs an initialized, unnamed list * @param contents - an array of {@link REXP}s to use as contents of this list */ public RList(REXP[] contents) { super(contents.length); int i=0; while (i0) { this.names=new Vector(names.length); int i = 0; while (i < names.length) this.names.add(names[i++]); while (this.names.size()0) { this.names=new Vector(names.length); int i = 0; while (i < names.length) this.names.add(names[i++]); while (this.names.size()0) { this.names=new Vector(names); while (this.names.size()true
if this list is named, false otherwise */ public boolean isNamed() { return names!=null; } /** get xpression given a key @param v key @return value which corresponds to the given key or null if the list is unnamed or key not found */ public REXP at(String v) { if (names==null) return null; int i = names.indexOf(v); if (i < 0) return null; return (REXP)elementAt(i); } /** get element at the specified position @param i index @return value at the index or null if the index is out of bounds */ public REXP at(int i) { return (i>=0 && inull is the list is unnamed or the index is out of range */ public String keyAt(int i) { return (names==null || i<0 || i>=names.size())?null:(String)names.get(i); } /** set key at the given index. Using this method automatically makes the list a named one even if the key is null. Out of range operations are undefined (currently no-ops) @param i index @param value key name */ public void setKeyAt(int i, String value) { if (i < 0) return; if (names==null) names = new Vector(); if (names.size() < size()) names.setSize(size()); if (i < size()) names.set(i, value); } /** returns all keys of the list * @return array containing all keys or null if list unnamed */ public String[] keys() { if (names==null) return null; int i = 0; String k[] = new String[names.size()]; while (i < k.length) { k[i] = keyAt(i); i++; }; return k; } // --- overrides that sync names public void add(int index, Object element) { super.add(index, element); if (names==null) return; names.add(index, null); } public boolean add(Object element) { super.add(element); if (names != null) names.add(null); return true; } public boolean addAll(Collection c) { boolean ch = super.addAll(c); if (names==null) return ch; int l = size(); while (names.size() 0) names.add(index, null); return ch; } public void clear() { super.clear(); names=null; } public Object clone() { return new RList(this, names); } public Object remove(int index) { Object o = super.remove(index); if (names != null) { names.remove(index); if (size()==0) names=null; } return o; } public boolean remove(Object elem) { int i = indexOf(elem); if (i<0) return false; remove(i); if (size()==0) names=null; return true; } public boolean removeAll(Collection c) { if (names==null) return super.removeAll(c); boolean changed=false; Iterator it = c.iterator(); while (it.hasNext()) changed|=remove(it.next()); return changed; } public boolean retainAll(Collection c) { if (names==null) return super.retainAll(c); boolean rm[] = new boolean[size()]; boolean changed=false; int i = 0; while (i0) { i--; if (rm[i]) remove(i); } return changed; } // --- old API mapping public void removeAllElements() { clear(); } public void insertElementAt(Object obj, int index) { add(index, obj); } public void addElement(Object obj) { add(obj); } public void removeElementAt(int index) { remove(index); } public boolean removeElement(Object obj) { return remove(obj); } // --- Map interface public boolean containsKey(Object key) { return (names==null)?false:names.contains(key); } public boolean containsValue(Object value) { return contains(value); } /** NOTE: THIS IS UNIMPLEMENTED and always returns null! Due to the fact that R lists are not proper maps we canot maintain a set-view of the list */ public Set entrySet() { return null; } public Object get(Object key) { return at((String)key); } /** Note: sinde RList is not really a Map, the returned set is only an approximation as it cannot reference duplicate or null names that may exist in the list */ public Set keySet() { if (names==null) return null; return new HashSet(names); } public Object put(Object key, Object value) { if (key==null) { add(value); return null; } if (names != null) { int p = names.indexOf(key); if (p >= 0) return super.set(p, value); } int i = size(); super.add(value); if (names==null) names = new Vector(i+1); while (names.size() < i) names.add(null); names.add(key); return null; } public void putAll(Map t) { if (t==null) return; // NOTE: this if branch is dead since RList cannot inherit from Map if (t instanceof RList) { // we need some more sophistication for RLists as they may have null-names which we append RList l = (RList) t; if (names==null) { addAll(l); return; } int n = l.size(); int i = 0; while (i < n) { String key = l.keyAt(i); if (key==null) add(l.at(i)); else put(key, l.at(i)); i++; } } else { Set ks = t.keySet(); Iterator i = ks.iterator(); while (i.hasNext()) { Object key = i.next(); put(key, t.get(key)); } } } public void putAll(RList t) { if (t == null) return; RList l = (RList) t; if (names==null) { addAll(l); return; } int n = l.size(); int i = 0; while (i < n) { String key = l.keyAt(i); if (key == null) add(l.at(i)); else put(key, l.at(i)); i++; } } public Object removeByKey(Object key) { if (names==null) return null; int i = names.indexOf(key); if (i<0) return null; Object o = elementAt(i); removeElementAt(i); names.removeElementAt(i); return o; } public Collection values() { return this; } // other public String toString() { return "RList"+super.toString()+"{"+(isNamed()?"named,":"")+size()+"}"; } } Rserve/src/client/java/RFactor.java0000644000176000001440000001355112205226215016743 0ustar ripleyuserspackage org.rosuda.REngine; // REngine // Copyright (C) 2007 Simon Urbanek // --- for licensing information see LICENSE file in the original distribution --- import java.util.*; /** representation of a factor variable. In R there is no actual object type called "factor", instead it is coded as an int vector with a list attribute. The parser code of REXP converts such constructs directly into the RFactor objects and defines an own XT_FACTOR type @version $Id$ */ public class RFactor { int ids[]; String levels[]; int index_base; /** create a new, empty factor var */ public RFactor() { ids=new int[0]; levels=new String[0]; } /** create a new factor variable, based on the supplied arrays. @param i array of IDs (inde_base..v.length+index_base-1) @param v values - cotegory names @param copy copy above vaules or just retain them @param index_base index of the first level element (1 for R factors, cannot be negtive) */ public RFactor(int[] i, String[] v, boolean copy, int index_base) { if (i==null) i = new int[0]; if (v==null) v = new String[0]; if (copy) { ids=new int[i.length]; System.arraycopy(i,0,ids,0,i.length); levels=new String[v.length]; System.arraycopy(v,0,levels,0,v.length); } else { ids=i; levels=v; } this.index_base = index_base; } /** create a new factor variable by factorizing a given string array. The levels will be created in the orer of appearance. @param c contents @param index_base base of the level index */ public RFactor(String c[], int index_base) { this.index_base = index_base; if (c == null) c = new String[0]; Vector lv = new Vector(); ids = new int[c.length]; int i = 0; while (i < c.length) { int ix = (c[i]==null)?-1:lv.indexOf(c[i]); if (ix<0 && c[i]!=null) { ix = lv.size(); lv.add(c[i]); } ids[i] = (ix<0)?REXPInteger.NA:(ix+index_base); i++; } levels = new String[lv.size()]; i = 0; while (i < levels.length) { levels[i] = (String) lv.elementAt(i); i++; } } /** same as RFactor(c, 1) */ public RFactor(String c[]) { this(c, 1); } /** same as RFactor(i,v, true, 1) */ public RFactor(int[] i, String[] v) { this(i, v, true, 1); } /** returns the level of a given case @param i case number @return name. may throw exception if out of range */ public String at(int i) { int li = ids[i] - index_base; return (li<0||li>levels.length)?null:levels[li]; } /** returns true if the data contain the given level index */ public boolean contains(int li) { int i = 0; while (i < ids.length) { if (ids[i] == li) return true; i++; } return false; } /** return true if the factor contains the given level (it is NOT the same as levelIndex==-1!) */ public boolean contains(String name) { int li = levelIndex(name); if (li<0) return false; int i = 0; while (i < ids.length) { if (ids[i] == li) return true; i++; } return false; } /** count the number of occurences of a given level index */ public int count(int levelIndex) { int i = 0; int ct = 0; while (i < ids.length) { if (ids[i] == levelIndex) ct++; i++; } return ct; } /** count the number of occurences of a given level name */ public int count(String name) { return count(levelIndex(name)); } /** return an array with level counts. */ public int[] counts() { int[] c = new int[levels.length]; int i = 0; while (i < ids.length) { final int li = ids[i] - index_base; if (li>=0 && lilevels.length)?null:levels[li]; } /** return the level index for a given case */ public int indexAt(int i) { return ids[i]; } /** return the factor as an array of strings */ public String[] asStrings() { String[] s = new String[ids.length]; int i = 0; while (i < ids.length) { s[i] = at(i); i++; } return s; } /** return the base of the levels index */ public int indexBase() { return index_base; } /** returns the number of cases */ public int size() { return ids.length; } public String toString() { return super.toString()+"["+ids.length+","+levels.length+",#"+index_base+"]"; } /** displayable representation of the factor variable public String toString() { //return "{"+((val==null)?";":("levels="+val.size()+";"))+((id==null)?"":("cases="+id.size()))+"}"; StringBuffer sb=new StringBuffer("{levels=("); if (val==null) sb.append("null"); else for (int i=0;i0)?",\"":"\""); sb.append((String)val.elementAt(i)); sb.append("\""); }; sb.append("),ids=("); if (id==null) sb.append("null"); else for (int i=0;i0) sb.append(","); sb.append((Integer)id.elementAt(i)); }; sb.append(")}"); return sb.toString(); } */ } Rserve/src/client/java/REXPDouble.java0000644000176000001440000000556012205226215017315 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPDouble represents a vector of double precision floating point values. */ public class REXPDouble extends REXPVector { private double[] payload; /** NA real value as defined in R. Note: it can NOT be used in comparisons, you must use {@link #isNA(double)} instead. */ public static final double NA = Double.longBitsToDouble(0x7ff00000000007a2L); /** Java screws up the bits in NA real values, so we cannot compare to the real bits used by R (0x7ff00000000007a2L) but use this value which is obtained by passing the bits through Java's double type */ static final long NA_bits = Double.doubleToRawLongBits(Double.longBitsToDouble(0x7ff00000000007a2L)); /** checks whether a given double value is a NA representation in R. Note that NA is NaN but not all NaNs are NA. */ public static boolean isNA(double value) { /* on OS X i386 the MSB of the fraction is set even though R doesn't set it. Although this is technically a good idea (to make it a QNaN) it's not what R does and thus makes the comparison tricky */ return (Double.doubleToRawLongBits(value) & 0xfff7ffffffffffffL) == (NA_bits & 0xfff7ffffffffffffL); } /** create real vector of the length 1 with the given value as its first (and only) element */ public REXPDouble(double load) { super(); payload=new double[] { load }; } public REXPDouble(double[] load) { super(); payload=(load==null)?new double[0]:load; } public REXPDouble(double[] load, REXPList attr) { super(attr); payload=(load==null)?new double[0]:load; } public int length() { return payload.length; } public Object asNativeJavaObject() { return payload; } /** return true */ public boolean isNumeric() { return true; } /** returns the values represented by this vector */ public double[] asDoubles() { return payload; } /** converts the values of this vector into integers by cast */ public int[] asIntegers() { int[] a = new int[payload.length]; int i = 0; while (i < payload.length) { a[i] = (int) payload[i]; i++; } return a; } /** converts the values of this vector into strings */ public String[] asStrings() { String[] s = new String[payload.length]; int i = 0; while (i < payload.length) { s[i] = ""+payload[i]; i++; } return s; } /** returns a boolean vector of the same length as this vector with true for NA values and false for any other values (including NaNs) */ public boolean[] isNA() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = isNA(payload[i]); i++; } return a; } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.length && i < maxDebugItems) { if (i>0) sb.append(","); sb.append(payload[i]); i++; } if (i < payload.length) sb.append(",.."); return sb.toString()+"}"; } } Rserve/src/client/java/LICENSE0000644000176000001440000000140212205226215015535 0ustar ripleyusersREngine - Java interface to R Copyright (C) 2004,5,6,7 Simon Urbanek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Rserve/src/client/java/MutableREXP.java0000644000176000001440000000016212205226215017465 0ustar ripleyuserspackage org.rosuda.REngine; public interface MutableREXP { public void setAttribute(String name, REXP value); } Rserve/src/client/java/Rserve/0000755000176000001440000000000012205226222015777 5ustar ripleyusersRserve/src/client/java/Rserve/Makefile0000644000176000001440000000073613442516164017460 0ustar ripleyusersRENG_SRC=$(wildcard ../*.java) RSRV_SRC=$(wildcard *.java) $(wildcard protocol/*.java) TARGETS=Rserve.jar all: $(TARGETS) JAVAC=javac JFLAGS=-encoding utf8 -source 1.4 -target 1.4 ../REngine.jar: $(RENG_SRC) make -C .. REngine.jar Rserve.jar: $(RSRV_SRC) ../REngine.jar @rm -rf org $(JAVAC) -d . -cp ../REngine.jar $(RSRV_SRC) jar fc $@ org rm -rf org clean: rm -rf org *~ protocol/*~ $(TARGETS) make -C test clean test: make -C test test .PHONY: clean all test Rserve/src/client/java/Rserve/Rserve.jar0000644000176000001440000007211412205226222017750 0ustar ripleyusersPK3C META-INF/PKPK3CMETA-INF/MANIFEST.MFMLK-. K-*ϳR03r.JM,IMu )h)f&W+x%irrPK'GGPK 3Corg/PK 3C org/rosuda/PK 3Corg/rosuda/REngine/PK 3Corg/rosuda/REngine/Rserve/PK3C0org/rosuda/REngine/Rserve/RFileInputStream.classUrV=O-(qb!B+1hPB*0IMڐ.*q$W~@w]tM,&΀3S:+鲟oԽ9&d{s9 c>Ź0c",.%"§|oM)>\#W0j3wJs5+Ss*U=wn-S(Y)`65vA\uiYLr*UTrAul<ܸg{%^"E*߲b-Tq!:]拄&-JN55vOxD$LhXĒH򧂆"J 1a: 6'ܺpW_Pޚ^v3]Kv^.I0x@F&#*h>6hI$jIZ/[DYԊMRXiT7u0仯HoJ1dQ'Ws us5^I}(F#M#yL 'py䶱fB2@D[/N+EueZbP Z [8!?"QRb*# c*cI,)ڽ CAEŇ*N8AtNAgCnJ%})֩H,$cGH)9a!]_ . t!6U*7MNQsx~.V4*xC^C:4ФW^P\Žqe[c'vI˗Óx%†B K`,<h,M< fK?ο!5ABD*yb!Pfl:\p?QC8q}6FHnE8DQ !=ʥ0ݔ_2/􉲿kH>EK/R{G x0XngP"w 5A8]XBr7ҢPKMZP PK3C1org/rosuda/REngine/Rserve/RFileOutputStream.classTsUnvM-mCR4ʲ4665H.׆ݰـ<;##3C<&4-NI:sso<p(Nb:Q+ P0|Y>Q1^Ru _{&,"\k߻cyY7|j6Z_QPPCtmi1zOdJ E@g4hn۫Z6lRo}g8Z)dT$q.W1tU1nP Eq*_}7ݫDIѩv'Koۍ1$Ӟ=']̤UlC&>n8 3riv\?6-Ggnѕ<gƫ:a_AEQEI}w7vp#HDr+5EH# W WB%/z_^ ޠ7$Hj$}ɍΐ,Lct e!@  =B G:?ԁK17Mzn0Aqd),#G&QQVpN +PL0Eb!A If&ѨʿW$w0A2ОY an ~IbFtC2 }E~Y*S?LPOTP2 Cɐ#$C}>N!{\#|c(6VqkJ^ =OQ|"<,d T.'8+u1~'|1^A~WsYdc#x {3_p>=-td ` .CI,HUkz賄 IA== ܿPKPK3C+org/rosuda/REngine/Rserve/RConnection.classZ |Tՙܛ̓ P#`(#CrIF8@ZQ|UaUW| $ZVkv۵mnEs4s9^;o~g,Oo7U 7E|zK5T۪j~ߨn4w4exSU7JG'7J"/yW1E5jsռS'9"nqH.N] )T\hnT"]ܪ/Х-RF~)e.LեR.t*xe.'e.'2[-s)2GD/2On.Pպ,ԥFZ76M6RzMhF]WZD-{ZFGO(٧f.9SͽҥIn\*+4YFe8[sTZf]r[Zd.tYK.t٨&]66MIdr2]mtr.ە.BMvhK8 *6]7=ۢ@g@")mcF9^ ͮM =q@58R'#i-hE{+z0)UP"s8* 4CX%3ڪ/17z> t 4)(Mkr^1eD%݌ P\s]>]c \u94)[P?a^'že1mߐrnb& R36ɪRG&W5"W#"b6C@=vR;S"ͱ݌mO97(uXSj-P7{zU_G@dM*CM{S\Aޔz#-˶P,EkrWSE-q' 4,$q&byOJR/fQ9C. ˆneNJdtI!6pn4Gz ܄yڲi _ X٤'Vhr!{? r^*6 GJ`w׿gr%]CQ35x^led鬝Ղ!WuԬOh,l&׫Em\}d/ڄ7h1$*aV]?VjGg%_,Bp|/!_d茜Qy.ΩX06 (IP)IՌuV_:}C>%H \>X!1&} ɕS-ImsHűerϱΐAYq+C\# bW>3E %Æ\+逩.EB̖̐u51}QVŋHtw(-"">4wEC!C 9 7$]@6Ff%`}PvEiZ2&orGhxy2~dȭxzLbq.CO+0ʴ5L>*Dԟ;[Jn$j;UcꑤTGSpD; |GU$JX $z"9,+ssZ2v}\) ."el<gJhPq-y8"񅢽 VjiXg( Kq3Gy9 r~3 | 1_I9ex٪[Ҵ$0iL|3SGP|^"/q%tގйfHRbgsg/#iflUf7KJnrdjrdGVlVwʙխTgQVQ$+bmZuk~F2F[QG;UPVqa!G}̵GDiR [6ݰa!ٲGɤĿ}KMRFO#؅*R,ͥC's]_'g*(a[~b ^\ͧIj_Gum2=QɑCOpľNX߮rsI[dXԗ[_Ǟx;Dr6z)(oB[X=/EV :a*Ym6/LV~5_^|OفOOp>//f;ȷ(;ன)UF8b}N'5F+^>99^jqGnESTS48=>TzMLAA6 hX ޟx6o3yd>u̹"5#pQK5jt5VwSpcu0P!krC鎚c(1)è:10*G9^J´Ml=G%3Gp)9!5q dqQƲ `.7WT{For:)rB%ϕ!oʐ),_|N{ 9^6m5è2m ix.\'h>j=4чanvD%!RYPYcٔÚ_N(#9X3QLw?M!e{ <ݎ~J79rMz FN㤒3SQ/faWYEY\M؀ b3І^lE?CDdxvLUN<2/7(R]R.1`tnYe H'er%Br/'Èʗ1(^ErLÕr,uڱ:c\hVIZ?n6nv-ns܄wce|>xw9^f2}J۳F4|V4< ϧV텪et4<{{9xeY'P 'W6k84bh]LqlUrX tSr R~J IH% Y=dsY}Ib*V)_!/Us>Ia88ǞQ{#' dPTJvH3*ώ0\놱8YFu4|xH/}1lq} 4Kӓ>KnK+_<>:Bweqs-pвOk,NX%D,W9c3n!/380iA3`%akrlX/8}?T~HJ Li"}̸+럝0Volrz36Vؒ!qKchGIf7}-DO6U SwW~^'׿3|=!(~Ⱥ?-Ք>ZGkxj~eqn]{^˺7lyjطm4 &}8oc-~u7m#MneqQYG!t49uv.+:Uk4{\wWZթuL هP/+ E/eDޢ no@'O,.<tCxJ7^OāPzO)Q\e meP>JǬX<^_1K dG9 qeqvz; Td\5uz ;,Yʶ^89^=f0'l@D8Zѷo}+X J R9RjR%ƒR{ċC,Ix2 o̶ eڔX2(c!DF@3AIiMlJeO\cTn^z.;y(˂$q}?!3g69+9+ӠKie8U"93=Mˎ%/ar4BwTK$Hks YI$/Ktt$HG2h"o`q}9l D KdK:l4/$mmn#2eI0~̓]X,]`gy1y)#H>P#WݻI>OE$ ݰY7,/yraU|I]>΢KI?N Jd DpDq We^!(Kܕ'joU{} K|êZ߇n1.]^M֠|Z٪AjPNNrhp܈V)̪A[~pe4vIe~Kx9iav4o'F[Qm.X H~_ÿdXChd7͜ ֟L4V?M~:~БL.gV$PKRLv\_/PK 3C#org/rosuda/REngine/Rserve/protocol/PK3C/org/rosuda/REngine/Rserve/protocol/jcrypt.classmZ |\E՟{wIfdIvhMmW6J6mIMSh!P ꧨP*E@B >?A$}ȯg̙sΝsW}@)j6ō5qSn:rA+#J:~BjRM!J*"uONNHe1IjE}'nfY\U/]s 5]sZ\Uӡ}zV΄l5ZKE(sRJ6pIhuE+d\R*-- .Z]h %2d%,JJʅ_P PR1bD@@@"DJJbT@*P(AVʁJzPAJ@=PP+J~=s`X8x04x 7 lEMGڳ}-GTkF6\9#KHwO! +[d94˶|-GyZz冾UZn9g{1qb)2gÞ ;ˣ,y҆eg,]nƎ uq6 o!]760#wSh s+v \4вk`h[˚ёC:((j!lvnUz̓'o `0Y3-ajLmԙ 3 `fLJj@ɓ9ۜ;]w-# 7a֛x֭DlipxKœo6$FCALE49 3״&,3;a2Bm-#{nhYlhM{G.l=2<:yxWˎ6̳pkQkph:|ܛPU,t`b._JҢ([~"#$fӀQ _Vf߄өU 7ܭmTx{ &͊j;xӰU׫haV'x ^qt13NGWT\Dshg]P}P{+ZwĉUj% B|\R]=Nal)ۄ7f]TWKٺcV+^*j}jWERoyߠ*3V} ;^W™}:Si'T՗vVR1^Z0ߧRjUQ2aBl6"޲@f*{ ؁R'ת}<+f=C=*%;Ls=*L6wS]GEBw6x뵲bDŽ]bJfD+DKG&3^xW ܔk!]q*KmתLx,chdcYT!a5 ݷPk.oCXd3_:sW"S*?MtF%g9WmթNַUjPY ;~}^Q7M6uuzH[=V_Gӗ_YRߩ_sg3>bQU&h%KLGq.UfȦTܔ3Nh*J#s@:i>rHH*}4U+iEPt2๨cU"VrV,Q>3 =#{&jqE7gU~R4Z_Ti7SߡP !Uܭ+Bwi ai eRӛh *6cA RNst_]tCԏqq]m$TucʅR1gբDv7)=fcd:qZgc(-JBDRMJS%Z* 29zRξBy:JJǯU1LPk3FJS%{7Jn˛'cNWNӧ4w̙sza֩I:0ZblԾЕfIFF5[y&3ϴIՅ5l>+`>ЂFseBeT4{T1K^R޿is͂GFEɓ ؑPoCao~]X,Wc8 H<H*S4 P iPfffrz@h80Ak%gQo!(XHB'\dK!`NVbnV\̊=kKl)R[Fx-'\f-6IxO>r;4"l`3`gn 7[O8hFm;pm&a[w<.;BJ8d[mp. cE{m;EbIv݄ń1eqB}w#M~NFץ_E Mc@P (Peֽ_Z=G=GhL\C0$QC&]y+P()BNyg"*o GVyg!*ldw[EZyVyH+-H+5486@ a$lb63 [@3 d0[mLLv`(H: -:$b.da&a7l{+8H9LIe2 1 3 L%L¥Lp0$I`.g0 og2 W0 W2 `$I&L{2 c$\$\$|I !&DB8 #࣠ZPpSp=S1PU68p &LCLaFs| p#Y&0p` gp3y&& L[/113w0_fdbfaag`d| : &Lo33a| x >" rB<,М?$ ޏ@ARAZ!CR "t 3``db~< lǒZa=ڈGX kq H],O/vwۘw7.ĽM.qo qWpW )aJa܍;w ssIO0na=U{ s> }P0aa#Gk넹녹 sn>!}̝J״G6l.m㾾QHF;,$a/}}y!g)C}Ax@e2/ o o8dAveN-.w ow o8*%]#}EW)I#BBMɜ* #?u!Bn-!!!\ =,}GcF2W+}O{D~ߚ;Tk^~|0H`׏28uGL%~",b* c,>&,Tg"+rm -/υDž_HPH|LH$:%¬&nl!aI39Yjh@XmWMs$fHy3W:M'1_$n!GHEC/]Oij{[+N"")@Jᗐ.n'~%tZ(Ӆ%"ɯ& `xGTrZd52e$65]|s u1S4f! bkb6JMVh3-U^VicBϓBύ^bs;ho`'Jf=%x-tRv|4!=o9~㵒Pz~/ s L%$=#=+I2 crгO[frPH焤?ItˌD#ttix f:4S%vfɍtmӍI簏fE\5Dc{/PBJI*=+I%'X0qy&^Ga/ R~K_I"aoTI1!a 7e|/g Sx6 Q^dpWUA<ñbՃi/~=*DAV#}kY6CW3,xW=8U(zUL6Qs׭mm懅#]$q)vnw1{Ic/ƾ'gԿxKa$[BTTndiPŖeUr.iaZ::_77X^7F5fv.,˒Vl㧙:#-G9)EΚI'kvIlz1?RNRM9?7p\Xyc>#|[ZpmO*s%>?' _ᕉ\'v>(~b8~f8W|rN6\ 'eEay VTfHuL0K:X/$b Hy4ϕ"j|qXG] ʓ,vQ]-*_|\x:%ou`38qD|#{'~3g7q o7%XBSt-TRT<1ZpJ:W:6\^]%f9^: a:9[jVluL*$~rb^\4HXdƛE"y1;=ʃybxx,Kmqv*l-0 mhDXnGUttRYrxouQ-ecu]0$6oZ/lNP3+X*FPE i0[Sn]XQy+8p[Cb@5\'>2=^U3['Yrw-{gz37[y>u-iFBǍFrIyXf_L~R#a qE:!D:c|7Jd4= #xN wg%09NvStlCS=+dix-4g|g21̞gr6n6b &>%;O<ΑA?L<'LjemȼOJf㋿Oc3OԆJQf =; ddd܀@PK+7]%PK3C.org/rosuda/REngine/Rserve/protocol/RTalk.classWkp>zZ QC !$AJc;&NM Ԗ#"i$@M@)ohRBi `Rȸs-E~j%oMI~νy9ŷ!t$@ad=-yLȃʯi> rgy iRZ!H =/$ =У }E`o@H j̢6|ɀ-$)ѵ#ŰNP=ຍWut3S!}: tD_EJ5T ӑZ/Юuyk$g |eylehȩ\)(YkWu5fzM=nYIsdH5XdW̜}ofA.+kiF@z84mn$3{!R#IIGv$B_6%mVdđ8lL,Qxb#5Rj`P2I. #XʦS&ў*q}`Vʷ6.FpV#㣂.dNXpjsuDH;^sbt~*e̽ 5\ΖHdXnBЍAiҝt(xF_aJ'$}EOV4r6ݻ3Ƙj4R o =K pv5+u,T'67<Ο l"dEioej ٞmOTHhZ[@!ݭn\#& i;kG@#zgP0{lA)ī Bt:|{K\L\x){\ls\\ /y1/}_1GJ^| _pዀ/vv5/uuN^z .܅q^>ɅNp?\x3s# _ Յt! g\8 lvswpxԅMhW厅kE1ڱΦ3$=Muy_4q\ /4N0_*^pSy⾁ M|6BY _(`-B"*%⛏IMf IzBGŽ r^3&xyeP"ޒ M8^srSrD]yzulfRXn&Gu ɑUh;$'{o4s_C5rAvb%jbgEnR2+9 XqoK`HŠ^wY4|h- ..jKgɭ<>^YՃԀ|!ڇ^o;cw,\̂bmMByDNĭ"\if4Ʃc@19$r ')IfiԜ<%#(oG8ȧǩV&1KB껧Rv:7~C_I&Ugto 7ӽߓ>t_;JM}_ӎpHAuHQԄvBT1Y~-\VF"OH jM05B:O&嫠ԅiiy*B]}>* }F`k'ԃz!45'1oJ'/?G-[P3:U VY1ùIEI\92 B໸ۿyܑGqO}i?D|?'3 p\K~K?a|~G8Ax8E E,WWHkE8-x#2F'K* :MzHWuQKsropZ'$6M 3!d׏vԽ͡ Ebu$?>sZC>ݯ uHWu=@+tOwE|%F!WS_r&\ #%gSA*?q+ 5:L[u_v[_ɿ-c|i1{z9LY?ximzD;=ιU⎱qicg]E 'TT]=- UڿPKU PK3C4org/rosuda/REngine/Rserve/protocol/REXPFactory.class: \Uu`PbjX((`2&Dq |IJKmBKm^kޭ629fϯ9{9{9^=~;@sLp3hp 6qBР :q R 'LGECUCv 5 u :5tih805LpM-&'?N'!$'q(4'0!Չ>LqqN`#$y$srG8FDZNPPj1uqJqqB.N4' 'g*=?Ni,rggrwk8 gp:ѳXasac1x kx:! KXL;!Ku,c7,<',r'$`J, -O??KpGCxą̲j0VǀXJu\jt\cPFtXf[t تZ^ :n/qY6 /GЖT./]XRqs-!0PhXK+C\-[XXR$WT3J JbTU²F6&NeD3.*SY&%-IrDSRVh\Z0_L[K* \Nc}|->|Bˋ,Δ~ͩuTݔsVF45|;ǾYGss(ӡ2gAcfa鹥eKgyan6=byAE 5#L*ilinliꃁ@@NSsc, 56oN#k!#XPI} 4!99sB Yhh !c &kV7ɱX3|%s"_fL-K5P=# 7[-̥(\a?'# j!kHyCI XZ)9$_hj!?OFPs}n`Pd?1yPP y̓Y<,dPEcksM`^=ـ7-^7hNf>b64x 0Xx-p -z,UȴVY2*Y`fQfV1aX Zq0  s[&E7} 5+Š֮ߠހ7Ҷ:y [jYQYYYQNo I5דʹBބ7o4;N 2fgyޣ­ލhxp; M^+}^Ao oYլtNq'b BFdƆ>XAocԁK.:e HqGUg1=;YGV*epNJ v'XғY@;p>t 'n$J VYhG+fA.ZQb)GiF^--goYlimjjlj54qOmo%@з[hHuKo;` -Y\6j͓Ge_aU}0Mo l%Y,j~!Ҭs eWMvȑѳR v3L%.>`03Jf6j,yVUGȌMb\zI׶L3H3 M} _.? !BzJ;t)zf:O \?b-OůpPAM59@E1V䛽߰13/X˩^I#kWnu74rvjl w猣 0"sܟ !Ʀ YxbsL4 Ny[j\oh9i[|<<~Ry%0hkh4eg թpT [?wiP@ (i&V'[X5Ћ,R 5;#ȻuNcCuS>Y7;F>fTMV*3B`E9+D!KZh/~J] z#≌̟>j[ 7-|qx,+;rkɏ}lsAfN4x(&Ϟ]K{@,.埜1R#0]}-SɣQtY:f[H}X׹봖p2ϑ t_! pI]Qx[ ' mQv;_~_~?D( ?B(Q?F(qŸŸ$(i»݄Ÿ!(|/?O Q: /E%@~W ^G_*l+lR-[ ^>ҨE~hz p|#?*RfNX8vA4PvƞWP󖠌ȜA}<2\*,N = j7ݠ~pH zxD`W48=B8]Y{15d-NHC4X`dBx5_J[o kbzl#4afȫ!&I?􀗖<j'|Kkۿ}Kb P _#H,mپ=0,?7%.MUU=1>\]/:Wr+ᴓG0z69>}Ǿe.ꆌ@+ytuV UmtCNҤn8-&3fx] k,$M; %oynf*{soεS"-t|ا;aJlqU^xؠ0vHf0!uV0 a\^=|rX520{ҷfnx ̧fSh UWw0^ۑO1 ٢z̉ZD:  \|8Ͳy檹&3lwCQ.~Y&Q!uWifZ4G4y%v a˔.HbSz x[ޚ+ rIq{,R<]1$tqWs]Nޛ<Fydge^ tԺx%a>jcsPTri hWKSxqϫL{G δXSՔ*##+|D'љv=:S~ӮNG<ݣoKMF&[NLZMcE2J$qԪOݰ(""|F%4OuPP꽉eRdGWuO/ =EG?Zk 糉:éW8a PZ!J= rlNaYt `R> ' cr,IMsHu6NDR8HAl݅d) |( Ó:G˫d4U0 G%l+(aػ|;A;P8f,׾ҎR&S92ra\cZȁ`%iyp=̂a!D͔B ٭mT]MmTIEٽT=HC=C^*~MTlCETd&/:J\B@ x Saq:<%$SeЍ؍+\{b؇9l/+k> ^#b(ND6!N7E>%%𶨆wD Q=u+#q=|,n?;q|*.LIBo—s8"z+ Q[e8[Q&I +2~P*GY'Kv(܁6eڕ)ON01Vc:i8H=pZCUbz!:LSpczPoǑ8JǨ/XS,l:N9qm(NeTX<6 smg4[!a+3mbag6l&,݈;qmε=EGq _OaCm =Hx T|=$H hpx8Kאa~ l񸑲4Ɲ!PPsSO@F}42͑t QJER, pEOauT$!'`IDrdIZ@K3= {g8!+#' &+zaTkU)8̙L qo} =HG<䶯u&$Xǐ4Qy@`m1P'++?ͲRK}.*_WfLD@i|+Nu::aDT)]XPgs$ϔ`TSzTEl;@m`S(J墳jgvpqǣ{~i@?,7><G Jrvd֎jЎz^ 쯮jlRSUUfuyBV8/H :+դV2c+u1䎸̚%E:ٕ\ͣy.v yzW'4ҋ3 NJє\ɹ{TSNjWxvR{d>V:L@<;L-;ݰ`]I30O"}ϳG7ZNZ[lҟ(G9p?_2=_%tkЂ:|.7q<|Owp:=lI6ďD :%/ G$1i_)xTb.KK{D! W !*١m&:_!N0 -^I(>Naj F)>!ls)`Q1v 1d0p'x; I0-]iR&!An~&PMFaGתЉ[Ҿ tiN16?ELɵd<ڊ4vJTM&ONY! qccN偭Ɗ{MjYꪞܑLCFEG!=BgI i^<7xxNR=b%.3=f5u8x4sOK`E9]\|>݅=l7ԮVxsr+bK%x>`CϖcI1FeO(mM!7W8y\:poSORgi8kn]E4buvA(*du/ɃGAHVЋQ덓AE󐒢pUVG&'fx[$w$$× _.~o`:% .)s GwB6AuiKt&rS^Eftu'myc-8dhC%f*iM IG T1t'F1QZXxTd^*^YpWKL_PS1q:FL |SD>~(fb6 f (cb(/ yBQ.E]"bX"DJ/nKIe/\<.3/~+VE-U'j# U ZCA!6(بx%JTI2eج6L\,W(ŕ&Ѯ)W-MF_ 9Q lՊp<)t` 8O桼V<&iQ !J&%O=R*,2~x^</{<| ^:ޥ?]iX6}PK( 4PK3C/org/rosuda/REngine/Rserve/RserveException.classV sE}Y2e10 B%& 4  9; ^HIaiaZC IgigiOXe|=9HQLutu}Y\lbӯa@àC4 k8ሆ G50aLq '4pJCNø) gel^͹⼆WdW5&|ބBE:Kf1RvTȇU39_,O8FŮX2w+2Um:N[AZ7\LI4vJ7oN aF@+[9 miTЧ进_ʶ/ZRl} G3>wK 7#5ޱePMV^ymK] Z Zs58fV`#($6%^"kŶ_i!e\!x56Q5WJ4Opu ?8QG &1H|H">& 0)q&Fψ1kb#''S/z]'#}YGZ7Dz*җGz:WDS+#}UX}n-z4֬X+Zv юwc>[lml>CQ/)7;~D3O7%z(9Sbbf$F,qms4ّM,W_Q-8u BŮY)*oIC\-YJ-՝#zwco cF.XEfby.zlKN}`̫ ,?b)q=q"bҵ)5qilK,,qH2MS{YIyx6N]H]~ۃqPKLW PK3C(org/rosuda/REngine/Rserve/RSession.classTmsU=7M{ yF$]D^ԖVBD>m;a۰w7'A2Cz68s=Qq.ףztA.%>ħ&h` e|fs|!l0`EG]V%$J:M~v0/H^:3_k0Nfkޮt4ڋ+02wL/Iֽ^kGqR qosAS']t0 [aǩfΩ(v&O.3Ujp%R35XTцJR@f\|21ߠ^7J,JZdZdF Ԛ5 k &Nb8nkl*dBڽ&Pv]o#wUCfͭo{*N4jM⺉u0LMPIN0&ZjZ?f&C:Ե/ ȶJHU],y^[|v5uw-/ilʼn/k]^ ۪ZE\MP3#y_33k='L-Lmm[zҞb6z:?!Sٌ 1-<`;ͳ b Y<~8ׁƋ8c}du?DzϘ~;cUS}vdj"?V(>T&)Ge9J-Q9J*)Ӈ-QHT)<;3)11aj#RRWjq4YS/0%|_PKSRhPK3C META-INF/PK3C'GG=META-INF/MANIFEST.MFPK 3Corg/PK 3C org/rosuda/PK 3Corg/rosuda/REngine/PK 3CBorg/rosuda/REngine/Rserve/PK3CMZP 0zorg/rosuda/REngine/Rserve/RFileInputStream.classPK3C1org/rosuda/REngine/Rserve/RFileOutputStream.classPK3CRLv\_/+n org/rosuda/REngine/Rserve/RConnection.classPK 3C##org/rosuda/REngine/Rserve/protocol/PK3Cꐈ6/dorg/rosuda/REngine/Rserve/protocol/jcrypt.classPK3C+7]%0f<org/rosuda/REngine/Rserve/protocol/RPacket.classPK3CU .!?org/rosuda/REngine/Rserve/protocol/RTalk.classPK3C( 44hIorg/rosuda/REngine/Rserve/protocol/REXPFactory.classPK3CLW /eorg/rosuda/REngine/Rserve/RserveException.classPK3CSRh(korg/rosuda/REngine/Rserve/RSession.classPK2oRserve/src/client/java/Rserve/RConnection.java0000644000176000001440000005513512205226215021076 0ustar ripleyuserspackage org.rosuda.REngine.Rserve; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004-08 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- import java.util.*; import java.io.*; import java.net.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.protocol.*; /** class providing TCP/IP connection to an Rserve @version $Id$ */ public class RConnection extends REngine { /** last error string */ String lastError=null; Socket s; boolean connected=false; InputStream is; OutputStream os; boolean authReq=false; int authType=AT_plain; String Key=null; RTalk rt=null; String host; int port; /** This static variable specifies the character set used to encode string for transfer. Under normal circumstances there should be no reason for changing this variable. The default is UTF-8, which makes sure that 7-bit ASCII characters are sent in a backward-compatible fashion. Currently (Rserve 0.1-7) there is no further conversion on Rserve's side, i.e. the strings are passed to R without re-coding. If necessary the setting should be changed before connecting to the Rserve in case later Rserves will provide a possibility of setting the encoding during the handshake. */ public static String transferCharset="UTF-8"; /** authorization type: plain text */ public static final int AT_plain = 0; /** authorization type: unix crypt */ public static final int AT_crypt = 1; /** version of the server (as reported in IDstring just after Rsrv) */ protected int rsrvVersion; /** make a new local connection on default port (6311) */ public RConnection() throws RserveException { this("127.0.0.1",6311); } /** make a new connection to specified host on default port (6311) @param host host name/IP */ public RConnection(String host) throws RserveException { this(host,6311); } /** make a new connection to specified host and given port. * Make sure you check {@link #isConnected} to ensure the connection was successfully created. * @param host host name/IP * @param port TCP port */ public RConnection(String host, int port) throws RserveException { this(host, port, null); } /** restore a connection based on a previously detached session * @param session detached session object */ RConnection(RSession session) throws RserveException { this(null, 0, session); } RConnection(String host, int port, RSession session) throws RserveException { try { if (connected) s.close(); s=null; } catch (Exception e) { throw new RserveException(this,"Cannot connect: "+e.getMessage()); } if (session!=null) { host=session.host; port=session.port; } connected=false; this.host=host; this.port=port; try { s=new Socket(host,port); // disable Nagle's algorithm since we really want immediate replies s.setTcpNoDelay(true); } catch (Exception sce) { throw new RserveException(this,"Cannot connect: "+sce.getMessage()); } try { is=s.getInputStream(); os=s.getOutputStream(); } catch (Exception gse) { throw new RserveException(this,"Cannot get io stream: "+gse.getMessage()); } rt=new RTalk(is,os); if (session==null) { byte[] IDs=new byte[32]; int n=-1; try { n=is.read(IDs); } catch (Exception sre) { throw new RserveException(this,"Error while receiving data: "+sre.getMessage()); } try { if (n!=32) { throw new RserveException(this,"Handshake failed: expected 32 bytes header, got "+n); } String ids=new String(IDs); if (ids.substring(0,4).compareTo("Rsrv")!=0) throw new RserveException(this,"Handshake failed: Rsrv signature expected, but received \""+ids+"\" instead."); try { rsrvVersion=Integer.parseInt(ids.substring(4,8)); } catch (Exception px) {} // we support (knowingly) up to 103 if (rsrvVersion>103) throw new RserveException(this,"Handshake failed: The server uses more recent protocol than this client."); if (ids.substring(8,12).compareTo("QAP1")!=0) throw new RserveException(this,"Handshake failed: unupported transfer protocol ("+ids.substring(8,12)+"), I talk only QAP1."); for (int i=12;i<32;i+=4) { String attr=ids.substring(i,i+4); if (attr.compareTo("ARpt")==0) { if (!authReq) { // this method is only fallback when no other was specified authReq=true; authType=AT_plain; } } if (attr.compareTo("ARuc")==0) { authReq=true; authType=AT_crypt; } if (attr.charAt(0)=='K') { Key=attr.substring(1,3); } } } catch (RserveException innerX) { try { s.close(); } catch (Exception ex01) {}; is=null; os=null; s=null; throw innerX; } } else { // we have a session to take care of try { os.write(session.key,0,32); } catch (Exception sre) { throw new RserveException(this,"Error while sending session key: "+sre.getMessage()); } rsrvVersion = session.rsrvVersion; } connected=true; lastError="OK"; } public void finalize() { close(); is=null; os=null; } /** get server version as reported during the handshake. @return server version as integer (Rsrv0100 will return 100) */ public int getServerVersion() { return rsrvVersion; } /** closes current connection */ public boolean close() { try { if (s != null) s.close(); connected = false; return true; } catch(Exception e) { }; return false; } /** evaluates the given command, but does not fetch the result (useful for assignment operations) @param cmd command/expression string */ public void voidEval(String cmd) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_voidEval,cmd+"\n"); if (rp!=null && rp.isOk()) return; throw new RserveException(this,"voidEval failed",rp); } /** evaluates the given command, detaches the session (see @link{detach()}) and closes connection while the command is being evaluted (requires Rserve 0.4+). Note that a session cannot be attached again until the commad was successfully processed. Techincally the session is put into listening mode while the command is being evaluated but accept is called only after the command was evaluated. One commonly used techique to monitor detached working sessions is to use second connection to poll the status (e.g. create a temporary file and return the full path before detaching thus allowing new connections to read it). @param cmd command/expression string @return session object that can be use to attach back to the session once the command completed */ public RSession voidEvalDetach(String cmd) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_detachedVoidEval,cmd+"\n"); if (rp==null || !rp.isOk()) throw new RserveException(this,"detached void eval failed",rp); RSession s = new RSession(this, rp); close(); return s; } REXP parseEvalResponse(RPacket rp) throws RserveException { int rxo=0; byte[] pc=rp.getCont(); if (rsrvVersion>100) { /* since 0101 eval responds correctly by using DT_SEXP type/len header which is 4 bytes long */ rxo=4; /* we should check parameter type (should be DT_SEXP) and fail if it's not */ if (pc[0]!=RTalk.DT_SEXP && pc[0]!=(RTalk.DT_SEXP|RTalk.DT_LARGE)) throw new RserveException(this,"Error while processing eval output: SEXP (type "+RTalk.DT_SEXP+") expected but found result type "+pc[0]+"."); if (pc[0]==(RTalk.DT_SEXP|RTalk.DT_LARGE)) rxo=8; // large data need skip of 8 bytes /* warning: we are not checking or using the length - we assume that only the one SEXP is returned. This is true for the current CMD_eval implementation, but may not be in the future. */ } if (pc.length>rxo) { try { REXPFactory rx=new REXPFactory(); rx.parseREXP(pc, rxo); return rx.getREXP(); } catch (REXPMismatchException me) { me.printStackTrace(); throw new RserveException(this, "Error when parsing response: "+me.getMessage()); } } return null; } /** evaluates the given command and retrieves the result @param cmd command/expression string @return R-xpression or null if an error occured */ public REXP eval(String cmd) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_eval,cmd+"\n"); if (rp!=null && rp.isOk()) return parseEvalResponse(rp); throw new RserveException(this,"eval failed",rp); } /** assign a string value to a symbol in R. The symbol is created if it doesn't exist already. @param sym symbol name. Currently assign uses CMD_setSEXP command of Rserve, i.e. the symbol value is NOT parsed. It is the responsibility of the user to make sure that the symbol name is valid in R (recall the difference between a symbol and an expression!). In fact R will always create the symbol, but it may not be accessible (examples: "bar\nfoo" or "bar$foo"). @param ct contents */ public void assign(String sym, String ct) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); byte[] symn=sym.getBytes(); byte[] ctn=ct.getBytes(); int sl=symn.length+1; int cl=ctn.length+1; if ((sl&3)>0) sl=(sl&0xfffffc)+4; // make sure the symbol length is divisible by 4 if ((cl&3)>0) cl=(cl&0xfffffc)+4; // make sure the content length is divisible by 4 byte[] rq=new byte[sl+4+cl+4]; int ic; for(ic=0;ic0) sl=(sl&0xfffffc)+4; // make sure the symbol length is divisible by 4 byte[] rq=new byte[sl+rl+((rl>0xfffff0)?12:8)]; int ic; for(ic=0;ic0xfffff0)?12:8)); RPacket rp=rt.request(RTalk.CMD_setSEXP,rq); if (rp!=null && rp.isOk()) return; throw new RserveException(this,"assign failed",rp); } catch (REXPMismatchException me) { throw new RserveException(this, "Error creating binary representation: "+me.getMessage()); } } /** open a file on the Rserve for reading @param fn file name. should not contain any path delimiters, since Rserve may restrict the access to local working directory. @return input stream to be used for reading. Note that the stream is read-once only, there is no support for seek or rewind. */ public RFileInputStream openFile(String fn) throws IOException { return new RFileInputStream(rt,fn); } /** create a file on the Rserve for writing @param fn file name. should not contain any path delimiters, since Rserve may restrict the access to local working directory. @return output stream to be used for writinging. Note that the stream is write-once only, there is no support for seek or rewind. */ public RFileOutputStream createFile(String fn) throws IOException { return new RFileOutputStream(rt,fn); } /** remove a file on the Rserve @param fn file name. should not contain any path delimiters, since Rserve may restrict the access to local working directory. */ public void removeFile(String fn) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_removeFile,fn); if (rp!=null && rp.isOk()) return; throw new RserveException(this,"removeFile failed",rp); } /** shutdown remote Rserve. Note that some Rserves cannot be shut down from the client side. */ public void shutdown() throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_shutdown); if (rp!=null && rp.isOk()) return; throw new RserveException(this,"shutdown failed",rp); } /** Sets send buffer size of the Rserve (in bytes) for the current connection. All responses send by Rserve are stored in the send buffer before transmitting. This means that any objects you want to get from the Rserve need to fit into that buffer. By default the size of the send buffer is 2MB. If you need to receive larger objects from Rserve, you will need to use this function to enlarge the buffer. In order to save memory, you can also reduce the buffer size once it's not used anymore. Currently the buffer size is only limited by the memory available and/or 1GB (whichever is smaller). Current Rserve implementations won't go below buffer sizes of 32kb though. If the specified buffer size results in 'out of memory' on the server, the corresponding error is sent and the connection is terminated.
Note: This command may go away in future versions of Rserve which will use dynamic send buffer allocation. @param sbs send buffer size (in bytes) min=32k, max=1GB */ public void setSendBufferSize(long sbs) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_setBufferSize,(int)sbs); if (rp!=null && rp.isOk()) return; throw new RserveException(this,"setSendBufferSize failed",rp); } /** set string encoding for this session. It is strongly * recommended to make sure the encoding is always set to UTF-8 * because that is the only encoding supported by this Java * client. It can be done either by uisng the * encoding option in the server or by calling * setStringEncoding("utf8") at the beginning of a session (but * after login). @param enc name of the encoding as defined by Rserve - as of Rserve version 0.5-3 valid values are "utf8", "latin1" and "native" (case-sensitive) @since Rserve 0.5-3 */ public void setStringEncoding(String enc) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp = rt.request(RTalk.CMD_setEncoding, enc); if (rp != null && rp.isOk()) return; throw new RserveException(this,"setStringEncoding failed", rp); } /** login using supplied user/pwd. Note that login must be the first command if used @param user username @param pwd password */ public void login(String user, String pwd) throws RserveException { if (!authReq) return; if (!connected || rt==null) throw new RserveException(this,"Not connected"); if (authType==AT_crypt) { if (Key==null) Key="rs"; RPacket rp=rt.request(RTalk.CMD_login,user+"\n"+jcrypt.crypt(Key,pwd)); if (rp!=null && rp.isOk()) return; try { s.close(); } catch(Exception e) {}; is=null; os=null; s=null; connected=false; throw new RserveException(this,"login failed",rp); } RPacket rp=rt.request(RTalk.CMD_login,user+"\n"+pwd); if (rp!=null && rp.isOk()) return; try {s.close();} catch (Exception e) {}; is=null; os=null; s=null; connected=false; throw new RserveException(this,"login failed",rp); } /** detaches the session and closes the connection (requires Rserve 0.4+). The session can be only resumed by calling @link{RSession.attach} */ public RSession detach() throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_detachSession); if (rp==null || !rp.isOk()) throw new RserveException(this,"Cannot detach",rp); RSession s = new RSession(this, rp); close(); return s; } /** check connection state. Note that currently this state is not checked on-the-spot, that is if connection went down by an outside event this is not reflected by the flag @return true if this connection is alive */ public boolean isConnected() { return connected; } /** check authentication requirement sent by server @return true is server requires authentication. In such case first command after connecting must be {@link #login}. */ public boolean needLogin() { return authReq; } /** get last error string @return last error string */ public String getLastError() { return lastError; } /** evaluates the given command in the master server process asynchronously (control command). Note that control commands are always asynchronous, i.e., the expression is enqueued for evaluation in the master process and the method returns before the expression is evaluated (in non-parallel builds the client has to close the connection before the expression can be evaluated). There is no way to check for errors and control commands should be sent with utmost care as they can abort the server process. The evaluation has no immediate effect on the client session. * @param cmd command/expression string * @since Rserve 0.6-0 */ public void serverEval(String cmd) throws RserveException { if (!connected || rt == null) throw new RserveException(this, "Not connected"); RPacket rp = rt.request(RTalk.CMD_ctrlEval, cmd+"\n"); if (rp != null && rp.isOk()) return; throw new RserveException(this,"serverEval failed",rp); } /** sources the given file (the path must be local to the server!) in the master server process asynchronously (control command). See {@link #serverEval()} for details on control commands. * @param serverFile path to a file on the server (it is recommended to always use full paths, because the server process has a different working directory than the client child process!). * @since Rserve 0.6-0 */ public void serverSource(String serverFile) throws RserveException { if (!connected || rt == null) throw new RserveException(this, "Not connected"); RPacket rp = rt.request(RTalk.CMD_ctrlSource, serverFile); if (rp != null && rp.isOk()) return; throw new RserveException(this,"serverSource failed",rp); } /** attempt to shut down the server process cleanly. Note that there is a fundamental difference between the {@link shutdown()} method and this method: serverShutdown() is a proper control command and thus fully authentication controllable, whereas {@link shutdown()} is a client-side command sent to the client child process and thus relying on the ability of the client to signal the server process which may be disabled. Therefore serverShutdown() is preferred and more reliable for Rserve 0.6-0 and higher. * @since Rserve 0.6-0 */ public void serverShutdown() throws RserveException { if (!connected || rt == null) throw new RserveException(this, "Not connected"); RPacket rp = rt.request(RTalk.CMD_ctrlShutdown); if (rp != null && rp.isOk()) return; throw new RserveException(this,"serverShutdown failed",rp); } //========= REngine interface API public REXP parse(String text, boolean resolve) throws REngineException { throw new REngineException(this, "Rserve doesn't support separate parsing step."); } public REXP eval(REXP what, REXP where, boolean resolve) throws REngineException { return new REXPNull(); } public REXP parseAndEval(String text, REXP where, boolean resolve) throws REngineException { if (where!=null) throw new REngineException(this, "Rserve doesn't support environments other than .GlobalEnv"); try { return eval(text); } catch (RserveException re) { throw new REngineException(this, re.getMessage()); } } /** assign into an environment @param symbol symbol name @param value value to assign @param env environment to assign to */ public void assign(String symbol, REXP value, REXP env) throws REngineException { if (env!=null) throw new REngineException(this, "Rserve doesn't support environments other than .GlobalEnv"); try { assign(symbol, value); } catch (RserveException re) { throw new REngineException(this, re.getMessage()); } } /** get a value from an environment @param symbol symbol name @param env environment @param resolve resolve the resulting REXP or just return a reference @return value */ public REXP get(String symbol, REXP env, boolean resolve) throws REngineException { if (!resolve) throw new REngineException(this, "Rserve doesn't support references"); try { return eval("get(\""+symbol+"\")"); } catch (RserveException re) { throw new REngineException(this, re.getMessage()); } } /** fetch the contents of the given reference. The resulting REXP may never be REXPReference. @param ref reference to resolve @return resolved reference */ public REXP resolveReference(REXP ref) throws REngineException { throw new REngineException(this, "Rserve doesn't support references"); } public REXP createReference(REXP ref) throws REngineException { throw new REngineException(this, "Rserve doesn't support references"); } public void finalizeReference(REXP ref) throws REngineException { throw new REngineException(this, "Rserve doesn't support references"); } public REXP getParentEnvironment(REXP env, boolean resolve) throws REngineException { throw new REngineException(this, "Rserve doesn't support environments other than .GlobalEnv"); } public REXP newEnvironment(REXP parent, boolean resolve) throws REngineException { throw new REngineException(this, "Rserve doesn't support environments other than .GlobalEnv"); } } Rserve/src/client/java/Rserve/protocol/0000755000176000001440000000000012205226215017642 5ustar ripleyusersRserve/src/client/java/Rserve/protocol/RTalk.java0000644000176000001440000002353712205226215021534 0ustar ripleyuserspackage org.rosuda.REngine.Rserve.protocol; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- import java.util.*; import java.io.*; import java.net.*; import org.rosuda.REngine.Rserve.RConnection; /** This class encapsulates the QAP1 protocol used by Rserv. it is independent of the underying protocol(s), therefore RTalk can be used over any transport layer

The current implementation supports long (0.3+/0102) data format only up to 32-bit and only for incoming packets.

@version $Id$ */ public class RTalk { public static final int DT_INT=1; public static final int DT_CHAR=2; public static final int DT_DOUBLE=3; public static final int DT_STRING=4; public static final int DT_BYTESTREAM=5; public static final int DT_SEXP=10; public static final int DT_ARRAY=11; /** this is a flag saying that the contents is large (>0xfffff0) and hence uses 56-bit length field */ public static final int DT_LARGE=64; public static final int CMD_login=0x001; public static final int CMD_voidEval=0x002; public static final int CMD_eval=0x003; public static final int CMD_shutdown=0x004; public static final int CMD_openFile=0x010; public static final int CMD_createFile=0x011; public static final int CMD_closeFile=0x012; public static final int CMD_readFile=0x013; public static final int CMD_writeFile=0x014; public static final int CMD_removeFile=0x015; public static final int CMD_setSEXP=0x020; public static final int CMD_assignSEXP=0x021; public static final int CMD_setBufferSize=0x081; public static final int CMD_setEncoding=0x082; public static final int CMD_detachSession=0x030; public static final int CMD_detachedVoidEval=0x031; public static final int CMD_attachSession=0x032; // control commands since 0.6-0 public static final int CMD_ctrlEval=0x42; public static final int CMD_ctrlSource=0x45; public static final int CMD_ctrlShutdown=0x44; // errors as returned by Rserve public static final int ERR_auth_failed=0x41; public static final int ERR_conn_broken=0x42; public static final int ERR_inv_cmd=0x43; public static final int ERR_inv_par=0x44; public static final int ERR_Rerror=0x45; public static final int ERR_IOerror=0x46; public static final int ERR_not_open=0x47; public static final int ERR_access_denied=0x48; public static final int ERR_unsupported_cmd=0x49; public static final int ERR_unknown_cmd=0x4a; public static final int ERR_data_overflow=0x4b; public static final int ERR_object_too_big=0x4c; public static final int ERR_out_of_mem=0x4d; public static final int ERR_ctrl_closed=0x4e; public static final int ERR_session_busy=0x50; public static final int ERR_detach_failed=0x51; InputStream is; OutputStream os; /** constructor; parameters specify the streams @param sis socket input stream @param sos socket output stream */ public RTalk(InputStream sis, OutputStream sos) { is=sis; os=sos; } /** writes bit-wise int to a byte buffer at specified position in Intel-endian form @param v value to be written @param buf buffer @param o offset in the buffer to start at. An int takes always 4 bytes */ public static void setInt(int v, byte[] buf, int o) { buf[o]=(byte)(v&255); o++; buf[o]=(byte)((v&0xff00)>>8); o++; buf[o]=(byte)((v&0xff0000)>>16); o++; buf[o]=(byte)((v&0xff000000)>>24); } /** writes cmd/resp/type byte + 3/7 bytes len into a byte buffer at specified offset. @param ty type/cmd/resp byte @param len length @param buf buffer @param o offset @return offset in buf just after the header. Please note that since Rserve 0.3 the header can be either 4 or 8 bytes long, depending on the len parameter. */ public static int setHdr(int ty, int len, byte[] buf, int o) { buf[o]=(byte)((ty&255)|((len>0xfffff0)?DT_LARGE:0)); o++; buf[o]=(byte)(len&255); o++; buf[o]=(byte)((len&0xff00)>>8); o++; buf[o]=(byte)((len&0xff0000)>>16); o++; if (len>0xfffff0) { // for large data we need to set the next 4 bytes as well buf[o]=(byte)((len&0xff000000)>>24); o++; buf[o]=0; o++; // since len is int, we get 32-bits only buf[o]=0; o++; buf[o]=0; o++; } return o; } /** creates a new header according to the type and length of the parameter @param ty type/cmd/resp byte @param len length */ public static byte[] newHdr(int ty, int len) { byte[] hdr=new byte[(len>0xfffff0)?8:4]; setHdr(ty,len,hdr,0); return hdr; } /** converts bit-wise stored int in Intel-endian form into Java int @param buf buffer containg the representation @param o offset where to start (4 bytes will be used) @return the int value. no bounds checking is done so you need to make sure that the buffer is big enough */ public static int getInt(byte[] buf, int o) { return ((buf[o]&255)|((buf[o+1]&255)<<8)|((buf[o+2]&255)<<16)|((buf[o+3]&255)<<24)); } /** converts bit-wise stored length from a header. "long" format is supported up to 32-bit @param buf buffer @param o offset of the header (length is at o+1) @return length */ public static int getLen(byte[] buf, int o) { return ((buf[o]&64)>0)? // "long" format; still - we support 32-bit only ((buf[o+1]&255)|((buf[o+2]&255)<<8)|((buf[o+3]&255)<<16)|((buf[o+4]&255)<<24)) : ((buf[o+1]&255)|((buf[o+2]&255)<<8)|((buf[o+3]&255)<<16)); } /** converts bit-wise Intel-endian format into long @param buf buffer @param o offset (8 bytes will be used) @return long value */ public static long getLong(byte[] buf, int o) { long low=((long)getInt(buf,o))&0xffffffffL; long hi=((long)getInt(buf,o+4))&0xffffffffL; hi<<=32; hi|=low; return hi; } public static void setLong(long l, byte[] buf, int o) { setInt((int)(l&0xffffffffL),buf,o); setInt((int)(l>>32),buf,o+4); } /** sends a request with no attached parameters @param cmd command @return returned packet or null if something went wrong */ public RPacket request(int cmd) { byte[] d = new byte[0]; return request(cmd,d); } /** sends a request with attached parameters @param cmd command @param cont contents - parameters @return returned packet or null if something went wrong */ public RPacket request(int cmd, byte[] cont) { return request(cmd,null,cont,0,(cont==null)?0:cont.length); } /** sends a request with attached prefix and parameters. Both prefix and cont can be null. Effectively request(a,b,null) and request(a,null,b) are equivalent. @param cmd command - a special command of -1 prevents request from sending anything @param prefix - this content is sent *before* cont. It is provided to save memory copy operations where a small header precedes a large data chunk (usually prefix conatins the parameter header and cont contains the actual data). @param cont contents @param offset offset in cont where to start sending (if <0 then 0 is assumed, if >cont.length then no cont is sent) @param len number of bytes in cont to send (it is clipped to the length of cont if necessary) @return returned packet or null if something went wrong */ public RPacket request(int cmd, byte[] prefix, byte[] cont, int offset, int len) { if (cont!=null) { if (offset>=cont.length) { cont=null; len=0; } else if (len>cont.length-offset) len=cont.length-offset; } if (offset<0) offset=0; if (len<0) len=0; int contlen=(cont==null)?0:len; if (prefix!=null && prefix.length>0) contlen+=prefix.length; byte[] hdr=new byte[16]; setInt(cmd,hdr,0); setInt(contlen,hdr,4); for(int i=8;i<16;i++) hdr[i]=0; try { if (cmd!=-1) { os.write(hdr); if (prefix!=null && prefix.length>0) os.write(prefix); if (cont!=null && cont.length>0) os.write(cont,offset,len); } byte[] ih=new byte[16]; if (is.read(ih)!=16) return null; int rep=getInt(ih,0); int rl =getInt(ih,4); if (rl>0) { byte[] ct=new byte[rl]; int n=0; while (nnull if something went wrong */ public RPacket request(int cmd, String par) { try { byte[] b=par.getBytes(RConnection.transferCharset); int sl=b.length+1; if ((sl&3)>0) sl=(sl&0xfffffc)+4; // make sure the length is divisible by 4 byte[] rq=new byte[sl+5]; int i; for(i=0;inull if something went wrong */ public RPacket request(int cmd, int par) { try { byte[] rq=new byte[8]; setInt(par,rq,4); setHdr(DT_INT,4,rq,0); return request(cmd,rq); } catch (Exception e) { }; return null; } } Rserve/src/client/java/Rserve/protocol/RPacket.java0000644000176000001440000000242412205226215022040 0ustar ripleyuserspackage org.rosuda.REngine.Rserve.protocol; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- /** small class encapsulating packets from/to Rserv @version $Id$ */ public class RPacket { int cmd; byte[] cont; /** construct new packet @param Rcmd command @param Rcont content */ public RPacket(int Rcmd, byte[] Rcont) { cmd=Rcmd; cont=Rcont; } /** get command @return command */ public int getCmd() { return cmd; } /** check last response for RESP_OK @return true if last response was OK */ public boolean isOk() { return ((cmd&15)==1); } /** check last response for RESP_ERR @return true if last response was ERROR */ public boolean isError() { return ((cmd&15)==2); } /** get status code of last response @return status code returned on last response */ public int getStat() { return ((cmd>>24)&127); } /** get content @return inner package content */ public byte[] getCont() { return cont; } public String toString() { return "RPacket[cmd="+cmd+",len="+((cont==null)?"":(""+cont.length))+"]"; } } Rserve/src/client/java/Rserve/protocol/jcrypt.java0000644000176000001440000005731612205226215022034 0ustar ripleyuserspackage org.rosuda.REngine.Rserve.protocol; /**************************************************************************** * jcrypt.java * * Java-based implementation of the unix crypt command * * Based upon C source code written by Eric Young, eay@psych.uq.oz.au * ****************************************************************************/ public class jcrypt { private static final int ITERATIONS = 16; private static final int con_salt[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, }; private static final boolean shifts2[] = { false, false, true, true, true, true, true, true, false, true, true, true, true, true, true, false }; private static final int skb[][] = { { /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ 0x00000000, 0x00000010, 0x20000000, 0x20000010, 0x00010000, 0x00010010, 0x20010000, 0x20010010, 0x00000800, 0x00000810, 0x20000800, 0x20000810, 0x00010800, 0x00010810, 0x20010800, 0x20010810, 0x00000020, 0x00000030, 0x20000020, 0x20000030, 0x00010020, 0x00010030, 0x20010020, 0x20010030, 0x00000820, 0x00000830, 0x20000820, 0x20000830, 0x00010820, 0x00010830, 0x20010820, 0x20010830, 0x00080000, 0x00080010, 0x20080000, 0x20080010, 0x00090000, 0x00090010, 0x20090000, 0x20090010, 0x00080800, 0x00080810, 0x20080800, 0x20080810, 0x00090800, 0x00090810, 0x20090800, 0x20090810, 0x00080020, 0x00080030, 0x20080020, 0x20080030, 0x00090020, 0x00090030, 0x20090020, 0x20090030, 0x00080820, 0x00080830, 0x20080820, 0x20080830, 0x00090820, 0x00090830, 0x20090820, 0x20090830, }, { /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ 0x00000000, 0x02000000, 0x00002000, 0x02002000, 0x00200000, 0x02200000, 0x00202000, 0x02202000, 0x00000004, 0x02000004, 0x00002004, 0x02002004, 0x00200004, 0x02200004, 0x00202004, 0x02202004, 0x00000400, 0x02000400, 0x00002400, 0x02002400, 0x00200400, 0x02200400, 0x00202400, 0x02202400, 0x00000404, 0x02000404, 0x00002404, 0x02002404, 0x00200404, 0x02200404, 0x00202404, 0x02202404, 0x10000000, 0x12000000, 0x10002000, 0x12002000, 0x10200000, 0x12200000, 0x10202000, 0x12202000, 0x10000004, 0x12000004, 0x10002004, 0x12002004, 0x10200004, 0x12200004, 0x10202004, 0x12202004, 0x10000400, 0x12000400, 0x10002400, 0x12002400, 0x10200400, 0x12200400, 0x10202400, 0x12202400, 0x10000404, 0x12000404, 0x10002404, 0x12002404, 0x10200404, 0x12200404, 0x10202404, 0x12202404, }, { /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ 0x00000000, 0x00000001, 0x00040000, 0x00040001, 0x01000000, 0x01000001, 0x01040000, 0x01040001, 0x00000002, 0x00000003, 0x00040002, 0x00040003, 0x01000002, 0x01000003, 0x01040002, 0x01040003, 0x00000200, 0x00000201, 0x00040200, 0x00040201, 0x01000200, 0x01000201, 0x01040200, 0x01040201, 0x00000202, 0x00000203, 0x00040202, 0x00040203, 0x01000202, 0x01000203, 0x01040202, 0x01040203, 0x08000000, 0x08000001, 0x08040000, 0x08040001, 0x09000000, 0x09000001, 0x09040000, 0x09040001, 0x08000002, 0x08000003, 0x08040002, 0x08040003, 0x09000002, 0x09000003, 0x09040002, 0x09040003, 0x08000200, 0x08000201, 0x08040200, 0x08040201, 0x09000200, 0x09000201, 0x09040200, 0x09040201, 0x08000202, 0x08000203, 0x08040202, 0x08040203, 0x09000202, 0x09000203, 0x09040202, 0x09040203, }, { /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ 0x00000000, 0x00100000, 0x00000100, 0x00100100, 0x00000008, 0x00100008, 0x00000108, 0x00100108, 0x00001000, 0x00101000, 0x00001100, 0x00101100, 0x00001008, 0x00101008, 0x00001108, 0x00101108, 0x04000000, 0x04100000, 0x04000100, 0x04100100, 0x04000008, 0x04100008, 0x04000108, 0x04100108, 0x04001000, 0x04101000, 0x04001100, 0x04101100, 0x04001008, 0x04101008, 0x04001108, 0x04101108, 0x00020000, 0x00120000, 0x00020100, 0x00120100, 0x00020008, 0x00120008, 0x00020108, 0x00120108, 0x00021000, 0x00121000, 0x00021100, 0x00121100, 0x00021008, 0x00121008, 0x00021108, 0x00121108, 0x04020000, 0x04120000, 0x04020100, 0x04120100, 0x04020008, 0x04120008, 0x04020108, 0x04120108, 0x04021000, 0x04121000, 0x04021100, 0x04121100, 0x04021008, 0x04121008, 0x04021108, 0x04121108, }, { /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ 0x00000000, 0x10000000, 0x00010000, 0x10010000, 0x00000004, 0x10000004, 0x00010004, 0x10010004, 0x20000000, 0x30000000, 0x20010000, 0x30010000, 0x20000004, 0x30000004, 0x20010004, 0x30010004, 0x00100000, 0x10100000, 0x00110000, 0x10110000, 0x00100004, 0x10100004, 0x00110004, 0x10110004, 0x20100000, 0x30100000, 0x20110000, 0x30110000, 0x20100004, 0x30100004, 0x20110004, 0x30110004, 0x00001000, 0x10001000, 0x00011000, 0x10011000, 0x00001004, 0x10001004, 0x00011004, 0x10011004, 0x20001000, 0x30001000, 0x20011000, 0x30011000, 0x20001004, 0x30001004, 0x20011004, 0x30011004, 0x00101000, 0x10101000, 0x00111000, 0x10111000, 0x00101004, 0x10101004, 0x00111004, 0x10111004, 0x20101000, 0x30101000, 0x20111000, 0x30111000, 0x20101004, 0x30101004, 0x20111004, 0x30111004, }, { /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ 0x00000000, 0x08000000, 0x00000008, 0x08000008, 0x00000400, 0x08000400, 0x00000408, 0x08000408, 0x00020000, 0x08020000, 0x00020008, 0x08020008, 0x00020400, 0x08020400, 0x00020408, 0x08020408, 0x00000001, 0x08000001, 0x00000009, 0x08000009, 0x00000401, 0x08000401, 0x00000409, 0x08000409, 0x00020001, 0x08020001, 0x00020009, 0x08020009, 0x00020401, 0x08020401, 0x00020409, 0x08020409, 0x02000000, 0x0A000000, 0x02000008, 0x0A000008, 0x02000400, 0x0A000400, 0x02000408, 0x0A000408, 0x02020000, 0x0A020000, 0x02020008, 0x0A020008, 0x02020400, 0x0A020400, 0x02020408, 0x0A020408, 0x02000001, 0x0A000001, 0x02000009, 0x0A000009, 0x02000401, 0x0A000401, 0x02000409, 0x0A000409, 0x02020001, 0x0A020001, 0x02020009, 0x0A020009, 0x02020401, 0x0A020401, 0x02020409, 0x0A020409, }, { /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ 0x00000000, 0x00000100, 0x00080000, 0x00080100, 0x01000000, 0x01000100, 0x01080000, 0x01080100, 0x00000010, 0x00000110, 0x00080010, 0x00080110, 0x01000010, 0x01000110, 0x01080010, 0x01080110, 0x00200000, 0x00200100, 0x00280000, 0x00280100, 0x01200000, 0x01200100, 0x01280000, 0x01280100, 0x00200010, 0x00200110, 0x00280010, 0x00280110, 0x01200010, 0x01200110, 0x01280010, 0x01280110, 0x00000200, 0x00000300, 0x00080200, 0x00080300, 0x01000200, 0x01000300, 0x01080200, 0x01080300, 0x00000210, 0x00000310, 0x00080210, 0x00080310, 0x01000210, 0x01000310, 0x01080210, 0x01080310, 0x00200200, 0x00200300, 0x00280200, 0x00280300, 0x01200200, 0x01200300, 0x01280200, 0x01280300, 0x00200210, 0x00200310, 0x00280210, 0x00280310, 0x01200210, 0x01200310, 0x01280210, 0x01280310, }, { /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ 0x00000000, 0x04000000, 0x00040000, 0x04040000, 0x00000002, 0x04000002, 0x00040002, 0x04040002, 0x00002000, 0x04002000, 0x00042000, 0x04042000, 0x00002002, 0x04002002, 0x00042002, 0x04042002, 0x00000020, 0x04000020, 0x00040020, 0x04040020, 0x00000022, 0x04000022, 0x00040022, 0x04040022, 0x00002020, 0x04002020, 0x00042020, 0x04042020, 0x00002022, 0x04002022, 0x00042022, 0x04042022, 0x00000800, 0x04000800, 0x00040800, 0x04040800, 0x00000802, 0x04000802, 0x00040802, 0x04040802, 0x00002800, 0x04002800, 0x00042800, 0x04042800, 0x00002802, 0x04002802, 0x00042802, 0x04042802, 0x00000820, 0x04000820, 0x00040820, 0x04040820, 0x00000822, 0x04000822, 0x00040822, 0x04040822, 0x00002820, 0x04002820, 0x00042820, 0x04042820, 0x00002822, 0x04002822, 0x00042822, 0x04042822, }, }; private static final int SPtrans[][] = { { /* nibble 0 */ 0x00820200, 0x00020000, 0x80800000, 0x80820200, 0x00800000, 0x80020200, 0x80020000, 0x80800000, 0x80020200, 0x00820200, 0x00820000, 0x80000200, 0x80800200, 0x00800000, 0x00000000, 0x80020000, 0x00020000, 0x80000000, 0x00800200, 0x00020200, 0x80820200, 0x00820000, 0x80000200, 0x00800200, 0x80000000, 0x00000200, 0x00020200, 0x80820000, 0x00000200, 0x80800200, 0x80820000, 0x00000000, 0x00000000, 0x80820200, 0x00800200, 0x80020000, 0x00820200, 0x00020000, 0x80000200, 0x00800200, 0x80820000, 0x00000200, 0x00020200, 0x80800000, 0x80020200, 0x80000000, 0x80800000, 0x00820000, 0x80820200, 0x00020200, 0x00820000, 0x80800200, 0x00800000, 0x80000200, 0x80020000, 0x00000000, 0x00020000, 0x00800000, 0x80800200, 0x00820200, 0x80000000, 0x80820000, 0x00000200, 0x80020200, }, { /* nibble 1 */ 0x10042004, 0x00000000, 0x00042000, 0x10040000, 0x10000004, 0x00002004, 0x10002000, 0x00042000, 0x00002000, 0x10040004, 0x00000004, 0x10002000, 0x00040004, 0x10042000, 0x10040000, 0x00000004, 0x00040000, 0x10002004, 0x10040004, 0x00002000, 0x00042004, 0x10000000, 0x00000000, 0x00040004, 0x10002004, 0x00042004, 0x10042000, 0x10000004, 0x10000000, 0x00040000, 0x00002004, 0x10042004, 0x00040004, 0x10042000, 0x10002000, 0x00042004, 0x10042004, 0x00040004, 0x10000004, 0x00000000, 0x10000000, 0x00002004, 0x00040000, 0x10040004, 0x00002000, 0x10000000, 0x00042004, 0x10002004, 0x10042000, 0x00002000, 0x00000000, 0x10000004, 0x00000004, 0x10042004, 0x00042000, 0x10040000, 0x10040004, 0x00040000, 0x00002004, 0x10002000, 0x10002004, 0x00000004, 0x10040000, 0x00042000, }, { /* nibble 2 */ 0x41000000, 0x01010040, 0x00000040, 0x41000040, 0x40010000, 0x01000000, 0x41000040, 0x00010040, 0x01000040, 0x00010000, 0x01010000, 0x40000000, 0x41010040, 0x40000040, 0x40000000, 0x41010000, 0x00000000, 0x40010000, 0x01010040, 0x00000040, 0x40000040, 0x41010040, 0x00010000, 0x41000000, 0x41010000, 0x01000040, 0x40010040, 0x01010000, 0x00010040, 0x00000000, 0x01000000, 0x40010040, 0x01010040, 0x00000040, 0x40000000, 0x00010000, 0x40000040, 0x40010000, 0x01010000, 0x41000040, 0x00000000, 0x01010040, 0x00010040, 0x41010000, 0x40010000, 0x01000000, 0x41010040, 0x40000000, 0x40010040, 0x41000000, 0x01000000, 0x41010040, 0x00010000, 0x01000040, 0x41000040, 0x00010040, 0x01000040, 0x00000000, 0x41010000, 0x40000040, 0x41000000, 0x40010040, 0x00000040, 0x01010000, }, { /* nibble 3 */ 0x00100402, 0x04000400, 0x00000002, 0x04100402, 0x00000000, 0x04100000, 0x04000402, 0x00100002, 0x04100400, 0x04000002, 0x04000000, 0x00000402, 0x04000002, 0x00100402, 0x00100000, 0x04000000, 0x04100002, 0x00100400, 0x00000400, 0x00000002, 0x00100400, 0x04000402, 0x04100000, 0x00000400, 0x00000402, 0x00000000, 0x00100002, 0x04100400, 0x04000400, 0x04100002, 0x04100402, 0x00100000, 0x04100002, 0x00000402, 0x00100000, 0x04000002, 0x00100400, 0x04000400, 0x00000002, 0x04100000, 0x04000402, 0x00000000, 0x00000400, 0x00100002, 0x00000000, 0x04100002, 0x04100400, 0x00000400, 0x04000000, 0x04100402, 0x00100402, 0x00100000, 0x04100402, 0x00000002, 0x04000400, 0x00100402, 0x00100002, 0x00100400, 0x04100000, 0x04000402, 0x00000402, 0x04000000, 0x04000002, 0x04100400, }, { /* nibble 4 */ 0x02000000, 0x00004000, 0x00000100, 0x02004108, 0x02004008, 0x02000100, 0x00004108, 0x02004000, 0x00004000, 0x00000008, 0x02000008, 0x00004100, 0x02000108, 0x02004008, 0x02004100, 0x00000000, 0x00004100, 0x02000000, 0x00004008, 0x00000108, 0x02000100, 0x00004108, 0x00000000, 0x02000008, 0x00000008, 0x02000108, 0x02004108, 0x00004008, 0x02004000, 0x00000100, 0x00000108, 0x02004100, 0x02004100, 0x02000108, 0x00004008, 0x02004000, 0x00004000, 0x00000008, 0x02000008, 0x02000100, 0x02000000, 0x00004100, 0x02004108, 0x00000000, 0x00004108, 0x02000000, 0x00000100, 0x00004008, 0x02000108, 0x00000100, 0x00000000, 0x02004108, 0x02004008, 0x02004100, 0x00000108, 0x00004000, 0x00004100, 0x02004008, 0x02000100, 0x00000108, 0x00000008, 0x00004108, 0x02004000, 0x02000008, }, { /* nibble 5 */ 0x20000010, 0x00080010, 0x00000000, 0x20080800, 0x00080010, 0x00000800, 0x20000810, 0x00080000, 0x00000810, 0x20080810, 0x00080800, 0x20000000, 0x20000800, 0x20000010, 0x20080000, 0x00080810, 0x00080000, 0x20000810, 0x20080010, 0x00000000, 0x00000800, 0x00000010, 0x20080800, 0x20080010, 0x20080810, 0x20080000, 0x20000000, 0x00000810, 0x00000010, 0x00080800, 0x00080810, 0x20000800, 0x00000810, 0x20000000, 0x20000800, 0x00080810, 0x20080800, 0x00080010, 0x00000000, 0x20000800, 0x20000000, 0x00000800, 0x20080010, 0x00080000, 0x00080010, 0x20080810, 0x00080800, 0x00000010, 0x20080810, 0x00080800, 0x00080000, 0x20000810, 0x20000010, 0x20080000, 0x00080810, 0x00000000, 0x00000800, 0x20000010, 0x20000810, 0x20080800, 0x20080000, 0x00000810, 0x00000010, 0x20080010, }, { /* nibble 6 */ 0x00001000, 0x00000080, 0x00400080, 0x00400001, 0x00401081, 0x00001001, 0x00001080, 0x00000000, 0x00400000, 0x00400081, 0x00000081, 0x00401000, 0x00000001, 0x00401080, 0x00401000, 0x00000081, 0x00400081, 0x00001000, 0x00001001, 0x00401081, 0x00000000, 0x00400080, 0x00400001, 0x00001080, 0x00401001, 0x00001081, 0x00401080, 0x00000001, 0x00001081, 0x00401001, 0x00000080, 0x00400000, 0x00001081, 0x00401000, 0x00401001, 0x00000081, 0x00001000, 0x00000080, 0x00400000, 0x00401001, 0x00400081, 0x00001081, 0x00001080, 0x00000000, 0x00000080, 0x00400001, 0x00000001, 0x00400080, 0x00000000, 0x00400081, 0x00400080, 0x00001080, 0x00000081, 0x00001000, 0x00401081, 0x00400000, 0x00401080, 0x00000001, 0x00001001, 0x00401081, 0x00400001, 0x00401080, 0x00401000, 0x00001001, }, { /* nibble 7 */ 0x08200020, 0x08208000, 0x00008020, 0x00000000, 0x08008000, 0x00200020, 0x08200000, 0x08208020, 0x00000020, 0x08000000, 0x00208000, 0x00008020, 0x00208020, 0x08008020, 0x08000020, 0x08200000, 0x00008000, 0x00208020, 0x00200020, 0x08008000, 0x08208020, 0x08000020, 0x00000000, 0x00208000, 0x08000000, 0x00200000, 0x08008020, 0x08200020, 0x00200000, 0x00008000, 0x08208000, 0x00000020, 0x00200000, 0x00008000, 0x08000020, 0x08208020, 0x00008020, 0x08000000, 0x00000000, 0x00208000, 0x08200020, 0x08008020, 0x08008000, 0x00200020, 0x08208000, 0x00000020, 0x00200020, 0x08008000, 0x08208020, 0x00200000, 0x08200000, 0x08000020, 0x00208000, 0x00008020, 0x08008020, 0x08200000, 0x00000020, 0x08208000, 0x00208020, 0x00000000, 0x08000000, 0x08200020, 0x00008000, 0x00208020 } }; private static final int cov_2char[] = { 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A }; private static final int byteToUnsigned(byte b) { int value = (int)b; return(value >= 0 ? value : value + 256); } private static int fourBytesToInt(byte b[], int offset) { int value; value = byteToUnsigned(b[offset++]); value |= (byteToUnsigned(b[offset++]) << 8); value |= (byteToUnsigned(b[offset++]) << 16); value |= (byteToUnsigned(b[offset++]) << 24); return(value); } private static final void intToFourBytes(int iValue, byte b[], int offset) { b[offset++] = (byte)((iValue) & 0xff); b[offset++] = (byte)((iValue >>> 8 ) & 0xff); b[offset++] = (byte)((iValue >>> 16) & 0xff); b[offset++] = (byte)((iValue >>> 24) & 0xff); } private static final void PERM_OP(int a, int b, int n, int m, int results[]) { int t; t = ((a >>> n) ^ b) & m; a ^= t << n; b ^= t; results[0] = a; results[1] = b; } private static final int HPERM_OP(int a, int n, int m) { int t; t = ((a << (16 - n)) ^ a) & m; a = a ^ t ^ (t >>> (16 - n)); return(a); } private static int [] des_set_key(byte key[]) { int schedule[] = new int[ITERATIONS * 2]; int c = fourBytesToInt(key, 0); int d = fourBytesToInt(key, 4); int results[] = new int[2]; PERM_OP(d, c, 4, 0x0f0f0f0f, results); d = results[0]; c = results[1]; c = HPERM_OP(c, -2, 0xcccc0000); d = HPERM_OP(d, -2, 0xcccc0000); PERM_OP(d, c, 1, 0x55555555, results); d = results[0]; c = results[1]; PERM_OP(c, d, 8, 0x00ff00ff, results); c = results[0]; d = results[1]; PERM_OP(d, c, 1, 0x55555555, results); d = results[0]; c = results[1]; d = (((d & 0x000000ff) << 16) | (d & 0x0000ff00) | ((d & 0x00ff0000) >>> 16) | ((c & 0xf0000000) >>> 4)); c &= 0x0fffffff; int s, t; int j = 0; for(int i = 0; i < ITERATIONS; i ++) { if(shifts2[i]) { c = (c >>> 2) | (c << 26); d = (d >>> 2) | (d << 26); } else { c = (c >>> 1) | (c << 27); d = (d >>> 1) | (d << 27); } c &= 0x0fffffff; d &= 0x0fffffff; s = skb[0][ (c ) & 0x3f ]| skb[1][((c >>> 6) & 0x03) | ((c >>> 7) & 0x3c)]| skb[2][((c >>> 13) & 0x0f) | ((c >>> 14) & 0x30)]| skb[3][((c >>> 20) & 0x01) | ((c >>> 21) & 0x06) | ((c >>> 22) & 0x38)]; t = skb[4][ (d ) & 0x3f ]| skb[5][((d >>> 7) & 0x03) | ((d >>> 8) & 0x3c)]| skb[6][ (d >>>15) & 0x3f ]| skb[7][((d >>>21) & 0x0f) | ((d >>> 22) & 0x30)]; schedule[j++] = ((t << 16) | (s & 0x0000ffff)) & 0xffffffff; s = ((s >>> 16) | (t & 0xffff0000)); s = (s << 4) | (s >>> 28); schedule[j++] = s & 0xffffffff; } return(schedule); } private static final int D_ENCRYPT ( int L, int R, int S, int E0, int E1, int s[] ) { int t, u, v; v = R ^ (R >>> 16); u = v & E0; v = v & E1; u = (u ^ (u << 16)) ^ R ^ s[S]; t = (v ^ (v << 16)) ^ R ^ s[S + 1]; t = (t >>> 4) | (t << 28); L ^= SPtrans[1][(t ) & 0x3f] | SPtrans[3][(t >>> 8) & 0x3f] | SPtrans[5][(t >>> 16) & 0x3f] | SPtrans[7][(t >>> 24) & 0x3f] | SPtrans[0][(u ) & 0x3f] | SPtrans[2][(u >>> 8) & 0x3f] | SPtrans[4][(u >>> 16) & 0x3f] | SPtrans[6][(u >>> 24) & 0x3f]; return(L); } private static final int [] body(int schedule[], int Eswap0, int Eswap1) { int left = 0; int right = 0; int t = 0; for(int j = 0; j < 25; j ++) { for(int i = 0; i < ITERATIONS * 2; i += 4) { left = D_ENCRYPT(left, right, i, Eswap0, Eswap1, schedule); right = D_ENCRYPT(right, left, i + 2, Eswap0, Eswap1, schedule); } t = left; left = right; right = t; } t = right; right = (left >>> 1) | (left << 31); left = (t >>> 1) | (t << 31); left &= 0xffffffff; right &= 0xffffffff; int results[] = new int[2]; PERM_OP(right, left, 1, 0x55555555, results); right = results[0]; left = results[1]; PERM_OP(left, right, 8, 0x00ff00ff, results); left = results[0]; right = results[1]; PERM_OP(right, left, 2, 0x33333333, results); right = results[0]; left = results[1]; PERM_OP(left, right, 16, 0x0000ffff, results); left = results[0]; right = results[1]; PERM_OP(right, left, 4, 0x0f0f0f0f, results); right = results[0]; left = results[1]; int out[] = new int[2]; out[0] = left; out[1] = right; return(out); } public static final String crypt(String salt, String original) { while(salt.length() < 2) salt += "A"; StringBuffer buffer = new StringBuffer(" "); char charZero = salt.charAt(0); char charOne = salt.charAt(1); buffer.setCharAt(0, charZero); buffer.setCharAt(1, charOne); int Eswap0 = con_salt[(int)charZero]; int Eswap1 = con_salt[(int)charOne] << 4; byte key[] = new byte[8]; for(int i = 0; i < key.length; i ++) key[i] = (byte)0; for(int i = 0; i < key.length && i < original.length(); i ++) { int iChar = (int)original.charAt(i); key[i] = (byte)(iChar << 1); } int schedule[] = des_set_key(key); int out[] = body(schedule, Eswap0, Eswap1); byte b[] = new byte[9]; intToFourBytes(out[0], b, 0); intToFourBytes(out[1], b, 4); b[8] = 0; for(int i = 2, y = 0, u = 0x80; i < 13; i ++) { for(int j = 0, c = 0; j < 6; j ++) { c <<= 1; if(((int)b[y] & u) != 0) c |= 1; u >>>= 1; if(u == 0) { y++; u = 0x80; } buffer.setCharAt(i, (char)cov_2char[c]); } } return(buffer.toString()); } } Rserve/src/client/java/Rserve/protocol/REXPFactory.java0000644000176000001440000005546312205226215022630 0ustar ripleyuserspackage org.rosuda.REngine.Rserve.protocol; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004-8 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- import java.util.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.*; /** representation of R-eXpressions in Java @version $Id$ */ public class REXPFactory { /** xpression type: NULL */ public static final int XT_NULL=0; /** xpression type: integer */ public static final int XT_INT=1; /** xpression type: double */ public static final int XT_DOUBLE=2; /** xpression type: String */ public static final int XT_STR=3; /** xpression type: language construct (currently content is same as list) */ public static final int XT_LANG=4; /** xpression type: symbol (content is symbol name: String) */ public static final int XT_SYM=5; /** xpression type: RBool */ public static final int XT_BOOL=6; /** xpression type: S4 object @since Rserve 0.5 */ public static final int XT_S4=7; /** xpression type: generic vector (RList) */ public static final int XT_VECTOR=16; /** xpression type: dotted-pair list (RList) */ public static final int XT_LIST=17; /** xpression type: closure (there is no java class for that type (yet?). currently the body of the closure is stored in the content part of the REXP. Please note that this may change in the future!) */ public static final int XT_CLOS=18; /** xpression type: symbol name @since Rserve 0.5 */ public static final int XT_SYMNAME=19; /** xpression type: dotted-pair list (w/o tags) @since Rserve 0.5 */ public static final int XT_LIST_NOTAG=20; /** xpression type: dotted-pair list (w tags) @since Rserve 0.5 */ public static final int XT_LIST_TAG=21; /** xpression type: language list (w/o tags) @since Rserve 0.5 */ public static final int XT_LANG_NOTAG=22; /** xpression type: language list (w tags) @since Rserve 0.5 */ public static final int XT_LANG_TAG=23; /** xpression type: expression vector */ public static final int XT_VECTOR_EXP=26; /** xpression type: string vector */ public static final int XT_VECTOR_STR=27; /** xpression type: int[] */ public static final int XT_ARRAY_INT=32; /** xpression type: double[] */ public static final int XT_ARRAY_DOUBLE=33; /** xpression type: String[] (currently not used, Vector is used instead) */ public static final int XT_ARRAY_STR=34; /** internal use only! this constant should never appear in a REXP */ public static final int XT_ARRAY_BOOL_UA=35; /** xpression type: RBool[] */ public static final int XT_ARRAY_BOOL=36; /** xpression type: raw (byte[]) @since Rserve 0.4-? */ public static final int XT_RAW=37; /** xpression type: Complex[] @since Rserve 0.5 */ public static final int XT_ARRAY_CPLX=38; /** xpression type: unknown; no assumptions can be made about the content */ public static final int XT_UNKNOWN=48; /** xpression type: RFactor; this XT is internally generated (ergo is does not come from Rsrv.h) to support RFactor class which is built from XT_ARRAY_INT */ public static final int XT_FACTOR=127; /** used for transport only - has attribute */ private static final int XT_HAS_ATTR=128; int type; REXPFactory attr; REXP cont; RList rootList; public REXP getREXP() { return cont; } public REXPList getAttr() { return (attr==null)?null:(REXPList)attr.cont; } public REXPFactory() { } public REXPFactory(REXP r) throws REXPMismatchException { if (r == null) r=new REXPNull(); REXPList a = r._attr(); cont = r; if (a != null) attr = new REXPFactory(a); if (r instanceof REXPNull) { type=XT_NULL; } else if (r instanceof REXPList) { RList l = r.asList(); type = l.isNamed()?XT_LIST_TAG:XT_LIST_NOTAG; if (r instanceof REXPLanguage) type = (type==XT_LIST_TAG)?XT_LANG_TAG:XT_LANG_NOTAG; } else if (r instanceof REXPGenericVector) { type = XT_VECTOR; // FIXME: may have to adjust names attr } else if (r instanceof REXPS4) { type = XT_S4; } else if (r instanceof REXPInteger) { // this includes factor - FIXME: do we need speacial handling? type = XT_ARRAY_INT; } else if (r instanceof REXPDouble) { type = XT_ARRAY_DOUBLE; } else if (r instanceof REXPString) { type = XT_ARRAY_STR; } else if (r instanceof REXPSymbol) { type = XT_SYMNAME; } else if (r instanceof REXPRaw) { type = XT_RAW; } else if (r instanceof REXPLogical) { type = XT_ARRAY_BOOL; } else { // throw new REXPMismatchException(r, "decode"); System.err.println("*** REXPFactory unable to interpret "+r); } } /** parses byte buffer for binary representation of xpressions - read one xpression slot (descends recursively for aggregated xpressions such as lists, vectors etc.) @param buf buffer containing the binary representation @param o offset in the buffer to start at @return position just behind the parsed xpression. Can be use for successive calls to {@link #parseREXP} if more than one expression is stored in the binary array. */ public int parseREXP(byte[] buf, int o) throws REXPMismatchException { int xl = RTalk.getLen(buf,o); boolean hasAtt = ((buf[o]&128)!=0); boolean isLong = ((buf[o]&64)!=0); int xt = (int)(buf[o]&63); //System.out.println("parseREXP: type="+xt+", len="+xl+", hasAtt="+hasAtt+", isLong="+isLong); if (isLong) o+=4; o+=4; int eox=o+xl; type=xt; attr=new REXPFactory(); cont=null; if (hasAtt) o = attr.parseREXP(buf, o); if (xt==XT_NULL) { cont = new REXPNull(getAttr()); return o; } if (xt==XT_DOUBLE) { long lr = RTalk.getLong(buf,o); double[] d = new double[] { Double.longBitsToDouble(lr) }; o+=8; if (o!=eox) { System.err.println("Warning: double SEXP size mismatch\n"); o=eox; } cont = new REXPDouble(d, getAttr()); return o; } if (xt==XT_ARRAY_DOUBLE) { int as=(eox-o)/8,i=0; double[] d=new double[as]; while (o 0) { c = 0; i = o; while (o < eox) { if (buf[o] == 0) { try { if (buf[i] == -1) { /* if the first byte is 0xff (-1 in signed char) then it either needs to be skipped (doubling) or there is an NA value */ if (buf[i + 1] == 0) s[c] = null; /* NA */ else s[c] = new String(buf, i + 1, o - i - 1, RConnection.transferCharset); } else s[c] = new String(buf, i, o - i, RConnection.transferCharset); } catch (java.io.UnsupportedEncodingException ex) { s[c]=""; } c++; i = o + 1; } o++; } } cont = new REXPString(s, getAttr()); return o; } if (xt==XT_VECTOR_STR) { Vector v=new Vector(); while(oPlease note that currently only XT_[ARRAY_]INT, XT_[ARRAY_]DOUBLE and XT_[ARRAY_]STR are supported! All other types will return 4 which is the size of the header. @return length of the REXP including headers (4 or 8 bytes)*/ public int getBinaryLength() throws REXPMismatchException { int l=0; int rxt = type; if (type==XT_LIST || type==XT_LIST_TAG || type==XT_LIST_NOTAG) rxt=(cont.asList()!=null && cont.asList().isNamed())?XT_LIST_TAG:XT_LIST_NOTAG; //System.out.print("len["+xtName(type)+"/"+xtName(rxt)+"] "); if (type==XT_VECTOR_STR) rxt=XT_ARRAY_STR; // VECTOR_STR is broken right now /* if (type==XT_VECTOR && cont.asList()!=null && cont.asList().isNamed()) setAttribute("names",new REXPString(cont.asList().keys())); */ boolean hasAttr = false; REXPList a = getAttr(); RList al = null; if (a!=null) al = a.asList(); if (al != null && al.size()>0) hasAttr=true; if (hasAttr) l+=attr.getBinaryLength(); switch (rxt) { case XT_NULL: case XT_S4: break; case XT_INT: l+=4; break; case XT_DOUBLE: l+=8; break; case XT_RAW: l+=4 + cont.asBytes().length; if ((l&3)>0) l=l-(l&3)+4; break; case XT_STR: case XT_SYMNAME: l+=(cont==null)?1:(cont.asString().length()+1); if ((l&3)>0) l=l-(l&3)+4; break; case XT_ARRAY_INT: l+=cont.asIntegers().length*4; break; case XT_ARRAY_DOUBLE: l+=cont.asDoubles().length*8; break; case XT_ARRAY_CPLX: l+=cont.asDoubles().length*8; break; case XT_ARRAY_BOOL: l += cont.asBytes().length + 4; if ((l & 3) > 0) l = l - (l & 3) + 4; break; case XT_LIST_TAG: case XT_LIST_NOTAG: case XT_LANG_TAG: case XT_LANG_NOTAG: case XT_LIST: case XT_VECTOR: { final RList lst = cont.asList(); int i=0; while (i0) l=l-(l&3)+4; // System.out.println("TAG length: "+(l-pl)); } i++; } if ((l&3)>0) l=l-(l&3)+4; break; } case XT_ARRAY_STR: { String sa[] = cont.asStrings(); int i=0; while (i < sa.length) { if (sa[i] != null) { try { byte b[] = sa[i].getBytes(RConnection.transferCharset); if (b.length > 0) { if (b[0] == -1) l++; l += b.length; } b = null; } catch (java.io.UnsupportedEncodingException uex) { // FIXME: we should so something ... so far we hope noone's gonna mess with the encoding } } else l++; // NA = -1 l++; i++; } if ((l&3)>0) l=l-(l&3)+4; break; } } // switch if (l>0xfffff0) l+=4; // large data need 4 more bytes // System.out.println("len:"+(l+4)+" "+xtName(rxt)+"/"+xtName(type)+" "+cont); return l+4; // add the header } /** Stores the REXP in its binary (ready-to-send) representation including header into a buffer and returns the index of the byte behind the REXP.

Please note that currently only XT_[ARRAY_]INT, XT_[ARRAY_]DOUBLE and XT_[ARRAY_]STR are supported! All other types will be stored as SEXP of the length 0 without any contents. @param buf buffer to store the REXP binary into @param off offset of the first byte where to store the REXP @return the offset of the first byte behind the stored REXP */ public int getBinaryRepresentation(byte[] buf, int off) throws REXPMismatchException { int myl=getBinaryLength(); boolean isLarge=(myl>0xfffff0); boolean hasAttr = false; final REXPList a = getAttr(); RList al = null; if (a != null) al = a.asList(); if (al != null && al.size()>0) hasAttr=true; int rxt=type, ooff=off; if (type==XT_VECTOR_STR) rxt=XT_ARRAY_STR; // VECTOR_STR is broken right now if (type==XT_LIST || type==XT_LIST_TAG || type==XT_LIST_NOTAG) rxt=(cont.asList()!=null && cont.asList().isNamed())?XT_LIST_TAG:XT_LIST_NOTAG; // System.out.println("@"+off+": "+xtName(rxt)+"/"+xtName(type)+" "+cont+" ("+myl+"/"+buf.length+") att="+hasAttr); RTalk.setHdr(rxt|(hasAttr?XT_HAS_ATTR:0),myl-(isLarge?8:4),buf,off); off+=(isLarge?8:4); if (hasAttr) off=attr.getBinaryRepresentation(buf, off); switch (rxt) { case XT_S4: case XT_NULL: break; case XT_INT: RTalk.setInt(cont.asInteger(),buf,off); break; case XT_DOUBLE: RTalk.setLong(Double.doubleToRawLongBits(cont.asDouble()),buf,off); break; case XT_ARRAY_INT: { int ia[]=cont.asIntegers(); int i=0, io=off; while(i 0) { for(int i =0; i < ba.length; i++) buf[io++] = (byte) ( (ba[i] == REXPLogical.NA) ? 2 : ((ba[i] == REXPLogical.FALSE) ? 0 : 1) ); while ((io & 3) != 0) buf[io++] = 3; } break; } case XT_ARRAY_DOUBLE: { double da[]=cont.asDoubles(); int i=0, io=off; while(i 0) { if (b[0] == -1) /* if the first entry happens to be -1 then we need to double it so it doesn't get confused with NAs */ buf[io++] = -1; System.arraycopy(b, 0, buf, io, b.length); io += b.length; } b = null; } catch (java.io.UnsupportedEncodingException uex) { // FIXME: we should so something ... so far we hope noone's gonna mess with the encoding } } else buf[io++] = -1; /* NAs are stored as 0xff (-1 in signed bytes) */ buf[io++] = 0; i++; } i = io - off; while ((i & 3) != 0) { buf[io++] = 1; i++; } // padding if necessary.. break; } case XT_LIST_TAG: case XT_LIST_NOTAG: case XT_LANG_TAG: case XT_LANG_NOTAG: case XT_LIST: case XT_VECTOR: case XT_VECTOR_EXP: { int io = off; final RList lst = cont.asList(); if (lst != null) { int i=0; while (i @"+off+", len "+b.length+" (cont "+buf.length+") \""+s+"\""); System.arraycopy(b,0,buf,io,b.length); io+=b.length; b=null; } catch (java.io.UnsupportedEncodingException uex) { // FIXME: we should so something ... so far we hope noone's gonna mess with the encoding } buf[io++]=0; while ((io&3)!=0) buf[io++]=0; // padding if necessary.. return io; } /** returns human-readable name of the xpression type as string. Arrays are denoted by a trailing asterisk (*). @param xt xpression type @return name of the xpression type */ public static String xtName(int xt) { if (xt==XT_NULL) return "NULL"; if (xt==XT_INT) return "INT"; if (xt==XT_STR) return "STRING"; if (xt==XT_DOUBLE) return "REAL"; if (xt==XT_BOOL) return "BOOL"; if (xt==XT_ARRAY_INT) return "INT*"; if (xt==XT_ARRAY_STR) return "STRING*"; if (xt==XT_ARRAY_DOUBLE) return "REAL*"; if (xt==XT_ARRAY_BOOL) return "BOOL*"; if (xt==XT_ARRAY_CPLX) return "COMPLEX*"; if (xt==XT_SYM) return "SYMBOL"; if (xt==XT_SYMNAME) return "SYMNAME"; if (xt==XT_LANG) return "LANG"; if (xt==XT_LIST) return "LIST"; if (xt==XT_LIST_TAG) return "LIST+T"; if (xt==XT_LIST_NOTAG) return "LIST/T"; if (xt==XT_LANG_TAG) return "LANG+T"; if (xt==XT_LANG_NOTAG) return "LANG/T"; if (xt==XT_CLOS) return "CLOS"; if (xt==XT_RAW) return "RAW"; if (xt==XT_S4) return "S4"; if (xt==XT_VECTOR) return "VECTOR"; if (xt==XT_VECTOR_STR) return "STRING[]"; if (xt==XT_VECTOR_EXP) return "EXPR[]"; if (xt==XT_FACTOR) return "FACTOR"; if (xt==XT_UNKNOWN) return "UNKNOWN"; return ""; } } Rserve/src/client/java/Rserve/RSession.java0000644000176000001440000000230712205226215020413 0ustar ripleyuserspackage org.rosuda.REngine.Rserve; import org.rosuda.REngine.Rserve.protocol.RPacket; import org.rosuda.REngine.Rserve.protocol.RTalk; public class RSession implements java.io.Serializable { // serial version UID should only change if method signatures change // significantly enough that previous versions cannot be used with // current versions private static final long serialVersionUID = -7048099825974875604l; String host; int port; byte[] key; transient RPacket attachPacket=null; // response on session attach int rsrvVersion; protected RSession() { // default no-args constructor for serialization } RSession(RConnection c, RPacket p) throws RserveException { this.host=c.host; this.rsrvVersion=c.rsrvVersion; byte[] ct = p.getCont(); if (ct==null || ct.length!=32+3*4) throw new RserveException(c, "Invalid response to session detach request."); this.port = RTalk.getInt(ct, 4); this.key=new byte[32]; System.arraycopy(ct, 12, this.key, 0, 32); } /** attach/resume this session */ public RConnection attach() throws RserveException { RConnection c = new RConnection(this); attachPacket = c.rt.request(-1); return c; } } Rserve/src/client/java/Rserve/RFileOutputStream.java0000644000176000001440000001025212205226215022242 0ustar ripleyusers// JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2003 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- // // RFileOutputStream.java // // Created by Simon Urbanek on Wed Oct 22 2003. // package org.rosuda.REngine.Rserve; import java.io.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.protocol.*; /** RFileOutputStream is an {@link OutputStream} to transfer files from the client to Rserve server. It is used very much like a {@link FileOutputStream}. Currently mark and seek is not supported. The current implementation is also "one-shot" only, that means the file can be written only once. @version $Id$ */ public class RFileOutputStream extends OutputStream { /** RTalk class to use for communication with the Rserve */ RTalk rt; /** set to true when {@link #close} was called. Any subsequent read requests on closed stream result in an {@link IOException} or error result */ boolean closed; /** tries to create a file on the R server, using specified {@link RTalk} object and filename. Be aware that the filename has to be specified in host format (which is usually unix). In general you should not use directories since Rserve provides an own directory for every connection. Future Rserve servers may even strip all directory navigation characters for security purposes. Therefore only filenames without path specification are considered valid, the behavior in respect to absolute paths in filenames is undefined. @param rti RTalk object for communication with Rserve @param fb filename of the file to create (existing file will be overwritten) */ RFileOutputStream(RTalk rti, String fn) throws IOException { rt=rti; RPacket rp=rt.request(RTalk.CMD_createFile,fn); if (rp==null || !rp.isOk()) throw new IOException((rp==null)?"Connection to Rserve failed":("Request return code: "+rp.getStat())); closed=false; } /** writes one byte to the file. This function should be avoided, since {@link RFileOutputStream} provides no buffering. This means that each call to this function leads to a complete packet exchange between the server and the client. Use {@link #write(byte[])} instead whenever possible. In fact this function calls write(b,0,1). @param b byte to write */ public void write(int b) throws IOException { byte[] ba=new byte[1]; write(ba,0,1); } /** writes the content of b into the file. This methods is equivalent to calling write(b,0,b.length). @param b content to write */ public void write(byte b[]) throws IOException { write(b,0,b.length); } /** Writes specified number of bytes to the remote file. @param b buffer containing the bytes to write @param off offset where to start @param len number of bytes to write */ public void write(byte[] b, int off, int len) throws IOException { if (closed) throw new IOException("File is not open"); if (len<0) len=0; boolean isLarge=(len>0xfffff0); byte[] hdr=RTalk.newHdr(RTalk.DT_BYTESTREAM,len); RPacket rp=rt.request(RTalk.CMD_writeFile,hdr,b,off,len); if (rp==null || !rp.isOk()) throw new IOException((rp==null)?"Connection to Rserve failed":("Request return code: "+rp.getStat())); } /** close stream - is not related to the actual RConnection, calling close does not close the RConnection. */ public void close() throws IOException { RPacket rp=rt.request(RTalk.CMD_closeFile,(byte[])null); if (rp==null || !rp.isOk()) throw new IOException((rp==null)?"Connection to Rserve failed":("Request return code: "+rp.getStat())); closed=true; } /** currently (Rserve 0.3) there is no way to force flush on the remote side, hence this function is noop. Future versions of Rserve may support this feature though. At any rate, it is safe to call it. */ public void flush() { } } Rserve/src/client/java/Rserve/RserveException.java0000644000176000001440000000532012205226215021771 0ustar ripleyusers// JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- // // RserveException.java // // Created by Simon Urbanek on Mon Aug 18 2003. // // $Id$ // package org.rosuda.REngine.Rserve; import org.rosuda.REngine.Rserve.protocol.RPacket; import org.rosuda.REngine.Rserve.protocol.RTalk; import org.rosuda.REngine.REngineException; public class RserveException extends REngineException { protected String err; protected int reqReturnCode; public String getRequestErrorDescription() { return getRequestErrorDescription(reqReturnCode); } public String getRequestErrorDescription(int code) { switch(code) { case 0: return "no error"; case 2: return "R parser: input incomplete"; case 3: return "R parser: syntax error"; case RTalk.ERR_auth_failed: return "authorization failed"; case RTalk.ERR_conn_broken: return "connection broken"; case RTalk.ERR_inv_cmd: return "invalid command"; case RTalk.ERR_inv_par: return "invalid parameter"; case RTalk.ERR_IOerror: return "I/O error on the server"; case RTalk.ERR_not_open: return "connection is not open"; case RTalk.ERR_access_denied: return "access denied (local to the server)"; case RTalk.ERR_unsupported_cmd: return "unsupported command"; case RTalk.ERR_unknown_cmd: return "unknown command"; case RTalk.ERR_data_overflow: return "data overflow, incoming data too big"; case RTalk.ERR_object_too_big: return "evaluation successful, but returned object is too big to transport"; case RTalk.ERR_out_of_mem: return "FATAL: Rserve ran out of memory, closing connection"; case RTalk.ERR_session_busy: return "session is busy"; case RTalk.ERR_detach_failed: return "session detach failed"; case RTalk.ERR_ctrl_closed: return "control pipe to master process is closed/broken"; } return "error code: "+code; } public String getMessage() { return super.getMessage()+((reqReturnCode!=-1)?", request status: "+getRequestErrorDescription():""); } public RserveException(RConnection c, String msg) { this(c,msg,-1); } public RserveException(RConnection c, String msg, int requestReturnCode) { super(c, msg); reqReturnCode=requestReturnCode; if (c!=null) c.lastError=getMessage(); } public RserveException(RConnection c, String msg, RPacket p) { this(c, msg, (p==null)?-1:p.getStat()); } public int getRequestReturnCode() { return reqReturnCode; } } Rserve/src/client/java/Rserve/test/0000755000176000001440000000000012205226215016760 5ustar ripleyusersRserve/src/client/java/Rserve/test/Makefile0000644000176000001440000000213113442516164020426 0ustar ripleyusersJAVA=java JAVAC=javac JFLAGS+=-encoding utf8 -source 1.4 -target 1.4 all: test PlotDemo.class StartRserve.class ../Rserve.jar: ../../REngine.jar $(MAKE) -C .. Rserve.jar ../../REngine.jar: $(MAKE) -C ../.. REngine.jar test: test.class ../Rserve.jar ../../REngine.jar $(JAVA) -cp ../Rserve.jar:../../REngine.jar:. test test.class: test.java ../Rserve.jar ../../REngine.jar $(JAVAC) $(JFLAGS) -d . -cp ../Rserve.jar:../../REngine.jar:. test.java PlotDemo.class: PlotDemo.java ../Rserve.jar ../../REngine.jar $(JAVAC) $(JFLAGS) -d . -cp ../Rserve.jar:../../REngine.jar:. $< PlotDemo: PlotDemo.class ../Rserve.jar ../../REngine.jar $(JAVA) -cp ../Rserve.jar:../../REngine.jar:. $@ jt: jt.class ../Rserve.jar ../../REngine.jar $(JAVA) -cp ../Rserve.jar:../../REngine.jar:. $@ jt.class: jt.java ../Rserve.jar ../../REngine.jar $(JAVAC) $(JFLAGS) -d . -cp ../Rserve.jar:../../REngine.jar:. jt.java StartRserve.class: StartRserve.java ../Rserve.jar ../../REngine.jar $(JAVAC) $(JFLAGS) -d . -cp ../Rserve.jar:../../REngine.jar:. StartRserve.java clean: rm -rf org *~ *.class .PHONY: test all clean Rserve/src/client/java/Rserve/test/test.java0000644000176000001440000002767412205226215020622 0ustar ripleyusersimport org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.*; class TestException extends Exception { public TestException(String msg) { super(msg); } } public class test { public static void main(String[] args) { try { RConnection c = new RConnection(); // REngine is the backend-agnostic API -- using eng instead of c makes sure that we don't use Rserve extensions inadvertently REngine eng = (REngine) c; System.out.println(">>" + c.eval("R.version$version.string").asString() + "<<"); { System.out.println("* Test string and list retrieval"); RList l = c.eval("{d=data.frame(\"huhu\",c(11:20)); lapply(d,as.character)}").asList(); int cols = l.size(); int rows = l.at(0).length(); String[][] s = new String[cols][]; for (int i=0; i= 0) { String s = line.substring(i + 11).trim(); int j = s.indexOf("REG_SZ"); if (j >= 0) s = s.substring(j + 6).trim(); installPath = s; System.out.println("R InstallPath = "+s); } } else System.out.println("Rserve>" + line); } } catch (IOException e) { e.printStackTrace(); } } } /** simple class that start Rserve locally if it's not running already - see mainly checkLocalRserve method. It spits out quite some debugging outout of the console, so feel free to modify it for your application if desired.

Important: All applications should shutdown every Rserve that they started! Never leave Rserve running if you started it after your application quits since it may pose a security risk. Inform the user if you started an Rserve instance. */ public class StartRserve { /** shortcut to launchRserve(cmd, "--no-save --slave", "--no-save --slave", false) */ public static boolean launchRserve(String cmd) { return launchRserve(cmd, "--no-save --slave","--no-save --slave",false); } /** attempt to start Rserve. Note: parameters are not quoted, so avoid using any quotes in arguments @param cmd command necessary to start R @param rargs arguments are are to be passed to R @param rsrvargs arguments to be passed to Rserve @return true if Rserve is running or was successfully started, false otherwise. */ public static boolean launchRserve(String cmd, String rargs, String rsrvargs, boolean debug) { try { Process p; boolean isWindows = false; String osname = System.getProperty("os.name"); if (osname != null && osname.length() >= 7 && osname.substring(0,7).equals("Windows")) { isWindows = true; /* Windows startup */ p = Runtime.getRuntime().exec("\""+cmd+"\" -e \"library(Rserve);Rserve("+(debug?"TRUE":"FALSE")+",args='"+rsrvargs+"')\" "+rargs); } else /* unix startup */ p = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", "echo 'library(Rserve);Rserve("+(debug?"TRUE":"FALSE")+",args=\""+rsrvargs+"\")'|"+cmd+" "+rargs }); System.out.println("waiting for Rserve to start ... ("+p+")"); // we need to fetch the output - some platforms will die if you don't ... StreamHog errorHog = new StreamHog(p.getErrorStream(), false); StreamHog outputHog = new StreamHog(p.getInputStream(), false); if (!isWindows) /* on Windows the process will never return, so we cannot wait */ p.waitFor(); System.out.println("call terminated, let us try to connect ..."); } catch (Exception x) { System.out.println("failed to start Rserve process with "+x.getMessage()); return false; } int attempts = 5; /* try up to 5 times before giving up. We can be conservative here, because at this point the process execution itself was successful and the start up is usually asynchronous */ while (attempts > 0) { try { RConnection c = new RConnection(); System.out.println("Rserve is running."); c.close(); return true; } catch (Exception e2) { System.out.println("Try failed with: "+e2.getMessage()); } /* a safety sleep just in case the start up is delayed or asynchronous */ try { Thread.sleep(500); } catch (InterruptedException ix) { }; attempts--; } return false; } /** checks whether Rserve is running and if that's not the case it attempts to start it using the defaults for the platform where it is run on. This method is meant to be set-and-forget and cover most default setups. For special setups you may get more control over R with <launchRserve instead. */ public static boolean checkLocalRserve() { if (isRserveRunning()) return true; String osname = System.getProperty("os.name"); if (osname != null && osname.length() >= 7 && osname.substring(0,7).equals("Windows")) { System.out.println("Windows: query registry to find where R is installed ..."); String installPath = null; try { Process rp = Runtime.getRuntime().exec("reg query HKLM\\Software\\R-core\\R"); StreamHog regHog = new StreamHog(rp.getInputStream(), true); rp.waitFor(); regHog.join(); installPath = regHog.getInstallPath(); } catch (Exception rge) { System.out.println("ERROR: unable to run REG to find the location of R: "+rge); return false; } if (installPath == null) { System.out.println("ERROR: canot find path to R. Make sure reg is available and R was installed with registry settings."); return false; } return launchRserve(installPath+"\\bin\\R.exe"); } return (launchRserve("R") || /* try some common unix locations of R */ ((new File("/Library/Frameworks/R.framework/Resources/bin/R")).exists() && launchRserve("/Library/Frameworks/R.framework/Resources/bin/R")) || ((new File("/usr/local/lib/R/bin/R")).exists() && launchRserve("/usr/local/lib/R/bin/R")) || ((new File("/usr/lib/R/bin/R")).exists() && launchRserve("/usr/lib/R/bin/R")) || ((new File("/usr/local/bin/R")).exists() && launchRserve("/usr/local/bin/R")) || ((new File("/sw/bin/R")).exists() && launchRserve("/sw/bin/R")) || ((new File("/usr/common/bin/R")).exists() && launchRserve("/usr/common/bin/R")) || ((new File("/opt/bin/R")).exists() && launchRserve("/opt/bin/R")) ); } /** check whether Rserve is currently running (on local machine and default port). @return true if local Rserve instance is running, false otherwise */ public static boolean isRserveRunning() { try { RConnection c = new RConnection(); System.out.println("Rserve is running."); c.close(); return true; } catch (Exception e) { System.out.println("First connect try failed with: "+e.getMessage()); } return false; } /** just a demo main method which starts Rserve and shuts it down again */ public static void main(String[] args) { System.out.println("result="+checkLocalRserve()); try { RConnection c=new RConnection(); c.shutdown(); } catch (Exception x) {}; } } Rserve/src/client/java/Rserve/test/jt.java0000644000176000001440000000205312205226215020240 0ustar ripleyusersimport java.io.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.*; public class jt { public static void main(String[] args) { try { RConnection c = new RConnection((args.length>0)?args[0]:"127.0.0.1"); BufferedReader ir=new BufferedReader(new InputStreamReader(System.in)); String s=null; System.out.print("> "); while ((s=ir.readLine()).length() > 0) { if (s.equals("shutdown")) { System.out.println("Sending shutdown request"); c.shutdown(); System.out.println("Shutdown successful. Quitting console."); return; } else { REXP rx = c.parseAndEval(s); System.out.println("result(debug): "+rx.toDebugString()); } System.out.print("> "); } } catch (RserveException rse) { System.out.println(rse); /* } catch (REXPMismatchException mme) { System.out.println(mme); mme.printStackTrace(); */ } catch (Exception e) { e.printStackTrace(); } } } Rserve/src/client/java/Rserve/test/PlotDemo.java0000644000176000001440000000757012205226215021357 0ustar ripleyusers// // PlotDemo demo - REngine and graphics // // $Id$ // import java.io.*; import java.util.*; import java.awt.*; import java.awt.event.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.*; /** A demonstration of the use of Rserver and graphics devices to create graphics in R, pull them into Java and display them. It is a really simple demo. */ public class PlotDemo extends Canvas { public static void main(String args[]) { try { String device = "jpeg"; // device we'll call (this would work with pretty much any bitmap device) // connect to Rserve (if the user specified a server at the command line, use it, otherwise connect locally) RConnection c = new RConnection((args.length>0)?args[0]:"127.0.0.1"); // if Cairo is installed, we can get much nicer graphics, so try to load it if (c.parseAndEval("suppressWarnings(require('Cairo',quietly=TRUE))").asInteger()>0) device="CairoJPEG"; // great, we can use Cairo device else System.out.println("(consider installing Cairo package for better bitmap output)"); // we are careful here - not all R binaries support jpeg // so we rather capture any failures REXP xp = c.parseAndEval("try("+device+"('test.jpg',quality=90))"); if (xp.inherits("try-error")) { // if the result is of the class try-error then there was a problem System.err.println("Can't open "+device+" graphics device:\n"+xp.asString()); // this is analogous to 'warnings', but for us it's sufficient to get just the 1st warning REXP w = c.eval("if (exists('last.warning') && length(last.warning)>0) names(last.warning)[1] else 0"); if (w.isString()) System.err.println(w.asString()); return; } // ok, so the device should be fine - let's plot - replace this by any plotting code you desire ... c.parseAndEval("data(iris); attach(iris); plot(Sepal.Length, Petal.Length, col=unclass(Species)); dev.off()"); // There is no I/O API in REngine because it's actually more efficient to use R for this // we limit the file size to 1MB which should be sufficient and we delete the file as well xp = c.parseAndEval("r=readBin('test.jpg','raw',1024*1024); unlink('test.jpg'); r"); // now this is pretty boring AWT stuff - create an image from the data and display it ... Image img = Toolkit.getDefaultToolkit().createImage(xp.asBytes()); Frame f = new Frame("Test image"); f.add(new PlotDemo(img)); f.addWindowListener(new WindowAdapter() { // just so we can close the window public void windowClosing(WindowEvent e) { System.exit(0); } }); f.pack(); f.setVisible(true); // close RConnection, we're done c.close(); } catch (RserveException rse) { // RserveException (transport layer - e.g. Rserve is not running) System.out.println(rse); } catch (REXPMismatchException mme) { // REXP mismatch exception (we got something we didn't think we get) System.out.println(mme); mme.printStackTrace(); } catch(Exception e) { // something else System.out.println("Something went wrong, but it's not the Rserve: " +e.getMessage()); e.printStackTrace(); } } Image img; public PlotDemo(Image img) { this.img=img; MediaTracker mediaTracker = new MediaTracker(this); mediaTracker.addImage(img, 0); try { mediaTracker.waitForID(0); } catch (InterruptedException ie) { System.err.println(ie); System.exit(1); } setSize(img.getWidth(null), img.getHeight(null)); } public void paint(Graphics g) { g.drawImage(img, 0, 0, null); } } Rserve/src/client/java/Rserve/RFileInputStream.java0000644000176000001440000000711512205226215022045 0ustar ripleyuserspackage org.rosuda.REngine.Rserve; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- import java.io.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.protocol.*; /** RFileInputStream is an {@link InputStream} to transfer files from Rserve server to the client. It is used very much like a {@link FileInputStream}. Currently mark and seek is not supported. The current implementation is also "one-shot" only, that means the file can be read only once. @version $Id$ */ public class RFileInputStream extends InputStream { /** RTalk class to use for communication with the Rserve */ RTalk rt; /** set to true when {@link #close} was called. Any subsequent read requests on closed stream result in an {@link IOException} or error result */ boolean closed; /** set to true once EOF is reached - or more specifically the first time remore fread returns OK and 0 bytes */ boolean eof; /** tries to open file on the R server, using specified {@link RTalk} object and filename. Be aware that the filename has to be specified in host format (which is usually unix). In general you should not use directories since Rserve provides an own directory for every connection. Future Rserve servers may even strip all directory navigation characters for security purposes. Therefore only filenames without path specification are considered valid, the behavior in respect to absolute paths in filenames is undefined. */ RFileInputStream(RTalk rti, String fn) throws IOException { rt=rti; RPacket rp=rt.request(RTalk.CMD_openFile,fn); if (rp==null || !rp.isOk()) throw new IOException((rp==null)?"Connection to Rserve failed":("Request return code: "+rp.getStat())); closed=false; eof=false; } /** reads one byte from the file. This function should be avoided, since {@link RFileInputStream} provides no buffering. This means that each call to this function leads to a complete packet exchange between the server and the client. Use {@link #read(byte[],int,int)} instead whenever possible. In fact this function calls #read(b,0,1). @return -1 on any failure, or the acquired byte (0..255) on success */ public int read() throws IOException { byte[] b=new byte[1]; if (read(b,0,1)<1) return -1; return b[0]; } /** Reads specified number of bytes (or less) from the remote file. @param b buffer to store the read bytes @param off offset where to strat filling the buffer @param len maximal number of bytes to read @return number of bytes read or -1 if EOF reached */ public int read(byte[] b, int off, int len) throws IOException { if (closed) throw new IOException("File is not open"); if (eof) return -1; RPacket rp=rt.request(RTalk.CMD_readFile,len); if (rp==null || !rp.isOk()) throw new IOException((rp==null)?"Connection to Rserve failed":("Request return code: "+rp.getStat())); byte[] rd=rp.getCont(); if (rd==null) { eof=true; return -1; }; int i=0; while(iRserve */ package org.rosuda.REngine.Rserve ; Rserve/src/client/java/REngineInputInterface.java0000644000176000001440000000157312205226215021574 0ustar ripleyuserspackage org.rosuda.REngine; /** interface defining delegate methods used by {@link REngine} to forward input callbacks from R. */ public interface REngineInputInterface { /** called when R enters the read stage of the event loop. *

Important: implementations should never use a direct return! That will cause a tigh-spinning event loop. Implementation must wait for input asynchronously (e.g., declare synchonized RReadConsole and use wait()) and return only when a complete line is available for processing. * @param eng calling engine * @param prompt prompt to display in the console * @param addToHistory flag indicating whether the input is transient (false) or to be recorded in the command history (true). * @return string to be processed as console input */ public String RReadConsole(REngine eng, String prompt, int addToHistory); } Rserve/src/client/java/REngineException.java0000644000176000001440000000164412205226215020611 0ustar ripleyusers// REngine - generic Java/R API // // Copyright (C) 2006 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- // // RSrvException.java // // Created by Simon Urbanek on Wed Jun 21 2006. // // $Id$ // package org.rosuda.REngine; /** REngineException is a generic exception that can be thrown by methods invoked on an R engine. */ public class REngineException extends Exception { /** engine associated with this exception */ protected REngine engine; /** creates an R engine exception @param engine engine associated with this exception @param msg message describing the cause */ public REngineException(REngine engine, String msg) { super(msg); this.engine = engine; } /** returns the engine associated with this exception @return engine associated with this exception */ public REngine getEngine() { return engine; } } Rserve/src/client/java/REXPS4.java0000644000176000001440000000027412205226215016366 0ustar ripleyuserspackage org.rosuda.REngine; /** S4 REXP is a completely vanilla REXP */ public class REXPS4 extends REXP { public REXPS4() { super(); } public REXPS4(REXPList attr) { super(attr); } } Rserve/src/client/java/REXPMismatchException.java0000644000176000001440000000360612205226215021526 0ustar ripleyusers// REngine - generic Java/R API // // Copyright (C) 2007,2008 Simon Urbanek // --- for licensing information see LICENSE file in the distribution --- // // REXPMismatch.java // // Created by Simon Urbanek on 2007/05/03 // // $Id: REngineException.java 2555 2006-06-21 20:36:42Z urbaneks $ // package org.rosuda.REngine; /** This exception is thrown whenever the operation requested is not supported by the given R object type, e.g. using asStrings on an S4 object. Most {@link REXP} methods throw this exception. Previous R/Java interfaces were silently returning null in those cases, but using exceptions helps to write more robust code. */ public class REXPMismatchException extends Exception { REXP sender; String access; /** primary constructor. The exception message will be formed as "attempt to access <REXP-class> as <access-string>" * @param sender R object that triggered this exception (cannot be null!) * @param access assumed type of the access that was requested. It should be a simple name of the assumed type (e.g. "vector"). The type name can be based on R semantics beyond basic types reflected by REXP classes. In cases where certain assertions were not satisfied, the string should be of the form "type (assertion)" (e.g. "data frame (must have dim>0)"). */ public REXPMismatchException(REXP sender, String access) { super("attempt to access "+sender.getClass().getName()+" as "+access); this.sender = sender; this.access = access; } /** retrieve the exception sender/origin * @return REXP object that triggered the exception */ public REXP getSender() { return sender; } /** get the assumed access type that was violated by the sender. * @return string describing the access type. See {@link #REXPMismatchException} for details. */ public String getAccess() { return access; } } Rserve/src/client/java/REngineUIInterface.java0000644000176000001440000000146512205226215021012 0ustar ripleyuserspackage org.rosuda.REngine; /** interface defining delegate methods used by {@link REngine} to forward user interface callbacks from R. */ public interface REngineUIInterface { /** called when the busy state of R changes - usual response is to change the shape of the cursor * @param eng calling engine * @param state busy state of R (0 = not busy) */ public void RBusyState (REngine eng, int state); /** called when R wants the user to choose a file. * @param eng calling engine * @param newFile if true then the user can specify a non-existing file to be created, otherwise an existing file must be selected. * @return full path and name of the selected file or null if the selection was cancelled. */ public String RChooseFile (REngine eng, boolean newFile); } Rserve/src/client/java/REXPUnknown.java0000644000176000001440000000175312205226215017542 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPUnknown is a stand-in for an object that cannot be represented in the REngine hierarchy. Usually this class can be encountered when new types are introduced in R or if a given engine doesn't support all data types. Usually REXPUnknown can only be retrieved from the engine but never assigned. */ public class REXPUnknown extends REXP { /** type of the unterlying obejct */ int type; /** creates a new unknown object of the given type * @param type internal R type code of this object */ public REXPUnknown(int type) { super(); this.type=type; } /** creates a new unknown object of the given type * @param type internal R type code of this object * @param attr attributes */ public REXPUnknown(int type, REXPList attr) { super(attr); this.type=type; } /** returns the internal R type of this unknown obejct * @return type code */ public int getType() { return type; } public String toString() { return super.toString()+"["+type+"]"; } } Rserve/src/client/java/package-info.java0000644000176000001440000000011012205226215017712 0ustar ripleyusers/** * High level java interface to R */ package org.rosuda.REngine ; Rserve/src/client/cxx/0000755000176000001440000000000012205226217014416 5ustar ripleyusersRserve/src/client/cxx/rsdown.cc0000644000176000001440000000437712205226215016252 0ustar ripleyusers/* * Small Rserve shutdown program * Copyright (C) 2004-8 Simon Urbanek, All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: demo1.cc 203 2007-05-10 18:12:06Z urbanek $ */ #define MAIN // we are the main program, we need to define this #define SOCK_ERRORS // we will use verbose socket errors #include "sisocks.h" #include "Rconnection.h" int main(int ac, char **av) { initsocks(); // this is needed for Win32 - it does nothing on unix Rconnection *rc = 0; int port = -1, help = 0; const char *sock_name = 0; const char *host_name = 0; const char *pwd = 0; int i = 1; while (i < ac) { if (av[i][0] == '-') { switch (av[i][1]) { case 'h': help = 1; break; case 'p': if (++i < ac) port = atoi(av[i]); break; case 'P': if (++i < ac) pwd = av[i]; else pwd = getpass("password: "); break; case 's': if (++i < ac) sock_name = av[i]; break; } } else if (!host_name) host_name = av[i]; i++; } if (help) { printf("\n Usage: %s [] [-p ] [-s ] [-P ] [-h] \n\n", av[0]); return 0; } if (host_name) { if (port > 1) rc = new Rconnection(host_name, port); else rc = new Rconnection(host_name); } else if (sock_name) { rc = new Rconnection(sock_name, -1); } else { rc = new Rconnection(); } i = rc->connect(); if (i) { char buf[1024]; sockerrorchecks(buf, 1024, -1); fprintf(stderr, "ERROR: unable to connect (result=%d, socket:%s).\n", i, buf); } else rc->shutdown(pwd); delete rc; return 0; } Rserve/src/client/cxx/rcmd.cc0000644000176000001440000000761612205226215015662 0ustar ripleyusers/* * Small demo to illustrate the use of the C++ interface to Rserve * Copyright (C) 2004 Simon Urbanek, All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Leser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id$ */ #define MAIN // we are the main program, we need to define this #define SOCK_ERRORS // we will use verbose socket errors #include "sisocks.h" #include "Rconnection.h" char buf[1024]; int main(int ac, char **av) { initsocks(); // this is needed for Win32 - it does nothing on unix Rconnection *rc = 0; int port = -1, help = 0, do_cd = 1; const char *sock_name = 0; const char *host_name = 0; const char *pwd = 0; const char *user = 0; const char *wd = 0; int i = 1; while (i < ac) { if (av[i][0] == '-') { switch (av[i][1]) { case 'h': help = 1; break; case 'H': if (++i < ac) host_name = av[i]; break; case 'u': if (++i < ac) user = av[i]; break; case 'p': if (++i < ac) port = atoi(av[i]); break; case 'P': if (++i < ac) pwd = av[i]; else pwd = getpass("password: "); break; case 's': if (++i < ac) sock_name = av[i]; break; case 'w': if (++i < ac) wd = av[i]; break; case 'n': do_cd = 0; break; case 'c': i++; } } i++; } if (wd) do_cd = 1; if (help) { printf("\n Usage: %s [-H ] [-c ] [-w

] [-n] [-p ] [-s ] [-u ] [-P ] [-h] [ [...]]\n\n", av[0]); return 0; } if (host_name) { if (port > 1) rc = new Rconnection(host_name, port); else rc = new Rconnection(host_name); } else if (sock_name) { rc = new Rconnection(sock_name, -1); } else { rc = new Rconnection(); } buf[1023]=0; i = rc->connect(); if (i) { sockerrorchecks(buf, 1023, -1); fprintf(stderr, "unable to connect (result=%d, socket:%s).\n", i, buf); return i; } if (user) { if (!pwd) pwd = ""; i = rc->login(user, pwd); if (i) { fprintf(stderr, "login failed (result=%d)\n", i); return i; } } if (do_cd) { char *es, *d; const char *c; if (!wd) wd = strdup(getwd(buf)); d = es = (char*) malloc(strlen(wd) * 2 + 14); c = wd; strcpy(d, "setwd(\""); d += 7; while (*c) { if (*c == '\"' || *c == '\\' || *c == '\'') (d++)[0] = '\\'; if (*c == '\n' || *c == '\r') (d++)[0] = ' '; else (d++)[0] = (c++)[0]; } strcpy(d, "\")"); rc->voidEval(es); free(es); } i = 1; // source all files specified at the command line and print the output while (i < ac) { if (av[i][0] == '-') { switch(av[i][1]) { /* skip options that have extra argument */ case 'c': if (++i < ac) { snprintf(buf, 1023, "try(paste(capture.output(%s),collapse='\\n'))", av[i]); Rstring *str = (Rstring*) rc->eval(buf); puts(str->string()); delete str; } break; case 'p': case 'P': case 's': case 'H': case 'u': case 'w': i++; } } else { snprintf(buf, 1023, "try(paste(capture.output(source(\"%s\")),collapse='\\n'))", av[i]); Rstring *str = (Rstring*) rc->eval(buf); puts(str->string()); delete str; } i++; } // dispose of the connection object - this implicitly closes the connection delete rc; return 0; } Rserve/src/client/cxx/COPYING0000644000176000001440000006350412205226215015457 0ustar ripleyusers GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! Rserve/src/client/cxx/configure.ac0000644000176000001440000000555412205226215016713 0ustar ripleyusers# Process this file with autoconf to produce a configure script. AC_INIT([Rserve-cxx-client],[0.1],[Simon.Urbanek@r-project.org]) AC_CONFIG_SRCDIR([Rconnection.cc]) AC_CONFIG_HEADER([config.h]) AC_PROG_CC AC_PROG_CXX AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([string.h memory.h sys/time.h unistd.h]) AC_CHECK_HEADERS([sys/stat.h sys/types.h sys/socket.h sys/un.h netinet/in.h netinet/tcp.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_BIGENDIAN(AC_DEFINE(BS_BIG_ENDIAN, 1, [Defined if the platform is big-endian]), AC_DEFINE(BS_LITTLE_ENDIAN, 1, [Defined if the platform is little-endian]), [ AC_MSG_RESULT(endianness unknown - will rely solely on compiler macros) AC_MSG_CHECKING([whether compiler sets endianness macros]) AC_COMPILE_IFELSE([ #if defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN_ || defined __BIG_ENDIAN__ || defined _BIG_ENDIAN_ #define BS_OK 1 #else cannot determine compiler's endianness #endif ],[AC_MSG_RESULT(yes)],[ AC_MSG_RESULT(no) AC_MSG_ERROR([Cannot determine endianness neither from the compiler nor using a test. Try adding -D_BIG_ENDIAN_ or -D_LITTLE_ENDIAN_ to PKG_CPPFLAGS. ])]) ]) AC_HEADER_TIME # Checks for library functions. AC_FUNC_FORK AC_TYPE_SIGNAL AC_CHECK_FUNCS([memset mkdir rmdir select socket]) # Check whether we can use crypt (and if we do if it's in the crypt library) AC_SEARCH_LIBS(crypt, crypt, [AC_DEFINE(HAS_CRYPT, 1, [If defined Rserve supports unix crypt password encryption.])]) AC_CHECK_HEADERS([crypt.h]) # socket related stuff - indroduced first due to Solaris # socklen_t - note that we don't try to find an equivalent! # we'll use BSD-style int in case this one isn't defined. # that should be fine for all major platforms. AC_CHECK_TYPE(socklen_t,, AC_DEFINE(socklen_t, int, [Define to `int' if neither nor define.]), [ #include #include ]) # connect may need -lsocket and/or -lnsl (e.g. on Solaris) AC_CHECK_FUNCS(connect) if test x"$ac_cv_func_connect" = x"no"; then case "$LIBS" in *-lnsl*) ;; *) AC_CHECK_LIB(nsl_s, printf) ;; esac case "$LIBS" in *-lnsl*) ;; *) AC_CHECK_LIB(nsl, printf) ;; esac case "$LIBS" in *-lsocket*) ;; *) AC_CHECK_LIB(socket, connect) ;; esac case "$LIBS" in *-linet*) ;; *) AC_CHECK_LIB(inet, connect) ;; esac dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value dnl has been cached. if test x"$ac_cv_lib_socket_connect" = x"yes" || test x"$ac_cv_lib_inet_connect" = x"yes"; then # ac_cv_func_connect=yes # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run AC_DEFINE(HAVE_CONNECT, 1, [ ]) fi fi # on some platforms libR expects dl code in the binary AC_CHECK_LIB(dl, dlopen) AC_CONFIG_FILES([Makefile]) AC_OUTPUT Rserve/src/client/cxx/Rsrv.h0000644000176000001440000004522212205226216015527 0ustar ripleyusers/* * Rsrv.h : constants and macros for Rserve client/server architecture * Copyright (C) 2002-13 Simon Urbanek * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; version 2.1 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Note: This header file is licensed under LGPL to allow other * programs to use it under LGPL. Rserve itself is licensed under GPL. * * $Id$ */ /* external defines: MAIN - should be defined in just one file that will contain the fn definitions and variables */ #ifndef __RSRV_H__ #define __RSRV_H__ #ifndef NO_CONFIG_H #include "config.h" #endif #define RSRV_VER 0x010703 /* Rserve v1.7-3 */ #define default_Rsrv_port 6311 /* Rserve communication is done over any reliable connection-oriented protocol (usually TCP/IP or local sockets). After the connection is established, the server sends 32 bytes of ID-string defining the capabilities of the server. Each attribute of the ID-string is 4 bytes long and is meant to be user-readable (i.e. don't use special characters), and it's a good idea to make "\r\n\r\n" the last attribute the ID string must be of the form: [0] "Rsrv" - R-server ID signature [4] "0100" - version of the R server [8] "QAP1" - protocol used for communication (here Quad Attributes Packets v1) [12] any additional attributes follow. \r\n and '-' are ignored. optional attributes (in any order; it is legitimate to put dummy attributes, like "----" or " " between attributes): "R151" - version of R (here 1.5.1) "ARpt" - authorization required (here "pt"=plain text, "uc"=unix crypt, "m5"=MD5) connection will be closed if the first packet is not CMD_login. if more AR.. methods are specified, then client is free to use the one he supports (usually the most secure) "K***" - key if encoded authentification is challenged (*** is the key) for unix crypt the first two letters of the key are the salt required by the server */ /* QAP1 transport protocol header structure all int and double entries throughout the transfer are in Intel-endianess format: int=0x12345678 -> char[4]=(0x78,0x56,x34,0x12) functions/macros for converting from native to protocol format are available below Please note also that all values muse be quad-aligned, i.e. the length must be divisible by 4. This is automatically assured for int/double etc., but care must be taken when using strings and byte streams. */ struct phdr { /* always 16 bytes */ int cmd; /* command */ int len; /* length of the packet minus header (ergo -16) */ int dof; /* data offset behind header (ergo usually 0) */ int res; /* high 32-bit of the packet length (since 0103 and supported on 64-bit platforms only) aka "lenhi", but the name was not changed to maintain compatibility */ }; /* each entry in the data section (aka parameter list) is preceded by 4 bytes: 1 byte : parameter type 3 bytes: length parameter list may be terminated by 0/0/0/0 but doesn't have to since "len" field specifies the packet length sufficiently (hint: best method for parsing is to allocate len+4 bytes, set the last 4 bytes to 0 and trverse list of parameters until (int)0 occurs since 0102: if the 7-th bit (0x40) in parameter type is set then the length is encoded in 7 bytes enlarging the header by 4 bytes. */ /* macros for handling the first int - split/combine (24-bit version only!) */ #define PAR_TYPE(X) ((X) & 255) #define PAR_LEN(X) (((unsigned int)(X)) >> 8) #define PAR_LENGTH PAR_LEN #define SET_PAR(TY,LEN) ((((unsigned int) (LEN) & 0xffffff) << 8) | ((TY) & 255)) #define CMD_STAT(X) (((X) >> 24)&127) /* returns the stat code of the response */ #define SET_STAT(X,s) ((X) | (((s) & 127) << 24)) /* sets the stat code */ #define CMD_RESP 0x10000 /* all responses have this flag set */ #define RESP_OK (CMD_RESP|0x0001) /* command succeeded; returned parameters depend on the command issued */ #define RESP_ERR (CMD_RESP|0x0002) /* command failed, check stats code attached string may describe the error */ #define CMD_OOB 0x20000 /* out-of-band data - i.e. unsolicited messages */ #define OOB_SEND (CMD_OOB | 0x1000) /* OOB send - unsolicited SEXP sent from the R instance to the client. 12 LSB are reserved for application-specific code */ #define OOB_MSG (CMD_OOB | 0x2000) /* OOB message - unsolicited message sent from the R instance to the client requiring a response. 12 LSB are reserved for application-specific code */ #define IS_OOB_SEND(X) (((X) & 0x0ffff000) == OOB_SEND) #define IS_OOB_MSG(X) (((X) & 0x0ffff000) == OOB_MSG) #define OOB_USR_CODE(X) ((X) & 0xfff) /* flag for create_server: Use QAP object-cap mode */ #define SRV_QAP_OC 0x40 /* mask of all flags that are relevant to QAP (so they can be passed through) */ #define SRV_QAP_FLAGS (SRV_QAP_OC) /* stat codes; 0-0x3f are reserved for program specific codes - e.g. for R connection they correspond to the stat of Parse command. the following codes are returned by the Rserv itself codes <0 denote Rerror as provided by R_tryEval */ #define ERR_auth_failed 0x41 /* auth.failed or auth.requested but no login came. in case of authentification failure due to name/pwd mismatch, server may send CMD_accessDenied instead */ #define ERR_conn_broken 0x42 /* connection closed or broken packet killed it */ #define ERR_inv_cmd 0x43 /* unsupported/invalid command */ #define ERR_inv_par 0x44 /* some parameters are invalid */ #define ERR_Rerror 0x45 /* R-error occured, usually followed by connection shutdown */ #define ERR_IOerror 0x46 /* I/O error */ #define ERR_notOpen 0x47 /* attempt to perform fileRead/Write on closed file */ #define ERR_accessDenied 0x48 /* this answer is also valid on CMD_login; otherwise it's sent if the server deosn;t allow the user to issue the specified command. (e.g. some server admins may block file I/O operations for some users) */ #define ERR_unsupportedCmd 0x49 /* unsupported command */ #define ERR_unknownCmd 0x4a /* unknown command - the difference between unsupported and unknown is that unsupported commands are known to the server but for some reasons (e.g. platform dependent) it's not supported. unknown commands are simply not recognized by the server at all. */ /* The following ERR_.. exist since 1.23/0.1-6 */ #define ERR_data_overflow 0x4b /* incoming packet is too big. currently there is a limit as of the size of an incoming packet. */ #define ERR_object_too_big 0x4c /* the requested object is too big to be transported in that way. If received after CMD_eval then the evaluation itself was successful. optional parameter is the size of the object */ /* since 1.29/0.1-9 */ #define ERR_out_of_mem 0x4d /* out of memory. the connection is usually closed after this error was sent */ /* since 0.6-0 */ #define ERR_ctrl_closed 0x4e /* control pipe to the master process is closed or broken */ /* since 0.4-0 */ #define ERR_session_busy 0x50 /* session is still busy */ #define ERR_detach_failed 0x51 /* unable to detach seesion (cannot determine peer IP or problems creating a listening socket for resume) */ /* since 1.7 */ #define ERR_disabled 0x61 /* feature is disabled */ #define ERR_unavailable 0x62 /* feature is not present in this build */ #define ERR_cryptError 0x63 /* crypto-system error */ #define ERR_securityClose 0x64 /* server-initiated close due to security violation (too many attempts, excessive timeout etc.) */ /* availiable commands */ #define CMD_login 0x001 /* "name\npwd" : - */ #define CMD_voidEval 0x002 /* string : - */ #define CMD_eval 0x003 /* string | encoded SEXP : encoded SEXP */ #define CMD_shutdown 0x004 /* [admin-pwd] : - */ /* security/encryption - all since 1.7-0 */ #define CMD_switch 0x005 /* string (protocol) : - */ #define CMD_keyReq 0x006 /* string (request) : bytestream (key) */ #define CMD_secLogin 0x007 /* bytestream (encrypted auth) : - */ #define CMD_OCcall 0x00f /* SEXP : SEXP -- it is the only command supported in object-capability mode and it requires that the SEXP is a language construct with OC reference in the first position */ #define CMD_OCinit 0x434f7352 /* SEXP -- 'RsOC' - command sent from the server in OC mode with the packet of initial capabilities. */ /* file I/O routines. server may answe */ #define CMD_openFile 0x010 /* fn : - */ #define CMD_createFile 0x011 /* fn : - */ #define CMD_closeFile 0x012 /* - : - */ #define CMD_readFile 0x013 /* [int size] : data... ; if size not present, server is free to choose any value - usually it uses the size of its static buffer */ #define CMD_writeFile 0x014 /* data : - */ #define CMD_removeFile 0x015 /* fn : - */ /* object manipulation */ #define CMD_setSEXP 0x020 /* string(name), REXP : - */ #define CMD_assignSEXP 0x021 /* string(name), REXP : - ; same as setSEXP except that the name is parsed */ /* session management (since 0.4-0) */ #define CMD_detachSession 0x030 /* : session key */ #define CMD_detachedVoidEval 0x031 /* string : session key; doesn't */ #define CMD_attachSession 0x032 /* session key : - */ /* control commands (since 0.6-0) - passed on to the master process */ /* Note: currently all control commands are asychronous, i.e. RESP_OK indicates that the command was enqueued in the master pipe, but there is no guarantee that it will be processed. Moreover non-forked connections (e.g. the default debug setup) don't process any control commands until the current client connection is closed so the connection issuing the control command will never see its result. */ #define CMD_ctrl 0x40 /* -- not a command - just a constant -- */ #define CMD_ctrlEval 0x42 /* string : - */ #define CMD_ctrlSource 0x45 /* string : - */ #define CMD_ctrlShutdown 0x44 /* - : - */ /* 'internal' commands (since 0.1-9) */ #define CMD_setBufferSize 0x081 /* [int sendBufSize] this commad allow clients to request bigger buffer sizes if large data is to be transported from Rserve to the client. (incoming buffer is resized automatically) */ #define CMD_setEncoding 0x082 /* string (one of "native","latin1","utf8") : -; since 0.5-3 */ /* special commands - the payload of packages with this mask does not contain defined parameters */ #define CMD_SPECIAL_MASK 0xf0 #define CMD_serEval 0xf5 /* serialized eval - the packets are raw serialized data without data header */ #define CMD_serAssign 0xf6 /* serialized assign - serialized list with [[1]]=name, [[2]]=value */ #define CMD_serEEval 0xf7 /* serialized expression eval - like serEval with one additional evaluation round */ /* data types for the transport protocol (QAP1) do NOT confuse with XT_.. values. */ #define DT_INT 1 /* int */ #define DT_CHAR 2 /* char */ #define DT_DOUBLE 3 /* double */ #define DT_STRING 4 /* 0 terminted string */ #define DT_BYTESTREAM 5 /* stream of bytes (unlike DT_STRING may contain 0) */ #define DT_SEXP 10 /* encoded SEXP */ #define DT_ARRAY 11 /* array of objects (i.e. first 4 bytes specify how many subsequent objects are part of the array; 0 is legitimate) */ #define DT_CUSTOM 32 /* custom types not defined in the protocol but used by applications */ #define DT_LARGE 64 /* new in 0102: if this flag is set then the length of the object is coded as 56-bit integer enlarging the header by 4 bytes */ /* XpressionTypes REXP - R expressions are packed in the same way as command parameters transport format of the encoded Xpressions: [0] int type/len (1 byte type, 3 bytes len - same as SET_PAR) [4] REXP attr (if bit 8 in type is set) [4/8] data .. */ #define XT_NULL 0 /* P data: [0] */ #define XT_INT 1 /* - data: [4]int */ #define XT_DOUBLE 2 /* - data: [8]double */ #define XT_STR 3 /* P data: [n]char null-term. strg. */ #define XT_LANG 4 /* - data: same as XT_LIST */ #define XT_SYM 5 /* - data: [n]char symbol name */ #define XT_BOOL 6 /* - data: [1]byte boolean (1=TRUE, 0=FALSE, 2=NA) */ #define XT_S4 7 /* P data: [0] */ #define XT_VECTOR 16 /* P data: [?]REXP,REXP,.. */ #define XT_LIST 17 /* - X head, X vals, X tag (since 0.1-5) */ #define XT_CLOS 18 /* P X formals, X body (closure; since 0.1-5) */ #define XT_SYMNAME 19 /* s same as XT_STR (since 0.5) */ #define XT_LIST_NOTAG 20 /* s same as XT_VECTOR (since 0.5) */ #define XT_LIST_TAG 21 /* P X tag, X val, Y tag, Y val, ... (since 0.5) */ #define XT_LANG_NOTAG 22 /* s same as XT_LIST_NOTAG (since 0.5) */ #define XT_LANG_TAG 23 /* s same as XT_LIST_TAG (since 0.5) */ #define XT_VECTOR_EXP 26 /* s same as XT_VECTOR (since 0.5) */ #define XT_VECTOR_STR 27 /* - same as XT_VECTOR (since 0.5 but unused, use XT_ARRAY_STR instead) */ #define XT_ARRAY_INT 32 /* P data: [n*4]int,int,.. */ #define XT_ARRAY_DOUBLE 33 /* P data: [n*8]double,double,.. */ #define XT_ARRAY_STR 34 /* P data: string,string,.. (string=byte,byte,...,0) padded with '\01' */ #define XT_ARRAY_BOOL_UA 35 /* - data: [n]byte,byte,.. (unaligned! NOT supported anymore) */ #define XT_ARRAY_BOOL 36 /* P data: int(n),byte,byte,... */ #define XT_RAW 37 /* P data: int(n),byte,byte,... */ #define XT_ARRAY_CPLX 38 /* P data: [n*16]double,double,... (Re,Im,Re,Im,...) */ #define XT_UNKNOWN 48 /* P data: [4]int - SEXP type (as from TYPEOF(x)) */ /* | +--- interesting flags for client implementations: P = primary type s = secondary type - its decoding is identical to a primary type and thus the client doesn't need to decode it separately. - = deprecated/removed. if a client doesn't need to support old Rserve versions, those can be safely skipped. Total primary: 4 trivial types (NULL, STR, S4, UNKNOWN) + 6 array types + 3 recursive types */ #define XT_LARGE 64 /* new in 0102: if this flag is set then the length of the object is coded as 56-bit integer enlarging the header by 4 bytes */ #define XT_HAS_ATTR 128 /* flag; if set, the following REXP is the attribute */ /* the use of attributes and vectors results in recursive storage of REXPs */ #define BOOL_TRUE 1 #define BOOL_FALSE 0 #define BOOL_NA 2 #define GET_XT(X) ((X)&63) #define GET_DT(X) ((X)&63) #define HAS_ATTR(X) (((X)&XT_HAS_ATTR)>0) #define IS_LARGE(X) (((X)&XT_LARGE)>0) #if defined sun && ! defined ALIGN_DOUBLES #define ALIGN_DOUBLES #endif /* this is the type used to calculate pointer distances */ /* note: we may want to use size_t or something more compatible */ typedef unsigned long rlen_t; #ifdef ULONG_MAX #define rlen_max ULONG_MAX #else #ifdef __LP64__ #define rlen_max 0xffffffffffffffffL #else #define rlen_max 0xffffffffL #endif /* __LP64__ */ #endif /* ULONG_MAX */ /* functions/macros to convert native endianess of int/double for transport currently ony PPC style and Intel style are supported */ /* Since 0.4-5 we no longer use configure-time endianness tests to allow cross-compilation. Either BS_xx_ENDIAN constant is defined by configure and thus should be relied upon only if the compiler contants don't work */ #if defined __BIG_ENDIAN__ || defined _BIG_ENDIAN_ #define SWAPEND 1 #elif defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN_ || defined BS_LITTLE_ENDIAN /* #undef SWAPEND */ #elif defined BS_BIG_ENDIAN #define SWAPEND 1 #elif __ia64__ || __i386__ || __x86_64__ /* take a guess based on the architecture (Intel-like) */ #define __LITTLE_ENDIAN__ 1 #elif __ppc__ || __ppc64__ /* any ppc */ #define __BIG_ENDIAN__ 1 #define SWAPEND 1 #elif ! defined Win32 /* Windows is little-endian is most cases, anywhere else we're stuck */ #error "Cannot determine endianness. Make sure config.h is included or __{BIG|LITTLE}_ENDIAN__ is defined ." #endif /* FIXME: all the mess below needs more efficient implementation - the current one is so messy to work around alignment problems on some platforms like Sun and HP 9000 */ #ifdef SWAPEND /* swap endianness - for PPC and co. */ #ifdef MAIN unsigned int itop(unsigned int i) { char b[4]; b[0]=((char*)&i)[3]; b[3]=((char*)&i)[0]; b[1]=((char*)&i)[2]; b[2]=((char*)&i)[1]; return *((unsigned int*)b); } double dtop(double i) { char b[8]; b[0]=((char*)&i)[7]; b[1]=((char*)&i)[6]; b[2]=((char*)&i)[5]; b[3]=((char*)&i)[4]; b[7]=((char*)&i)[0]; b[6]=((char*)&i)[1]; b[5]=((char*)&i)[2]; b[4]=((char*)&i)[3]; return *((double*)b); } void fixdcpy(void *t,void *s) { int i=0; while (i<8) { ((char*)t)[7-i]=((char*)s)[i]; i++; } } #else extern unsigned int itop(unsigned int i); extern double dtop(double i); extern void fixdcpy(void *t,void *s); #endif #define ptoi(X) itop(X) /* itop*itop=id */ #define ptod(X) dtop(X) #else #define itop(X) (X) #define ptoi(X) (X) #define dtop(X) (X) #define ptod(X) (X) #define fixdcpy(T,S) ((double*)(T))[0]=((double*)(S))[0]; #define NATIVE_COPY 1 #endif #ifndef HAVE_CONFIG_H /* this tiny function can be used to make sure that the endianess is correct (it is not included if the package was configured with autoconf since then it should be fine anyway) */ #ifdef MAIN int isByteSexOk() { int i; i=itop(0x12345678); return (*((char*)&i)==0x78); } #else extern int isByteSexOk(); #endif #else #define isByteSexOk 1 #endif /* STANDALONE_RSERVE takes precedence over RSERVE_PKG */ #if defined STANDALONE_RSERVE && defined RSERVE_PKG #undef RSERVE_PKG #endif #endif /*--- The following makes the indenting behavior of emacs compatible with Xcode's 4/4 setting ---*/ /* Local Variables: */ /* indent-tabs-mode: t */ /* tab-width: 4 */ /* c-basic-offset: 4 */ /* End: */ Rserve/src/client/cxx/config.h.in0000644000176000001440000001016012205226217016437 0ustar ripleyusers/* config.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* Defined if the platform is big-endian */ #undef BS_BIG_ENDIAN /* Defined if the platform is little-endian */ #undef BS_LITTLE_ENDIAN /* If defined Rserve supports unix crypt password encryption. */ #undef HAS_CRYPT /* */ #undef HAVE_CONNECT /* Define to 1 if you have the header file. */ #undef HAVE_CRYPT_H /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `dl' library (-ldl). */ #undef HAVE_LIBDL /* Define to 1 if you have the `inet' library (-linet). */ #undef HAVE_LIBINET /* Define to 1 if you have the `nsl' library (-lnsl). */ #undef HAVE_LIBNSL /* Define to 1 if you have the `nsl_s' library (-lnsl_s). */ #undef HAVE_LIBNSL_S /* Define to 1 if you have the `socket' library (-lsocket). */ #undef HAVE_LIBSOCKET /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the `mkdir' function. */ #undef HAVE_MKDIR /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_TCP_H /* Define to 1 if you have the `rmdir' function. */ #undef HAVE_RMDIR /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT /* Define to 1 if you have the `socket' function. */ #undef HAVE_SOCKET /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_UN_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vfork' function. */ #undef HAVE_VFORK /* Define to 1 if you have the header file. */ #undef HAVE_VFORK_H /* Define to 1 if `fork' works. */ #undef HAVE_WORKING_FORK /* Define to 1 if `vfork' works. */ #undef HAVE_WORKING_VFORK /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `int' if does not define. */ #undef pid_t /* Define to `int' if neither nor define. */ #undef socklen_t /* Define as `fork' if `vfork' does not work. */ #undef vfork Rserve/src/client/cxx/sisocks.h0000644000176000001440000001700612205226216016250 0ustar ripleyusers/* system independent sockets (basically for unix and Win) * Copyright (C) 2000,1 Simon Urbanek * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; version 2.1 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * conditional defines: MAIN should be defined in just one file that will contain the fn definitions and variables USE_SNPRINTF emulate snprintf on Win platforms (you will lose the security which is provided under unix of course) SOCK_ERRORS include error code handling and checking functions */ #ifndef __SISOCKS_H__ #define __SISOCKS_H__ #if defined __GNUC__ && !defined unix && !defined Win32 /* MacOS X hack (gcc on any platform should behave as unix - except for Win32, where we need to keep using winsock) */ #define unix #endif #if defined STANDALONE_RSERVE && defined RSERVE_PKG #undef RSERVE_PKG #endif #if defined SOCK_ERRORS || defined USE_SNPRINTF #include #endif #include #ifdef unix #include #include #include #include #include #include #include #define sockerrno errno #define SOCKET int #define INVALID_SOCKET (-1) #define closesocket(A) close(A) #else #define windows #include #include #include #include #define inet_aton(A,B) (0, B.s_addr=inet_addr(A)) #define sockerrno WSAGetLastError() #ifndef WIN64 #define ECONNREFUSED WSAECONNREFUSED #define EADDRINUSE WSAEADDRINUSE #define ENOTSOCK WSAENOTSOCK #define EISCONN WSAEISCONN #define ETIMEDOUT WSAETIMEDOUT #define ENETUNREACH WSAENETUNREACH #define EINPROGRESS WSAEINPROGRESS #define EALREADY WSAEALREADY #define EAFNOSUPPORT WSAEAFNOSUPPORT #define EBADF WSAEBADF #define EINVAL WSAEINVAL #define EOPNOTSUPP WSAEOPNOTSUPP #define EFAULT WSAEFAULT #define EWOULDBLOCK WSAEWOULDBLOCK #define EACCES WSAEACCES #else #define ECONNREFUSED WSAECONNREFUSED #define EADDRINUSE WSAEADDRINUSE #define ENOTSOCK WSAENOTSOCK #define EISCONN WSAEISCONN #define ETIMEDOUT WSAETIMEDOUT #define ENETUNREACH WSAENETUNREACH #define EINPROGRESS WSAEINPROGRESS #define EALREADY WSAEALREADY #define EOPNOTSUPP WSAEOPNOTSUPP #define EWOULDBLOCK WSAEWOULDBLOCK #endif #ifdef USE_SNPRINTF #ifdef MAIN int snprintf(char *buf, int len, char *fmt, ...) { va_list argptr; int cnt; va_start(argptr, fmt); cnt = vsprintf(buf, fmt, argptr); va_end(argptr); return(cnt); } #else extern int snprintf(char *buf, int len, char *fmt, ...); #endif #endif #endif #define SA struct sockaddr #define SAIN struct sockaddr_in #ifdef windows #ifdef MAIN int initsocks(void) { WSADATA dt; /* initialize WinSock 1.1 */ return (WSAStartup(0x0101,&dt))?-1:0; } #else extern int initsocks(void); #endif #define donesocks() WSACleanup() #else /* no stupid stuff necessary for unix */ #define initsocks() #define donesocks() #endif #ifdef SOCK_ERRORS #ifdef MAIN int suppmode=0; int socklasterr; FILE *sockerrlog=0; /* copy error description to buf or set *buf=0 if none */ int sockerrorchecks(char *buf, int blen, int res) { *buf=0; if (res==-1) { switch(sockerrno) { case EBADF: strncpy(buf,"bad descriptor",blen); break; case EINVAL: strncpy(buf,"already in use",blen); break; case EACCES: strncpy(buf,"access denied",blen); break; case ENOTSOCK: strncpy(buf,"descriptor is not a socket",blen); break; case EOPNOTSUPP: strncpy(buf,"operation not supported",blen); break; case EFAULT: strncpy(buf,"fault",blen); break; case EWOULDBLOCK: strncpy(buf,"operation would block",blen); break; case EISCONN: strncpy(buf,"is already connected",blen); break; case ECONNREFUSED: strncpy(buf,"connection refused",blen); break; case ETIMEDOUT: strncpy(buf,"operation timed out",blen); break; case ENETUNREACH: strncpy(buf,"network is unreachable",blen); break; case EADDRINUSE: strncpy(buf,"address already in use",blen); break; case EINPROGRESS: strncpy(buf,"in progress",blen); break; case EALREADY: strncpy(buf,"previous connect request not completed yet",blen); break; #ifdef unix default: snprintf(buf,blen,"unknown socket error %d",sockerrno); #else default: sprintf(buf,"unknown socket error %d",sockerrno); #endif } } return res; } #ifdef RSERVE_PKG /* use error instead of exit */ #include int sockerrorcheck(char *sn, int rtb, int res) { if ((signed int)res == -1) { char sock_err_buf[72]; sockerrorchecks(sock_err_buf, sizeof(sock_err_buf), res); if (rtb) Rf_error("%s socket error #%d (%s)", sn, (int) sockerrno, sock_err_buf); else Rf_warning("%s socket error #%d (%s)", sn, (int) sockerrno, sock_err_buf); } return res; } #else /* check socket error and add to log file if necessary */ int sockerrorcheck(char *sn, int rtb, int res) { if (!sockerrlog) sockerrlog=stderr; if ((signed int)res==-1) { if (socklasterr==sockerrno) { suppmode++; } else { if (suppmode>0) { fprintf(sockerrlog,"##> REP: (last error has been repeated %d times.)\n",suppmode); suppmode=0; } fprintf(sockerrlog,"##> SOCK_ERROR: %s error #%d",sn,sockerrno); switch(sockerrno) { case EBADF: fprintf(sockerrlog,"(bad descriptor)"); break; case EINVAL: fprintf(sockerrlog,"(already in use)"); break; case EACCES: fprintf(sockerrlog,"(access denied)"); break; case ENOTSOCK: fprintf(sockerrlog,"(descriptor is not a socket)"); break; case EOPNOTSUPP: fprintf(sockerrlog,"(operation not supported)"); break; case EFAULT: fprintf(sockerrlog,"(fault)"); break; case EWOULDBLOCK: fprintf(sockerrlog,"(operation would block)"); break; case EISCONN: fprintf(sockerrlog,"(is already connected)"); break; case ECONNREFUSED: fprintf(sockerrlog,"(connection refused)"); break; case ETIMEDOUT: fprintf(sockerrlog,"(operation timed out)"); break; case ENETUNREACH: fprintf(sockerrlog,"(network is unreachable)"); break; case EADDRINUSE: fprintf(sockerrlog,"(address already in use)"); break; case EINPROGRESS: fprintf(sockerrlog,"(in progress)"); break; case EALREADY: fprintf(sockerrlog,"(previous connect request not completed yet)"); break; default: fprintf(sockerrlog,"(?)"); } fprintf(sockerrlog,"\n"); fflush(sockerrlog); socklasterr=sockerrno; } if (rtb) exit(1); } return res; } #endif #else extern int suppmode; extern int socklasterr; extern FILE *sockerrlog; int sockerrorchecks(char *buf, int blen, int res); int sockerrorcheck(char *sn, int rtb, int res); #endif #define FCF(X,F) sockerrorcheck(X,1,F) #define CF(X,F) sockerrorcheck(X,0,F) #endif #ifdef MAIN struct sockaddr *build_sin(struct sockaddr_in *sa,char *ip,int port) { memset(sa,0,sizeof(struct sockaddr_in)); sa->sin_family=AF_INET; sa->sin_port=htons(port); sa->sin_addr.s_addr=(ip)?inet_addr(ip):htonl(INADDR_ANY); return (struct sockaddr*)sa; } #else struct sockaddr *build_sin(struct sockaddr_in *sa,char *ip,int port); #endif #endif /* __SISOCKS_H__ */ Rserve/src/client/cxx/Makefile.in0000644000176000001440000000044612205226215016465 0ustar ripleyusers# Makefile for C++ Rserve clients. # # $Id$ SRC = $(wildcard *.cc) OBJ = $(SRC:%.cc=%.o) DST = demo1 rcons rsdown LIBS+=@LIBS@ CPPFLAGS+=-DHAVE_CONFIG_H all: $(DST) $(OBJ) %: Rconnection.o %.o $(CXX) $^ -o $@ $(LIBS) debug: $(MAKE) CXXFLAGS=-g all clean: rm -rf *~ *.o \#* .\#* $(DST) Rserve/src/client/cxx/Makefile.win0000755000176000001440000000063412205226215016656 0ustar ripleyusers# Makefile for C++ Rserve clients - Win32 version # # $Id$ SRC = $(wildcard *.cc) OBJ = $(SRC:%.cc=%.o) DST = demo1 rcons CXXFLAGS+=-I../include -I../include/Win32 -I.. -I. -DWin32 LIBS+=-lwsock32 linkRL= all: $(DST) demo1: Rconnection.o demo1.o $(CXX) $^ -o $@ $(LIBS) rcons: Rconnection.o rcons.o $(CXX) $^ -o $@ $(LIBS) $(linkRL) debug: CXXFLAGS=-g $(MAKE) all clean: rm -rf *~ *.o \#* .\#* $(DST) Rserve/src/client/cxx/demo1.cc0000644000176000001440000001010212205226215015722 0ustar ripleyusers/* * Small demo to illustrate the use of the C++ interface to Rserve * Copyright (C) 2004 Simon Urbanek, All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Leser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id$ */ #include using std::cout; #define MAIN // we are the main program, we need to define this #define SOCK_ERRORS // we will use verbose socket errors #include "sisocks.h" #include "Rconnection.h" // this is just a very silly example to show how the C++ API works ... int main(int argc, char **argv) { initsocks(); // this is needed for Win32 - it does nothing on unix Rconnection *rc = new Rconnection(); int i=rc->connect(); if (i) { char msg[128]; sockerrorchecks(msg, 128, -1); printf("unable to connect (result=%d, socket:%s).\n", i, msg); return i; } double d[6] = { 1.5, 2.4, 5.6, -1.2, 0.6, 1.7 }; // assign the above contents to the variable "a" in R Rdouble *rd = new Rdouble(d, 6); rc->assign("a", rd); delete rd; // create a 2 x 3 matrix named "b" and calculate b * t(b) matrix product Rdouble *x = (Rdouble*) rc->eval("b<-matrix(a,2); b%*%t(b)"); if (x) { // if everything was fine, we have the result cout << x << "\n"; // just for fun - let's get the matrix dimensionality Rinteger *dim = (Rinteger*) x->attribute("dim"); if (dim) cout << dim->intAt(0) << " by " << dim->intAt(1) << " matrix\n"; // and print the contents of the matrix (unformatted) double *d = x->doubleArray(); int i=0, ct = x->length(); while (i < ct) { cout << d[i++] << " "; } cout << "\n"; // finally dispose of the object delete x; } // integer constant assignment test int ia[6] = { 1, 4, 6, 3, 5 , 2 }; Rinteger *ri = new Rinteger(ia, 6); rc->assign("i", ri); delete ri; // let's get the whole iris data Rvector *iris = (Rvector*) rc->eval("data(iris); iris"); if (!iris) { cout << "oops! couldn't get iris data\n"; delete rc; return 0; } // now let's just get the sepal width - this a cheap operation, no talking to Rserve, because we have all the data already Rdouble *sw = (Rdouble*) iris->byName("Sepal.Width"); double *swd = sw->doubleArray(); // and print it ... { int i=0, ct=sw->length(); while (i using std::cout; #define MAIN // we are the main program, we need to define this #define SOCK_ERRORS // we will use verbose socket errors #include "Rconnection.h" #ifdef READLINE #include #include #endif #ifdef READLINE char *c=0; #else char c[1024]; #endif int main(int argc, char **argv) { initsocks(); // this is needed for Win32 - it does noting on unix Rconnection *rc = new Rconnection(); int i=rc->connect(); if (i) { char msg[128]; sockerrorchecks(msg, 128, -1); printf("unable to connect (result=%d, socket:%s).\n", i, msg); return i; } printf("connected. Type \"q\" to quit.\n"); do { #ifdef READLINE c=readline("Rcli> "); if (c && *c) add_history(c); #else printf("Rcli> "); c[1023]=0; fgets(c,1023,stdin); char *rq=c; while(*rq && rq-c<1023) { if (*rq=='\n') *rq=0; rq++; } #endif if (!strcmp(c,"q") || !strcmp(c,"quit") || !strcmp(c,"exit")) { cout << "ok, you got enough, right? leaving.\n"; break; } int res=0; if (!strcmp(c,"shutdown")) { // this is a demo of low-level commands being send via "request" Rmessage *msg=new Rmessage(); cout << "performing shutdown.\n"; res=rc->request(msg,CMD_shutdown); delete(msg); } else if (*c) { // this is a regular "eval" demo Rexp *xp=rc->eval(c, &res); if (xp) { cout << "type=" << xp->type << ", len=" << xp->len << ", result:" << *xp << "\n"; if (xp->attr) cout << "attributes: " << *xp->attr << "\n"; delete(xp); } else cout << "eval failed with result " << res << "\n"; } if (res) { cout << "request failed with error code " << res << "\n"; break; } } while (1); delete(rc); return 0; } Rserve/src/client/cxx/Rconnection.h0000644000176000001440000003220512205226215017050 0ustar ripleyusers/* * C++ Interface to Rserve * Copyright (C) 2004-8 Simon Urbanek, All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Leser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Although this code is licensed under LGPL v2.1, we strongly encourage * everyone modifying this software to contribute back any improvements and * bugfixes to the project for the benefit all other users. Thank you. * * $Id$ */ /* external defines: SWAPEND - needs to be defined for platforms with inverse endianess related to Intel MAIN - should be defined in just one file that will contain the fn definitions and variables (this is inherited from Rsrv.h and sisocks.h) */ #ifndef __RCONNECTION_H__ #define __RCONNECTION_H__ #if defined __GNUC__ && !defined unix && !defined Win32 && !defined WIN32 #define unix #endif #include #include #include "sisocks.h" #include "Rsrv.h" typedef unsigned int Rsize_t; //=== Rconnection error codes #define CERR_connect_failed -1 #define CERR_handshake_failed -2 #define CERR_invalid_id -3 #define CERR_protocol_not_supp -4 #define CERR_not_connected -5 #define CERR_peer_closed -7 #define CERR_malformed_packet -8 #define CERR_send_error -9 #define CERR_out_of_mem -10 #define CERR_not_supported -11 #define CERR_io_error -12 // this one is custom - authentication method required by // the server is not supported in this client #define CERR_auth_unsupported -20 #define A_required 0x001 #define A_crypt 0x002 #define A_plain 0x004 //===================================== Rmessage ---- QAP1 storage class Rmessage { public: struct phdr head; char *data; Rsize_t len; int complete; // the following is avaliable only for parsed messages (max 16 pars) int pars; unsigned int *par[16]; Rmessage(); Rmessage(int cmd); // 0 data Rmessage(int cmd, const char *txt); // DT_STRING data Rmessage(int cmd, int i); // DT_INT data (1 entry) Rmessage(int cmd, const void *buf, int len, int raw_data=0); // raw data or DT_BYTESTREAM virtual ~Rmessage(); int command() { return complete?head.cmd:-1; } Rsize_t length() { return complete?head.len:-1; } int is_complete() { return complete; } int read(int s); void parse(); int send(int s); }; //===================================== Rexp --- basis for all SEXPs class Rexp { public: Rmessage *msg; unsigned int *pos; Rsize_t len; Rexp *attr; int type; /* memory manegement for data/len: - content is in a message and this Rexp is the master of that message: master=0; msg=; - content is in a message, but this Rexp is not the master master=; msg=0 - content is all self-allocated with no message associated master=this; msg=0 */ char *data, *next; protected: // the next two are only cached if requested, no direct access allowed int attribs; const char **attrnames; Rexp *master; // if this is set then this Rexp allocated the memory for us, so we are not supposed to free anything; if this is set to "this" then the content is self-allocated, including any data int rcount; // reference count - only for a master - it counts how many children still exist public: Rexp(Rmessage *msg); Rexp(unsigned int *pos, Rmessage *msg=0); Rexp(int type, const char *data=0, int len=0, Rexp *attr=0); virtual ~Rexp(); void set_master(Rexp *m); char *parse(unsigned int *pos); virtual Rsize_t storageSize() { return len+((len>0x7fffff)?8:4); } virtual void store(char *buf); Rexp *attribute(const char *name); const char **attributeNames(); virtual Rsize_t length() { return len; } friend std::ostream& operator<< (std::ostream& os, const Rexp& exp) { return ((Rexp&)exp).os_print(os); } friend std::ostream& operator<< (std::ostream& os, const Rexp* exp) { return ((Rexp*)exp)->os_print(os); } virtual std::ostream& os_print(std::ostream& os) { return os << "Rexp[type=" << type << ",len=" << len <<"]"; } }; //===================================== Rint --- XT_INT/XT_ARRAY_INT class Rinteger : public Rexp { public: Rinteger(Rmessage *msg) : Rexp(msg) { fix_content(); } Rinteger(unsigned int *ipos, Rmessage *imsg) : Rexp(ipos, imsg) { fix_content(); } Rinteger(int *array, int count) : Rexp(XT_ARRAY_INT, (char*)array, count*sizeof(int)) { fix_content(); } int *intArray() { return (int*) data; } int intAt(int pos) { return (pos>=0 && (unsigned)pos=0 && (unsigned)pos= nel) ? 0 : cont[i]; } char *string() { return stringAt(0); } virtual Rsize_t length() { return nel; } unsigned int count() { return nel; } int indexOfString(const char *str); virtual std::ostream& os_print (std::ostream& os) { return os << "char*[" << nel <<"]\"" << string() <<"\".."; } private: void decode() { char *c = (char*) data; unsigned int i = 0; nel = 0; while (i < len) { if (!c[i]) nel++; i++; } if (nel) { i = 0; cont = (char**) malloc(sizeof(char*)*nel); while (i < nel) { cont[i] = strdup(c); while (*c) c++; c++; i++; } } else cont = 0; } }; //===================================== Rstring --- XT_STR class Rstring : public Rexp { public: Rstring(Rmessage *msg) : Rexp(msg) {} Rstring(unsigned int *ipos, Rmessage *imsg) : Rexp(ipos, imsg) {} Rstring(const char *str) : Rexp(XT_STR, str, strlen(str)+1) {} char *string() { return (char*) data; } virtual std::ostream& os_print (std::ostream& os) { return os << "\"" << string() <<"\""; } }; //===================================== Rlist --- XT_LIST (CONS lists) class Rlist : public Rexp { public: Rexp *head, *tag; Rlist *tail; Rlist(Rmessage *msg) : Rexp(msg) { head=tag=0; tail=0; fix_content(); } Rlist(unsigned int *ipos, Rmessage *imsg) : Rexp(ipos, imsg) { head=tag=0; tail=0; fix_content(); } /* this is a sort of special constructor that allows to create a Rlist based solely on its content. This is necessary since 0.5 because each LISTSXP is no longer represented by its own encoded SEXP but they are packed in one content list instead */ Rlist(int type, Rexp *head, Rexp *tag, char *next, Rmessage *imsg) : Rexp(type, 0, 0, 0) { this->head = head; this->tag = tag; tail = 0; this->next = next; this->msg = imsg; master = 0; } virtual ~Rlist(); Rexp *entryByTagName(const char *tagName) { if (tag && (tag->type==XT_SYM || tag->type==XT_SYMNAME) && !strcmp(((Rsymbol*)tag)->symbolName(),tagName)) return head; if (tail) return tail->entryByTagName(tagName); return 0; } virtual std::ostream& os_print (std::ostream& os) { os << "Rlist[tag="; if (tag) os << *tag; else os << ""; os << ",head="; if (head) os << *head; else os << ""; if (tail) os << ",tail=" << *tail; return os << "]"; } private: void fix_content(); }; //===================================== Rvector --- XT_VECTOR (general lists) class Rvector : public Rexp { protected: Rexp **cont; int count; // cached char **strs; public: Rvector(Rmessage *msg) : Rexp(msg) { cont=0; count=0; strs=0; fix_content(); } Rvector(unsigned int *ipos, Rmessage *imsg) : Rexp(ipos, imsg) { cont=0; count=0; strs=0; fix_content(); } virtual ~Rvector(); char **strings(); int indexOf(Rexp *exp); int indexOfString(const char *str); virtual Rsize_t length() { return (Rsize_t) count; } char *stringAt(int i) { if (i < 0 || i >= count || !cont[i] || cont[i]->type != XT_STR) return 0; return ((Rstring*)cont[i])->string(); } Rexp *elementAt(int i) { return (i < 0 || i >= count || !cont[i]) ? 0 : cont[i]; } Rexp* byName(const char *name); virtual std::ostream& os_print (std::ostream& os) { os << "Rvector[count=" << count << ":"; int i=0; while (i. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: Simon.Urbanek@r-project.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='Rserve-cxx-client' PACKAGE_TARNAME='rserve-cxx-client' PACKAGE_VERSION='0.1' PACKAGE_STRING='Rserve-cxx-client 0.1' PACKAGE_BUGREPORT='Simon.Urbanek@r-project.org' PACKAGE_URL='' ac_unique_file="Rconnection.cc" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='LTLIBOBJS LIBOBJS EGREP GREP CPP ac_ct_CXX CXXFLAGS CXX OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CXX CXXFLAGS CCC CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures Rserve-cxx-client 0.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/rserve-cxx-client] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of Rserve-cxx-client 0.1:";; esac cat <<\_ACEOF Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXX C++ compiler command CXXFLAGS C++ compiler flags CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF Rserve-cxx-client configure 0.1 generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval "test \"\${$3+set}\"" = set; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------------------ ## ## Report this to Simon.Urbanek@r-project.org ## ## ------------------------------------------ ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_mongrel # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_compile # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_type # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by Rserve-cxx-client $as_me 0.1, which was generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5 ; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5 ; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5 ; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5 ; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if test "${ac_cv_objext+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if test "${ac_cv_prog_cxx_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if test "${ac_cv_path_GREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if test "${ac_cv_path_EGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5 $as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; } if test "${ac_cv_header_sys_wait_h+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif int main () { int s; wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_sys_wait_h=yes else ac_cv_header_sys_wait_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5 $as_echo "$ac_cv_header_sys_wait_h" >&6; } if test $ac_cv_header_sys_wait_h = yes; then $as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in string.h memory.h sys/time.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in sys/stat.h sys/types.h sys/socket.h sys/un.h netinet/in.h netinet/tcp.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if test "${ac_cv_c_const+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if test "${ac_cv_c_bigendian+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define BS_BIG_ENDIAN 1" >>confdefs.h ;; #( no) $as_echo "#define BS_LITTLE_ENDIAN 1" >>confdefs.h ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: endianness unknown - will rely solely on compiler macros" >&5 $as_echo "endianness unknown - will rely solely on compiler macros" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler sets endianness macros" >&5 $as_echo_n "checking whether compiler sets endianness macros... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN_ || defined __BIG_ENDIAN__ || defined _BIG_ENDIAN_ #define BS_OK 1 #else cannot determine compiler's endianness #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "Cannot determine endianness neither from the compiler nor using a test. Try adding -D_BIG_ENDIAN_ or -D_LITTLE_ENDIAN_ to PKG_CPPFLAGS. " "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if test "${ac_cv_header_time+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi # Checks for library functions. ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" if test "x$ac_cv_type_pid_t" = x""yes; then : else cat >>confdefs.h <<_ACEOF #define pid_t int _ACEOF fi for ac_header in vfork.h do : ac_fn_c_check_header_mongrel "$LINENO" "vfork.h" "ac_cv_header_vfork_h" "$ac_includes_default" if test "x$ac_cv_header_vfork_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_VFORK_H 1 _ACEOF fi done for ac_func in fork vfork do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done if test "x$ac_cv_func_fork" = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working fork" >&5 $as_echo_n "checking for working fork... " >&6; } if test "${ac_cv_func_fork_works+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_fork_works=cross else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* By Ruediger Kuhlmann. */ return fork () < 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_fork_works=yes else ac_cv_func_fork_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_fork_works" >&5 $as_echo "$ac_cv_func_fork_works" >&6; } else ac_cv_func_fork_works=$ac_cv_func_fork fi if test "x$ac_cv_func_fork_works" = xcross; then case $host in *-*-amigaos* | *-*-msdosdjgpp*) # Override, as these systems have only a dummy fork() stub ac_cv_func_fork_works=no ;; *) ac_cv_func_fork_works=yes ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5 $as_echo "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;} fi ac_cv_func_vfork_works=$ac_cv_func_vfork if test "x$ac_cv_func_vfork" = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working vfork" >&5 $as_echo_n "checking for working vfork... " >&6; } if test "${ac_cv_func_vfork_works+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_vfork_works=cross else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Thanks to Paul Eggert for this test. */ $ac_includes_default #include #ifdef HAVE_VFORK_H # include #endif /* On some sparc systems, changes by the child to local and incoming argument registers are propagated back to the parent. The compiler is told about this with #include , but some compilers (e.g. gcc -O) don't grok . Test for this by using a static variable whose address is put into a register that is clobbered by the vfork. */ static void #ifdef __cplusplus sparc_address_test (int arg) # else sparc_address_test (arg) int arg; #endif { static pid_t child; if (!child) { child = vfork (); if (child < 0) { perror ("vfork"); _exit(2); } if (!child) { arg = getpid(); write(-1, "", 0); _exit (arg); } } } int main () { pid_t parent = getpid (); pid_t child; sparc_address_test (0); child = vfork (); if (child == 0) { /* Here is another test for sparc vfork register problems. This test uses lots of local variables, at least as many local variables as main has allocated so far including compiler temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should reuse the register of parent for one of the local variables, since it will think that parent can't possibly be used any more in this routine. Assigning to the local variable will thus munge parent in the parent process. */ pid_t p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(), p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid(); /* Convince the compiler that p..p7 are live; otherwise, it might use the same hardware register for all 8 local variables. */ if (p != p1 || p != p2 || p != p3 || p != p4 || p != p5 || p != p6 || p != p7) _exit(1); /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent from child file descriptors. If the child closes a descriptor before it execs or exits, this munges the parent's descriptor as well. Test for this by closing stdout in the child. */ _exit(close(fileno(stdout)) != 0); } else { int status; struct stat st; while (wait(&status) != child) ; return ( /* Was there some problem with vforking? */ child < 0 /* Did the child fail? (This shouldn't happen.) */ || status /* Did the vfork/compiler bug occur? */ || parent != getpid() /* Did the file descriptor bug occur? */ || fstat(fileno(stdout), &st) != 0 ); } } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_vfork_works=yes else ac_cv_func_vfork_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_vfork_works" >&5 $as_echo "$ac_cv_func_vfork_works" >&6; } fi; if test "x$ac_cv_func_fork_works" = xcross; then ac_cv_func_vfork_works=$ac_cv_func_vfork { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5 $as_echo "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;} fi if test "x$ac_cv_func_vfork_works" = xyes; then $as_echo "#define HAVE_WORKING_VFORK 1" >>confdefs.h else $as_echo "#define vfork fork" >>confdefs.h fi if test "x$ac_cv_func_fork_works" = xyes; then $as_echo "#define HAVE_WORKING_FORK 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 $as_echo_n "checking return type of signal handlers... " >&6; } if test "${ac_cv_type_signal+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { return *(signal (0, 0)) (0) == 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_type_signal=int else ac_cv_type_signal=void fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 $as_echo "$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF for ac_func in memset mkdir rmdir select socket do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done # Check whether we can use crypt (and if we do if it's in the crypt library) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing crypt" >&5 $as_echo_n "checking for library containing crypt... " >&6; } if test "${ac_cv_search_crypt+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char crypt (); int main () { return crypt (); ; return 0; } _ACEOF for ac_lib in '' crypt; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_crypt=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if test "${ac_cv_search_crypt+set}" = set; then : break fi done if test "${ac_cv_search_crypt+set}" = set; then : else ac_cv_search_crypt=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_crypt" >&5 $as_echo "$ac_cv_search_crypt" >&6; } ac_res=$ac_cv_search_crypt if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define HAS_CRYPT 1" >>confdefs.h fi for ac_header in crypt.h do : ac_fn_c_check_header_mongrel "$LINENO" "crypt.h" "ac_cv_header_crypt_h" "$ac_includes_default" if test "x$ac_cv_header_crypt_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_CRYPT_H 1 _ACEOF fi done # socket related stuff - indroduced first due to Solaris # socklen_t - note that we don't try to find an equivalent! # we'll use BSD-style int in case this one isn't defined. # that should be fine for all major platforms. ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" " #include #include " if test "x$ac_cv_type_socklen_t" = x""yes; then : else $as_echo "#define socklen_t int" >>confdefs.h fi # connect may need -lsocket and/or -lnsl (e.g. on Solaris) for ac_func in connect do : ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect" if test "x$ac_cv_func_connect" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_CONNECT 1 _ACEOF fi done if test x"$ac_cv_func_connect" = x"no"; then case "$LIBS" in *-lnsl*) ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf in -lnsl_s" >&5 $as_echo_n "checking for printf in -lnsl_s... " >&6; } if test "${ac_cv_lib_nsl_s_printf+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl_s $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char printf (); int main () { return printf (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nsl_s_printf=yes else ac_cv_lib_nsl_s_printf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_s_printf" >&5 $as_echo "$ac_cv_lib_nsl_s_printf" >&6; } if test "x$ac_cv_lib_nsl_s_printf" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBNSL_S 1 _ACEOF LIBS="-lnsl_s $LIBS" fi ;; esac case "$LIBS" in *-lnsl*) ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf in -lnsl" >&5 $as_echo_n "checking for printf in -lnsl... " >&6; } if test "${ac_cv_lib_nsl_printf+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char printf (); int main () { return printf (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nsl_printf=yes else ac_cv_lib_nsl_printf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_printf" >&5 $as_echo "$ac_cv_lib_nsl_printf" >&6; } if test "x$ac_cv_lib_nsl_printf" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBNSL 1 _ACEOF LIBS="-lnsl $LIBS" fi ;; esac case "$LIBS" in *-lsocket*) ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5 $as_echo_n "checking for connect in -lsocket... " >&6; } if test "${ac_cv_lib_socket_connect+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char connect (); int main () { return connect (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_connect=yes else ac_cv_lib_socket_connect=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5 $as_echo "$ac_cv_lib_socket_connect" >&6; } if test "x$ac_cv_lib_socket_connect" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSOCKET 1 _ACEOF LIBS="-lsocket $LIBS" fi ;; esac case "$LIBS" in *-linet*) ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -linet" >&5 $as_echo_n "checking for connect in -linet... " >&6; } if test "${ac_cv_lib_inet_connect+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-linet $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char connect (); int main () { return connect (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_inet_connect=yes else ac_cv_lib_inet_connect=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_inet_connect" >&5 $as_echo "$ac_cv_lib_inet_connect" >&6; } if test "x$ac_cv_lib_inet_connect" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBINET 1 _ACEOF LIBS="-linet $LIBS" fi ;; esac if test x"$ac_cv_lib_socket_connect" = x"yes" || test x"$ac_cv_lib_inet_connect" = x"yes"; then # ac_cv_func_connect=yes # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run $as_echo "#define HAVE_CONNECT 1" >>confdefs.h fi fi # on some platforms libR expects dl code in the binary { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if test "${ac_cv_lib_dl_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDL 1 _ACEOF LIBS="-ldl $LIBS" fi ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : ${CONFIG_STATUS=./config.status} ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by Rserve-cxx-client $as_me 0.1, which was generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ Rserve-cxx-client config.status 0.1 configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_t=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_t"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$tmp/stdin" case $ac_file in -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi Rserve/src/client/cxx/ReadMe.txt0000644000176000001440000000536412205226215016322 0ustar ripleyusersThis directory contains a sample C++ client for Rserve You can compile this client without R. Just run "configure" in the Rserve directory, a corresponding Makefile will be automatically generated. Win32: There is no configure for Windows, but there is a special Makefile.win to build it - use "make -f Makefile.win" - it requires MinGW (or compatible) and GNU make. This C++ interface is experimental and does not come in form of a library, it is left to the user to build one or just use it in static form. Rconnection.h and Rconnection.cc is all that's needed. This directory also contains two little examples: * demo1.cc This (rather silly) example demonstrates the basic use of the API, such as assigning contents, evaluating expressions and fetching various parts of the data. * rcons.cc A very simple console to Rserve. It uses the os_print method to print the results and its attributes. It is helpful if you want to understand how R and Rserve stores various expressions. * rcmd.cc This program "sources" all files specified on the command line into a Rserve session and prints its output. It is something like a 'fast' version of R CMD BATCH. It's very simple, so look at the code if you want a more sophisticated behavior. The entire C++ interface handles only the most basic types such as lists, vectors, doubles, integers and strings. Look at the sources to see how to implement other types if necessary (although there isn't too much missing, maybe logical vectors ...). A word about the memory allocation of the objects here: in most cases the memory is allocated by the Rmessage object that receives the evaluated expression for R. All further Rexp objects are just pointers inside that message. For convenience there is one "main" Rexp, which knows about the message and automaically deallocates it upon its own destruction. This means that from user's point of view there is always only *one* object which can be deleted, namely the one returned by 'eval'. The user should *never* delete any object obtained indirectly from another Rexp. Complex Rexps, such as Rvector always return direct pointers to their content. This applies also to pointer to other types obtained from Rexp such as doubleArray of Rdouble. You should always copy this content if you plan to make modifications. This approach was taken to provide very fast access to all objects returned from Rserve. Usually noting needs to be copied - this is imporant, because the objects could be quite large. Please feel free to contribute to this project. I don't use this C++ interface myself, therefore it is left to the users to extend it further. All low-level handling is implemented, therefore it is much easier to add high-level functionality. see also: http://www.rosuda.org/Rserve/ Simon Urbanek, Sept 2004 Rserve/src/client/cxx/Rconnection.cc0000644000176000001440000006247412205226215017221 0ustar ripleyusers/* * C++ Interface to Rserve * Copyright (C) 2004-8 Simon Urbanek, All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Leser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Although this code is licensed under LGPL v2.1, we strongly encourage * everyone modifying this software to contribute back any improvements and * bugfixes to the project for the benefit all other users. Thank you. * * $Id$ */ /* external defines: SWAPEND - needs to be defined for platforms with inverse endianess related to Intel see also SOCK_ERROR, MAIN and other defines in sisocks.h */ /* locally generated status error and return codes: -1 - operation failed (e.g. connect failed) -2 - handhake failed -3 - invalid ID string -4 - protocol not supported -5 - not connected -6 - - unused - -7 - remote connection close -8 - malformed packet -9 - send error -10 - out of memory -11 - operation is unsupported (e.g. unix login while crypt is not linked) -12 - eval didn't return a SEXP (possibly the server is too old/buggy or crashed) */ #include "Rconnection.h" #include #include "sisocks.h" #ifdef unix #include #include #else #define AF_LOCAL -1 #endif #if defined HAVE_NETINET_TCP_H && defined HAVE_NETINET_IN_H #define CAN_TCP_NODELAY #include #include #endif #ifdef Win32 #define CAN_TCP_NODELAY #endif #include "Rsrv.h" #ifndef AF_LOCAL #define AF_LOCAL AF_UNIX #endif // NOTE: 0103 compatibility has not been established! use at your own risk! static const char *myID = "Rsrv0103QAP1"; /* this client supports up to protocol version 0103 */ #define IS_LIST_TYPE_(TYPE) ((TYPE) == XT_LIST || (TYPE) == XT_LIST_NOTAG || (TYPE) == XT_LIST_TAG) #define IS_SYMBOL_TYPE_(TYPE) ((TYPE) == XT_SYM || (TYPE) == XT_SYMNAME) static Rexp *new_parsed_Rexp(unsigned int *d, Rmessage *msg) { int type=ptoi(*d)&0x3f; #ifdef DEBUG_CXX printf("new_parsed_Rexp(%p, %p) type=%d\n", d, msg, type); #endif if (type==XT_ARRAY_INT || type==XT_INT) return new Rinteger(d,msg); if (type==XT_ARRAY_DOUBLE || type==XT_DOUBLE) return new Rdouble(d,msg); if (IS_LIST_TYPE_(type)) return new Rlist(d,msg); if (type==XT_VECTOR) return new Rvector(d,msg); if (type==XT_STR) return new Rstring(d,msg); if (type==XT_SYM || type==XT_SYMNAME) return new Rsymbol(d,msg); if (type==XT_ARRAY_STR) return new Rstrings(d,msg); return new Rexp(d,msg); } static Rexp *new_parsed_Rexp_from_Msg(Rmessage *msg) { int hl=1; unsigned int *hp=msg->par[0]; Rsize_t plen=hp[0]>>8; if ((hp[0]&DT_LARGE)>0) { hl++; plen|=((Rsize_t)hp[1])<<24; } return new_parsed_Rexp(hp+hl,msg); } Rmessage::Rmessage() { complete=0; data=0; len=0; } Rmessage::Rmessage(int cmd) { memset(&head,0,sizeof(head)); head.cmd = cmd; data=0; len=0; complete=1; } Rmessage::Rmessage(int cmd, const char *txt) { memset(&head,0,sizeof(head)); int tl=strlen(txt)+1; if ((tl&3)>0) tl=(tl+4)&0xffffc; // allign the text len=tl+4; // message length is tl + 4 (short format only) head.cmd=cmd; head.len=len; data=(char*)malloc(tl+16); memset(data,0,tl+16); *((int*)data)=itop(SET_PAR(DT_STRING,tl)); strcpy(data+4,txt); complete=1; } Rmessage::Rmessage(int cmd, const void *buf, int dlen, int raw_data) { memset(&head,0,sizeof(head)); len=(raw_data)?dlen:(dlen+4); head.cmd=cmd; head.len=len; data=(char*)malloc(len); memcpy(data, (raw_data)?buf:((char*)buf+4), dlen); if (!raw_data) *((int*)data)=itop(SET_PAR(DT_BYTESTREAM,dlen)); complete=1; } Rmessage::Rmessage(int cmd, int i) { memset(&head,0,sizeof(head)); len=8; // DT_INT+len (4) + payload-1xINT (4) head.cmd=cmd; head.len=len; data=(char*)malloc(8); *((int*)data)=itop(SET_PAR(DT_INT,4)); ((int*)data)[1]=itop(i); complete=1; } Rmessage::~Rmessage() { if(data) free(data); complete=0; } int Rmessage::read(int s) { complete=0; int n=recv(s,(char*)&head,sizeof(head),0); if (n!=sizeof(head)) { closesocket(s); s=-1; return (n==0)?-7:-8; } Rsize_t i=len=head.len=ptoi(head.len); head.cmd=ptoi(head.cmd); head.dof=ptoi(head.dof); head.res=ptoi(head.res); if (head.dof>0) { // skip past DOF if present char sb[256]; int k=head.dof; while (k>0) { n=recv(s,(char*)sb,(k>256)?256:k,0); if (n<1) { closesocket(s); s=-1; return -8; // malformed packet } k-=n; } } if (i>0) { data=(char*) malloc(i); if (!data) { closesocket(s); s=-1; return -10; // out of memory } char *dp=data; while(i>0 && (n=recv(s,(char*)dp,i,0))>0) { dp+=n; i-=n; } if (i>0) { closesocket(s); s=-1; return -8; } } parse(); complete=1; return 0; } void Rmessage::parse() { pars=0; if (len<4) return; char *c=data, *eop=c+len; while (c>8; if ((p1&DT_LARGE)>0) { hs+=4; unsigned int p2=ptoi(pp[1]); len|=((Rsize_t)p2)<<24; } #ifdef DEBUG_CXX printf(" par %d: %d length %d\n", pars, p1&0x3f, len); #endif par[pars++]=(unsigned int*)c; c+=hs; c+=len; if (pars>15) break; // max 16 pars } } int Rmessage::send(int s) { int failed=0; head.cmd=itop(head.cmd); head.len=itop(head.len); head.dof=itop(head.dof); head.res=itop(head.res); if (::send(s,(char*)&head,sizeof(head),0)!=sizeof(head)) failed=-1; if (!failed && len>0 && (Rsize_t)::send(s,data,len,0)!=len) failed=-1; head.cmd=ptoi(head.cmd); head.len=ptoi(head.len); head.dof=ptoi(head.dof); head.res=ptoi(head.res); return failed; } Rexp::Rexp(Rmessage *msg) { #ifdef DEBUG_CXX printf("new Rexp@%x\n", this); #endif master=0; rcount=0; attr=0; attribs=0; this->msg=msg; int hl=1; unsigned int *hp=msg->par[0]; Rsize_t plen=hp[0]>>8; if ((hp[0]&DT_LARGE)>0) { hl++; plen|=((Rsize_t)hp[1])<<24; } next=parse(hp+hl); } Rexp::Rexp(unsigned int *pos, Rmessage *msg) { #ifdef DEBUG_CXX printf("new Rexp@%x\n", this); #endif attr=0; master=0; this->msg=msg; rcount=0; attribs=0; next=parse(pos); } Rexp::Rexp(int type, const char *data, int len, Rexp *attr) { this->attr=attr; master=this; rcount=0; attribs=0; this->type=type; this->msg=0; if (len>0) { #ifdef DEBUG_CXX fprintf(stderr, "Rexp::Rexp %p: allocating %d bytes\n", this, len); #endif this->data=(char*) malloc(len); memcpy(this->data, data, len); this->len=len; } else this->len=0; next=(char*)data+this->len; } Rexp::~Rexp() { #ifdef DEBUG_CXX printf("releasing Rexp@%p\n", this); #endif if (attr) delete(attr); attr=0; if (master) { if (master==this) { free(data); len=0; } else master->rcount--; master=0; } if (msg) { if (rcount>0) fprintf(stderr, "WARNING! Rexp master %lx delete requested, but %d object(s) are using our memory - refusing to free, leaking...\n", (long)this, rcount); else delete(msg); } msg=0; } void Rexp::set_master(Rexp *m) { if (master) master->rcount--; master=m; if (m) m->rcount++; } char *Rexp::parse(unsigned int *pos) { // plen is not used this->pos=pos; int hl=1; unsigned int p1=ptoi(pos[0]); len=p1>>8; if ((p1&XT_LARGE)>0) { hl++; len|=((Rsize_t)(ptoi(pos[1])))<<24; } data=(char*)(pos+hl); if (p1&XT_HAS_ATTR) { attr=new_parsed_Rexp((unsigned int*)data, 0); len-=attr->next-data; data=attr->next; if (master || msg) attr->set_master(master?master:this); } type=p1&0x3f; #ifdef DEBUG_CXX printf("Rexp(type=%d, len=%d, attr=%p)\n", type, len, attr); #endif return data+len; } void Rexp::store(char *buf) { int hl=4; unsigned int *i = (unsigned int*)buf; i[0]=SET_PAR(type, len); i[0]=itop(i[0]); if (len>0x7fffff) { buf[0]|=XT_LARGE; i[1]=itop(len>>24); hl+=4; } memcpy(buf+hl, data, len); } Rexp *Rexp::attribute(const char *name) { return (attr && IS_LIST_TYPE_(attr->type)) ? ((Rlist*)attr)->entryByTagName(name) : 0; } const char **Rexp::attributeNames() { if (!attr || !IS_LIST_TYPE_(attr->type)) return 0; if (attribs == 0) { // let us cache attribute names Rlist *l = (Rlist*) attr; while (l && (IS_LIST_TYPE_(l->type))) { if (l->tag && IS_SYMBOL_TYPE_(l->tag->type)) attribs++; l = l->tail; } attrnames = (const char**) malloc(sizeof(char*)*(attribs+1)); l = (Rlist*) attr; while (l && IS_LIST_TYPE_(l->type)) { if (l->tag && IS_SYMBOL_TYPE_(l->tag->type)) attrnames[attribs++] = ((Rsymbol*)l->tag)->symbolName(); l = l->tail; } attrnames[attribs] = 0; } return attrnames; } void Rinteger::fix_content() { if (len<0 || !data) return; #ifdef SWAPEND int *i = (int*) data; int *j = (int*) (data+len); while (inext; if (ptrnext; if (ptrtype!=XT_LIST) { // if tail is not a list, then something is wrong - just delete it delete(tail); tail=0; } } } } } else if (type == XT_LIST_NOTAG) { /* new style list w/o tags */ Rlist *lt = this; int n = 0; while (ptr < eod) { Rexp *h = new_parsed_Rexp((unsigned int*) ptr, 0); if (!h) break; if (n) lt = lt->tail = new Rlist(type, h, 0, h->next, msg); else lt->head = h; n++; ptr = h->next; } } else if (type == XT_LIST_TAG) { /* new style list with tags */ Rlist *lt = this; int n = 0; while (ptr < eod) { Rexp *h = new_parsed_Rexp((unsigned int*) ptr, 0); #ifdef DEBUG_CXX printf(" LIST_TAG: n=%d, ptr=%p, h=%p\n", n, ptr, h); #endif if (!h) break; ptr = h->next; Rexp *t = new_parsed_Rexp((unsigned int*) ptr, 0); #ifdef DEBUG_CXX printf(" tag=%p (ptr=%p)\n", t, ptr); #endif if (!t) break; if (n) lt = lt->tail = new Rlist(type, h, t, t->next, msg); else { lt->head = h; lt->tag = t; } ptr = t->next; n++; } next = ptr; } #ifdef DEBUG_CXX printf(" end of list %p, ptr=%p\n", this, ptr); #endif } Rvector::~Rvector() { int i=0; while(itype==XT_STR) sc++; i++; } if (sc==0) return 0; strs=(char**)malloc(sizeof(char*)*(sc+1)); i=0; sc=0; while (itype==XT_STR) strs[sc++]=((Rstring*)cont[i])->string(); i++; } strs[sc]=0; return strs; } int Rvector::indexOf(Rexp *exp) { int i=0; while (itype==XT_STR && !strcmp(((Rstring*)cont[i])->string(),str)) return i; i++; } return -1; } int Rstrings::indexOfString(const char *str) { unsigned int i = 0; while (i < nel) { if (cont[i] && !strcmp(cont[i], str)) return i; i++; } return -1; } Rexp* Rvector::byName(const char *name) { /* here we are not using IS_LIST_TYPE_() because XT_LIST_NOTAG is guaranteed to not match */ if (count < 1 || !attr || (attr->type!=XT_LIST && attr->type != XT_LIST_TAG)) return 0; Rexp *e = ((Rlist*) attr)->head; if (((Rlist*) attr)->tag) e = ((Rlist*) attr)->entryByTagName("names"); if (!e || (e->type!=XT_VECTOR && e->type!=XT_ARRAY_STR && e->type!=XT_STR)) return 0; if (e->type == XT_VECTOR) { int pos = ((Rvector*)e)->indexOfString(name); if (pos>-1 && postype == XT_ARRAY_STR) { int pos = ((Rstrings*)e)->indexOfString(name); if (pos>-1 && posstring(),name)) return cont[0]; } return 0; } void Rvector::fix_content() { char *ptr = data; char *eod = data+len; capacity=16; cont=(Rexp**) malloc(sizeof(Rexp*)*capacity); while (ptrnext; else break; count++; } } Rconnection::Rconnection(const char *host, int port) { if (!host) host = "127.0.0.1"; this->host = strdup(host); this->port = port; family = (port==-1) ? AF_LOCAL : AF_INET; s = -1; auth = 0; salt[0] = '.'; salt[1] = '.'; session_key = 0; } Rconnection::Rconnection(Rsession *session) { const char *sHost = session->host(); if (!sHost) sHost="127.0.0.1"; this->host = strdup(sHost); this->port = session->port(); family = AF_INET; s = -1; auth = 0; salt[0]='.'; salt[1]='.'; session_key = (char*) malloc(32); memcpy(session_key, session->key(), 32); } Rconnection::~Rconnection() { if (host) free(host); host = 0; if (s != -1) closesocket(s); s = -1; } int Rconnection::connect() { #ifdef unix struct sockaddr_un sau; #endif SAIN sai; char IDstring[33]; if (family==AF_INET) { memset(&sai,0,sizeof(sai)); build_sin(&sai,host,port); } else { #ifdef unix memset(&sau,0,sizeof(sau)); sau.sun_family=AF_LOCAL; strcpy(sau.sun_path,host); // FIXME: possible overflow! #else return -11; // unsupported #endif } IDstring[32]=0; int i; s=socket(family,SOCK_STREAM,0); if (family==AF_INET) { #ifdef CAN_TCP_NODELAY int opt=1; setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (const char*) &opt, sizeof(opt)); #endif i=::connect(s,(SA*)&sai,sizeof(sai)); } #ifdef unix else i=::connect(s,(SA*)&sau,sizeof(sau)); #endif if (i==-1) { closesocket(s); s=-1; return -1; // connect failed } if (session_key) { // resume a session int n = send(s, session_key, 32, 0); if (n != 32) { closesocket(s); s = -1; return -2; // handshake failed (session key send error) } Rmessage *msg = new Rmessage(); int q = msg->read(s); delete msg; return q; } int n=recv(s,IDstring,32,0); if (n!=32) { closesocket(s); s=-1; return -2; // handshake failed (no IDstring) } if (strncmp(IDstring,myID,4)) { closesocket(s); s=-1; return -3; // invalid IDstring } if (strncmp(IDstring+8,myID+8,4) || strncmp(IDstring+4,myID+4,4)>0) { closesocket(s); s=-1; return -4; // protocol not supported } { int i=12; while (i<32) { if (!strncmp(IDstring+i, "ARuc", 4)) auth|=A_required|A_crypt; if (!strncmp(IDstring+i, "ARpt", 4)) auth|=A_required|A_plain; if (IDstring[i]=='K') { salt[0]=IDstring[i+1]; salt[1]=IDstring[i+2]; } i+=4; } } return 0; } int Rconnection::disconnect() { if (s>-1) { closesocket(s); s=-1; } return 0; } /**--- low-level functions --*/ int Rconnection::request(Rmessage *msg, int cmd, int len, void *par) { struct phdr ph; if (s==-1) return -5; // not connected memset(&ph,0,sizeof(ph)); ph.len=itop(len); ph.cmd=itop(cmd); if (send(s,(char*)&ph,sizeof(ph),0)!=sizeof(ph)) { closesocket(s); s=-1; return -9; } if (len>0 && send(s,(char*)par,len,0)!=len) { closesocket(s); s=-1; return -9; } return msg->read(s); } int Rconnection::request(Rmessage *targetMsg, Rmessage *contents) { if (s==-1) return -5; // not connected if (contents->send(s)) { closesocket(s); s=-1; return -9; // send error } return targetMsg->read(s); } /** --- high-level functions -- */ int Rconnection::shutdown(const char *key) { Rmessage *msg = new Rmessage(); Rmessage *cm = key?new Rmessage(CMD_shutdown, key):new Rmessage(CMD_shutdown); int res = request(msg, cm); delete cm; delete msg; return res; } int Rconnection::assign(const char *symbol, Rexp *exp) { Rmessage *msg=new Rmessage(); Rmessage *cm=new Rmessage(CMD_setSEXP); int tl=strlen(symbol)+1; if (tl&3) tl=(tl+4)&0xfffc; Rsize_t xl=exp->storageSize(); Rsize_t hl=4+tl+4; if (xl>0x7fffff) hl+=4; cm->data=(char*) malloc(hl+xl); cm->head.len=cm->len=hl+xl; ((unsigned int*)cm->data)[0]=SET_PAR(DT_STRING, tl); ((unsigned int*)cm->data)[0]=itop(((unsigned int*)cm->data)[0]); strcpy(cm->data+4, symbol); ((unsigned int*)(cm->data+4+tl))[0]=SET_PAR((Rsize_t) ((xl>0x7fffff)?(DT_SEXP|DT_LARGE):DT_SEXP), (Rsize_t) xl); ((unsigned int*)(cm->data+4+tl))[0]=itop(((unsigned int*)(cm->data+4+tl))[0]); if (xl>0x7fffff) ((unsigned int*)(cm->data+4+tl))[1]=itop(xl>>24); exp->store(cm->data+hl); int res=request(msg,cm); delete (cm); if (res) { delete(msg); return res; } if (!res) res = CMD_STAT(msg->command()); delete(msg); return res; } int Rconnection::voidEval(const char *cmd) { int status=0; eval(cmd, &status, 1); return status; } Rexp *Rconnection::eval(const char *cmd, int *status, int opt) { /* opt = 1 -> void eval */ Rmessage *msg=new Rmessage(); Rmessage *cmdMessage=new Rmessage((opt&1)?CMD_voidEval:CMD_eval, cmd); int res=request(msg,cmdMessage); delete (cmdMessage); if (opt&1 && !res) { if (status) *status=0; // we should put response code here delete(msg); return 0; } if ((opt & 1) == 0 && !res && (msg->pars!=1 || (ptoi(msg->par[0][0])&0x3f)!=DT_SEXP)) { delete(msg); if (status) *status=-12; // returned object is not SEXP return 0; } if (res) { delete(msg); if (status) *status=res; return 0; } if (status) *status=0; return new_parsed_Rexp_from_Msg(msg); } /** detached eval (aka detached void eval) initiates eval and detaches the session. * @param cmd command to evaluate. If NULL equivalent to simple detach() * @param status optional status to be reported (zero on success) * @return object describintg he session. * Note that the caller is responsible for freeing the object if not needed. */ Rsession *Rconnection::detachedEval(const char *cmd, int *status) { Rmessage *msg = new Rmessage(); Rmessage *cmdMessage = cmd ? new Rmessage(CMD_detachedVoidEval, cmd) : new Rmessage(CMD_detachSession); int res = request(msg, cmdMessage); delete cmdMessage; if (res) { if (status) *status = res; delete msg; return 0; } if (msg->pars != 2 || PAR_TYPE(ptoi(msg->par[0][0])) != DT_INT || PAR_LEN(ptoi(msg->par[0][0])) != sizeof(int) || PAR_TYPE(ptoi(msg->par[1][0])) != DT_BYTESTREAM || PAR_LEN(ptoi(msg->par[1][0])) != 32) { // invalid contents if (status) *status = -12; delete msg; return 0; } Rsession *session = new Rsession(host, ptoi(msg->par[0][1]), (const char*) (msg->par[1] + 1)); delete msg; if (status) *status=0; return session; } Rsession *Rconnection::detach(int *status) { return detachedEval(0, status); } int Rconnection::openFile(const char *fn) { Rmessage *msg=new Rmessage(); Rmessage *cmdMessage=new Rmessage(CMD_openFile, fn); int res=request(msg,cmdMessage); delete (cmdMessage); if (!res) res=CMD_STAT(msg->command()); delete (msg); return res; } int Rconnection::createFile(const char *fn) { Rmessage *msg=new Rmessage(); Rmessage *cmdMessage=new Rmessage(CMD_createFile, fn); int res=request(msg,cmdMessage); delete (cmdMessage); if (!res) res=CMD_STAT(msg->command()); delete (msg); return res; } int Rconnection::readFile(char *buf, unsigned int len) { Rmessage *msg=new Rmessage(); Rmessage *cmdMessage=new Rmessage(CMD_readFile, len); int res=request(msg,cmdMessage); delete(cmdMessage); if (!res) { // FIXME: Rserve up to 0.4-0 actually sends buggy response - it ommits DT_BYTESTREAM header! if (msg->len > len) { // we're in trouble here - techincally we should not get this delete(msg); return CERR_malformed_packet; } if (msg->len > 0) memcpy(buf, msg->data, msg->len); int rl = msg->len; delete(msg); return rl; } delete(msg); return CERR_io_error; } int Rconnection::writeFile(const char *buf, unsigned int len) { Rmessage *msg=new Rmessage(); Rmessage *cmdMessage=new Rmessage(CMD_writeFile, buf, len); int res=request(msg,cmdMessage); delete(cmdMessage); if (!res && msg->command()==RESP_OK) { delete(msg); return 0; } delete(msg); // FIXME: this is not really true ... return (res==0)?CERR_io_error:res; } int Rconnection::closeFile() { Rmessage *msg=new Rmessage(); Rmessage *cmdMessage=new Rmessage(CMD_closeFile); int res=request(msg,cmdMessage); delete(cmdMessage); if (!res && msg->command()==RESP_OK) { delete(msg); return 0; } delete(msg); // FIXME: this is not really true ... return (res==0)?CERR_io_error:res; } int Rconnection::removeFile(const char *fn) { Rmessage *msg=new Rmessage(); Rmessage *cmdMessage=new Rmessage(CMD_removeFile, fn); int res=request(msg,cmdMessage); delete (cmdMessage); if (!res) res=CMD_STAT(msg->command()); delete (msg); return res; } int Rconnection::login(const char *user, const char *pwd) { char *authbuf, *c; if (!(auth&A_required)) return 0; authbuf=(char*) malloc(strlen(user)+strlen(pwd)+22); strcpy(authbuf, user); c=authbuf+strlen(user); *c='\n'; c++; strcpy(c,pwd); #ifdef unix if (auth&A_crypt) strcpy(c,crypt(pwd,salt)); #else if (!(auth&A_plain)) { free(authbuf); return CERR_auth_unsupported; } #endif Rmessage *msg=new Rmessage(); Rmessage *cmdMessage=new Rmessage(CMD_login, authbuf); int res=request(msg,cmdMessage); delete (cmdMessage); if (!res) res=CMD_STAT(msg->command()); delete (msg); free(authbuf); return res; } #ifdef CMD_ctrl /* server control methods */ int serverEval(const char *cmd); int serverSource(const char *fn); int serverShutdown(); int Rconnection::serverEval(const char *cmd) { Rmessage *msg = new Rmessage(); /* result message */ Rmessage *cmdMessage = new Rmessage(CMD_ctrlEval, cmd); /* request message */ int res = request(msg, cmdMessage); delete (cmdMessage); if (!res) res = CMD_STAT(msg->command()); delete (msg); return res; } int Rconnection::serverSource(const char *fn) { Rmessage *msg = new Rmessage(); /* result message */ Rmessage *cmdMessage = new Rmessage(CMD_ctrlSource, fn); /* request message */ int res = request(msg, cmdMessage); delete (cmdMessage); if (!res) res = CMD_STAT(msg->command()); delete (msg); return res; } int Rconnection::serverShutdown() { Rmessage *msg = new Rmessage(); /* result message */ Rmessage *cmdMessage = new Rmessage(CMD_ctrlShutdown); /* request message */ int res = request(msg, cmdMessage); delete (cmdMessage); if (!res) res = CMD_STAT(msg->command()); delete (msg); return res; } #endif Rserve/src/client/README.txt0000644000176000001440000000110012205226215015300 0ustar ripleyusersThis directory contains various Rserve clients: cxx - minimal C++ client java - Java client based on the REngine API. This is the actively developed Java client as it is more flexible and consistent than the older JRclient. It supports multiple back-ends such as Rserve or JRI. php - minimal PHP client and example code that can be used to run FastRWeb via PHP instead of CGI NOTE: a more complete PHP client written by Clement Turbelin based on this minimal version is available from http://code.google.com/p/rserve-php Rserve/src/client/php/0000755000176000001440000000000012205226215014401 5ustar ripleyusersRserve/src/client/php/simple.php0000644000176000001440000002675412205226215016421 0ustar ripleyusers>= 8; $r .= chr($i & 255); $i >>=8; $r .= chr($i & 255); $i >>=8; $r .= chr($i & 255); return $r; } function mkint24($i) { $r = chr($i & 255); $i >>= 8; $r .= chr($i & 255); $i >>=8; $r .= chr($i & 255); return $r; } function flt64($buf, $o=0) { $ss = substr($buf, $o, 8); if ($machine_is_bigendian) for ($k = 0; $k < 7; $k++) $ss[7 - $k] = $buf[$o + $k]; $r = unpack("d", substr($buf, $o, 8)); return $r[1]; } function mkp_str($cmd, $string) { $n = strlen($string) + 1; $string .= chr(0); while (($n & 3) != 0) { $string .= chr(1); $n++; } return mkint32($cmd) . mkint32($n + 4) . mkint32(0) . mkint32(0) . chr(4) . mkint24($n) . $string; } function get_rsp($socket) { $n = socket_recv($socket, $buf, 16, 0); if ($n != 16) return FALSE; $len = int32($buf, 4); $ltg = $len; while ($ltg > 0) { $n = socket_recv($socket, $b2, $ltg, 0); if ($n > 0) { $buf .= $b2; unset($b2); $ltg -= $n; } else break; } return $buf; } // parse SEXP results -- limited implementation for now (large packets and some data types are not supported) function parse_SEXP($buf, &$offset, &$attr = NULL) { $r = $buf; $i = $offset; // some simple parsing - just skip attributes and assume short responses $ra = int8($r, $i); $rl = int24($r, $i + 1); $i += 4; $offset = $eoa = $i + $rl; // echo "[data type ".($ra & 63).", length ".$rl." with payload from ".$i." to ".$eoa."]
\n"; if (($ra & 64) == 64) { echo "sorry, long packets are not supported (yet)."; return FALSE; } if ($ra > 127) { $ra &= 127; $al = int24($r, $i + 1); $attr = parse_SEXP($buf, $i); $i += $al + 4; } if ($ra == 0) return NULL; if ($ra == 16) { // generic vector $a = array(); while ($i < $eoa) $a[] = parse_SEXP($buf, /* & */ $i); // if the 'names' attribute is set, convert the plain array into a map if (isset($attr['names'])) { $names = $attr['names']; $na = array(); $n = count($a); for ($k = 0; $k < $n; $k++) $na[$names[$k]] = $a[$k]; return $na; } return $a; } if ($ra == 19) { // symbol $oi = $i; while ($i < $eoa && ord($r[$i]) != 0) $i++; return substr($buf, $oi, $i - $oi); } if ($ra == 20 || $ra == 22) { // pairlist w/o tags $a = array(); while ($i < $eoa) $a[] = parse_SEXP($buf, /* & */ $i); return $a; } if ($ra == 21 || $ra == 23) { // pairlist with tags $a = array(); while ($i < $eoa) { $val = parse_SEXP($buf, /* & */ $i); $tag = parse_SEXP($buf, /* & */ $i); $a[$tag] = $val; } return $a; } if ($ra == 32) { // integer array $a = array(); while ($i < $eoa) { $a[] = int32($r, $i); $i += 4; } if (count($a) == 1) return $a[0]; return $a; } if ($ra == 33) { // double array $a = array(); while ($i < $eoa) { $a[] = flt64($r, $i); $i += 8; } if (count($a) == 1) return $a[0]; return $a; } if ($ra == 34) { // string array $a = array(); $oi = $i; while ($i < $eoa) { if (ord($r[$i]) == 0) { $a[] = substr($r, $oi, $i - $oi); $oi = $i + 1; } $i++; } if (count($a) == 1) return $a[0]; return $a; } if ($ra == 36) { // boolean vector $n = int32($r, $i); $i += 4; $k = 0; $a = array(); while ($k < $n) { $v = int8($r, $i++); $a[$k++] = ($v == 1) ? TRUE : (($v == 0) ? FALSE : NULL); } if ($n == 1) return $a[0]; return $a; } if ($ra == 37) { // raw vector $len = int32($r, $i); $i += 4; return substr($r, $i, $len); } if ($ra == 48) { // unimplemented type in Rserve $uit = int32($r, $i); // echo "Note: result contains type #$uit unsupported by Rserve.
"; return NULL; } echo "Warning: type ".$ra." is currently not implemented in the PHP client."; return FALSE; } //------------ Rserve API functions // if port is 0 then host is interpreted as unix socket, otherwise host is the host to connect to (default is local) and port is the TCP port number (6311 is the default) function Rserve_connect($host="127.0.0.1", $port=6311) { if ($port == 0) $ok = (($socket = socket_create(AF_UNIX, SOCK_STREAM, 0)) and (socket_connect($socket, $host))); else $ok = (($socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) and (socket_connect($socket, $host, $port))); if ($ok) { $n = socket_recv($socket, $buf, 32, 0); if ($n < 32 || strncmp($buf, "Rsrv", 4) != 0) { echo "Invalid response from server."; return FALSE; } $rv = substr($buf, 4, 4); if (strcmp($rv, "0103") != 0) { echo "Unsupported protocol version."; return FALSE; } } else { echo "Unable to connect
".socket_strerror(socket_last_error())."
"; return FALSE; } return $socket; } function Rserve_eval($socket, $command, $attr = NULL) { $pkt = mkp_str(3, $command); socket_send($socket, $pkt, strlen($pkt), 0); $r = get_rsp($socket); $res = int32($r); $sc = ($res >> 24) & 127; $rr = $res & 255; if ($rr != 1) { echo "eval failed with error code " . $sc; return FALSE; } if (int8($r, 16) != 10) { echo "invalid response (expecting SEXP)"; return FALSE; } $i = 20; return parse_SEXP($r, $i, /* & */ $attr); } function Rserve_assign_raw($socket, $name, $what) { // CMD_setSEXP $bl = strlen($what); if ($bl > 16777088) trigger_error("Body in Rserve_assign_raw is too big ($bl bytes), only small QAP packets are currently supported."); $n = strlen($name) + 1; $name .= chr(0); while (($n & 3) != 0) { $name .= chr(1); $n++; } // [CMD_setSEXP][DT_STRING(name)][DT_SEXP([XT_RAW, (i32) len, what])] = payload + 4 + 4 + 8 $pkt = mkint32(0x20) /* CMD_setSXP */ . mkint32($n + $bl + 16) . mkint32(0) . mkint32(0) . chr(4) . mkint24($n) . $name . chr(10) /* SEXP */ . mkint24($bl + 8). chr(37) /* XT_RAW */ . mkint24($bl + 4) . mkint32($bl) . $what; socket_send($socket, $pkt, strlen($pkt), 0); $r = get_rsp($socket); $res = int32($r); $sc = ($res >> 24) & 127; $rr = $res & 255; if ($rr != 1) { echo "eval failed with error code " . $sc; return FALSE; } return TRUE; } function Rserve_close($socket) { return socket_close($socket); } //========== FastRWeb - compatible requests - sample use of the client to behave like Rcgi in FastRWeb $root = "/var/FastRWeb"; // set to the root of your FastRWeb installation - must be absolute function process_FastRWeb($host, $port) { global $root; // $req = array_merge($_GET, $_POST); $path = $_SERVER['PATH_INFO']; if (!isset($path)) { echo "No path specified."; return FALSE; } $path = str_replace("..", "_", $path); // sanitize paths // We cannot check for the presence of the script, because FastRWeb now // supports PATH_INFO *after* the script name. // If you don't care but want fast error, uncomment the followign two lines. // $script = "$root/web.R$path.R"; // if (!file_exists($script)) { echo "Script [$script] $path.R does not exist."; return FALSE; } $raddr = $_SERVER['REMOTE_ADDR']; $method = $_SERVER['REQUEST_METHOD']; $ct = $_SERVER['CONTENT_TYPE']; $cl = $_SERVER['CONTENT_LENGTH'] + 0; // escape as needed $uri = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $_SERVER['REQUEST_URI'])); // NOTE: the C client URI-encodes control characters and quotes -- maybe a good idea? $cook = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $_SERVER['HTTP_COOKIE'])); $qs = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $_SERVER['QUERY_STRING'])); $path = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $path)); $s = Rserve_connect($host, $port); $bodyval = "NULL"; if ($ct == "" && $cl == 0) $cl = -1; else { $body = file_get_contents("php://input"); Rserve_assign_raw($s, "body", $body); $bodyval = ".GlobalEnv\$body"; } $r = Rserve_eval($s, "{ library(FastRWeb); request<-list(uri=\"$uri\", method=\"$method\", c.type=\"$ct\", c.length=$cl, body=$bodyval, client.ip=\"$raddr\", query.string=\"$qs\", raw.cookies=\"$cook\"); FastRWeb:::.run(request,\"$root\",\"$path\") }"); Rserve_close($s); if (!is_array($r)) { // this ususally means that an erro rocurred since the returned value is jsut a string ob_end_flush(); echo $r; exit(0); } if (isset($r[2])) header("Content-type: $r[2]"); if (($r[0] == "file") or ($r[0] == "tmpfile")) { error_log("INFO: $r[0]: '$r[1]'"); $contents = file_get_contents($root."/tmp/".$r[1]); ob_end_clean(); echo $contents; if ($r[0] == "tmpfile") unlink($r[0]); exit(0); } if ($r[0] == "html") { ob_end_clean(); echo (is_array($r[1]) ? implode("\n", $r[1]) : $r[1]); exit(0); } print_r($r); ob_end_flush(); exit(0); } //--- the following lines serve as FastRWeb handler (see FastRWeb package and IASC paper) // NOTE: this implementation is for FastRWeb 1.1 and higher! // If you changed the socket setting or use remote server change the parameters (host, port) below process_FastRWeb("$root/socket", 0); // default FastRWeb setting ob_end_flush(); /*========== user code -- example and test -- comment out the above and uncomment this for testing $s = Rserve_connect(); if ($s == FALSE) { echo "Connect FAILED"; } else { print_r (Rserve_eval($s, "list(str=R.version.string,foo=1:10,bar=1:5/2,logic=c(TRUE,FALSE,NA))")); echo "

"; print_r (Rserve_eval($s, "{x=rnorm(10); y=x+rnorm(10)/2; lm(y~x)}")); Rserve_close($s); } ob_end_flush(); */ ?> Rserve/src/Makevars.in0000644000176000001440000000227012205226215014436 0ustar ripleyusersPKG_CPPFLAGS=-DRSERVE_PKG -I. -Iinclude @CPPFLAGS@ PKG_LIBS=@LIBS@ all: $(SHLIB) @WITH_SERVER_TRUE@ server @WITH_CLIENT_TRUE@ $(MAKE) client SERVER_SRC = standalone.c md5.c session.c qap_decode.c qap_encode.c sha1.c base64.c websockets.c RSserver.c tls.c http.c oc.c rsio.c SERVER_H = Rsrv.h qap_encode.h qap_decode.h RSserver.h http.h oc.h sha1.h md5.h rsio.h server: $(SERVER_SRC) $(SERVER_H) $(CC) -DSTANDALONE_RSERVE -DDAEMON -I. -Iinclude $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(PKG_CPPFLAGS) $(PKG_CFLAGS) -o Rserve $(SERVER_SRC) $(ALL_LIBS) $(PKG_LIBS) $(CC) -DSTANDALONE_RSERVE -DRSERV_DEBUG -DNODAEMON -I. -Iinclude $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(PKG_CPPFLAGS) $(PKG_CFLAGS) -o Rserve.dbg $(SERVER_SRC) $(ALL_LIBS) $(PKG_LIBS) # merging to bin/Rserve works only if installed from sources, won't work for binary -./mergefat Rserve "$(R_HOME)/bin/Rserve" -./mergefat Rserve.dbg "$(R_HOME)/bin/Rserve.dbg" client: config.h cp config.h client/cxx/ make -C client/cxx -@mkdir ../inst 2>/dev/null -rm -rf ../inst/client -cp -R client ../inst/ cp Rsrv.h config.h include/sisocks.h ../inst/client/cxx/ clean: rm -f *~ *.o *.lo *.so \#* $(XFILES) .PHONY: client clean server Rserve/src/rsio.h0000644000176000001440000000470212205226215013464 0ustar ripleyusers/* small IPC framework that allows bi-directional communication between parent/child processes including the ability to pass fds/sockets (C)Copyright 2013 Simon Urbanek License: 2-clause BSD Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef RSIO_H__ #define RSIO_H__ typedef struct rsio rsio_t; #define RSMSG_HAS_FD 0x01 typedef unsigned long rsmsglen_t; typedef struct { int cmd; int flags; int fd; rsmsglen_t len; unsigned char data[1]; } rsmsg_t; rsio_t *rsio_new(); void rsio_free(rsio_t *io); void rsio_close(rsio_t *io); /* one of the two *must* be called before any read/write operations */ void rsio_set_child(rsio_t *io); void rsio_set_parent(rsio_t *io); void rsmsg_free(rsmsg_t *msg); rsmsg_t *rsio_read_msg(rsio_t *io); /* 0 on success, -1 on send fail, -2 on out of memory */ int rsio_write(rsio_t *io, const void *buf, rsmsglen_t len, int cmd, int fd); int rsio_write_msg(rsio_t *io, rsmsg_t *msg); /* mainly to allow easy forwarding */ /* this is a compatibility hack for now so we can attach rsio into a set of select() calls. note that this can be -1 (closed, unconnected, unimplemented, ...) */ int rsio_select_fd(rsio_t *io); #endif Rserve/src/Rserv.c0000644000176000001440000032031612205226215013606 0ustar ripleyusers/* * Rserv : R-server that allows to use embedded R via TCP/IP * Copyright (C) 2002-13 Simon Urbanek * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id$ */ /* external defines: COOPERATIVE - forces cooperative version of Rserv on unix platforms (default for non-unix platforms) FORKED - each connection is forked to a new process. This is the recommended way to use this server. The advantage is (beside the fact that this works ;)) that each client has a separate namespace since the processes are independent (default for unix platforms) SWAPEND - define if the platform has byte order inverse to Intel (like PPC) RSERV_DEBUG - if defined various verbose output is produced DAEMON - if defined the server daemonizes (unix only) CONFIG_FILE - location of the config file (default /etc/Rserv.conf) reported versions: -------------------- 0100 - Rserve 0.1-1 .. 0.1-9 CMD_eval sends SEXP directly without the data type header. This is in fact an inconsistency and was fixed in 0101. New clients should be aware of this and support this behavior or reject 0100 connections. 0101 - Rserve 0.1-10 .. 0.2-x 0102 - Rserve 0.3 added support for large parameters/expressions 0103 - Rserve 0.5 discard the notion of scalar types The current implementation uses DT_LARGE/XT_LARGE only for SEXPs larger than 0xfffff0. No commands except for CMD_set/assignREXP with DT_REXP accept large input, in particular all file operations. All objects smaller 8MB should be encoded without the use of DT_LARGE/XT_LARGE. */ /* config file entries: [default] ---------------------- workdir [depends on the CONFIG_FILE define] pwdfile [none=disabled] remote enable|disable [disable] auth required|disable [disable] plaintext enable|disable [disable] (strongly discouraged to enable) fileio enable|disable [enable] interactive yes|no [yes] (the default may change to "no" in the future!) socket [none] maxinbuf [262144 = 256MB] maxsendbuf [0 = no limit] cachepwd no|yes|indefinitely unix only (works only if Rserve was started by root): uid gid su now|server|client encoding native|latin1|utf8 [native] source eval control enable|disable [disable] r-control enable|disable [disable] A note about security: Anyone with access to R has access to the shell via "system" command, so you should consider following rules: - NEVER EVER run Rserv as root (unless uid/gid is used) - this compromises the box totally - use "remote disable" whenever you don't need remote access. - if you need remote access use "auth required" and "plaintext disable" consider also that anyone with the access can decipher other's passwords if he knows how to. the authentication prevents hackers from the net to break into Rserv, but it doesn't (and cannot) protect from inside attacks (since R has no security measures). You should also use a special, restricted user for running Rserv as a public server, so noone can try to hack the box it runs on. From 0.6-1 on you can set gid/uid and use "su client", "cachepwd yes" and only a root-readable password file such that clients cannot read it and also cannot affect the server process (this works on unix only). - don't enable plaintext unless you really have to. Passing passwords in plain text over the net is not wise and not necessary since both Rserv and JRclient provide encrypted passwords with server-side challenge (thus safe from sniffing). */ #ifndef NO_CONFIG_H #include "config.h" #endif #if defined STANDALONE_RSERVE || defined RSERVE_PKG #define USE_RINTERNALS 1 #define SOCK_ERRORS #define LISTENQ 16 #define MAIN /* some OSes don't like too large chunks to be sent/received, so we imit the socket I/O sizes by this constant. It should be a 31-bit value for compatibility. */ #ifdef WIN32 /* Windows is really bad (as usual) */ #define max_sio_chunk 1048576 #else #define max_sio_chunk 134217728 #endif #if defined NODAEMON && defined DAEMON #undef DAEMON #endif #if !defined WIN32 && !defined unix #define unix #endif /* FORKED is default for unix platforms */ #if defined unix && !defined COOPERATIVE && !defined FORKED #define FORKED #endif #ifndef CONFIG_FILE #ifdef unix #define CONFIG_FILE "/etc/Rserv.conf" #else #define CONFIG_FILE "Rserv.cfg" #endif #endif /* we have no configure for WIN32 so we have to take care of socklen_t */ #ifdef WIN32 typedef int socklen_t; #define CAN_TCP_NODELAY #define _WINSOCKAPI_ #include #include #include #include #include #endif #include #include #include #include #ifdef unix #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #include #include #include #include #include #include /* needed for unix sockets */ #endif #ifdef FORKED #include #include #endif #ifdef ERROR #undef ERROR #endif #include #include #include #include #if (R_VERSION >= R_Version(2,3,0)) #ifdef WIN32 /* Windows doesn't have Rinterface */ extern __declspec(dllimport) int R_SignalHandlers; #else #include #endif #endif #include #include "Rsrv.h" #include "qap_encode.h" #include "qap_decode.h" #include "md5.h" /* we don't bother with sha1.h so this is the declaration */ void sha1hash(const char *buf, int len, unsigned char hash[20]); #ifdef HAVE_CRYPT_H #include #endif #if R_VERSION >= R_Version(2,9,0) #include #endif #if defined HAVE_NETINET_TCP_H && defined HAVE_NETINET_IN_H #define CAN_TCP_NODELAY #include #include #endif /* AF_LOCAL is the POSIX version of AF_UNIX - we need this e.g. for AIX */ #ifndef AF_LOCAL #define AF_LOCAL AF_UNIX #endif /* send buffer size (default 2MB) Currently Rserve stores entire responses in memory before sending it. This is not really neccessary and may (hopefully will) change in the future. Send buffer specifies the maximal amount of data sent from Rserve to the client in one response. */ #ifndef sndBS /* configure may have defined one already */ #define sndBS (2048*1024) #endif /* the # of arguments to R_ParseVector changed since R 2.5.0 */ #if R_VERSION < R_Version(2,5,0) #define RS_ParseVector R_ParseVector #else #define RS_ParseVector(A,B,C) R_ParseVector(A,B,C,R_NilValue) #endif /* child control commands */ #define CCTL_EVAL 1 /* data: string */ #define CCTL_SOURCE 2 /* data: string */ #define CCTL_SHUTDOWN 3 /* - */ #define MAX_CTRL_DATA (1024*1024) /* max. length of data for control commands - larger data will be ignored */ #include "RSserver.h" #include "websockets.h" #include "http.h" #include "tls.h" #include "oc.h" struct args { server_t *srv; /* server that instantiated this connection */ SOCKET s; SOCKET ss; void *res1, *res2; /* the following entries are not populated by Rserve but can be used by server implemetations */ char *buf, *sbuf; int ver, bp, bl, sp, sl, flags; long l1, l2; /* The following fields are informational, populated by Rserve */ SAIN sa; int ucix; #ifdef unix struct sockaddr_un su; #endif char res[128]; /* reserved space for server-specific fields */ }; static int port = default_Rsrv_port; static int tls_port = -1; static int active = 1; /* 1 = server loop is active, 0 = shutdown */ static int UCIX = 1; /* unique connection index */ static char *localSocketName = 0; /* if set listen on this local (unix) socket instead of TCP/IP */ static int localSocketMode = 0; /* if set, chmod is used on the socket when created */ static int allowIO = 1; /* 1=allow I/O commands, 0=don't */ static char *workdir = "/tmp/Rserv"; static int wd_mode = 0755; static char *pwdfile = 0; static SOCKET csock = -1; static int parentPID = -1; int is_child = 0; /* 0 for parent (master), 1 for children */ int parent_pipe = -1; /* pipe to the master process or -1 if not available */ int can_control = 0; /* control commands will be rejected unless this flag is set */ int child_control = 0; /* enable/disable the ability of children to send commands to the master process */ int self_control = 0; /* enable/disable the ability to use control commands from within the R process */ static int tag_argv = 0;/* tag the ARGV with client/server IDs */ static char *pidfile = 0;/* if set by configuration generate pid file */ #ifdef DAEMON int daemonize = 1; #endif char **main_argv; /* this is only set by standalone! */ int main_argc; rlen_t maxSendBufSize = 0; /* max. sendbuf for auto-resize. 0=no limit */ int Rsrv_interactive = 1; /* default for R_Interactive flag */ static char authkey[1024]; /* server-side authentication key */ static int authkey_req = 0; /* number of auth requests */ static char *auth_fn; /* authentication function */ #ifdef unix static int umask_value = 0; #endif int global_srv_flags = 0; static char *http_user, *https_user, *ws_user; static char **allowed_ips = 0; void stop_server_loop() { active = 0; } #include "rsdebug.h" #include "rserr.h" #ifdef unix #ifdef HAVE_SYS_TYPES_H #include #endif #include #include #include static char tmpdir_buf[1024]; #include #ifdef unix char wdname[512]; int cinp[2]; #endif static void prepare_set_user(int uid, int gid) { /* create a new tmpdir() and make it owned by uid:gid */ /* we use uid.gid in the name to minimize cleanup issues - we assume that it's ok to share tempdirs between sessions of the same user */ snprintf(tmpdir_buf, sizeof(tmpdir_buf), "%s.%d.%d", R_TempDir, uid, gid); mkdir(tmpdir_buf, 0700); /* it is ok to fail if it exists already */ /* gid can be 0 to denote no gid change -- but we will be using 0700 anyway so the actual gid is not really relevant */ chown(tmpdir_buf, uid, gid); R_TempDir = strdup(tmpdir_buf); if (workdir) /* FIXME: gid=0 will be bad here ! */ chown(wdname, uid, gid); } static int set_user(const char *usr) { struct passwd *p = getpwnam(usr); if (!p) return 0; prepare_set_user(p->pw_uid, p->pw_gid); if (setgid(p->pw_gid)) return 0; initgroups(p->pw_name, p->pw_gid); if (setuid(p->pw_uid)) return 0; return 1; } static int fork_http(args_t *arg) { #ifdef unix int res = fork(); #else int res = -1; #endif if (res == 0 && http_user && !set_user(http_user)) { #ifdef STANDALONE_RSERVE fprintf(stderr, "ERROR: failed to set user '%s', aborting\n", http_user); #endif exit(1); } return res; } static int fork_https(args_t *arg) { #ifdef unix int res = fork(); #else int res = -1; #endif if (res == 0 && https_user && !set_user(https_user)) { #ifdef STANDALONE_RSERVE fprintf(stderr, "ERROR: failed to set user '%s', aborting\n", https_user); #endif exit(1); } return res; } static int fork_ws(args_t *arg) { #ifdef unix int res = fork(); #else int res = -1; #endif if (res == 0 && ws_user && !set_user(ws_user)) { #ifdef STANDALONE_RSERVE fprintf(stderr, "ERROR: failed to set user '%s', aborting\n", ws_user); #endif exit(1); } return res; } #else static int fork_http(args_t *arg) { return -1; } static int fork_https(args_t *arg) { return -1; } static int fork_ws(args_t *arg) { return -1; } #endif #ifdef STANDALONE_RSERVE static const char *rserve_ver_id = "$Id$"; static char rserve_rev[16]; /* this is generated from rserve_ver_id by main */ #endif #define localUCIX UCIX /* string encoding handling */ #if (R_VERSION < R_Version(2,8,0)) || (defined DISABLE_ENCODING) #define mkRChar(X) mkChar(X) #else #define USE_ENCODING 1 cetype_t string_encoding = CE_NATIVE; /* default is native */ #define mkRChar(X) mkCharCE((X), string_encoding) #endif static SEXP Rserve_ctrlCMD(int command, SEXP what) { long cmd[2] = { 0, 0 }; const char *str; if (!self_control) Rf_error("R control is not premitted in this instance of Rserve"); if (parent_pipe == -1) Rf_error("Connection to the parent process has been lost."); if (TYPEOF(what) != STRSXP || LENGTH(what) != 1) Rf_error("Invalid parameter, must be a single string."); str = CHAR(STRING_ELT(what, 0)); /* FIXME: should we do some re-coding? This is not ripe for CHAR_FE since the target is our own instance and not the client ... */ cmd[0] = command; cmd[1] = strlen(str) + 1; if (write(parent_pipe, cmd, sizeof(cmd)) != sizeof(cmd) || (cmd[1] && write(parent_pipe, str, cmd[1]) != cmd[1])) { #ifdef RSERV_DEBUG printf(" - Rserve_ctrlCMD send to parent pipe (cmd=%ld, len=%ld) failed, closing parent pipe\n", cmd[0], cmd[1]); #endif close(parent_pipe); parent_pipe = -1; Rf_error("Error writing to parent pipe"); } return ScalarLogical(1); } SEXP Rserve_ctrlEval(SEXP what) { return Rserve_ctrlCMD(CCTL_EVAL, what); } SEXP Rserve_ctrlSource(SEXP what) { return Rserve_ctrlCMD(CCTL_SOURCE, what); } /* this is the representation of NAs in strings. We chose 0xff since that should never occur in UTF-8 strings. If 0xff occurs in the beginning of a string anyway, it will be doubled to avoid misrepresentation. */ static const unsigned char NaStringRepresentation[2] = { 255, 0 }; static int set_string_encoding(const char *enc, int verbose) { #ifdef USE_ENCODING if (!strcmp(enc, "native")) string_encoding = CE_NATIVE; else if (!strcmp(enc, "latin1")) string_encoding = CE_LATIN1; else if (!strcmp(enc, "utf8")) string_encoding = CE_UTF8; else { if (verbose) RSEprintf("WARNING: invalid encoding value '%s' - muse be one of 'native', 'latin1' or 'utf8'.\n", enc); return 0; } return 1; #else if (verbose) RSEprintf("WARNING: 'encoding' defined but this Rserve has no encoding support.\n"); return 0; #endif } /* "smart" atoi - accepts 0x for hex and 0 for octal */ static int satoi(const char *str) { if (!str) return 0; if (str[0]=='0') { if (str[1]=='x') return strtol(str + 2, 0, 16); if (str[1]>='0' && str[1]<='9') return strtol(str + 1, 0, 8); } return atoi(str); } static char *getParseName(int n) { switch(n) { case PARSE_NULL: return "null"; case PARSE_OK: return "ok"; case PARSE_INCOMPLETE: return "incomplete"; case PARSE_ERROR: return "error"; case PARSE_EOF: return "EOF"; } return ""; } #ifdef RSERV_DEBUG static void printSEXP(SEXP e) /* merely for debugging purposes in fact Rserve binary transport supports more types than this function. */ { int t = TYPEOF(e); int i = 0; if (TYPEOF(ATTRIB(e)) == LISTSXP) printf("[*has attr*] "); if (t==NILSXP) { printf("NULL value\n"); return; } if (t==LANGSXP) { printf("language construct\n"); return; } if (t==LISTSXP) { SEXP l = e; printf("dotted-pair list:\n"); while (l != R_NilValue) { if (dumpLimit && i>dumpLimit) { printf("..."); break; }; if (TAG(l) != R_NilValue) { printf("(TAG:"); printSEXP(TAG(l)); printf(") "); } printSEXP(CAR(l)); l=CDR(l); } return; } if (t==REALSXP) { if (LENGTH(e)>1) { printf("Vector of real variables: "); while(idumpLimit) { printf("..."); break; } i++; } putchar('\n'); } else printf("Real variable %f\n",*REAL(e)); return; } if (t==CPLXSXP) { if (LENGTH(e)>1) { printf("Vector of complex variables: "); while(idumpLimit) { printf("..."); break; } i++; } putchar('\n'); } else printf("Complex variable %f+%fi\n",COMPLEX(e)[0].r,COMPLEX(e)[0].i); return; } if (t==RAWSXP) { printf("Raw vector: "); while(idumpLimit) { printf("..."); break; } i++; } putchar('\n'); return; } if (t==EXPRSXP) { printf("Vector of %d expressions:\n",LENGTH(e)); while(idumpLimit) { printf("..."); break; }; printSEXP(VECTOR_ELT(e,i)); i++; } return; } if (t==INTSXP) { printf("Vector of %d integers:\n",LENGTH(e)); while(idumpLimit) { printf("..."); break; } printf("%d",INTEGER(e)[i]); if (idumpLimit) { printf("..."); break; } printf("%d",INTEGER(e)[i]); if (idumpLimit) { printf("..."); break; }; printSEXP(VECTOR_ELT(e,i)); i++; } return; } if (t==STRSXP) { printf("String vector of length %d:\n",LENGTH(e)); while(idumpLimit) { printf("..."); break; }; printSEXP(VECTOR_ELT(e,i)); i++; } return; } if (t==CHARSXP) { printf("scalar string: \"%s\"\n", CHAR(e)); return; } if (t==SYMSXP) { printf("Symbol, name: "); printSEXP(PRINTNAME(e)); return; } if (t==S4SXP) { printf("S4 object\n"); return; } printf("Unknown type: %d\n",t); } #endif /* if set Rserve doesn't accept other than local connections. */ static int localonly = 1; /* send a response including the data part */ void Rserve_QAP1_send_resp(args_t *arg, int rsp, rlen_t len, const void *buf) { server_t *srv = arg->srv; struct phdr ph; rlen_t i = 0; memset(&ph, 0, sizeof(ph)); /* do not tag OOB with CMD_RESP */ if (!(rsp & CMD_OOB)) rsp |= CMD_RESP; ph.cmd = itop(rsp); ph.len = itop(len); #ifdef __LP64__ ph.res = itop(len >> 32); #endif #ifdef RSERV_DEBUG printf("OUT.sendRespData\nHEAD "); printDump(&ph,sizeof(ph)); if (len == 0) printf("(no body)\n"); else { printf("BODY "); printDump(buf, len); } if (io_log) { struct timeval tv; snprintf(io_log_fn, sizeof(io_log_fn), "/tmp/Rserve-io-%d.log", getpid()); FILE *f = fopen(io_log_fn, "a"); if (f) { double ts = 0; if (!gettimeofday(&tv, 0)) ts = ((double) tv.tv_sec) + ((double) tv.tv_usec) / 1000000.0; if (first_ts < 1.0) first_ts = ts; fprintf(f, "%.3f [+%4.3f] SRV --> CLI [sendRespData] (%x, %ld bytes)\n HEAD ", ts, ts - first_ts, rsp, (long) len); fprintDump(f, &ph, sizeof(ph)); fprintf(f, " BODY "); if (len) fprintDump(f, buf, len); else fprintf(f, "\n"); fclose(f); } } #endif srv->send(arg, (char*)&ph, sizeof(ph)); while (i < len) { int rs = srv->send(arg, (char*)buf + i, (len - i > max_sio_chunk) ? max_sio_chunk : (len - i)); if (rs < 1) break; i += rs; } } /* initial ID string */ char *IDstring="Rsrv0103QAP1\r\n\r\n--------------\r\n"; /* require authentication flag (default: no) */ int authReq = 0; /* use plain password flag (default: no) */ int usePlain = 0; /* max. size of the input buffer (per connection) */ rlen_t maxInBuf = 256 * (1024 * 1024); /* default is 256MB */ /* if non-zero then the password file is loaded before client su so it can be unreadable by the clients */ int cache_pwd = 0; char *pwd_cache; /* if client_su is set then Rserve switches uid/gid */ #define SU_NOW 0 #define SU_SERVER 1 #define SU_CLIENT 2 static int su_time = SU_NOW; static void load_pwd_cache() { FILE *f = fopen(pwdfile, "r"); if (f) { int fs = 0; fseek(f, 0, SEEK_END); fs = ftell(f); fseek(f, 0, SEEK_SET); pwd_cache = (char*) malloc(fs + 1); if (pwd_cache) { if (fread(pwd_cache, 1, fs, f) != fs) { free(pwd_cache); pwd_cache = 0; } else pwd_cache[fs] = 0; } fclose(f); } } struct source_entry { struct source_entry* next; char line[8]; } *src_list=0, *src_tail=0; static int ws_port = -1, enable_qap = 1, enable_ws_qap = 0, enable_ws_text = 0, wss_port = 0; static int ws_qap_oc = 0, qap_oc = 0; /* FIXME: self.* commands can be loaded either from Rserve.so or from stand-alone binary. This will cause a mess since some things are private and some are not - we have to sort that out. In the meantime a quick hack is to make the relevant config (here enable_oob) global */ int enable_oob = 0; static int http_port = -1; static int https_port = -1; static int switch_qap_tls = 0; static int ws_upgrade = 0; static int http_raw_body = 0; static int use_ipv6 = 0; static int requested_uid = 0, requested_gid = 0; static char *requested_chroot = 0; static int auto_uid = 0, auto_gid = 0; static int default_uid = 0, default_gid = 0; static int random_uid = 0, random_gid = 0; static int random_uid_low = 32768, random_uid_high = 65530; #ifdef HAVE_RSA static int rsa_load_key(const char *buf); #endif /* FIXME: we are not preventing collisions - we have to keep track of the uid assignments to children and no reuse those alive */ static int get_random_uid() { int uid = random_uid_low + UCIX % (random_uid_high - random_uid_low + 1); return uid; } static int performConfig(int when) { int fail = 0; #ifdef unix if (when == SU_NOW) { if (requested_chroot && chroot(requested_chroot)) { perror("chroot"); RSEprintf("chroot(\"%s\"): failed.\n", requested_chroot); fail++; } } if (cache_pwd) load_pwd_cache();/* load pwd file into memory before su */ if (when == SU_CLIENT && random_uid) { /* FIXME: we */ int ruid = get_random_uid(); prepare_set_user(ruid, random_gid ? ruid : 0); if (random_gid) setgid(ruid); setuid(ruid); } else if (su_time == when) { if (requested_uid) prepare_set_user(requested_uid, requested_gid); if (requested_gid) setgid(requested_gid); if (requested_uid) setuid(requested_uid); } #endif return fail; } /* called once the server process is setup (e.g. after daemon fork for forked servers) */ static void RSsrv_init() { if (pidfile) { FILE *f = fopen(pidfile, "w"); if (f) { fprintf(f, "%d\n", getpid()); fclose(f); } else RSEprintf("WARNING: cannot write into pid file '%s'\n", pidfile); } } static void RSsrv_done() { if (pidfile) { unlink(pidfile); pidfile = 0; } } /* attempts to set a particular configuration setting returns: 1 = setting accepted, 0 = unknown setting, -1 = setting known but failed */ static int setConfig(const char *c, const char *p) { if (!strcmp(c, "log.io")) { #ifdef RSERV_DEBUG io_log = (*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') ? 1 : 0; #endif return 1; } if (!strcmp(c, "deamon")) { #ifdef DAEMON daemonize = (*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') ? 1 : 0; #endif return 1; } if (!strcmp(c, "remote")) { localonly = (*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') ? 0 : 1; return 1; } if (!strcmp(c, "tag.argv")) { tag_argv = (*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c, "keep.alive")) { if (*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') global_srv_flags |= SRV_KEEPALIVE; else global_srv_flags &= ~ SRV_KEEPALIVE; return 1; } if (!strcmp(c, "switch.qap.tls")) { switch_qap_tls = (*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c, "qap.oc") || !strcmp(c, "rserve.oc")) { qap_oc = (*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c, "websockets.qap.oc")) { ws_qap_oc = (*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c, "random.uid")) { random_uid = (*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c, "random.gid")) { random_gid = (*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c, "random.uid.range")) { const char *c = p; int lo = atoi(c); if (lo < 1) RSEprintf("ERROR: invalid random.uid.range start (%d)\n", lo); else { while (*c >= '0' && *c <= '9') c++; while (*c && (*c < '0' || *c > '9')) c++; if (*c) { int hi = atoi(c); if (hi <= lo) RSEprintf("ERROR: invalid random.uid.range (%d..%d)\n", lo, hi); else { random_uid_low = lo; random_uid_high = hi; } } } return 1; } if (!strcmp(c, "auto.uid")) { auto_uid = (*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c, "auto.gid")) { auto_gid = (*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c, "default.uid")) { default_uid = satoi(p); return 1; } if (!strcmp(c, "default.gid")) { default_gid = satoi(p); return 1; } if (!strcmp(c,"port") || !strcmp(c, "qap.port")) { if (*p) { int np = satoi(p); if (np > 0) port = np; } return 1; } if (!strcmp(c, "ipv6")) { use_ipv6 = (*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c, "http.upgrade.websockets")) { ws_upgrade = (*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c, "http.raw.body")) { http_raw_body = (*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c,"websockets.port")) { if (*p) { int np = satoi(p); if (np > 0) ws_port = np; } return 1; } if (!strcmp(c,"http.port")) { if (*p) { int np = satoi(p); if (np > 0) http_port = np; } return 1; } if (!strcmp(c, "tls.key")) { tls_t *tls = shared_tls(0); if (!tls) tls = shared_tls(new_tls()); set_tls_pk(tls, p); return 1; } if (!strcmp(c, "tls.ca")) { tls_t *tls = shared_tls(0); if (!tls) tls = shared_tls(new_tls()); set_tls_ca(tls, p, 0); return 1; } if (!strcmp(c, "tls.cert")) { tls_t *tls = shared_tls(0); if (!tls) tls = shared_tls(new_tls()); set_tls_cert(tls, p); return 1; } if (!strcmp(c, "pid.file") && *p) { pidfile = strdup(p); return 1; } if (!strcmp(c, "rsa.key")) { #ifdef HAVE_RSA if (*p) { FILE *f = fopen(p, "r"); if (f) { char *buf = (char*) malloc(65536); if (buf) { int n = fread(buf, 1, 65535, f); buf[n] = 0; if (rsa_load_key(buf) == -1) RSEprintf("ERROR: not a valid RSA private key in '%s'\n", p); } else RSEprintf("ERROR: cannot allocate memory for the RSA key\n"); fclose(f); } else RSEprintf("ERROR: cannot open rsa.key file '%s'\n", p); } #else RSEprintf("WARNING: rsa.key specified but RSA is not supported in this build!\n"); #endif return 1; } if (!strcmp(c, "tls.port") || !strcmp(c, "qap.tls.port")) { if (*p) { int np = satoi(p); if (np > 0) tls_port = np; } return 1; } if (!strcmp(c,"https.port") || !strcmp(c, "http.tls.port")) { if (*p) { int np = satoi(p); if (np > 0) https_port = np; } return 1; } if (!strcmp(c, "websockets.tls.port")) { if (*p) { int np = satoi(p); if (np > 0) wss_port = np; } return 1; } if (!strcmp(c, "rserve") || !strcmp(c, "qap")) { enable_qap = (p[0] == 'e' || p[0] == 'y' || p[0] == '1' || p[0] == 'T') ? 1 : 0; return 1; } if (!strcmp(c, "websockets.qap")) { enable_ws_qap = (p[0] == 'e' || p[0] == 'y' || p[0] == '1' || p[0] == 'T') ? 1 : 0; return 1; } if (!strcmp(c, "websockets.text")) { enable_ws_text = (p[0] == 'e' || p[0] == 'y' || p[0] == '1' || p[0] == 'T') ? 1 : 0; return 1; } if (!strcmp(c, "websockets") && (p[0] == 'e' || p[0] == 'y' || p[0] == '1' || p[0] == 'T')) { enable_ws_qap = 1; enable_ws_text = 1; return 1; } if (!strcmp(c,"maxinbuf")) { if (*p) { long ns = atol(p); if (ns > 32) { maxInBuf = ns; maxInBuf *= 1024; } } return 1; } if (!strcmp(c,"source") || !strcmp(c,"eval")) { #ifdef RSERV_DEBUG printf("Found source entry \"%s\"\n", p); #endif if (*p) { struct source_entry* se= (struct source_entry*) malloc(sizeof(struct source_entry)+strlen(p)+16); if (!strcmp(c,"source")) { strcpy(se->line, "try(source(\""); strcat(se->line, p); strcat(se->line, "\"))"); } else strcpy(se->line, p); se->next=0; if (!src_tail) src_tail=src_list=se; else { src_tail->next=se; src_tail=se; } } return 1; } if (!strcmp(c,"maxsendbuf")) { if (*p) { long ns = atol(p); if (ns > 32) { maxSendBufSize = ns; maxSendBufSize *= 1024; } } return 1; } #ifdef unix if (!strcmp(c, "su") && *p) { if (*p == 'n') su_time = SU_NOW; else if (*p == 's') su_time = SU_SERVER; else if (*p == 'c') su_time = SU_CLIENT; else { RSEprintf("su value invalid - must be 'now', 'server' or 'client'.\n"); return -1; } return 1; } if (!strcmp(c, "http.user") && *p) { http_user = strdup(p); return 1; } if (!strcmp(c, "https.user") && *p) { https_user = strdup(p); return 1; } if (!strcmp(c, "websockets.user") && *p) { ws_user = strdup(p); return 1; } if (!strcmp(c,"uid") && *p) { requested_uid = satoi(p); return 1; } if (!strcmp(c,"gid") && *p) { requested_gid = satoi(p); return 1; } if (!strcmp(c,"chroot") && *p) { requested_chroot = strdup(p); return 1; } if (!strcmp(c,"umask") && *p) { umask_value = satoi(p); return 1; } #endif if (!strcmp(c,"allow") && *p) { char **l; if (!allowed_ips) { allowed_ips = (char**) malloc(sizeof(char*)*128); *allowed_ips = 0; } l = allowed_ips; while (*l) l++; if (l - allowed_ips >= 127) { RSEprintf("WARNING: Maximum of allowed IPs (127) exceeded, ignoring 'allow %s'\n", p); return -1; } else { *l = strdup(p); l++; *l = 0; } return 1; } if (!strcmp(c, "control") && (p[0] == 'e' || p[0] == 'y' || p[0] == '1' || p[0] == 'T')) { child_control = 1; return 1; } if (!strcmp(c,"workdir")) { workdir = (*p) ? strdup(p) : 0; return 1; } if (!strcmp(c, "workdir.mode")) { int cm = satoi(p); if (!cm) RSEprintf("ERROR: invalid workdir.mode\n"); else { wd_mode = cm; if ((wd_mode & 0700) != 0700) RSEprintf("WARNING: workdir.mode does not contain 0700 - this may cause problems\n"); } return 1; } if (!strcmp(c,"encoding") && *p) { set_string_encoding(p, 1); return 1; } if (!strcmp(c,"socket")) { localSocketName = (*p) ? strdup(p) : 0; return 1; } if (!strcmp(c,"sockmod") && *p) { localSocketMode = satoi(p); return 1; } if (!strcmp(c,"pwdfile")) { pwdfile = (*p) ? strdup(p) : 0; return 1; } if (!strcmp(c,"auth.function")) { auth_fn = (*p) ? strdup(p) : 0; return 1; } if (!strcmp(c,"auth")) { authReq = (*p=='1' || *p=='y' || *p=='r' || *p=='e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c,"interactive")) { Rsrv_interactive = (*p=='1' || *p=='y' || *p=='t' || *p=='e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c,"plaintext")) { usePlain = (*p=='1' || *p=='y' || *p=='e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c,"oob")) { enable_oob = (*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c,"fileio")) { allowIO = (*p=='1' || *p=='y' || *p=='e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c, "r-control") || !strcmp(c, "r.control")) { self_control = (*p=='1' || *p=='y' || *p=='e' || *p == 'T') ? 1 : 0; return 1; } if (!strcmp(c, "cachepwd")) { cache_pwd = (*p == 'i') ? 2 : ((*p == '1' || *p == 'y' || *p == 'e' || *p == 'T') ? 1 : 0); return 1; } return 0; } /* load config file */ static int loadConfig(const char *fn) { FILE *f; char buf[512]; char *c,*p,*c1; #ifdef RSERV_DEBUG printf("Loading config file %s\n",fn); #endif f = fopen(fn,"r"); if (!f) { #ifdef RSERV_DEBUG printf("Failed to find config file %s\n",fn); #endif return -1; } buf[511] = 0; while(!feof(f)) if (fgets(buf,511,f)) { c = buf; while(*c == ' ' || *c == '\t') c++; p = c; while(*p && *p != '\t' && *p != ' ' && *p != '=' && *p != ':') { if (*p >= 'A' && *p <= 'Z') *p |= 0x20; /* to lower case */ p++; } if (*p) { *p = 0; p++; while(*p && (*p == '\t' || *p == ' ')) p++; } c1 = p; while(*c1) if(*c1 == '\n' || *c1 == '\r') *c1 = 0; else c1++; #ifdef RSERV_DEBUG printf("conf> command=\"%s\", parameter=\"%s\"\n", c, p); #endif setConfig(c, p); } fclose(f); #ifndef HAS_CRYPT if (!usePlain) { RSEprintf("WARNING: useplain=no, but this Rserve has no crypt support!\nSet useplain=yes or compile with crypt support (if your system supports crypt).\nFalling back to plain text password.\n"); usePlain=1; } #endif #ifdef RSERV_DEBUG printf("Loaded config file %s\n",fn); #endif if (cache_pwd == 2) load_pwd_cache(); return 0; } /* size of the input buffer (default 512kB) was 2k before 1.23, but since 1.22 we support CMD_assign/set and hence the incoming packets can be substantially bigger. since 1.29 we support input buffer resizing, therefore we start with a small buffer and allocate more if necessary */ static rlen_t inBuf = 32768; /* 32kB should be ok unless CMD_assign sends large data */ /* static buffer size used for file transfer. The user is still free to allocate its own size */ #define sfbufSize 32768 /* static file buffer size */ /* pid of the last child (not really used ATM) */ static int lastChild; #ifdef FORKED static void sigHandler(int i) { if (i==SIGTERM || i==SIGHUP) active = 0; } static void brkHandler(int i) { #ifdef STANDALONE_RSERVE fprintf(stderr, "\nCaught break signal, shutting down Rserve.\n"); #else Rprintf("Caught break signal, shutting down Rserve.\n"); #endif active = 0; /* kill(getpid(), SIGUSR1); */ } #endif /* used for generating salt code (2x random from this array) */ const char *code64="./0123456789ABCDEFGHIJKLMNOPQRSTUVWYXZabcdefghijklmnopqrstuvwxyz"; /** parses a string, stores the number of expressions in parts and the resulting statis in status. the returned SEXP may contain multiple expressions */ SEXP parseString(char *s, int *parts, ParseStatus *status) { int maxParts = 1; char *c = s; SEXP cv, pr = R_NilValue; while (*c) { if (*c == '\n' || *c == ';') maxParts++; c++; } PROTECT(cv = allocVector(STRSXP, 1)); SET_STRING_ELT(cv, 0, mkRChar(s)); while (maxParts > 0) { pr = RS_ParseVector(cv, maxParts, status); if (*status != PARSE_INCOMPLETE && *status != PARSE_EOF) break; maxParts--; } UNPROTECT(1); *parts = maxParts; return pr; } /** parse a string containing the specified number of expressions */ SEXP parseExps(char *s, int exps, ParseStatus *status) { SEXP cv, pr; PROTECT(cv = allocVector(STRSXP, 1)); SET_STRING_ELT(cv, 0, mkRChar(s)); pr = RS_ParseVector(cv, 1, status); UNPROTECT(1); return pr; } void voidEval(char *cmd) { ParseStatus stat; int Rerror; int j = 0; SEXP xp = parseString(cmd,&j,&stat); PROTECT(xp); #ifdef RSERV_DEBUG printf("voidEval: buffer parsed, stat=%d, parts=%d\n",stat,j); if (xp) printf("result type: %d, length: %d\n",TYPEOF(xp),LENGTH(xp)); else printf("result is \n"); #endif if (stat!=1) { UNPROTECT(1); return; } else { SEXP exp = R_NilValue; #ifdef RSERV_DEBUG printf("R_tryEval(xp,R_GlobalEnv,&Rerror);\n"); #endif if (TYPEOF(xp) == EXPRSXP && LENGTH(xp) > 0) { int bi = 0; while (bi < LENGTH(xp)) { SEXP pxp = VECTOR_ELT(xp, bi); Rerror = 0; #ifdef RSERV_DEBUG printf("Calling R_tryEval for expression %d [type=%d] ...\n", bi+1, TYPEOF(pxp)); #endif exp = R_tryEval(pxp, R_GlobalEnv, &Rerror); bi++; #ifdef RSERV_DEBUG printf("Expression %d, error code: %d\n", bi, Rerror); if (Rerror) printf(">> early error, aborting further evaluations\n"); #endif if (Rerror) break; } } else { Rerror = 0; exp = R_tryEval(xp, R_GlobalEnv, &Rerror); } UNPROTECT(1); } return; } #define sendRespData(A, C, L, D) srv->send_resp(A, C, L, D) #define sendResp(A,C) srv->send_resp(A, C, 0, 0) struct sockaddr_in session_peer_sa; SOCKET session_socket; unsigned char session_key[32]; /* detach session and setup everything such that in can be resumed at some point */ int detach_session(args_t *arg) { SAIN ssa; SOCKET s = arg->s; server_t *srv = arg->srv; int port = 32768; SOCKET ss = FCF("open socket",socket(AF_INET,SOCK_STREAM,0)); int reuse = 1; /* enable socket address reusage */ socklen_t sl = sizeof(session_peer_sa); struct dsresp { int pt1; int port; int pt2; unsigned char key[32]; } dsr; if (getpeername(s, (SA*) &session_peer_sa, &sl)) { sendResp(arg, SET_STAT(RESP_ERR,ERR_detach_failed)); return -1; } setsockopt(ss,SOL_SOCKET,SO_REUSEADDR,(const char*)&reuse,sizeof(reuse)); #ifdef WIN32 while ((port = (((int) rand()) & 0x7fff)+32768)>65000) {}; #else while ((port = (((int) random()) & 0x7fff)+32768)>65000) {}; #endif while (bind(ss,build_sin(&ssa,0,port),sizeof(ssa))) { if (errno!=EADDRINUSE) { #ifdef RSERV_DEBUG printf("session: error in bind other than EADDRINUSE (0x%x)", errno); #endif closesocket(ss); sendResp(arg, SET_STAT(RESP_ERR,ERR_detach_failed)); return -1; } port++; if (port>65530) { #ifdef RSERV_DEBUG printf("session: can't find available prot to listed on.\n"); #endif closesocket(ss); sendResp(arg, SET_STAT(RESP_ERR,ERR_detach_failed)); return -1; } } if (listen(ss,LISTENQ)) { #ifdef RSERV_DEBUG printf("session: cannot listen.\n"); #endif closesocket(ss); sendResp(arg, SET_STAT(RESP_ERR,ERR_detach_failed)); return -1; } { int i=0; while (i<32) session_key[i++]=(unsigned char) rand(); } #ifdef RSERV_DEBUG printf("session: listening on port %d\n", port); #endif dsr.pt1 = itop(SET_PAR(DT_INT,sizeof(int))); dsr.port = itop(port); dsr.pt2 = itop(SET_PAR(DT_BYTESTREAM,32)); memcpy(dsr.key, session_key, 32); sendRespData(arg, RESP_OK, 3*sizeof(int)+32, &dsr); closesocket(s); #ifdef RSERV_DEBUG printf("session: detached, closing connection.\n"); #endif session_socket = ss; return 0; } /* static char *sres_id = "RsS1 \r\n\r\n"; */ /* resume detached session. return the new socket after resume is complete, but don't send the response message */ SOCKET resume_session() { SOCKET s=-1; SAIN lsa; socklen_t al=sizeof(lsa); char clk[32]; #ifdef RSERV_DEBUG printf("session: resuming session, waiting for connections.\n"); #endif while ((s=accept(session_socket, (SA*)&lsa,&al))>1) { if (lsa.sin_addr.s_addr != session_peer_sa.sin_addr.s_addr) { #ifdef RSERV_DEBUG printf("session: different IP, rejecting\n"); #endif closesocket(s); } else { int n=0; if ((n=recv(s, (char*)clk, 32, 0)) != 32) { #ifdef RSERV_DEBUG printf("session: expected 32, got %d = closing\n", n); #endif closesocket(s); } else if (memcmp(clk, session_key, 32)) { #ifdef RSERV_DEBUG printf("session: wrong key, closing\n"); #endif closesocket(s); } else { #ifdef RSERV_DEBUG printf("session: accepted\n"); #endif return s; } } } return -1; } #ifdef WIN32 # include #endif typedef struct child_process { pid_t pid; int inp; struct child_process *prev, *next; } child_process_t; child_process_t *children; /* handling of the password file - we emulate stdio API but allow both file and buffer back-ends transparently */ typedef struct pwdf { FILE *f; char *ptr; } pwdf_t; static pwdf_t *pwd_open() { pwdf_t *f = malloc(sizeof(pwdf_t)); if (!f) return 0; if (cache_pwd && pwd_cache) { f->ptr = pwd_cache; f->f = 0; return f; } f->f = fopen(pwdfile, "r"); if (!f->f) { free(f); return 0; } return f; } static char *pwd_gets(char *str, int n, pwdf_t *f) { char *c, *s = str; if (f->f) return fgets(str, n, f->f); c = f->ptr; while (*c == '\r' || *c == '\n') c++; /* skip empty lines */ while (*c && *c != '\r' && *c != '\n' && (--n > 0)) *(s++) = *(c++); if (*c == '\n' || *c == '\r') { *c = 0; c++; } f->ptr = c; *s = 0; return str; } static int pwd_eof(pwdf_t *f) { if (f->f) return feof(f->f); return (f->ptr[0]) ? 0 : 1; } static void pwd_close(pwdf_t *f) { if (f->f) fclose(f->f); free(f); } args_t *self_args; static char dump_buf[32768]; /* scratch buffer that is static so mem alloc doesn't fail */ static int send_oob_sexp(int cmd, SEXP exp) { if (!self_args) Rf_error("OOB commands can only be used from code evaluated inside an Rserve client instance"); if (!enable_oob) Rf_error("OOB command is disallowed by the current Rserve configuration - use 'oob enable' to allow its use"); { args_t *a = self_args; server_t *srv = a->srv; char *sendhead = 0, *sendbuf; /* check buffer size vs REXP size to avoid dangerous overflows todo: resize the buffer as necessary */ rlen_t rs = QAP_getStorageSize(exp); /* increase the buffer by 25% for safety */ /* FIXME: there are issues with multi-byte strings that expand when converted. They should be convered by this margin but it is an ugly hack!! */ rs += (rs >> 2); #ifdef RSERV_DEBUG printf("result storage size = %ld bytes\n",(long)rs); #endif sendbuf = (char*) malloc(rs); if (!sendbuf) Rf_error("Unable to allocate large enough buffer to send the object"); else { /* first we have 4 bytes of a header saying this is an encoded SEXP, then comes the SEXP */ char *sxh = sendbuf + 8; char *tail = (char*)QAP_storeSEXP((unsigned int*)sxh, exp, rs); /* set type to DT_SEXP and correct length */ if ((tail - sxh) > 0xfffff0) { /* we must use the "long" format */ rlen_t ll = tail - sxh; ((unsigned int*)sendbuf)[0] = itop(SET_PAR(DT_SEXP | DT_LARGE, ll & 0xffffff)); ((unsigned int*)sendbuf)[1] = itop(ll >> 24); sendhead = sendbuf; } else { sendhead = sendbuf + 4; ((unsigned int*)sendbuf)[1] = itop(SET_PAR(DT_SEXP,tail - sxh)); } #ifdef RSERV_DEBUG printf("stored SEXP; length=%ld (incl. DT_SEXP header)\n",(long) (tail - sendhead)); #endif sendRespData(a, cmd, tail - sendhead, sendhead); free(sendbuf); } } return 1; } SEXP Rserve_oobSend(SEXP exp, SEXP code) { int oob_code = asInteger(code); return ScalarLogical(send_oob_sexp(OOB_USR_CODE(oob_code) | OOB_SEND, exp) == 1 ? TRUE : FALSE); } SEXP Rserve_oobMsg(SEXP exp, SEXP code) { struct phdr ph; int oob_code = asInteger(code), n; int res = send_oob_sexp(OOB_USR_CODE(oob_code) | OOB_MSG, exp); args_t *a = self_args; /* send_oob_sexp has checked this already so it's ok */ server_t *srv = a->srv; if (res != 1) /* never happens since send_oob_sexp returns only on success */ Rf_error("Sending OOB_MSG failed"); /* FIXME: this is very similar (but not the same) as the read loop in Rserve itself - we should modularize this and re-use the parts */ #ifdef RSERV_DEBUG printf("OOB-msg (%x) - waiting for response packet\n", oob_code); #endif if ((n = srv->recv(a, (char*)&ph, sizeof(ph))) == sizeof(ph)) { size_t plen = 0, i; #ifdef RSERV_DEBUG printf("\nOOB response header read result: %d\n", n); if (n > 0) printDump(&ph, n); #endif ph.len = ptoi(ph.len); ph.cmd = ptoi(ph.cmd); ph.dof = ptoi(ph.dof); #ifdef __LP64__ ph.res = ptoi(ph.res); plen = (unsigned int) ph.len; plen |= (((size_t) (unsigned int) ph.res) << 32); #else plen = ph.len; #endif #ifdef RSERV_DEBUG if (io_log) { struct timeval tv; snprintf(io_log_fn, sizeof(io_log_fn), "/tmp/Rserve-io-%d.log", getpid()); FILE *f = fopen(io_log_fn, "a"); if (f) { double ts = 0; if (!gettimeofday(&tv, 0)) ts = ((double) tv.tv_sec) + ((double) tv.tv_usec) / 1000000.0; if (first_ts < 1.0) first_ts = ts; fprintf(f, "%.3f [+%4.3f] SRV <-- CLI [OOB recv] (%x, %ld bytes)\n HEAD ", ts, ts - first_ts, ph.cmd, (long) plen); fprintDump(f, &ph, sizeof(ph)); fclose(f); } } #endif if (plen) { char *orb = (char*) malloc(plen + 8); if (!orb) { /* error, but we have to pull the while packet as to not kill the queue */ size_t chk = (sizeof(dump_buf) < max_sio_chunk) ? sizeof(dump_buf) : max_sio_chunk; i = plen; while((n = srv->recv(a, dump_buf, (i < chk) ? i : chk))) { if (n > 0) i -= n; if (i < 1 || n < 1) break; } if (i > 0) { /* something went wrong */ /* FIXME: is this ok? do we need a common close function to shutdown TLS etc.? */ closesocket(a->s); a->s = -1; Rf_error("cannot allocate buffer for OOB msg result + read error, aborting conenction"); } /* packet discarded so connection is ok, but it is still a mem alloc error */ Rf_error("cannot allocate buffer for OOB msg result"); } /* ok, got the buffer, fill it */ i = 0; while ((n = srv->recv(a, orb + i, (plen - i > max_sio_chunk) ? max_sio_chunk : (plen - i)))) { if (n > 0) i += n; if (i >= plen || n < 1) break; } #ifdef RSERV_DEBUG if (io_log) { FILE *f = fopen(io_log_fn, "a"); if (f) { fprintf(f, " BODY "); if (i) fprintDump(f, orb, i); else fprintf(f, "\n"); fclose(f); } } #endif if (i < plen) { /* uh, oh, the stream is corrupted */ closesocket(a->s); a->s = -1; free(orb); Rf_error("read error while reading OOB msg respose, aborting connection"); } /* parse the payload - we ony support SEXPs though (and DT_STRING) */ { unsigned int *hi = (unsigned int*) orb, pt = PAR_TYPE(ptoi(hi[0])); unsigned long psz = PAR_LEN(ptoi(hi[0])); SEXP res; if (pt & DT_LARGE) { psz |= hi[1] << 24; pt ^= DT_LARGE; hi++; } if (pt == DT_STRING) { const char *s = (const char *) ++hi, *se = s + psz; while (se-- > s) if (!*se) break; if (se == s && *s) { free(orb); Rf_error("unterminated string in OOB msg response"); } res = mkString(s); free(orb); return res; } if (pt != DT_SEXP) { free(orb); Rf_error("unsupported parameter type %d in OOB msg response", PAR_TYPE(ptoi(hi[0]))); } hi++; /* FIXME: we should use R allocation for orb since it will leak if there is an error in any allocation in decoding --- but we can't do the before reading since it would fail to read the stream in case of an error - so we're stuck a bit ... */ res = QAP_decode(&hi); free(orb); return res; } } } else { closesocket(a->s); a->s = -1; Rf_error("read error im OOB msg header"); } return R_NilValue; } /* server forking For a regular forked server this is simply fork(), but for pre-forked servers ... ? */ int RS_fork(args_t *arg) { #ifdef unix return (arg->srv && arg->srv->fork) ? arg->srv->fork(arg) : fork(); #else return -1; #endif } static void restore_signal_handlers(); /* forward decl */ /* return 0 if the child was prepared. Returns the result of fork() is forked and this is the parent */ int Rserve_prepare_child(args_t *arg) { #ifdef FORKED #ifdef unix int cinp[2]; #endif #ifdef Win32 long rseed = rand(); #else long rseed = random(); #endif rseed ^= time(0); parent_pipe = -1; cinp[0] = -1; #if 0 /* currenlty we disable controls in sub-protocols */ /* we use the input pipe only if child control is enabled. disabled pipe means no registration */ if ((child_control || self_control) && pipe(cinp) != 0) cinp[0] = -1; #endif if ((lastChild = RS_fork(arg)) != 0) { /* parent/master part */ /* close the connection socket - the child has it already */ closesocket(arg->s); if (cinp[0] != -1) { /* if we have a valid pipe register the child */ child_process_t *cp = (child_process_t*) malloc(sizeof(child_process_t)); close(cinp[1]); /* close the write end which is what the child will be using */ #ifdef RSERV_DEBUG printf("child %d was spawned, registering input pipe\n", (int)lastChild); #endif cp->inp = cinp[0]; cp->pid = lastChild; cp->next = children; if (children) children->prev = cp; cp->prev = 0; children = cp; } return lastChild; } /* child part */ restore_signal_handlers(); /* the handlers handle server shutdown so not needed in the child */ if (main_argv && tag_argv && strlen(main_argv[0]) >= 8) strcpy(main_argv[0] + strlen(main_argv[0]) - 8, "/RsrvCHx"); is_child = 1; if (cinp[0] != -1) { /* if we have a vaild pipe to the parent set it up */ parent_pipe = cinp[1]; close(cinp[0]); } #ifdef Win32 srand(rseed); #else srandom(rseed); #endif parentPID = getppid(); close_all_srv_sockets(); /* close all server sockets - this includes arg->ss */ #ifdef CAN_TCP_NODELAY { int opt = 1; setsockopt(arg->s, IPPROTO_TCP, TCP_NODELAY, (const char*) &opt, sizeof(opt)); } #endif performConfig(SU_CLIENT); #endif self_args = arg; return 0; } /* text protocol (exposed by WS) */ void Rserve_text_connected(void *thp) { args_t *arg = (args_t*) thp; server_t *srv = arg->srv; int bl = 1024*1024, bp = 0, n; ParseStatus stat; char *buf = (char*) malloc(bl--); if (!buf) { RSEprintf("ERROR: cannot allocate buffer\n"); return; } self_args = arg; snprintf(buf, bl, "OK\n"); srv->send(arg, buf, strlen(buf)); while ((n = srv->recv(arg, buf + bp, bl - bp)) > 0) { bp += n; if (!(arg->flags & F_INFRAME)) { /* end of frame */ SEXP xp; int parts; buf[bp] = 0; xp = parseString(buf, &parts, &stat); if (stat != PARSE_OK) { snprintf(buf, bl, "ERROR: Parse error: %s\n", getParseName(stat)); srv->send(arg, buf, strlen(buf)); } else { SEXP exp = R_NilValue; int err = 0; PROTECT(xp); if (TYPEOF(xp) == EXPRSXP && LENGTH(xp) > 0) { int bi = 0; while (bi < LENGTH(xp)) { SEXP pxp = VECTOR_ELT(xp, bi); #ifdef RSERV_DEBUG printf("Calling R_tryEval for expression %d [type=%d] ...\n", bi + 1, TYPEOF(pxp)); #endif exp = R_tryEval(pxp, R_GlobalEnv, &err); bi++; #ifdef RSERV_DEBUG printf("Expression %d, error code: %d\n", bi, err); if (err) printf(">> early error, aborting further evaluations\n"); #endif if (err) break; } } else exp = R_tryEval(xp, R_GlobalEnv, &err); if (!err && TYPEOF(exp) != STRSXP) exp = R_tryEval(lang2(install("as.character"), exp), R_GlobalEnv, &err); if (!err && TYPEOF(exp) == STRSXP) { int i = 0, l = LENGTH(exp); long tl = 0; char *sb = buf; while (i < l) { tl += strlen(Rf_translateCharUTF8(STRING_ELT(exp, i))) + 1; i++; } if (tl > bl) { sb = (char*) malloc(tl); if (!sb) { RSEprintf("ERROR: cannot allocate buffer for the result string\n"); snprintf(buf, bl, "ERROR: cannot allocate buffer for the result string\n"); srv->send(arg, buf, strlen(buf)); } } if (sb) { tl = 0; for (i = 0; i < l; i++) { strcpy(sb + tl, Rf_translateCharUTF8(STRING_ELT(exp, i))); tl += strlen(sb + tl); if (i < l - 1) sb[tl++] = '\n'; } srv->send(arg, sb, tl); if (sb != buf) free(sb); } } else { if (err) snprintf(buf, bl, "ERROR: evaluation error %d\n", err); else snprintf(buf, bl, "ERROR: result cannot be coerced into character\n"); srv->send(arg, buf, strlen(buf)); } } bp = 0; } else { /* continuation of a frame */ if (bp >= bl) { RSEprintf("WARNING: frame exceeds max size, ignoring\n"); while ((arg->flags & F_INFRAME) && srv->recv(arg, buf, bl) > 0) ; bp = 0; } } } } static char auth_buf[4096]; static const char *hexc = "0123456789abcdef"; static const char *sec_salt = "##secure"; /* special object to denote secure login */ static int auth_user(const char *usr, const char *pwd, const char *salt) { int authed = 0; unsigned char md5h[16]; unsigned char sh1h[20]; char md5_pwd[34]; /* MD5 hex representation of the password */ char sha1_pwd[42]; /* SHA1 hex representation of the password */ md5hash(pwd, strlen(pwd), md5h); sha1hash(pwd, strlen(pwd), sh1h); { /* create hex-encoded versions of the password hashes */ char *mp = md5_pwd; int k; for (k = 0; k < 16; k++) { *(mp++) = hexc[md5h[k] >> 4]; *(mp++) = hexc[md5h[k] & 15]; } *mp = 0; mp = sha1_pwd; for (k = 0; k < 20; k++) { *(mp++) = hexc[sh1h[k] >> 4]; *(mp++) = hexc[sh1h[k] & 15]; } *mp = 0; } authed = 1; #ifdef RSERV_DEBUG printf("Authentication attempt (login='%s', pwd='%s', pwdfile='%s')\n", usr, pwd, pwdfile); #endif if (auth_fn) { SEXP res, authv = PROTECT(allocVector(STRSXP, 2)); int eres = 0; SET_STRING_ELT(authv, 0, mkChar(usr)); SET_STRING_ELT(authv, 1, mkChar(pwd)); res = R_tryEval(lang2(install(auth_fn), authv), R_GlobalEnv, &eres); UNPROTECT(1); return (res && TYPEOF(res) == LGLSXP && LENGTH(res) == 1 && LOGICAL(res)[0] == TRUE); } if (pwdfile) { pwdf_t *pwf; int ctrl_flag = 0, u_uid = 0, u_gid = 0; authed = 0; /* if pwdfile exists, default is access denied */ /* we abuse variables of other commands since we are the first command ever used so we can trash them */ pwf = pwd_open(); if (pwf) { auth_buf[sizeof(auth_buf) - 1] = 0; while(!pwd_eof(pwf)) if (pwd_gets(auth_buf, sizeof(auth_buf) - 1, pwf)) { char *login = auth_buf, *c1 = auth_buf, *c2, *l_uid = 0, *l_gid = 0; /* and are valid separators */ while(*c1 && *c1 != ' ' && *c1 != '\t') { /* [@]username[/uid[,gid]] {$MD5/SHA1hash|password} */ if (*c1 == '/' && !l_uid) { *c1 = 0; l_uid = c1 + 1; } else if (*c1 == ',' && l_uid) { *c1 = 0; if (!l_gid) l_gid = c1 + 1; } c1++; } if (l_uid) u_uid = satoi(l_uid); if (l_gid) u_gid = satoi(l_gid); if (l_uid && !l_gid) u_gid = u_uid; if (*c1) { *c1 = 0; c1++; while(*c1 == ' ' || *c1 == '\t') c1++; /* skip leading blanks */ } c2 = c1; while(*c2) if (*c2 == '\r' || *c2=='\n') *c2 = 0; else c2++; ctrl_flag = 0; if (*login == '#') continue; /* skip comment lines */ if (*login == '@') { /* only users with @ prefix can use control commands */ login++; ctrl_flag = 1; } if (*login == '*') { /* general authentication - useful to set control access but leave client access open */ authed = 1; #ifdef RSERV_DEBUG printf("Public authentication enabled (found * entry), allowing login without checking.\n"); #endif break; } if (!strcmp(login, usr)) { /* login found */ #ifdef RSERV_DEBUG printf("Found login '%s', checking password.\n", usr); printf(" - stored pwd = '%s', md5='%s', sha1='%s'\n", c1, md5_pwd, sha1_pwd); #endif if ((usePlain || salt == sec_salt) && ((*c1 == '$' && strlen(c1) == 33 && !strcmp(c1 + 1, md5_pwd)) || (*c1 == '$' && strlen(c1) == 41 && !strcmp(c1 + 1, sha1_pwd)) || ((*c1 != '$' || (strlen(c1) != 33 && strlen(c1) !=41)) && !strcmp(c1, pwd)))) { authed = 1; #ifdef RSERV_DEBUG printf(" - %s password matches.\n", (*c1 == '$' && strlen(c1) == 33) ? "MD5" : ((*c1 == '$' && strlen(c1) == 41) ? "SHA1" : "plain")); #endif } else { #ifdef HAS_CRYPT c2 = crypt(c1, salt); #ifdef RSERV_DEBUG printf(" - checking crypted '%s' vs '%s'\n", c2, pwd); #endif if (!strcmp(c2, pwd)) authed = 1; #endif } } if (authed) break; } /* if fgets */ pwd_close(pwf); if (authed) { can_control = ctrl_flag; #ifdef unix if (auto_uid && !u_uid && !default_uid) { authed = 0; #ifdef DEBUG_RSERV printf(" - no uid in the user entry and no default.uid, refusing authentication\n"); #endif } else { if (auto_uid) prepare_set_user(u_uid ? u_uid : default_uid, auto_gid ? (u_gid ? u_gid : default_gid) : 0); if (auto_gid) setgid(u_gid ? u_gid : default_gid); if (auto_uid) setuid(u_uid ? u_uid : default_uid); } #endif } } /* if (pwf) */ } #ifdef DEBUG_RSERV printf(" - authentication %s\n", authed ? "succeeded" : "failed"); #endif return authed; } #ifdef HAVE_RSA #include #include #ifdef RSERV_DEBUG #include #endif static RSA *rsa_srv_key; static char rsa_buf[32768]; #define SRV_KEY_LEN 512 /* from base64.c */ int base64decode(const char *src, void *dst, int max_len); static int rsa_load_key(const char *buf) { int n; const char *c = buf; const unsigned char *ptr; while (1) { while (*c == ' ' || *c == '\t') c++; if (*c == '-') { /* header line */ while (*c && *c != '\n' && *c != '\r') c++; while (*c == '\n' || *c == '\r') c++; continue; } if (*c == '\n' || *c == '\r') while (*c == '\n' || *c == '\r') c++; else break; } if (!*c) return -1; n = base64decode(c, rsa_buf, sizeof(rsa_buf)); if (n < 1) return -1; ptr = (const unsigned char*) rsa_buf; rsa_srv_key = d2i_RSAPrivateKey(NULL, &ptr, n); if (!rsa_srv_key) return -1; return 0; } static int rsa_gen_resp(char **dst) { unsigned char *kb; unsigned char *pt; int kl; if (!rsa_srv_key) { #ifdef RSERV_DEBUG printf("rsa_gen_resp: generating RSA key\n"); #endif rsa_srv_key = RSA_generate_key(4096, 65537, 0, 0); #ifdef RSERV_DEBUG printf(" - done\n"); #endif } if (!rsa_srv_key || RAND_bytes((unsigned char*) authkey, sizeof(authkey)) == 0) return 0; kb = calloc(65536, 1); if (!kb) return 0; kb[0] = SRV_KEY_LEN & 0xff; kb[1] = (SRV_KEY_LEN >> 8) & 0xff; memcpy(kb + 4, authkey, SRV_KEY_LEN); pt = kb + SRV_KEY_LEN + 8; kl = i2d_RSAPublicKey(rsa_srv_key, &pt); kb[SRV_KEY_LEN + 4] = kl & 0xff; kb[SRV_KEY_LEN + 5] = (kl >> 8) & 0xff; *dst = (char*) kb; return SRV_KEY_LEN + kl + 8; } static int rsa_decode(char *dst, const char *src, int len) { int dec = 0, blk = RSA_size(rsa_srv_key); while (len > 0) { int db = (len > blk) ? blk : len; int n = RSA_private_decrypt(db, (unsigned char*)src, (unsigned char*) dst, rsa_srv_key, RSA_PKCS1_OAEP_PADDING); if (n <= 0) { #ifdef RSERV_DEBUG printf("rsa_decode (dec=%d, len=%d, db=%d) failed: %s\n", dec, len, db, ERR_error_string(ERR_get_error(), 0)); #endif return -1; } dst += n; dec += n; src += db; len -= db; } return dec; } /* the client encodes, so we don't use it for now static int rsa_encode(char *dst, char *src, int len) { return RSA_public_encrypt(len, (unsigned char*)src, (unsigned char*) dst, rsa_srv_key, RSA_PKCS1_OAEP_PADDING); } */ #endif #ifdef unix #include #include static void rm_rf(const char *what) { struct stat st; if (!lstat(what, &st)) { chmod(what, st.st_mode | ((st.st_mode & S_IFDIR) ? S_IRWXU : S_IWUSR)); if (st.st_mode & S_IFDIR) { /* dirs need to be deleted recursively */ DIR *dir = opendir(what); char path[PATH_MAX]; if (dir) { struct dirent *d; while ((d = readdir(dir))) { if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) continue; snprintf(path, sizeof(path), "%s/%s", what, d->d_name); rm_rf(path); } closedir(dir); } rmdir(what); } else unlink(what); } } #endif /* FIXME: we are not using Rserve_prepare_child so the behavior may differ between QAP and others! */ /* working thread/function. the parameter is of the type struct args* */ /* This server function implements the Rserve QAP1 protocol */ void Rserve_QAP1_connected(void *thp) { SOCKET s; struct args *a = (struct args*)thp; struct phdr ph; server_t *srv = a->srv; char *buf, *c, *cc, *c1; int pars; int process; int rn; ParseStatus stat; char *sendbuf; rlen_t sendBufSize; char *tail; char *sfbuf; int Rerror; int authed=0; int unaligned=0; #ifdef HAS_CRYPT char salt[5]; #endif rlen_t tempSB=0; int parT[16]; rlen_t parL[16]; void *parP[16]; SEXP xp,exp; FILE *cf=0; #ifdef FORKED #ifdef Win32 long rseed = rand(); #else long rseed = random(); #endif rseed ^= time(0); if (!is_child) { /* in case we get called from a child (e.g. other server has spawned us) we perform the following only as parent - assuming it has been done already */ parent_pipe = -1; cinp[0] = -1; /* we use the input pipe only if child control is enabled. disabled pipe means no registration */ if ((child_control || self_control) && pipe(cinp) != 0) cinp[0] = -1; if ((lastChild = RS_fork(a)) != 0) { /* parent/master part */ /* close the connection socket - the child has it already */ closesocket(a->s); if (cinp[0] != -1) { /* if we have a valid pipe register the child */ child_process_t *cp = (child_process_t*) malloc(sizeof(child_process_t)); close(cinp[1]); /* close the write end which is what the child will be using */ #ifdef RSERV_DEBUG printf("child %d was spawned, registering input pipe\n", (int)lastChild); #endif cp->inp = cinp[0]; cp->pid = lastChild; cp->next = children; if (children) children->prev = cp; cp->prev = 0; children = cp; } free(a); /* release the args */ return; } if (main_argv && tag_argv && strlen(main_argv[0]) >= 8) strcpy(main_argv[0] + strlen(main_argv[0]) - 8, "/RsrvCHq"); /* child part */ restore_signal_handlers(); /* the handlers handle server shutdown so not needed in the child */ is_child = 1; if (cinp[0] != -1) { /* if we have a vaild pipe to the parent set it up */ parent_pipe = cinp[1]; close(cinp[0]); } #ifdef Win32 srand(rseed); #else srandom(rseed); #endif parentPID = getppid(); close_all_srv_sockets(); /* close all server sockets - this includes a->ss */ performConfig(SU_CLIENT); } #endif self_args = a; buf = (char*) malloc(inBuf + 8); sfbuf = (char*) malloc(sfbufSize); if (!buf || !sfbuf) { RSEprintf("FATAL: cannot allocate initial buffers. closing client connection.\n"); s = a->s; free(a); closesocket(s); return; } memset(buf, 0, inBuf + 8); #ifdef unix if (workdir) { if (chdir(workdir)) mkdir(workdir,0755); wdname[511]=0; snprintf(wdname, 511, "%s/conn%d", workdir, (int)getpid()); rm_rf(wdname); mkdir(wdname, wd_mode); chdir(wdname); } #endif sendBufSize = sndBS; sendbuf = (char*) malloc(sendBufSize); #ifdef RSERV_DEBUG printf("connection accepted.\n"); #endif s = a->s; /* FIXME: we used to free a here, but now that we use it we have to defer that ... */ csock = s; #ifdef CAN_TCP_NODELAY { int opt=1; setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (const char*) &opt, sizeof(opt)); } #endif if ((a->srv->flags & SRV_TLS) && shared_tls(0)) add_tls(a, shared_tls(0), 1); if (a->srv->flags & SRV_QAP_OC) { /* use OC handshake instead of regular QAP ID string */ rlen_t rs; int Rerr = 0; SEXP oc; #ifdef RSERV_DEBUG printf("evaluating oc.init()\n"); #endif oc = R_tryEval(PROTECT(LCONS(install("oc.init"), R_NilValue)), R_GlobalEnv, &Rerr); UNPROTECT(1); if (Rerr) { /* cannot get any capabilities, bail out */ #ifdef RSERV_DEBUG printf("ERROR: failed to eval oc.init() - aborting!"); #endif free(sendbuf); free(sfbuf); closesocket(s); return; } PROTECT(oc); a->flags |= F_OUT_BIN; /* in OC everything is binary */ rs = QAP_getStorageSize(oc); #ifdef RSERV_DEBUG printf("oc.init storage size = %ld bytes\n",(long)rs); #endif if (rs > sendBufSize - 64L) { /* is the send buffer too small ? */ unsigned int osz = (rs > 0xffffffff) ? 0xffffffff : rs; osz = itop(osz); #ifdef RSERV_DEBUG printf("ERROR: object too big (sendBuf=%ld)\n", sendBufSize); #endif /* FIXME: */ sendRespData(a, SET_STAT(RESP_ERR, ERR_object_too_big), 4, &osz); free(sendbuf); free(sfbuf); closesocket(s); return; } else { char *sxh = sendbuf + 8, *sendhead = 0; char *tail = (char*)QAP_storeSEXP((unsigned int*)sxh, oc, rs); /* set type to DT_SEXP and correct length */ if ((tail - sxh) > 0xfffff0) { /* we must use the "long" format */ rlen_t ll = tail - sxh; ((unsigned int*)sendbuf)[0] = itop(SET_PAR(DT_SEXP | DT_LARGE, ll & 0xffffff)); ((unsigned int*)sendbuf)[1] = itop(ll >> 24); sendhead = sendbuf; } else { sendhead = sendbuf + 4; ((unsigned int*)sendbuf)[1] = itop(SET_PAR(DT_SEXP,tail - sxh)); } #ifdef RSERV_DEBUG printf("stored SEXP; length=%ld (incl. DT_SEXP header)\n",(long) (tail - sendhead)); #endif sendRespData(a, CMD_OCinit, tail - sendhead, sendhead); } } else { strcpy(buf,IDstring); if (authReq) { #ifdef HAS_CRYPT /* advertize crypt */ memcpy(buf+16,"ARuc",4); salt[0]='K'; salt[1]=code64[rand()&63]; salt[2]=code64[rand()&63]; salt[3]=' '; salt[4]=0; memcpy(buf+20,salt,4); /* append plaintext if enabled */ if (usePlain) memcpy(buf + 24,"ARpt",4); #else /* if crypt is not an option, we may need to advertize plain text if enabled */ if (usePlain) memcpy(buf + 16, "ARpt", 4); #endif } #ifdef HAVE_TLS if (switch_qap_tls) { char *ep = buf + 16; while (*ep != '-') ep += 4; memcpy(ep, "TLS\n", 4); } #endif #ifdef RSERV_DEBUG printf("sending ID string.\n"); #endif srv->send(a, (char*)buf, 32); } /* everything is binary from now on */ a->flags |= F_OUT_BIN; can_control = 0; if (!authReq && !pwdfile) /* control is allowed by default only if authentication is not required and passwd is not present. In all other cases it will be set during authentication. */ can_control = 1; while((rn = srv->recv(a, (char*)&ph, sizeof(ph))) == sizeof(ph)) { SEXP eval_result = 0; size_t plen = 0; SEXP pp = R_NilValue; /* packet payload (as a raw vector) for special commands */ Rerror = 0; #ifdef RSERV_DEBUG printf("\nheader read result: %d\n", rn); if (rn > 0) printDump(&ph, rn); #endif ph.len = ptoi(ph.len); ph.cmd = ptoi(ph.cmd); ph.dof = ptoi(ph.dof); #ifdef __LP64__ ph.res = ptoi(ph.res); plen = (unsigned int) ph.len; plen |= (((size_t) (unsigned int) ph.res) << 32); #else plen = ph.len; #endif process = 0; pars = 0; #ifdef RSERV_DEBUG if (io_log) { struct timeval tv; snprintf(io_log_fn, sizeof(io_log_fn), "/tmp/Rserve-io-%d.log", getpid()); FILE *f = fopen(io_log_fn, "a"); if (f) { double ts = 0; if (!gettimeofday(&tv, 0)) ts = ((double) tv.tv_sec) + ((double) tv.tv_usec) / 1000000.0; if (first_ts < 1.0) first_ts = ts; fprintf(f, "%.3f [+%4.3f] SRV <-- CLI [QAP loop] (%x, %ld bytes)\n HEAD ", ts, ts - first_ts, ph.cmd, (long) plen); fprintDump(f, &ph, sizeof(ph)); fclose(f); } } #endif /* in OC mode everything but OCcall is invalid */ if ((a->srv->flags & SRV_QAP_OC) && ph.cmd != CMD_OCcall) { sendResp(a, SET_STAT(RESP_ERR, ERR_disabled)); free(sendbuf); free(sfbuf); closesocket(s); return; } if ((ph.cmd & CMD_SPECIAL_MASK) == CMD_SPECIAL_MASK) { /* this is a very special case - we load the packet payload into a raw vector directly to prevent unnecessaru copying */ pp = allocVector(RAWSXP, plen); char *pbuf = (char*) RAW(pp); size_t i = 0; #ifdef RSERV_DEBUG printf("loading (raw) buffer (awaiting %d bytes)\n", (int)plen); #endif while((rn = srv->recv(a, pbuf + i, (plen - i > max_sio_chunk) ? max_sio_chunk : (plen - i)))) { if (rn > 0) i += rn; if (i >= plen || rn < 1) break; } } else if (plen > 0) { unsigned int phead; int parType = 0; rlen_t parLen = 0; if (!maxInBuf || plen < maxInBuf) { rlen_t i; if (plen >= inBuf) { #ifdef RSERV_DEBUG printf("resizing input buffer (was %ld, need %ld) to %ld\n", (long)inBuf, (long) plen, (long)(((plen | 0x1fffL) + 1L))); #endif free(buf); /* the buffer is just a scratchpad, so we don't need to use realloc */ buf = (char*) malloc(inBuf = ((plen | 0x1fffL) + 1L)); /* use 8kB granularity */ if (!buf) { #ifdef RSERV_DEBUG fprintf(stderr,"FATAL: out of memory while resizing buffer to %d,\n", (int)inBuf); #endif sendResp(a, SET_STAT(RESP_ERR,ERR_out_of_mem)); free(sendbuf); free(sfbuf); closesocket(s); return; } } #ifdef RSERV_DEBUG printf("loading buffer (awaiting %ld bytes)\n",(long) plen); #endif i = 0; while ((rn = srv->recv(a, ((char*)buf) + i, (plen - i > max_sio_chunk) ? max_sio_chunk : (plen - i)))) { if (rn > 0) i += rn; if (i >= plen || rn < 1) break; } #ifdef RSERV_DEBUG if (io_log) { FILE *f = fopen(io_log_fn, "a"); if (f) { fprintf(f, " BODY "); if (i) fprintDump(f, buf, i); else fprintf(f, "\n"); fclose(f); } } #endif if (i < plen) break; memset(buf + plen, 0, 8); unaligned = 0; #ifdef RSERV_DEBUG printf("parsing parameters (buf=%p, len=%ld)\n", buf, (long) plen); if (plen > 0) printDump(buf,plen); #endif c = buf + ph.dof; while((c < buf + ph.dof + plen) && (phead = ptoi(*((unsigned int*)c)))) { rlen_t headSize = 4; parType = PAR_TYPE(phead); parLen = PAR_LEN(phead); if ((parType & DT_LARGE) > 0) { /* large parameter */ headSize += 4; parLen |= ((rlen_t)((unsigned int)ptoi(*(unsigned int*)(c + 4)))) << 24; parType ^= DT_LARGE; } #ifdef RSERV_DEBUG printf("PAR[%d]: %08lx (PAR_LEN=%ld, PAR_TYPE=%d, large=%s, c=%p, ptr=%p)\n", pars, i, (long)parLen, parType, (headSize==8)?"yes":"no", c, c + headSize); #endif #ifdef ALIGN_DOUBLES if (unaligned) { /* on Sun machines it is deadly to process unaligned parameters, therefore we respond with ERR_inv_par */ #ifdef RSERV_DEBUG printf("Platform specific: last parameter resulted in unaligned stream for the current one, sending ERR_inv_par.\n"); #endif sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); process = 1; ph.cmd = 0; break; } #endif if (parLen & 3) unaligned=1; parT[pars] = parType; parL[pars] = parLen; parP[pars] = c + headSize; pars++; c += parLen + headSize; /* par length plus par head */ if (pars > 15) break; } /* we don't parse more than 16 parameters */ } else { RSEprintf("WARNING: discarding buffer because too big (awaiting %ld bytes)\n", (long)plen); size_t i = plen, chk = (inBuf < max_sio_chunk) ? inBuf : max_sio_chunk; while((rn = srv->recv(a, (char*)buf, (i < chk) ? i : chk))) { if (rn > 0) i -= rn; if (i < 1 || rn < 1) break; } if (i > 0) break; /* if the pars are bigger than my buffer, send data_overflow response (since 1.23/0.1-6; was inv_par before) */ sendResp(a, SET_STAT(RESP_ERR, ERR_data_overflow)); process = 1; ph.cmd = 0; } } /** IMPORTANT! The pointers in par[..] point to RAW data, i.e. you have to use ptoi(..) in order to get the real integer value. */ /** NOTE: Rserve doesn't check for alignment of parameters. This is ok for most platforms, but on Sun hardware this means that an user can send a package that will cause segfault in the client thread by sending unaligned parameters. This won't affect the server, only the connection child process dies. Since 0.1-10 we report ERR_inv_par on Sun for non-aligned parameters. */ #ifdef RSERV_DEBUG printf("CMD=%08x, pars=%d\n", ph.cmd, pars); #endif if (ph.cmd == CMD_OCcall) { int valid = 0; SEXP val = R_NilValue; if (pars >= 1 && (parT[0] == DT_SEXP || parT[0] == (DT_SEXP | DT_LARGE))) { int boffs = 0; unsigned int *sptr; if (parT[0] & DT_LARGE) boffs++; sptr = ((unsigned int*)parP[0]) + boffs; val = QAP_decode(&sptr); if (val && TYPEOF(val) == LANGSXP) { SEXP ocref = CAR(val); if (TYPEOF(ocref) == STRSXP && LENGTH(ocref) == 1) { SEXP ocv = oc_resolve(CHAR(STRING_ELT(ocref, 0))); if (ocv && ocv != R_NilValue) { /* valid reference -- replace it in the call */ SETCAR(val, ocv); valid = 1; } } } } /* invalid calls lead to immediate termination with no message */ if (!valid) { free(sendbuf); free(sfbuf); closesocket(s); return; } PROTECT(val); #ifdef RSERV_DEBUG printf(" running eval on SEXP (after OC replacement): "); printSEXP(val); #endif eval_result = R_tryEval(val, R_GlobalEnv, &Rerror); UNPROTECT(1); process = 1; } if (ph.cmd == CMD_switch) { if (pars < 1 || parT[0] != DT_STRING) sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); else { c = (char*) parP[0]; if (!strcmp(c, "TLS")) { if (switch_qap_tls && shared_tls(0)) { sendResp(a, RESP_OK); add_tls(a, shared_tls(0), 1); } else sendResp(a, SET_STAT(RESP_ERR, ERR_disabled)); } else sendResp(a, SET_STAT(RESP_ERR, ERR_unsupportedCmd)); } continue; } if (ph.cmd == CMD_keyReq) { if (pars < 1 || parT[0] != DT_STRING) sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); else { c = (char*) parP[0]; #ifdef HAVE_RSA /* rsa-authkey - generates authkey and sends server's public RSA key */ if (strstr(c, "rsa-authkey")) { if (++authkey_req < 2) { char *pload = 0; int pl = rsa_gen_resp(&pload); if (pl < 1) sendResp(a, SET_STAT(RESP_ERR, ERR_cryptError)); else sendRespData(a, RESP_OK, pl, pload); if (pload) free(pload); } else { sendResp(a, SET_STAT(RESP_ERR, ERR_securityClose)); closesocket(s); free(sendbuf); free(sfbuf); free(buf); return; } } else #endif sendResp(a, SET_STAT(RESP_ERR, ERR_unavailable)); } continue; } if (ph.cmd == CMD_secLogin) { #ifdef HAVE_RSA if (pars < 1 || parT[0] != DT_BYTESTREAM || parL[0] >= sizeof(rsa_buf)) sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); else { int dl = 0; if (!rsa_srv_key || (dl = rsa_decode(rsa_buf, (char*) parP[0], parL[0])) < 1) { #ifdef RSERV_DEBUG printf("CMD_secLogin: decode failed - rsa_srv_key=%p, dl = %d (payload %d)\n", (void*)rsa_srv_key, dl, (int) parL[0]); #endif sendResp(a, SET_STAT(RESP_ERR, ERR_auth_failed)); } else { unsigned char *rb = (unsigned char*) rsa_buf; if (rb[0] != (SRV_KEY_LEN & 0xff) || rb[1] != ((SRV_KEY_LEN >> 8) & 0xff) || rb[2] || rb[3] || memcmp(rb + 4, authkey, SRV_KEY_LEN)) { #ifdef RSERV_DEBUG printf("CMD_secLogin: authkey mismatch\n"); #endif sendResp(a, SET_STAT(RESP_ERR, ERR_auth_failed)); } else { unsigned int asl = rb[SRV_KEY_LEN + 5]; asl <<= 8; asl |= rb[SRV_KEY_LEN + 4]; #ifdef RSERV_DEBUG printf("CMD_secLogin: authkey matches, asl payload: %d\n", asl); #endif if (asl + SRV_KEY_LEN + 8 > dl) sendResp(a, SET_STAT(RESP_ERR, ERR_auth_failed)); else { char *ac, *au = 0, *ap = 0; int i; au = ac = ((char*) rb) + SRV_KEY_LEN + 8; for (i = 0; i < asl; i++) if (ac[i] == '\n') { ac[i] = 0; if (!ap) ap = ac + i + 1; } if (ac[asl - 1]) ac[asl] = 0; authed = auth_user(au, ap ? ap : "", sec_salt); if (authed) { process = 1; sendResp(a, RESP_OK); } } } } } #else sendResp(a, SET_STAT(RESP_ERR, ERR_unavailable)); continue; #endif } if (!authed && ph.cmd==CMD_login) { if (pars < 1 || parT[0] != DT_STRING) sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); else { #ifdef HAS_CRYPT const char *my_salt = salt + 1; #else const char *my_salt = 0; #endif c = (char*)parP[0]; cc = c; while(*cc && *cc != '\n') cc++; if (*cc) { *cc = 0; cc++; }; c1 = cc; while(*c1) if(*c1 == '\n' || *c1 == '\r') *c1=0; else c1++; /* c=login, cc=pwd */ authed = auth_user(c, cc, my_salt); if (authed) { process = 1; sendResp(a, RESP_OK); } } } /* if not authed by now, close connection */ if (authReq && !authed) { sendResp(a, SET_STAT(RESP_ERR, ERR_auth_failed)); closesocket(s); free(sendbuf); free(sfbuf); free(buf); return; } if (ph.cmd==CMD_shutdown) { /* FIXME: now that we have control commands we may rethink this ... */ sendResp(a, RESP_OK); #ifdef RSERV_DEBUG printf("initiating clean shutdown.\n"); #endif active = 0; closesocket(s); free(sendbuf); free(sfbuf); free(buf); #ifdef FORKED if (parentPID > 0) kill(parentPID, SIGTERM); exit(0); #endif return; } if (ph.cmd == CMD_ctrlEval || ph.cmd == CMD_ctrlSource || ph.cmd == CMD_ctrlShutdown) { process = 1; #ifdef RSERV_DEBUG printf("control command: %s [can control: %s, pipe: %d]\n", (ph.cmd == CMD_ctrlEval) ? "eval" : ((ph.cmd == CMD_ctrlSource) ? "source" : "shutdown"), can_control ? "yes" : "no", parent_pipe); #endif if (!can_control) /* no right to do this */ sendResp(a, SET_STAT(RESP_ERR, ERR_accessDenied)); else { /* source and eval require a parameter */ if ((ph.cmd == CMD_ctrlEval || ph.cmd == CMD_ctrlSource) && (pars < 1 || parT[0] != DT_STRING)) sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); else { if (parent_pipe == -1) sendResp(a, SET_STAT(RESP_ERR, ERR_ctrl_closed)); else { long cmd[2] = { 0, 0 }; if (ph.cmd == CMD_ctrlEval) { cmd[0] = CCTL_EVAL; cmd[1] = strlen(parP[0]) + 1; } else if (ph.cmd == CMD_ctrlSource) { cmd[0] = CCTL_SOURCE; cmd[1] = strlen(parP[0]) + 1; } else cmd[0] = CCTL_SHUTDOWN; if (write(parent_pipe, cmd, sizeof(cmd)) != sizeof(cmd)) { #ifdef RSERV_DEBUG printf(" - send to parent pipe (cmd=%ld, len=%ld) failed, closing parent pipe\n", cmd[0], cmd[1]); #endif close(parent_pipe); parent_pipe = -1; sendResp(a, SET_STAT(RESP_ERR, ERR_ctrl_closed)); } else { if (cmd[1] && write(parent_pipe, parP[0], cmd[1]) != cmd[1]) { #ifdef RSERV_DEBUG printf(" - send to parent pipe (cmd=%ld, len=%ld, sending data) failed, closing parent pipe\n", cmd[0], cmd[1]); #endif close(parent_pipe); parent_pipe = 01; sendResp(a, SET_STAT(RESP_ERR, ERR_ctrl_closed)); } else sendResp(a, RESP_OK); } } } } } if (ph.cmd == CMD_setEncoding) { /* set string encoding */ process = 1; if (pars<1 || parT[0] != DT_STRING) sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); else { char *c = (char*) parP[0]; #ifdef RSERV_DEBUG printf(">>CMD_setEncoding '%s'.\n", c ? c : ""); #endif #ifdef USE_ENCODING if (c && set_string_encoding(c, 0)) sendResp(a, RESP_OK); else sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); #else sendResp(a, SET_STAT(RESP_ERR, ERR_unsupportedCmd)); #endif } } if (ph.cmd == CMD_setBufferSize) { process = 1; /* FIXME: configuration allows 64-bit numbers but CMD_setBufferSize does not */ if (pars < 1 || parT[0] != DT_INT) sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); else { rlen_t ns = ptoi(((unsigned int*)(parP[0]))[0]); #ifdef RSERV_DEBUG printf(">>CMD_setSendBuf to %ld bytes.\n", (long)ns); #endif if (ns > 0) { /* 0 means don't touch the buffer size */ if (ns < 32768) ns = 32768; /* we enforce a minimum of 32kB */ free(sendbuf); sendbuf = (char*)malloc(sendBufSize); if (!sendbuf) { #ifdef RSERV_DEBUG fprintf(stderr,"FATAL: out of memory while resizing send buffer to %ld,\n", sendBufSize); #endif sendResp(a, SET_STAT(RESP_ERR, ERR_out_of_mem)); free(buf); free(sfbuf); closesocket(s); return; } sendBufSize = ns; } sendResp(a, RESP_OK); } } if (ph.cmd==CMD_openFile||ph.cmd==CMD_createFile) { process=1; if (!allowIO) sendResp(a, SET_STAT(RESP_ERR,ERR_accessDenied)); else { if (pars<1 || parT[0]!=DT_STRING) sendResp(a, SET_STAT(RESP_ERR,ERR_inv_par)); else { c=(char*)(parP[0]); if (cf) fclose(cf); #ifdef RSERV_DEBUG printf(">>CMD_open/createFile(%s)\n",c); #endif cf=fopen(c,(ph.cmd==CMD_openFile)?"rb":"wb"); if (!cf) sendResp(a, SET_STAT(RESP_ERR, ERR_IOerror)); else sendResp(a, RESP_OK); } } } if (ph.cmd==CMD_removeFile) { process=1; if (!allowIO) sendResp(a, SET_STAT(RESP_ERR, ERR_accessDenied)); else { if (pars<1 || parT[0]!=DT_STRING) sendResp(a, SET_STAT(RESP_ERR,ERR_inv_par)); else { c=(char*)parP[0]; #ifdef RSERV_DEBUG printf(">>CMD_removeFile(%s)\n",c); #endif if (remove(c)) sendResp(a, SET_STAT(RESP_ERR, ERR_IOerror)); else sendResp(a, RESP_OK); } } } if (ph.cmd == CMD_closeFile) { process = 1; if (!allowIO) sendResp(a, SET_STAT(RESP_ERR, ERR_accessDenied)); else { if (cf) fclose(cf); #ifdef RSERV_DEBUG printf(">>CMD_closeFile\n"); #endif cf = 0; sendResp(a, RESP_OK); } } if (ph.cmd==CMD_readFile) { process = 1; if (!allowIO) sendResp(a, SET_STAT(RESP_ERR, ERR_accessDenied)); else { if (!cf) sendResp(a, SET_STAT(RESP_ERR, ERR_notOpen)); else { rlen_t fbufl = sfbufSize; char *fbuf = sfbuf; if (pars == 1 && parT[0] == DT_INT) fbufl = ptoi(((unsigned int*)(parP[0]))[0]); #ifdef RSERV_DEBUG printf(">>CMD_readFile(%ld)\n", fbufl); #endif if (fbufl < 0) fbufl = sfbufSize; if (fbufl > sfbufSize) { #ifdef RSERV_DEBUG printf(" - requested size %ld is larger than default buffer %ld, allocating extra buffer\n", (long) fbufl, (long) sfbufSize); #endif fbuf = (char*)malloc(fbufl); } if (!fbuf) /* well, logically not clean (it's out of memory), but in practice likely true */ sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); else { size_t i = fread(fbuf, 1, fbufl, cf); if (i > 0) sendRespData(a, RESP_OK, i, fbuf); else sendResp(a, RESP_OK); if (fbuf != sfbuf) free(fbuf); } } } } if (ph.cmd==CMD_writeFile) { process=1; if (!allowIO) sendResp(a, SET_STAT(RESP_ERR, ERR_accessDenied)); else { if (!cf) sendResp(a, SET_STAT(RESP_ERR, ERR_notOpen)); else { if (pars < 1 || parT[0] != DT_BYTESTREAM) sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); else { size_t i = 0; #ifdef RSERV_DEBUG printf(">>CMD_writeFile(%ld,...)\n", (long) parL[0]); #endif c = (char*)parP[0]; if (parL[0] > 0) i = fwrite(c, 1, parL[0], cf); if (i > 0 && i != parL[0]) sendResp(a, SET_STAT(RESP_ERR, ERR_IOerror)); else sendResp(a, RESP_OK); } } } } /*--- CMD_setSEXP / CMD_assignSEXP ---*/ if (ph.cmd==CMD_setSEXP || ph.cmd==CMD_assignSEXP) { process=1; if (pars < 2 || parT[0] != DT_STRING) sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); else { SEXP val, sym=0; unsigned int *sptr; int parType = parT[1]; int boffs = 0; c=(char*)parP[0]; /* name of the symbol */ #ifdef RSERV_DEBUG printf(">>CMD_set/assignREXP (%s, REXP)\n",c); #endif if (ph.cmd==CMD_assignSEXP) { sym = parseExps(c, 1, &stat); if (stat != 1) { #ifdef RSERV_DEBUG printf(">>CMD_assignREXP-failed to parse \"%s\", stat=%d\n",c,stat); #endif sendResp(a, SET_STAT(RESP_ERR, stat)); goto respSt; } if (TYPEOF(sym)==EXPRSXP && LENGTH(sym)>0) { sym = VECTOR_ELT(sym,0); /* we should de-allocate the vector here .. if we can .. */ } } switch (parType) { case DT_STRING: #ifdef RSERV_DEBUG printf(" assigning string \"%s\"\n",((char*)(parP[1]))); #endif PROTECT(val = allocVector(STRSXP,1)); SET_STRING_ELT(val, 0, mkRChar((char*)(parP[1]))); defineVar(sym ? sym : install(c), val ,R_GlobalEnv); UNPROTECT(1); sendResp(a, RESP_OK); break; case DT_SEXP|DT_LARGE: boffs = 1; /* we're not using the size, so in fact we just advance the pointer and don't care about the length */ case DT_SEXP: sptr = ((unsigned int*)parP[1]) + boffs; val = QAP_decode(&sptr); if (val == 0) sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); else { PROTECT(val); #ifdef RSERV_DEBUG printf(" assigning SEXP: "); printSEXP(val); #endif defineVar(sym ? sym : install(c), val, R_GlobalEnv); UNPROTECT(1); sendResp(a, RESP_OK); } break; default: sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); } } } if (ph.cmd==CMD_detachSession) { process=1; if (!detach_session(a)) { s = resume_session(); sendResp(a, RESP_OK); } } if (ph.cmd==CMD_serEval || ph.cmd==CMD_serEEval || ph.cmd == CMD_serAssign) { int Rerr = 0; SEXP us = R_tryEval(LCONS(install("unserialize"),CONS(pp,R_NilValue)), R_GlobalEnv, &Rerr); PROTECT(us); process = 1; if (Rerr == 0) { if (ph.cmd == CMD_serAssign) { if (TYPEOF(us) != VECSXP || LENGTH(us) < 2) { sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); } else { R_tryEval(LCONS(install("<-"),CONS(VECTOR_ELT(us, 0), CONS(VECTOR_ELT(us, 1), R_NilValue))), R_GlobalEnv, &Rerr); if (Rerr == 0) sendResp(a, RESP_OK); else sendResp(a, SET_STAT(RESP_ERR, Rerr)); } } else { SEXP ev = R_tryEval(us, R_GlobalEnv, &Rerr); if (Rerr == 0 && ph.cmd == CMD_serEEval) /* one more round */ ev = R_tryEval(ev, R_GlobalEnv, &Rerr); PROTECT(ev); if (Rerr == 0) { SEXP sr = R_tryEval(LCONS(install("serialize"),CONS(ev, CONS(R_NilValue, R_NilValue))), R_GlobalEnv, &Rerr); if (Rerr == 0 && TYPEOF(sr) == RAWSXP) { sendRespData(a, RESP_OK, LENGTH(sr), RAW(sr)); } else if (Rerr == 0) Rerr = -2; } UNPROTECT(1); } UNPROTECT(1); if (Rerr) { sendResp(a, SET_STAT(RESP_ERR, Rerr)); } } } if (ph.cmd == CMD_voidEval || ph.cmd == CMD_eval || ph.cmd == CMD_detachedVoidEval) { int is_large = (parT[0] & DT_LARGE) ? 1 : 0; if (is_large) parT[0] ^= DT_LARGE; process = 1; if (pars < 1 || (parT[0] != DT_STRING && parT[0] != DT_SEXP)) sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); else if (parT[0] == DT_SEXP) { unsigned int *sptr = ((unsigned int*)parP[0]) + is_large; SEXP val = QAP_decode(&sptr); if (!val) { #ifdef RSERV_DEBUG printf(" FAILED to decode SEXP parameter\n"); #endif sendResp(a, SET_STAT(RESP_ERR, ERR_inv_par)); } else { PROTECT(val); #ifdef RSERV_DEBUG printf(" running eval on SEXP: "); printSEXP(val); #endif eval_result = R_tryEval(val, R_GlobalEnv, &Rerror); UNPROTECT(1); } } else { int j = 0; c = (char*)parP[0]; if (is_large) c += 4; #ifdef RSERV_DEBUG printf("parseString(\"%s\")\n",c); #endif xp = parseString(c, &j, &stat); PROTECT(xp); #ifdef RSERV_DEBUG printf("buffer parsed, stat=%d, parts=%d\n", stat, j); if (xp) printf("result type: %d, length: %d\n",TYPEOF(xp),LENGTH(xp)); else printf("result is \n"); #endif if (stat == 1 && ph.cmd == CMD_detachedVoidEval && detach_session(a)) sendResp(a, SET_STAT(RESP_ERR, ERR_detach_failed)); else if (stat != 1) sendResp(a, SET_STAT(RESP_ERR, stat)); else { #ifdef RSERV_DEBUG printf("R_tryEval(xp,R_GlobalEnv,&Rerror);\n"); #endif if (ph.cmd==CMD_detachedVoidEval) s = -1; if (TYPEOF(xp) == EXPRSXP && LENGTH(xp) > 0) { int bi = 0; while (bi < LENGTH(xp)) { SEXP pxp = VECTOR_ELT(xp, bi); Rerror = 0; #ifdef RSERV_DEBUG printf("Calling R_tryEval for expression %d [type=%d] ...\n",bi+1,TYPEOF(pxp)); #endif eval_result = R_tryEval(pxp, R_GlobalEnv, &Rerror); bi++; #ifdef RSERV_DEBUG printf("Expression %d, error code: %d\n", bi, Rerror); if (Rerror) printf(">> early error, aborting further evaluations\n"); #endif if (Rerror) break; } } else { Rerror = 0; eval_result = R_tryEval(xp, R_GlobalEnv, &Rerror); } } UNPROTECT(1); /* xp */ } } /* any command above can set eval_result -- in that case we encode the result and send it as the reply */ if (eval_result || Rerror) { if (eval_result) exp = PROTECT(eval_result); #ifdef RSERV_DEBUG printf("expression(s) evaluated (Rerror=%d).\n",Rerror); if (!Rerror) printSEXP(exp); #endif if (ph.cmd == CMD_detachedVoidEval && s == -1) s = resume_session(); if (Rerror) { sendResp(a, SET_STAT(RESP_ERR, (Rerror < 0) ? Rerror : -Rerror)); } else { if (ph.cmd == CMD_voidEval || ph.cmd == CMD_detachedVoidEval) sendResp(a, RESP_OK); else { char *sendhead = 0; int canProceed = 1; /* check buffer size vs REXP size to avoid dangerous overflows todo: resize the buffer as necessary */ rlen_t rs = QAP_getStorageSize(exp); /* increase the buffer by 25% for safety */ /* FIXME: there are issues with multi-byte strings that expand when converted. They should be convered by this margin but it is an ugly hack!! */ rs += (rs >> 2); #ifdef RSERV_DEBUG printf("result storage size = %ld bytes\n",(long)rs); #endif if (rs > sendBufSize - 64L) { /* is the send buffer too small ? */ canProceed = 0; if (maxSendBufSize && rs + 64L > maxSendBufSize) { /* first check if we're allowed to resize */ unsigned int osz = (rs > 0xffffffff) ? 0xffffffff : rs; osz = itop(osz); #ifdef RSERV_DEBUG printf("ERROR: object too big (sendBuf=%ld)\n", sendBufSize); #endif sendRespData(a, SET_STAT(RESP_ERR, ERR_object_too_big), 4, &osz); } else { /* try to allocate a large, temporary send buffer */ tempSB = rs + 64L; tempSB &= rlen_max << 12; tempSB += 0x1000; #ifdef RSERV_DEBUG printf("Trying to allocate temporary send buffer of %ld bytes.\n", (long)tempSB); #endif free(sendbuf); sendbuf = (char*)malloc(tempSB); if (!sendbuf) { tempSB = 0; #ifdef RSERV_DEBUG printf("Failed to allocate temporary send buffer of %ld bytes. Restoring old send buffer of %ld bytes.\n", (long)tempSB, (long)sendBufSize); #endif sendbuf = (char*)malloc(sendBufSize); if (!sendbuf) { /* we couldn't re-allocate the buffer */ #ifdef RSERV_DEBUG fprintf(stderr,"FATAL: out of memory while re-allocating send buffer to %ld (fallback#1)\n", sendBufSize); #endif sendResp(a, SET_STAT(RESP_ERR, ERR_out_of_mem)); free(buf); free(sfbuf); closesocket(s); return; } else { unsigned int osz = (rs > 0xffffffff) ? 0xffffffff : rs; osz = itop(osz); #ifdef RSERV_DEBUG printf("ERROR: object too big (sendBuf=%ld) and couldn't allocate big enough send buffer\n", sendBufSize); #endif sendRespData(a, SET_STAT(RESP_ERR, ERR_object_too_big), 4, &osz); } } else canProceed = 1; } } if (canProceed) { /* first we have 4 bytes of a header saying this is an encoded SEXP, then comes the SEXP */ char *sxh = sendbuf + 8; tail = (char*)QAP_storeSEXP((unsigned int*)sxh, exp, rs); /* set type to DT_SEXP and correct length */ if ((tail - sxh) > 0xfffff0) { /* we must use the "long" format */ rlen_t ll = tail - sxh; ((unsigned int*)sendbuf)[0] = itop(SET_PAR(DT_SEXP | DT_LARGE, ll & 0xffffff)); ((unsigned int*)sendbuf)[1] = itop(ll >> 24); sendhead = sendbuf; } else { sendhead = sendbuf + 4; ((unsigned int*)sendbuf)[1] = itop(SET_PAR(DT_SEXP,tail - sxh)); } #ifdef RSERV_DEBUG printf("stored SEXP; length=%ld (incl. DT_SEXP header)\n",(long) (tail - sendhead)); #endif sendRespData(a, RESP_OK, tail - sendhead, sendhead); if (tempSB) { /* if this is just a temporary sendbuffer then shrink it back to normal */ #ifdef RSERV_DEBUG printf("Releasing temporary sendbuf and restoring old size of %ld bytes.\n", sendBufSize); #endif free(sendbuf); sendbuf = (char*)malloc(sendBufSize); if (!sendbuf) { /* this should be really rare since tempSB was much larger */ #ifdef RSERV_DEBUG fprintf(stderr,"FATAL: out of memory while re-allocating send buffer to %ld (fallback#2),\n", sendBufSize); #endif sendResp(a, SET_STAT(RESP_ERR, ERR_out_of_mem)); free(buf); free(sfbuf); closesocket(s); return; } } } } if (eval_result) UNPROTECT(1); /* exp / eval_result */ } #ifdef RSERV_DEBUG printf("reply sent.\n"); #endif } /* END if (eval_result) */ respSt: if (s == -1) { rn = 0; break; } if (!process) sendResp(a, SET_STAT(RESP_ERR, ERR_inv_cmd)); } #ifdef RSERV_DEBUG if (rn == 0) printf("Connection closed by peer.\n"); else { printf("malformed packet (n=%d). closing socket to prevent garbage.\n", rn); if (rn > 0) printDump(&ph, rn); } #endif if (rn > 0) sendResp(a, SET_STAT(RESP_ERR, ERR_conn_broken)); closesocket(s); free(sendbuf); free(sfbuf); free(buf); { /* run .Rserve.done() if present */ SEXP fun, fsym = install(".Rserve.done"); fun = findVarInFrame(R_GlobalEnv, fsym); if (Rf_isFunction(fun)) { #ifdef unix chdir(wdname); /* guarantee that we are running in the workign directory */ #endif R_tryEval(lang1(fsym), R_GlobalEnv, &Rerror); } } #ifdef unix if (workdir) { chdir(workdir); rmdir(wdname); } #endif #ifdef RSERV_DEBUG printf("done.\n"); #endif #ifdef FORKED /* we should not return to the main loop, but terminate instead */ exit(0); #endif } typedef void (*sig_fn_t)(int); #ifdef unix /* NULL ptr is used on some systems as SIG_DFL so we have to define our own value for "not set" */ static void sig_not_set(int x) {} sig_fn_t old_HUP = sig_not_set, old_TERM = sig_not_set, old_INT = sig_not_set; static void setup_signal_handlers() { #ifdef FORKED if (old_HUP == sig_not_set) old_HUP = signal(SIGHUP, sigHandler); if (old_TERM == sig_not_set) old_TERM = signal(SIGTERM, sigHandler); if (old_INT == sig_not_set) old_INT = signal(SIGINT, brkHandler); #endif } static void restore_signal_handlers() { if (old_HUP != sig_not_set) { signal(SIGHUP, old_HUP); old_HUP = sig_not_set; } if (old_TERM != sig_not_set) { signal(SIGTERM, old_TERM); old_TERM = sig_not_set; } if (old_INT != sig_not_set) { signal(SIGINT, old_INT); old_INT = sig_not_set; } } #else static void setup_signal_handlers() { } static void restore_signal_handlers() { } #endif #define MAX_SERVERS 128 static int servers; static server_t *server[MAX_SERVERS]; int add_server(server_t *srv) { if (!srv) return 0; if (servers >= MAX_SERVERS) { RSEprintf("ERROR: too many servers\n"); return 0; } server[servers++] = srv; #ifdef RSERV_DEBUG printf("INFO: adding server %p (total %d servers)\n", (void*) srv, servers); #endif return 1; } int rm_server(server_t *srv) { int i = 0; if (!srv) return 0; while (i < servers) { if (server[i] == srv) { int j = i + 1; while (j < servers) { server[j - 1] = server[j]; j++; } servers--; } else i++; } if (srv->fin) srv->fin(srv); #ifdef RSERV_DEBUG printf("INFO: removing server %p (total %d servers left)\n", (void*) srv, servers); #endif return 1; } int server_recv(args_t *arg, void *buf, rlen_t len) { return recv(arg->s, buf, len, 0); } int server_send(args_t *arg, const void *buf, rlen_t len) { return send(arg->s, buf, len, 0); } server_t *create_Rserve_QAP1(int flags) { server_t *srv; if (use_ipv6) flags |= SRV_IPV6; if (localonly) flags |= SRV_LOCAL; srv = create_server((flags & SRV_TLS) ? tls_port : port, localSocketName, localSocketMode, flags); if (srv) { srv->connected = Rserve_QAP1_connected; srv->send_resp = Rserve_QAP1_send_resp; srv->fin = server_fin; srv->recv = server_recv; srv->send = server_send; add_server(srv); return srv; } return 0; } void serverLoop() { struct timeval timv; int selRet = 0; fd_set readfds; if (main_argv && tag_argv == 1 && strlen(main_argv[0]) >= 8) { strcpy(main_argv[0] + strlen(main_argv[0]) - 8, "/RsrvSRV"); tag_argv = 2; } while(active && (servers || children)) { /* main serving loop */ int i; int maxfd = 0; #ifdef FORKED while (waitpid(-1, 0, WNOHANG) > 0); #endif /* 500ms (used to be 10ms) - it shouldn't really matter since it's ok for us to sleep -- the timeout will only influence how often we collect terminated children and (maybe) how quickly we react to shutdown */ timv.tv_sec = 0; timv.tv_usec = 500000; FD_ZERO(&readfds); for (i = 0; i < servers; i++) if (server[i]) { int ss = server[i]->ss; if (ss > maxfd) maxfd = ss; FD_SET(ss, &readfds); } if (children) { child_process_t *cp = children; while (cp) { FD_SET(cp->inp, &readfds); if (cp->inp > maxfd) maxfd = cp->inp; cp = cp->next; } } selRet = select(maxfd + 1, &readfds, 0, 0, &timv); if (selRet > 0) { for (i = 0; i < servers; i++) { socklen_t al; struct args *sa; server_t *srv = server[i]; int ss = srv->ss; int succ = 0; if (server[i] && FD_ISSET(ss, &readfds)) { sa = (struct args*)malloc(sizeof(struct args)); memset(sa, 0, sizeof(struct args)); al = sizeof(sa->sa); #ifdef unix if (server[i]->unix_socket) { al = sizeof(sa->su); sa->s = CF("accept", accept(ss, (SA*)&(sa->su), &al)); } else #endif sa->s = CF("accept", accept(ss, (SA*)&(sa->sa), &al)); accepted_server(srv, sa->s); sa->ucix = UCIX++; sa->ss = ss; sa->srv = srv; /* memset(sa->sk,0,16); sa->sfd=-1; #if defined SESSIONS && defined FORKED { int pd[2]; if (!pipe(&pd)) { } } #endif */ if (allowed_ips && !srv->unix_socket && !use_ipv6) { /* FIXME: IPv6 unsafe - filtering won't work on IPv6 addresses */ char **laddr = allowed_ips; int allowed = 0; while (*laddr) if (sa->sa.sin_addr.s_addr == inet_addr(*(laddr++))) { allowed=1; break; } if (allowed) { #ifdef RSERV_DEBUG printf("INFO: accepted connection for server %p, calling connected\n", (void*) srv); #endif srv->connected(sa); succ = 1; #ifdef FORKED /* when the child returns it means it's done (likely an error) but it is forked, so the only right thing to do is to exit */ if (is_child) exit(2); #endif } else { #ifdef RSERV_DEBUG printf("INFO: peer is not on allowed IP list, closing connection\n"); #endif closesocket(sa->s); } } else { /* ---> remote enabled */ #ifdef RSERV_DEBUG printf("INFO: accepted connection for server %p, calling connected\n", (void*) srv); #endif srv->connected(sa); succ = 1; if (is_child) /* same as above */ exit(2); } #ifdef Win32 } } } #else } if (succ) { /* if there was an actual connection, offer to run .Rserve.served */ SEXP fun, fsym = install(".Rserve.served"); int evalErr = 0; fun = findVarInFrame(R_GlobalEnv, fsym); if (Rf_isFunction(fun)) R_tryEval(lang1(fsym), R_GlobalEnv, &evalErr); } } /* end loop over servers */ if (children) { /* one of the children signalled */ child_process_t *cp = children; while (cp) { if (FD_ISSET(cp->inp, &readfds)) { long cmd[2]; int n = read(cp->inp, cmd, sizeof(cmd)); if (n < sizeof(cmd)) { /* is anything less arrives, assume corruption and remove the child */ child_process_t *ncp = cp->next; #ifdef RSERV_DEBUG printf("pipe to child %d closed (n=%d), removing child\n", (int) cp->pid, n); #endif close(cp->inp); /* remove the child from the list */ if (cp->prev) cp->prev->next = ncp; else children = ncp; if (ncp) ncp->prev = cp->prev; free(cp); cp = ncp; } else { /* we got a valid command */ /* FIXME: we should perform more rigorous checks on the protocol - we are currently ignoring anything bad */ char cib[256]; char *xb = 0; #ifdef RSERV_DEBUG printf(" command from child %d: %ld data bytes: %ld\n", (int) cp->pid, cmd[0], cmd[1]); #endif cib[0] = 0; cib[255] = 0; n = 0; if (cmd[1] > 0 && cmd[1] < 256) n = read(cp->inp, cib, cmd[1]); else if (cmd[1] > 0 && cmd[1] < MAX_CTRL_DATA) { xb = (char*) malloc(cmd[1] + 4); xb[0] = 0; if (xb) n = read(cp->inp, xb, cmd[1]); if (n > 0) xb[n] = 0; } #ifdef RSERV_DEBUG printf(" - read %d bytes of %ld data from child %d\n", n, cmd[1], (int) cp->pid); #endif if (n == cmd[1]) { /* perform commands only if we got all the data */ if (cmd[0] == CCTL_EVAL) { #ifdef RSERV_DEBUG printf(" - control calling voidEval(\"%s\")\n", xb ? xb : cib); #endif voidEval(xb ? xb : cib); } else if (cmd[0] == CCTL_SOURCE) { int evalRes = 0; SEXP exp; SEXP sfn = PROTECT(allocVector(STRSXP, 1)); SET_STRING_ELT(sfn, 0, mkRChar(xb ? xb : cib)); exp = LCONS(install("source"), CONS(sfn, R_NilValue)); #ifdef RSERV_DEBUG printf(" - control calling source(\"%s\")\n", xb ? xb : cib); #endif R_tryEval(exp, R_GlobalEnv, &evalRes); #ifdef RSERV_DEBUG printf(" - result: %d\n", evalRes); #endif UNPROTECT(1); } else if (cmd[0] == CCTL_SHUTDOWN) { #ifdef RSERV_DEBUG printf(" - shutdown via control, setting active to 0\n"); #endif active = 0; } } cp = cp->next; } } else cp = cp->next; } /* loop over children */ } /* end if (children) */ } /* end if (selRet > 0) */ #endif } /* end while(active) */ } #ifndef STANDALONE_RSERVE /* run Rserve inside R */ SEXP run_Rserve(SEXP cfgFile, SEXP cfgPars) { server_stack_t *ss; if (TYPEOF(cfgFile) == STRSXP && LENGTH(cfgFile) > 0) { int i, n = LENGTH(cfgFile); for (i = 0; i < n; i++) loadConfig(CHAR(STRING_ELT(cfgFile, i))); } if (TYPEOF(cfgPars) == STRSXP && LENGTH(cfgPars) > 0) { int i, n = LENGTH(cfgPars); SEXP sNam = Rf_getAttrib(cfgPars, R_NamesSymbol); if (TYPEOF(sNam) != STRSXP || LENGTH(sNam) != n) Rf_error("invalid configuration parameters"); for (i = 0; i < n; i++) { const char *key = CHAR(STRING_ELT(sNam, i)); const char *value = CHAR(STRING_ELT(cfgPars, i)); int res = setConfig(key, value); if (res == 0) Rf_warning("Unknown configuration setting `%s`, ignored.", key); } } RSsrv_init(); /* FIXME: should we really do this ? setuid, chroot etc. are not meant to work inside R ... */ performConfig(SU_NOW); ss = create_server_stack(); if (enable_qap) { server_t *srv = create_Rserve_QAP1((qap_oc ? SRV_QAP_OC : 0) | global_srv_flags); if (!srv) { release_server_stack(ss); RSsrv_done(); Rf_error("Unable to start Rserve server"); } push_server(ss, srv); } if (tls_port > 0) { server_t *srv = create_Rserve_QAP1(SRV_TLS | (qap_oc ? SRV_QAP_OC : 0) | global_srv_flags); if (!srv) { release_server_stack(ss); RSsrv_done(); Rf_error("Unable to start TLS/Rserve server"); } push_server(ss, srv); } if (http_port > 0) { int flags = (enable_ws_qap ? WS_PROT_QAP : 0) | (enable_ws_text ? WS_PROT_TEXT : 0) | (ws_qap_oc ? SRV_QAP_OC : 0) | global_srv_flags; server_t *srv = create_HTTP_server(http_port, flags | (ws_upgrade ? HTTP_WS_UPGRADE : 0) | (http_raw_body ? HTTP_RAW_BODY : 0)); if (!srv) { release_server_stack(ss); RSsrv_done(); Rf_error("Unable to start HTTP server on port %d", http_port); } push_server(ss, srv); } if (https_port > 0) { int flags = (enable_ws_qap ? WS_PROT_QAP : 0) | (enable_ws_text ? WS_PROT_TEXT : 0) | (ws_qap_oc ? SRV_QAP_OC : 0) | global_srv_flags; server_t *srv = create_HTTP_server(https_port, SRV_TLS | flags | (ws_upgrade ? HTTP_WS_UPGRADE : 0) | (http_raw_body ? HTTP_RAW_BODY : 0)); if (!srv) { release_server_stack(ss); RSsrv_done(); Rf_error("Unable to start HTTPS server on port %d", https_port); } push_server(ss, srv); } if (enable_ws_text || enable_ws_qap) { server_t *srv; if (ws_port < 1 && wss_port < 1 && !ws_upgrade) { release_server_stack(ss); RSsrv_done(); Rf_error("Invalid or missing websockets port"); } if (ws_port > 0) { srv = create_WS_server(ws_port, (enable_ws_qap ? WS_PROT_QAP : 0) | (enable_ws_text ? WS_PROT_TEXT : 0) | (ws_qap_oc ? SRV_QAP_OC : 0) | global_srv_flags); if (!srv) { release_server_stack(ss); RSsrv_done(); Rf_error("Unable to start WebSockets server on port %d", ws_port); } push_server(ss, srv); } if (wss_port > 0) { srv = create_WS_server(wss_port, (enable_ws_qap ? WS_PROT_QAP : 0) | (enable_ws_text ? WS_PROT_TEXT : 0) | (ws_qap_oc ? SRV_QAP_OC : 0) | WS_TLS | global_srv_flags); if (!srv) { release_server_stack(ss); RSsrv_done(); Rf_error("Unable to start TLS/WebSockets server on port %d", wss_port); } push_server(ss, srv); } } if (!server_stack_size(ss)) { Rf_warning("No server protocol is enabled, nothing to do"); release_server_stack(ss); RSsrv_done(); return ScalarLogical(FALSE); } setup_signal_handlers(); Rprintf("-- running Rserve in this R session (pid=%d), %d server(s) --\n(This session will block until Rserve is shut down)\n", getpid(), server_stack_size(ss)); active = 1; serverLoop(); restore_signal_handlers(); release_server_stack(ss); RSsrv_done(); return ScalarLogical(TRUE); } #endif #endif /*--- The following makes the indenting behavior of emacs compatible with Xcode's 4/4 setting ---*/ /* Local Variables: */ /* indent-tabs-mode: t */ /* tab-width: 4 */ /* c-basic-offset: 4 */ /* End: */ Rserve/src/session.h0000644000176000001440000000101012205226215014160 0ustar ripleyusers#ifndef SESSION_H__ #define SESSION_H__ struct sSession { unsigned char key[16]; int s; }; struct sSession *new_session(char key[16]); struct sSession *find_session(char key[16]); void free_session(char key[16]); /* functions for walking thorugh sessions. warning: next_session becomes invalid if new_session or free_session is called between first_session and and any subsequent next_session */ struct sSession *first_session(); struct sSession *next_session(struct sSession* current); #endif Rserve/src/http.h0000644000176000001440000000037512205226215013471 0ustar ripleyusers#ifndef HTTP_H__ #define HTTP_H__ #include "RSserver.h" #define HTTP_WS_UPGRADE 0x10 #define HTTP_RAW_BODY 0x20 /* if set, no attempts are made to decode the request body of known types */ server_t *create_HTTP_server(int port, int flags); #endif Rserve/src/Makevars.win0000644000176000001440000000177412205226215014635 0ustar ripleyusersPKG_CPPFLAGS=-DRSERVE_PKG -DWin32 -I. -Iinclude -Iinclude/Win32 PKG_LIBS=-lws2_32 all: $(SHLIB) server # $(MAKE) client SERVER_SRC = standalone.c md5.c session.c qap_decode.c qap_encode.c sha1.c base64.c websockets.c RSserver.c tls.c http.c oc.c rsio.c SERVER_H = Rsrv.h qap_encode.h qap_decode.h RSserver.h http.h oc.h sha1.h md5.h rsio.h server: $(SERVER_SRC) $(SERVER_H) $(CC) -DSTANDALONE_RSERVE -DDAEMON -I. -Iinclude $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(PKG_CPPFLAGS) $(PKG_CFLAGS) -o Rserve.exe $(SERVER_SRC) $(ALL_LIBS) $(PKG_LIBS) $(CC) -DSTANDALONE_RSERVE -DRSERV_DEBUG -DNODAEMON -I. -Iinclude $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(PKG_CPPFLAGS) $(PKG_CFLAGS) -o Rserve_d.exe $(SERVER_SRC) $(ALL_LIBS) $(PKG_LIBS) client: config.h cp config.h client/cxx/ make -C client/cxx -@mkdir ../inst 2>/dev/null -rm -rf ../inst/client -cp -R client ../inst/ cp Rsrv.h config.h include/sisocks.h ../inst/client/cxx/ clean: rm -f *~ *.o *.lo *.so *.exe \#* $(XFILES) .PHONY: client clean server Rserve/src/qap_decode.c0000644000176000001440000001633512205226215014574 0ustar ripleyusers#include "qap_decode.h" #include #include #define decode_to_SEXP QAP_decode /* string encoding handling */ #if (R_VERSION < R_Version(2,8,0)) || (defined DISABLE_ENCODING) #define mkRChar(X) mkChar(X) #else #define USE_ENCODING 1 extern cetype_t string_encoding; #define mkRChar(X) mkCharCE((X), string_encoding) #endif /* this is the representation of NAs in strings. We chose 0xff since that should never occur in UTF-8 strings. If 0xff occurs in the beginning of a string anyway, it will be doubled to avoid misrepresentation. */ static const unsigned char NaStringRepresentation[2] = { 255, 0 }; /* decode_toSEXP is used to decode SEXPs from binary form and create corresponding objects in R. UPC is a pointer to a counter of UNPROTECT calls which will be necessary after we're done. The buffer position is advanced to the point where the SEXP ends (more precisely it points to the next stored SEXP). */ SEXP decode_to_SEXP(unsigned int **buf) { unsigned int *b = *buf, *pab = *buf; char *c, *cc; SEXP val = 0, vatt = 0; int ty = PAR_TYPE(ptoi(*b)); rlen_t ln = PAR_LEN(ptoi(*b)); R_len_t i, l; if (IS_LARGE(ty)) { ty ^= XT_LARGE; b++; ln |= ((rlen_t) (unsigned int) ptoi(*b)) << 24; } #ifdef RSERV_DEBUG printf("decode: type=%d, len=%ld\n", ty, (long)ln); #endif b++; pab = b; /* pre-attr b */ if (ty & XT_HAS_ATTR) { #ifdef RSERV_DEBUG printf(" - has attributes\n"); #endif *buf = b; vatt = PROTECT(decode_to_SEXP(buf)); b = *buf; ty = ty ^ XT_HAS_ATTR; #ifdef RSERV_DEBUG printf(" - returned from attributes(@%p)\n", (void*)*buf); #endif ln -= (((char*)b) - ((char*)pab)); /* adjust length */ } /* b = beginning of the SEXP data (after attrs) pab = beginning before attrs (=just behind the heaer) ln = length of th SEX payload (w/o attr) */ switch(ty) { case XT_NULL: val = R_NilValue; *buf = b; break; case XT_INT: case XT_ARRAY_INT: l = ln / 4; val = allocVector(INTSXP, l); #ifdef NATIVE_COPY memcpy(INTEGER(val), b, l * sizeof(int)); b += l; #else i = 0; while (i < l) { INTEGER(val)[i] = ptoi(*b); i++; b++; } #endif *buf = b; break; case XT_ARRAY_BOOL: { int vl = ptoi(*(b++)); char *cb = (char*) b; val = allocVector(LGLSXP, vl); i = 0; while (i < vl) { LOGICAL(val)[i] = (cb[i] == 1) ? TRUE : ((cb[i] == 0) ? FALSE : NA_LOGICAL); i++; } while ((i & 3) != 0) i++; b = (unsigned int*) (cb + i); } *buf = b; break; case XT_DOUBLE: case XT_ARRAY_DOUBLE: l = ln / 8; val = allocVector(REALSXP, l); #ifdef NATIVE_COPY memcpy(REAL(val), b, sizeof(double) * l); b += l * 2; #else i = 0; while (i < l) { fixdcpy(REAL(val) + i, b); b += 2; i++; } #endif *buf = b; break; case XT_ARRAY_CPLX: l = ln / 16; val = allocVector(CPLXSXP, l); #ifdef NATIVE_COPY memcpy(COMPLEX(val), b, sizeof(*COMPLEX(val)) * l); b += l * 4; #else i = 0; while (i < l) { fixdcpy(&(COMPLEX(val)[i].r),b); b+=2; fixdcpy(&(COMPLEX(val)[i].i),b); b+=2; i++; } #endif *buf = b; break; case XT_ARRAY_STR: { /* count the number of elements */ char *sen = (c = (char*)(b)) + ln; i = 0; while (c < sen) { if (!*c) i++; c++; } /* protect so we can alloc CHARSXPs */ val = PROTECT(allocVector(STRSXP, i)); i = 0; cc = c = (char*)b; while (c < sen) { SEXP sx; if (!*c) { if ((unsigned char)cc[0] == NaStringRepresentation[0]) { if ((unsigned char)cc[1] == NaStringRepresentation[1]) sx = R_NaString; else sx = mkRChar(cc + 1); } else sx = mkRChar(cc); SET_STRING_ELT(val, i, sx); i++; cc = c + 1; } c++; } UNPROTECT(1); } *buf = (unsigned int*)((char*)b + ln); break; case XT_RAW: i = ptoi(*b); val = allocVector(RAWSXP, i); memcpy(RAW(val), (b + 1), i); *buf = (unsigned int*)((char*)b + ln); break; case XT_VECTOR: case XT_VECTOR_EXP: { unsigned char *ie = (unsigned char*) b + ln; R_len_t n = 0; SEXP lh = R_NilValue; SEXP vr = allocVector(VECSXP, 1); *buf = b; PROTECT(vr); while ((unsigned char*)*buf < ie) { SEXP v = decode_to_SEXP(buf); lh = CONS(v, lh); SET_VECTOR_ELT(vr, 0, lh); /* this is our way of staying protected .. maybe not optimal .. */ n++; } #ifdef RSERV_DEBUG printf(" vector (%s), %d elements\n", (ty == XT_VECTOR) ? "generic" : ((ty == XT_VECTOR_EXP) ? "expression" : "string"), n); #endif val = PROTECT(allocVector((ty==XT_VECTOR) ? VECSXP : ((ty == XT_VECTOR_EXP) ? EXPRSXP : STRSXP), n)); while (n > 0) { n--; SET_VECTOR_ELT(val, n, CAR(lh)); lh = CDR(lh); } #ifdef RSERV_DEBUG printf(" end of vector %lx/%lx\n", (long) *buf, (long) ie); #endif UNPROTECT(2); /* val and vr */ break; } case XT_STR: case XT_SYMNAME: /* i=ptoi(*b); b++; */ #ifdef RSERV_DEBUG printf(" string/symbol(%d) '%s'\n", ty, (char*)b); #endif { char *c = (char*) b; if (ty == XT_STR) { val = mkRChar(c); } else val = install(c); } *buf = (unsigned int*)((char*)b + ln); break; case XT_S4: val = Rf_allocS4Object(); break; case XT_LIST_NOTAG: case XT_LIST_TAG: case XT_LANG_NOTAG: case XT_LANG_TAG: { SEXP vnext = R_NilValue, vtail = 0; unsigned char *ie = (unsigned char*) b + ln; val = R_NilValue; *buf = b; while ((unsigned char*)*buf < ie) { #ifdef RSERV_DEBUG printf(" el %08lx of %08lx\n", (unsigned long)*buf, (unsigned long) ie); #endif SEXP el = PROTECT(decode_to_SEXP(buf)); SEXP ea = R_NilValue; if (ty == XT_LANG_TAG || ty==XT_LIST_TAG) { #ifdef RSERV_DEBUG printf(" tag %08lx of %08lx\n", (unsigned long)*buf, (unsigned long) ie); #endif ea = decode_to_SEXP(buf); if (ea != R_NilValue) PROTECT(ea); } if (ty == XT_LANG_TAG || ty == XT_LANG_NOTAG) vnext = LCONS(el, R_NilValue); else vnext = CONS(el, R_NilValue); PROTECT(vnext); if (ea != R_NilValue) SET_TAG(vnext, ea); if (vtail) { SETCDR(vtail, vnext); UNPROTECT((ea == R_NilValue) ? 2 : 3); } else { UNPROTECT((ea == R_NilValue) ? 2 : 3); PROTECT(val); /* protect the root */ val = vnext; } vtail = vnext; } if (vtail) UNPROTECT(1); break; } default: REprintf("Rserve SEXP parsing: unsupported type %d\n", ty); val = R_NilValue; *buf = (unsigned int*)((char*)b + ln); } if (vatt) { /* if vatt contains "class" we have to set the object bit [we could use classgets(vec,kls) instead] */ SEXP head = vatt; int has_class = 0; PROTECT(val); SET_ATTRIB(val, vatt); while (head != R_NilValue) { if (TAG(head) == R_ClassSymbol) { has_class = 1; break; } head = CDR(head); } if (has_class) /* if it has a class slot, we have to set the object bit */ SET_OBJECT(val, 1); #ifdef SET_S4_OBJECT /* FIXME: we have currently no way of knowing whether an object derived from a non-S4 type is actually S4 object. Hence we can only flag "pure" S4 objects */ if (TYPEOF(val) == S4SXP) SET_S4_OBJECT(val); #endif UNPROTECT(2); /* vatt + val */ } /* NOTE: val is NOT protected - this guarantees that recursion doesn't fill up the stack */ return val; } Rserve/src/websockets.h0000644000176000001440000000210312205226215014652 0ustar ripleyusers#ifndef WEBSOCKETS_H__ #define WEBSOCKETS_H__ #include "RSserver.h" #define WS_PROT_QAP 0x01 #define WS_PROT_TEXT 0x02 /* NOTE: this is not the same as SRV_TLS! It is annoying, but WS needs to chain TLS futher down, if SRC_TLS is set then QAP will be tunneled through TLS but we need to wrap WS around it first */ #define WS_TLS 0x08 /* WARNING: HTTP uses 0x10 and 0x20 */ #define WS_PROT_ALL (WS_PROT_QAP | WS_PROT_TEXT) server_t *create_WS_server(int port, int protocols); /* upgrade HTTP connection to WS - assumes that the HTTP server has parsed the request already only WS 13+ handshake is supported by this function */ void WS13_upgrade(args_t *arg, const char *key, const char *protocol, const char *version); /* flags used in args_t.flags */ #define F_INFRAME 0x010 #define F_MASK 0x020 #define F_IN_BIN 0x040 #define F_OUT_BIN 0x080 #define SET_F_FT(X, FT) X = (((X) & 0xfff) | (((FT) & 15) << 12)) #define GET_F_FT(X) (((X) >> 12) & 15) #define GET_MASK_ID(X) ((X) & 3) #define SET_F_MASK(X, M) X = (((X) & 0xfffc) | F_MASK | ((M) & 3)) #endif Rserve/src/standalone.c0000644000176000001440000002307312205226215014635 0ustar ripleyusers#include #ifdef STANDALONE_RSERVE /* this is a bad hack for compatibility. Eventually we should have a defined layer */ #include "Rserv.c" extern int Rf_initEmbeddedR(int, char**); #include /* R API from oc.c */ SEXP Rserve_oc_register(SEXP what); static int ex(int res) { RSsrv_done(); return res; } /* main function - start Rserve */ int main(int argc, char **argv) { int stat, i, http_flags; char **top_argv; int top_argc; main_argv = argv; main_argc = argc; rserve_rev[0] = 0; { /* cut out the SVN revision from the Id string */ const char *c = strstr(rserve_ver_id, ".c "); if (c) { const char *d = c + 3; c = d; while (*c && *c != ' ') c++; strncpy(rserve_rev, d, c - d); } } #ifdef RSERV_DEBUG printf("Rserve %d.%d-%d (%s) (C)Copyright 2002-2013 Simon Urbanek\n%s\n\n",RSRV_VER>>16,(RSRV_VER>>8)&255,RSRV_VER&255, rserve_rev, rserve_ver_id); #endif if (!isByteSexOk()) { fprintf(stderr, "FATAL ERROR: This program was not correctly compiled - the endianess is wrong!\nUse -DSWAPEND when compiling on PPC or similar platforms.\n"); return -100; } loadConfig(CONFIG_FILE); /** copy argv while removing Rserve specific parameters */ top_argc = 1; top_argv = (char**) malloc(sizeof(char*) * (argc + 1)); top_argv[0] = argv[0]; i = 0; while (++i < argc) { int isRSP = 0; if (argv[i] && *argv[i] == '-' && argv[i][1] == '-') { if (!strcmp(argv[i] + 2, "RS-port")) { isRSP = 1; if (++i == argc) fprintf(stderr,"Missing port specification for --RS-port.\n"); else { port = satoi(argv[i]); if (port < 1) { fprintf(stderr,"Invalid port number in --RS-port, using default port.\n"); port = default_Rsrv_port; } } } if (!strcmp(argv[i] + 2, "RS-dumplimit")) { isRSP = 1; if (++i == argc) fprintf(stderr,"Missing limit specification for --RS-dumplimit.\n"); else { #ifdef RSERV_DEBUG dumpLimit = satoi(argv[i]); #endif } } if (!strcmp(argv[i] + 2, "RS-socket")) { isRSP = 1; if (++i == argc) fprintf(stderr,"Missing socket specification for --RS-socket.\n"); else localSocketName = argv[i]; } if (!strcmp(argv[i] + 2, "RS-encoding")) { isRSP = 1; if (++i == argc) fprintf(stderr,"Missing socket specification for --RS-encoding.\n"); else set_string_encoding(argv[i], 1); } if (!strcmp(argv[i] + 2, "RS-workdir")) { isRSP = 1; if (++i == argc) fprintf(stderr,"Missing directory specification for --RS-workdir.\n"); else workdir=argv[i]; } if (!strcmp(argv[i] + 2, "RS-conf")) { isRSP = 1; if (++i == argc) fprintf(stderr,"Missing config file specification for --RS-conf.\n"); else loadConfig(argv[i]); } if (!strcmp(argv[i] + 2, "RS-source")) { isRSP = 1; if (++i == argc) fprintf(stderr,"Missing R file specification for --RS-source.\n"); else setConfig("source", argv[i]); } if (!strcmp(argv[i] + 2, "RS-pidfile")) { isRSP = 1; if (++i == argc) fprintf(stderr,"Missing file specification for --RS-pidfile.\n"); else setConfig("pid.file", argv[i]); } if (!strcmp(argv[i] + 2, "RS-enable-control")) { isRSP = 1; setConfig("control", "enable"); } if (!strcmp(argv[i] + 2, "RS-enable-remote")) { isRSP = 1; setConfig("remote", "enable"); } if (!strcmp(argv[i] + 2, "RS-settings")) { printf("Rserve v%d.%d-%d\n\nconfig file: %s\nworking root: %s\nport: %d\nlocal socket: %s\nauthorization required: %s\nplain text password: %s\npasswords file: %s\nallow I/O: %s\nallow remote access: %s\ncontrol commands: %s\ninteractive: %s\nmax.input buffer size: %ld kB\n\n", RSRV_VER>>16, (RSRV_VER>>8)&255, RSRV_VER&255, CONFIG_FILE, workdir, port, localSocketName ? localSocketName : "[none, TCP/IP used]", authReq ? "yes" : "no", usePlain ? "allowed" : "not allowed", pwdfile ? pwdfile : "[none]", allowIO ? "yes" : "no", localonly ? "no" : "yes", child_control ? "yes" : "no", Rsrv_interactive ? "yes" : "no", maxInBuf / 1024L); return 0; } if (!strcmp(argv[i] + 2, "version")) { printf("Rserve v%d.%d-%d (%s)\n",RSRV_VER>>16,(RSRV_VER>>8)&255,RSRV_VER&255,rserve_rev); } if (!strcmp(argv[i] + 2, "help")) { printf("Usage: R CMD Rserve []\n\nOptions: --help this help screen\n --version prints Rserve version (also passed to R)\n --RS-port listen on the specified TCP port\n --RS-socket use specified local (unix) socket instead of TCP/IP.\n --RS-workdir use specified working directory root for connections.\n --RS-encoding set default server string encoding to .\n --RS-conf load additional config file.\n --RS-settings dumps current settings of the Rserve\n --RS-source source the specified file on startup.\n --RS-enable-control enable control commands\n --RS-enable-remote enable remote connections\n\nAll other options are passed to the R engine.\n\n"); #ifdef RSERV_DEBUG printf("debugging flag:\n --RS-dumplimit sets limit of items/bytes to dump in debugging output. set to 0 for unlimited\n\n"); #endif return 0; } } if (!isRSP) top_argv[top_argc++]=argv[i]; } performConfig(SU_NOW); stat = Rf_initEmbeddedR(top_argc,top_argv); if (stat < 0) { printf("Failed to initialize embedded R! (stat=%d)\n",stat); return 2; } #ifndef WIN32 /* windows uses this in init, unix doesn't so we set it here */ R_Interactive = Rsrv_interactive; /* we let R install sig handlers, but remove those that are bad */ signal(SIGSEGV, SIG_DFL); signal(SIGILL, SIG_DFL); #ifdef SIGBUS signal(SIGBUS, SIG_DFL); #endif /* FIXME: not sure about SIGPIPE - it's ok to use R's handling when caused by R code, but it's unclear if it can be caused by Rserve's internal code which would prefer death to surrender ... */ #endif if (src_list) { /* do any sourcing if necessary */ struct source_entry *se=src_list; #ifdef RSERV_DEBUG printf("Executing source/eval commands from the config file.\n"); #endif while (se) { #ifdef RSERV_DEBUG printf("voidEval(\"%s\")\n", se->line); #endif voidEval(se->line); se = se->next; } #ifdef RSERV_DEBUG printf("Done with initial commands.\n"); #endif } performConfig(SU_SERVER); { /* NOTE: R_registerRoutines *replaces* all existing registrations !! So we have to register everything for all. */ R_CallMethodDef mainCallMethods[] = { {"Rserve_ctrlEval", (DL_FUNC) &Rserve_ctrlEval, 1}, {"Rserve_ctrlSource", (DL_FUNC) &Rserve_ctrlSource, 1}, {"Rserve_oobSend", (DL_FUNC) &Rserve_oobSend, 2}, {"Rserve_oobMsg", (DL_FUNC) &Rserve_oobMsg, 2}, {"Rserve_oc_register", (DL_FUNC) &Rserve_oc_register, 1}, {NULL, NULL, 0} }; R_registerRoutines(R_getEmbeddingDllInfo(), 0, mainCallMethods, 0, 0); } #if defined RSERV_DEBUG || defined Win32 printf("Rserve: Ok, ready to answer queries.\n"); #endif #if defined DAEMON && defined unix if (daemonize) { /* ok, we're in unix, so let's daemonize properly */ if (fork() != 0) { puts("Rserv started in daemon mode."); exit(0); } setsid(); chdir("/"); } else puts("Rserve started in non-daemon mode."); #endif RSsrv_init(); #ifdef unix umask(umask_value); #endif if (enable_qap && !create_Rserve_QAP1(global_srv_flags | (qap_oc ? SRV_QAP_OC : 0))) { fprintf(stderr, "ERROR: unable to start Rserve server\n"); return ex(1); } if (tls_port > 0 && !create_Rserve_QAP1(global_srv_flags | SRV_TLS | (qap_oc ? SRV_QAP_OC : 0))) { fprintf(stderr, "ERROR: unable to start Rserve TLS server\n"); return ex(1); } http_flags = global_srv_flags; if (ws_upgrade) { http_flags = global_srv_flags | (enable_ws_qap ? WS_PROT_QAP : 0) | (enable_ws_text ? WS_PROT_TEXT : 0) | (ws_qap_oc ? SRV_QAP_OC : 0); if (http_flags & (WS_PROT_TEXT | WS_PROT_QAP)) http_flags |= HTTP_WS_UPGRADE; else fprintf(stderr, "WARNING: http.upgrade.websockets is enabled but no WS sub-protocol is enabled, ignoring\n"); } if (http_port > 0) { server_t *srv = create_HTTP_server(http_port, http_flags); if (!srv) { fprintf(stderr, "ERROR: unable to start Rserve HTTP server\n"); return ex(1); } srv->fork = fork_http; } if (https_port > 0) { server_t *srv = create_HTTP_server(https_port, http_flags | SRV_TLS); if (!srv) { fprintf(stderr, "ERROR: unable to start Rserve HTTPS server\n"); return ex(1); } srv->fork = fork_https; } if (enable_ws_text || enable_ws_qap) { if (ws_port < 1 && wss_port < 1) { if (!ws_upgrade) fprintf(stderr, "WARNING: Invalid or missing websockets port, WebSockets server will not start\n"); } else { if (ws_port > 0) { server_t *srv = create_WS_server(ws_port, global_srv_flags | (enable_ws_qap ? WS_PROT_QAP : 0) | (enable_ws_text ? WS_PROT_TEXT : 0) | (ws_qap_oc ? SRV_QAP_OC : 0)); if (srv) srv->fork = fork_ws; } if (wss_port > 0) { server_t *srv = create_WS_server(wss_port, global_srv_flags | (enable_ws_qap ? WS_PROT_QAP : 0) | (enable_ws_text ? WS_PROT_TEXT : 0) | (ws_qap_oc ? SRV_QAP_OC : 0) | WS_TLS); if (srv) srv->fork = fork_ws; } } } setup_signal_handlers(); serverLoop(); #ifdef unix if (localSocketName) remove(localSocketName); #endif #ifdef RSERV_DEBUG printf("\nServer terminated normally.\n"); #endif restore_signal_handlers(); return ex(0); } #endif /*--- The following makes the indenting behavior of emacs compatible with Xcode's 4/4 setting ---*/ /* Local Variables: */ /* indent-tabs-mode: t */ /* tab-width: 4 */ /* c-basic-offset: 4 */ /* End: */ Rserve/src/md5.h0000644000176000001440000000061012205226215013167 0ustar ripleyusers#ifndef MD5_H #define MD5_H typedef unsigned int uint32; struct MD5Context { uint32 buf[4]; uint32 bits[2]; unsigned char in[64]; }; extern void MD5Init(); extern void MD5Update(); extern void MD5Final(); extern void MD5Transform(); typedef struct MD5Context MD5_CTX; unsigned char *md5hash(const void *buf, int len, unsigned char hash[16]); #endif /* !MD5_H */ Rserve/src/qap_decode.h0000644000176000001440000000027712205226215014577 0ustar ripleyusers#ifndef QAP_DECODE_H__ #define QAP_DECODE_H__ #ifndef USE_RINTERNALS #define USE_RINTERNALS 1 #include #endif #include "Rsrv.h" SEXP QAP_decode(unsigned int **buf); #endif Rserve/src/include/0000755000176000001440000000000012205226215013757 5ustar ripleyusersRserve/src/include/sbthread.h0000644000176000001440000000653512205226215015735 0ustar ripleyusers/*****************************************************************\ * sbthread - system-independent basic threads * * (C)Copyright 2001 Simon Urbanek * *---------------------------------------------------------------* * Supported platforms: unix w pthread, Win32 * \*****************************************************************/ #ifndef __SBTHREAD_H__ #define __SBTHREAD_H__ #ifdef unix /* begin unix (pthread) implementation */ #include #define decl_sbthread void * #define sbthread_result(A) (void *)(A) #define sbthread_mutex pthread_mutex_t sbthread_mutex *sbthread_create_mutex() { pthread_mutex_t lm=PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t *m=(pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); memcpy(m,&lm,sizeof(pthread_mutex_t)); return m; }; #define sbthread_lock_mutex(M) pthread_mutex_lock(M); #define sbthread_unlock_mutex(M) pthread_mutex_unlock(M); void sbthread_destroy_mutex(sbthread_mutex *m) { pthread_mutex_destroy(m); free(m); }; int sbthread_create(void * (thr)(void *), void *par) { pthread_t Thread; pthread_attr_t ThreadAttr; pthread_attr_init(&ThreadAttr); pthread_attr_setdetachstate(&ThreadAttr,PTHREAD_CREATE_DETACHED); return pthread_create(&Thread,&ThreadAttr,*thr,par); }; #else /* end of unix, begin of Win32 */ #include #define decl_sbthread DWORD WINAPI #define sbthread_result(A) (DWORD)(A) #define sbthread_mutex char #ifndef sleep /* this has nothing to do with threads, but may be usefull */ #define sleep(A) Sleep((A)*1000) #endif unsigned int sbthread_mutex_counter=1; sbthread_mutex *sbthread_create_mutex(void) { char mtxn[64],*c; unsigned int i,j; HANDLE m; strcpy(mtxn,"sbthread_mutex"); /* this isn't really thread-safe, but creating more mutexes at exactly the same time by different threads on an SMP machine is ... let's say inprobable. moreover ++ might be atomic. creating yet another mutex for this single operation seems to me as an overkill. but if you need 100% thread-safe code, feel free to implement it here ;) */ sbthread_mutex_counter++; i=15; j=sbthread_mutex_counter; while (j>0) { mtxn[i]=65+(j&15); i++; j>>=4; }; mtxn[i]=0; i++; m=CreateMutex(0,0,mtxn); if (!m) return 0; memcpy(&mtxn[i],&m,sizeof(m)); i+=sizeof(m)*2+1; c=(char*)malloc(i); memcpy(c,mtxn,i); /* content: name\0[createHANDLE][ownershipHANDLE] */ return c; }; int sbthread_lock_mutex(sbthread_mutex *m) { HANDLE h; int i; h=OpenMutex(MUTEX_ALL_ACCESS,0,m); if (!h) return 0; if (WaitForSingleObject(h,INFINITE)==WAIT_FAILED) return 0; i=strlen(m); i+=sizeof(h)+1; memcpy(&m[i],&h,sizeof(h)); return 1; }; int sbthread_unlock_mutex(sbthread_mutex *m) { HANDLE h; int i; i=strlen(m); i+=sizeof(h)+1; memcpy(&h,&m[i],sizeof(h)); if (!h) return 0; memset(&m[i],0,sizeof(h)); ReleaseMutex(h); CloseHandle(h); return 1; }; void sbthread_destroy_mutex(sbthread_mutex *m) { HANDLE h; int i; i=strlen(m); i+=sizeof(h)+1; memcpy(&h,&m[i],sizeof(h)); if (h) return; // oh, mutex is still in use memcpy(&h,&m[i-sizeof(h)],sizeof(h)); CloseHandle(h); free(m); }; int sbthread_create(LPTHREAD_START_ROUTINE sa, void *par) { DWORD tid; return CreateThread(0,0,sa,par,0,&tid); }; #endif /* Windows implementation */ #endif /* __SBTHREAD_H__ */ Rserve/src/include/sisocks.h0000644000176000001440000001700612205226215015612 0ustar ripleyusers/* system independent sockets (basically for unix and Win) * Copyright (C) 2000,1 Simon Urbanek * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; version 2.1 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * conditional defines: MAIN should be defined in just one file that will contain the fn definitions and variables USE_SNPRINTF emulate snprintf on Win platforms (you will lose the security which is provided under unix of course) SOCK_ERRORS include error code handling and checking functions */ #ifndef __SISOCKS_H__ #define __SISOCKS_H__ #if defined __GNUC__ && !defined unix && !defined Win32 /* MacOS X hack (gcc on any platform should behave as unix - except for Win32, where we need to keep using winsock) */ #define unix #endif #if defined STANDALONE_RSERVE && defined RSERVE_PKG #undef RSERVE_PKG #endif #if defined SOCK_ERRORS || defined USE_SNPRINTF #include #endif #include #ifdef unix #include #include #include #include #include #include #include #define sockerrno errno #define SOCKET int #define INVALID_SOCKET (-1) #define closesocket(A) close(A) #else #define windows #include #include #include #include #define inet_aton(A,B) (0, B.s_addr=inet_addr(A)) #define sockerrno WSAGetLastError() #ifndef WIN64 #define ECONNREFUSED WSAECONNREFUSED #define EADDRINUSE WSAEADDRINUSE #define ENOTSOCK WSAENOTSOCK #define EISCONN WSAEISCONN #define ETIMEDOUT WSAETIMEDOUT #define ENETUNREACH WSAENETUNREACH #define EINPROGRESS WSAEINPROGRESS #define EALREADY WSAEALREADY #define EAFNOSUPPORT WSAEAFNOSUPPORT #define EBADF WSAEBADF #define EINVAL WSAEINVAL #define EOPNOTSUPP WSAEOPNOTSUPP #define EFAULT WSAEFAULT #define EWOULDBLOCK WSAEWOULDBLOCK #define EACCES WSAEACCES #else #define ECONNREFUSED WSAECONNREFUSED #define EADDRINUSE WSAEADDRINUSE #define ENOTSOCK WSAENOTSOCK #define EISCONN WSAEISCONN #define ETIMEDOUT WSAETIMEDOUT #define ENETUNREACH WSAENETUNREACH #define EINPROGRESS WSAEINPROGRESS #define EALREADY WSAEALREADY #define EOPNOTSUPP WSAEOPNOTSUPP #define EWOULDBLOCK WSAEWOULDBLOCK #endif #ifdef USE_SNPRINTF #ifdef MAIN int snprintf(char *buf, int len, char *fmt, ...) { va_list argptr; int cnt; va_start(argptr, fmt); cnt = vsprintf(buf, fmt, argptr); va_end(argptr); return(cnt); } #else extern int snprintf(char *buf, int len, char *fmt, ...); #endif #endif #endif #define SA struct sockaddr #define SAIN struct sockaddr_in #ifdef windows #ifdef MAIN int initsocks(void) { WSADATA dt; /* initialize WinSock 1.1 */ return (WSAStartup(0x0101,&dt))?-1:0; } #else extern int initsocks(void); #endif #define donesocks() WSACleanup() #else /* no stupid stuff necessary for unix */ #define initsocks() #define donesocks() #endif #ifdef SOCK_ERRORS #ifdef MAIN int suppmode=0; int socklasterr; FILE *sockerrlog=0; /* copy error description to buf or set *buf=0 if none */ int sockerrorchecks(char *buf, int blen, int res) { *buf=0; if (res==-1) { switch(sockerrno) { case EBADF: strncpy(buf,"bad descriptor",blen); break; case EINVAL: strncpy(buf,"already in use",blen); break; case EACCES: strncpy(buf,"access denied",blen); break; case ENOTSOCK: strncpy(buf,"descriptor is not a socket",blen); break; case EOPNOTSUPP: strncpy(buf,"operation not supported",blen); break; case EFAULT: strncpy(buf,"fault",blen); break; case EWOULDBLOCK: strncpy(buf,"operation would block",blen); break; case EISCONN: strncpy(buf,"is already connected",blen); break; case ECONNREFUSED: strncpy(buf,"connection refused",blen); break; case ETIMEDOUT: strncpy(buf,"operation timed out",blen); break; case ENETUNREACH: strncpy(buf,"network is unreachable",blen); break; case EADDRINUSE: strncpy(buf,"address already in use",blen); break; case EINPROGRESS: strncpy(buf,"in progress",blen); break; case EALREADY: strncpy(buf,"previous connect request not completed yet",blen); break; #ifdef unix default: snprintf(buf,blen,"unknown socket error %d",sockerrno); #else default: sprintf(buf,"unknown socket error %d",sockerrno); #endif } } return res; } #ifdef RSERVE_PKG /* use error instead of exit */ #include int sockerrorcheck(char *sn, int rtb, int res) { if ((signed int)res == -1) { char sock_err_buf[72]; sockerrorchecks(sock_err_buf, sizeof(sock_err_buf), res); if (rtb) Rf_error("%s socket error #%d (%s)", sn, (int) sockerrno, sock_err_buf); else Rf_warning("%s socket error #%d (%s)", sn, (int) sockerrno, sock_err_buf); } return res; } #else /* check socket error and add to log file if necessary */ int sockerrorcheck(char *sn, int rtb, int res) { if (!sockerrlog) sockerrlog=stderr; if ((signed int)res==-1) { if (socklasterr==sockerrno) { suppmode++; } else { if (suppmode>0) { fprintf(sockerrlog,"##> REP: (last error has been repeated %d times.)\n",suppmode); suppmode=0; } fprintf(sockerrlog,"##> SOCK_ERROR: %s error #%d",sn,sockerrno); switch(sockerrno) { case EBADF: fprintf(sockerrlog,"(bad descriptor)"); break; case EINVAL: fprintf(sockerrlog,"(already in use)"); break; case EACCES: fprintf(sockerrlog,"(access denied)"); break; case ENOTSOCK: fprintf(sockerrlog,"(descriptor is not a socket)"); break; case EOPNOTSUPP: fprintf(sockerrlog,"(operation not supported)"); break; case EFAULT: fprintf(sockerrlog,"(fault)"); break; case EWOULDBLOCK: fprintf(sockerrlog,"(operation would block)"); break; case EISCONN: fprintf(sockerrlog,"(is already connected)"); break; case ECONNREFUSED: fprintf(sockerrlog,"(connection refused)"); break; case ETIMEDOUT: fprintf(sockerrlog,"(operation timed out)"); break; case ENETUNREACH: fprintf(sockerrlog,"(network is unreachable)"); break; case EADDRINUSE: fprintf(sockerrlog,"(address already in use)"); break; case EINPROGRESS: fprintf(sockerrlog,"(in progress)"); break; case EALREADY: fprintf(sockerrlog,"(previous connect request not completed yet)"); break; default: fprintf(sockerrlog,"(?)"); } fprintf(sockerrlog,"\n"); fflush(sockerrlog); socklasterr=sockerrno; } if (rtb) exit(1); } return res; } #endif #else extern int suppmode; extern int socklasterr; extern FILE *sockerrlog; int sockerrorchecks(char *buf, int blen, int res); int sockerrorcheck(char *sn, int rtb, int res); #endif #define FCF(X,F) sockerrorcheck(X,1,F) #define CF(X,F) sockerrorcheck(X,0,F) #endif #ifdef MAIN struct sockaddr *build_sin(struct sockaddr_in *sa,char *ip,int port) { memset(sa,0,sizeof(struct sockaddr_in)); sa->sin_family=AF_INET; sa->sin_port=htons(port); sa->sin_addr.s_addr=(ip)?inet_addr(ip):htonl(INADDR_ANY); return (struct sockaddr*)sa; } #else struct sockaddr *build_sin(struct sockaddr_in *sa,char *ip,int port); #endif #endif /* __SISOCKS_H__ */ Rserve/src/include/Win32/0000755000176000001440000000000012205226215014661 5ustar ripleyusersRserve/src/include/Win32/config.h0000644000176000001440000000334512205226215016304 0ustar ripleyusers/* config.h for Windows This file is based on a config.h as generated by configure run on a MinGW gcc system. Most of it is not used, because many parts of Rserve have its own Win32 code, but it may become handy at some later point. Last update: Rserve 0.4-5, R 2.4.0, MinGW gcc 3.4.5 */ /* Defined if the platform is little-endian */ #define BS_LITTLE_ENDIAN 1 /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 /* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #define HAVE_MALLOC 1 /* Define to 1 if you have the header file. */ #define HAVE_MEMORY_H 1 /* Define to 1 if you have the `memset' function. */ #define HAVE_MEMSET 1 /* Define to 1 if you have the `mkdir' function. */ #define HAVE_MKDIR 1 /* Define to 1 if you have the `rmdir' function. */ #define HAVE_RMDIR 1 /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TIME_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #define HAVE_UNISTD_H 1 /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Define to 1 if you can safely include both and . */ #define TIME_WITH_SYS_TIME 1 Rserve/src/include/Win32/Startup.h0000644000176000001440000000547412205226215016506 0ustar ripleyusers/* * R : A Computer Language for Statistical Data Analysis * Copyright (C) 1999-2003 The R Development Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef STARTUP_H_ #define STARTUP_H_ #include /* TRUE/FALSE */ #ifdef Win32 typedef int (*blah1) (char *, char *, int, int); typedef void (*blah2) (char *, int); typedef void (*blah3) (); typedef void (*blah4) (char *); typedef int (*blah5) (char *); typedef void (*blah6) (int); typedef enum {RGui, RTerm, LinkDLL} UImode; #endif /* Startup Actions */ typedef enum { SA_NORESTORE,/* = 0 */ SA_RESTORE, SA_DEFAULT,/* was === SA_RESTORE */ SA_NOSAVE, SA_SAVE, SA_SAVEASK, SA_SUICIDE } SA_TYPE; typedef struct { Rboolean R_Quiet; Rboolean R_Slave; Rboolean R_Interactive; Rboolean R_Verbose; Rboolean LoadSiteFile; Rboolean LoadInitFile; Rboolean DebugInitFile; SA_TYPE RestoreAction; SA_TYPE SaveAction; unsigned long vsize; unsigned long nsize; unsigned long max_vsize; unsigned long max_nsize; unsigned long ppsize; int NoRenviron; /* Permanent copy of the command line arguments and the number of them passed to the application. These are populated via the routine R_set_command_line_arguments() called from R_common_command_line(). */ int NumCommandLineArgs; char **CommandLineArgs; #ifdef Win32 char *rhome; /* R_HOME */ char *home; /* HOME */ blah1 ReadConsole; blah2 WriteConsole; blah3 CallBack; blah4 message; blah5 yesnocancel; blah6 busy; UImode CharacterMode; Rboolean DebugMenuitem; #endif } structRstart; typedef structRstart *Rstart; void R_DefParams(Rstart); void R_SetParams(Rstart); void R_SetWin32(Rstart); void R_SizeFromEnv(Rstart); void R_common_command_line(int *, char **, Rstart); void R_set_command_line_arguments(int argc, char **argv, Rstart Rp); void setup_Rmainloop(void); /* originally from Defn.h : */ void R_CleanUp(SA_TYPE, int, int); void R_StartUp(void); FILE *R_OpenInitFile(void); FILE *R_OpenSysInitFile(void); FILE *R_OpenSiteFile(void); #endif Rserve/src/include/Win32/psignal.h0000644000176000001440000001410012205226215016463 0ustar ripleyusers/***************************************************************************** * * * signal.h * * * * Freely redistributable and modifiable. Use at your own risk. * * * * Copyright 1994-1999 The Downhill Project * * http://www.ede.com/free/u2nt * * * *****************************************************************************/ /* Original version taken at Changes (g.m.): 10.06.1999: Made self contained - Changed some names 11.06.1999: Added 'sigsetjmp' and 'siglongjmp' 12.06.1999: Added pause and sigsuspend (require a version (also a non POSIX one) of sleep; if your system don't have it define DONT_HAVE_SLEEP) 27/06/1999: (BDR) convert sigsetjmp and siglongjmp macros to (,,) 12/07/1999: (BDR) fix sigsetjmp macro to set saved_mask */ #ifndef _PSIGNAL_H_ #define _PSIGNAL_H_ #include #include #include #define SIGHUP 1 /* hangup */ #define SIGINT 2 /* interrupt */ #define SIGQUIT 3 /* quit */ #define SIGILL 4 /* illegal instruction (not reset when caught) */ #define SIGTRAP 5 /* trace trap (not reset when caught) */ #define SIGEMT 7 /* EMT instruction */ #define SIGFPE 8 /* floating point exception */ #define SIGKILL 9 /* kill (cannot be caught or ignored) */ #define SIGBUS 10 /* bus error */ #define SIGSEGV 11 /* segmentation violation */ #define SIGSYS 12 /* bad argument to system call */ #define SIGPIPE 13 /* write on a pipe with no one to read it */ #define SIGALRM 14 /* alarm clock */ #define SIGTERM 15 /* software termination signal from kill */ #define SIGURG 16 /* urgent condition on IO channel */ #define SIGSTOP 17 /* sendable stop signal not from tty */ #define SIGTSTP 18 /* stop signal from tty */ #define SIGCONT 19 /* continue a stopped process */ #define SIGCHLD 20 /* to parent on child stop or exit */ #define SIGCLD 20 /* System V name for SIGCHLD */ #define SIGBREAK 21 /* to readers pgrp upon background tty read */ #define SIGABRT 22 /* used by abort */ #define SIGIO 23 /* input/output possible signal */ #define SIGPOLL SIGIO /* System V name for SIGIO */ #define SIGXCPU 24 /* exceeded CPU time limit */ #define SIGXFSZ 25 /* exceeded file size limit */ #define SIGVTALRM 26 /* virtual time alarm */ #define SIGPROF 27 /* profiling time alarm */ #define SIGWINCH 28 /* window changed */ #define SIGLOST 29 /* resource lost (eg, record-lock lost) */ #define SIGUSR1 30 /* user defined signal 1 */ #define SIGUSR2 31 /* user defined signal 2 */ #define NSIG 32 /* signal 0 implied */ #ifndef RC_INVOKED /* * A pointer to a signal handler function. A signal handler takes a * single int, which is the signal it handles. */ typedef void (*sighandler_t)(int nSig); #ifndef _SIGSET_T_ #define _SIGSET_T_ typedef int sigset_t; #endif /* Not _SIGSET_T_ */ /* * These are special values of signal handler pointers which are * used to send a signal to the default handler (SIG_DFL), ignore * the signal (SIG_IGN), or indicate an error return (SIG_ERR). */ #define SIG_DFL ((sighandler_t) 0) #define SIG_IGN ((sighandler_t) 1) #define SIG_ERR ((sighandler_t) -1) #ifdef __cplusplus extern "C" { #endif /* Signal mask actions ===================================================== */ #define SIG_BLOCK 0 #define SIG_UNBLOCK 1 #define SIG_SETMASK 2 /* Signal flag actions ===================================================== */ #define SA_NOCLDSTOP 1 #define SA_RESETHAND 2 /* Struct stuff **************************************************************/struct sigaction { void (*sa_handler)(int); sigset_t sa_mask; int sa_flags; }; typedef struct { jmp_buf jmpbuf; /* Calling environment. */ int mask_was_saved; /* Saved the signal mask? */ sigset_t saved_mask; /* Saved signal mask. */ } sigjmp_buf[1]; /* Prototype stuff ***********************************************************/ unsigned long sigsetmask(unsigned long signal_Block_MaskNew); unsigned long sigblock(unsigned long signal_Block_MaskNew); int sighold(int signal_Number); int sigrelse(int signal_Number); int sigaction(int signal_Number,struct sigaction* sigaction_Info, struct sigaction* signaction_InfoOld); int sigaddset(sigset_t* sigset_Info,int signal_Number); int sigdelset(sigset_t* sigset_Info,int signal_Number); int sigemptyset(sigset_t* sigset_Info); int sigfillset(sigset_t* sigset_Info); int sigismember(sigset_t* sigset_Info,int signal_Number); int sigpending(sigset_t* sigset_Info); int sigprocmask(int mask_Function,sigset_t* sigset_Info, sigset_t* sigset_InfoOld); sighandler_t signal(int signal_Number, sighandler_t); void raise(int); int pause(void); int sigsuspend(sigset_t* sigset_Info); /* Re-mapped functions ===================================================== */ #define sigmask(signal_Index) (1<<(signal_Index-1)) /* This must be a macro, since we want setjmp working in the calling environment */ /* #define sigsetjmp(jb, sm) (\ sm?sigprocmask(SIG_SETMASK,NULL,&jb->saved_mask):0,\ jb->mask_was_saved=sm,\ setjmp(jb->jmpbuf)) we only currently use the case sm=0, so avoid compiler warnings by */ #define sigsetjmp(jb, sm) (jb->mask_was_saved=0, setjmp(jb->jmpbuf)) /* We can transform this in a function but ... */ #define siglongjmp(jb, val) (((jb->mask_was_saved)?\ sigprocmask(SIG_SETMASK, &jb->saved_mask, 0):0),\ longjmp(jb->jmpbuf, val)) #ifdef __cplusplus } #endif #endif /* Not RC_INVOKED */ #endif /* Not _PSIGNAL_H_ */ Rserve/src/include/Parse.h0000644000176000001440000000047412205226215015207 0ustar ripleyusers/* This is a fall-back for R versions that don't have R_ext/Parse.h (R versions before 2.1.0) */ #ifndef R_EXT_PARSE_H_ #define R_EXT_PARSE_H_ typedef enum { PARSE_NULL, PARSE_OK, PARSE_INCOMPLETE, PARSE_ERROR, PARSE_EOF } ParseStatus; SEXP R_ParseVector(SEXP, int, ParseStatus *); #endif Rserve/NAMESPACE0000644000176000001440000000017012205226215012762 0ustar ripleyusersuseDynLib(Rserve, run_Rserve) export(Rserve, self.ctrlEval, self.ctrlSource, self.oobSend, self.oobMessage, run.Rserve) Rserve/clients/0000755000176000001440000000000013455133430013212 5ustar ripleyusersRserve/clients/java/0000755000176000001440000000000012205226222014125 5ustar ripleyusersRserve/clients/java/REngineCallbacks.java0000644000176000001440000000025712205226215020125 0ustar ripleyuserspackage org.rosuda.REngine; /** REngineCallbacks is a virtual interface that poses as a superclass of all callback delegate classes. */ public interface REngineCallbacks { } Rserve/clients/java/REngineStdOutput.java0000644000176000001440000000074212205226215020220 0ustar ripleyuserspackage org.rosuda.REngine; /** implementation of the {@link REngineOutputInterface} which uses standard output. */ public class REngineStdOutput implements REngineCallbacks, REngineOutputInterface { public synchronized void RWriteConsole(REngine eng, String text, int oType) { ((oType == 0) ? System.out : System.err).print(text); } public void RShowMessage(REngine eng, String text) { System.err.println("*** "+text); } public void RFlushConsole(REngine eng) { } } Rserve/clients/java/Makefile0000644000176000001440000000150213442516164015576 0ustar ripleyusersRENG_SRC=$(wildcard *.java) RSRV_SRC=$(wildcard Rserve/*.java) $(wildcard Rserve/protocol/*.java) JRI_SRC=$(wildcard JRI/*.java) TARGETS=REngine.jar Rserve.jar all: $(TARGETS) JAVAC=javac JAVADOC=javadoc JDFLAGS=-author -version -breakiterator -link http://java.sun.com/j2se/1.4.2/docs/api/ JFLAGS+=-source 1.4 -target 1.4 REngine.jar: $(RENG_SRC) @rm -rf org $(JAVAC) -d . $(JFLAGS) $(RENG_SRC) jar fc $@ org rm -rf org Rserve.jar: $(RSRV_SRC) REngine.jar @rm -rf org $(JAVAC) -d . -cp REngine.jar $(RSRV_SRC) jar fc $@ org rm -rf org clean: rm -rf org *~ $(TARGETS) doc make -C Rserve clean make -C JRI clean test: make -C Rserve test rc: Rserve.jar Rserve/test/jt.java make -C Rserve/test jt doc: $(RENG_SRC) $(RSRV_SRC) $(JRI_SRC) rm -rf $@ mkdir $@ $(JAVADOC) -d $@ $(JDFLAGS) $^ .PHONY: clean all test Rserve/clients/java/REXPGenericVector.java0000644000176000001440000000574312205226215020241 0ustar ripleyuserspackage org.rosuda.REngine; import java.util.Vector; import java.util.HashMap; /** REXPGenericVector represents a generic vector in R. Its elements can be typically of any {@link REXP} type. */ public class REXPGenericVector extends REXPVector { /** payload */ private RList payload; /** creates a new generic vector from a list. If the list is named, the "names" attribute is created automatically from it. * @param list list to create the vector from */ public REXPGenericVector(RList list) { super(); payload=(list==null)?new RList():list; // automatically generate 'names' attribute if (payload.isNamed()) attr = new REXPList( new RList(new REXP[] { new REXPString(payload.keys()) }, new String[] { "names" })); } /** creates a new generic vector from a list. Note that the names in the list are ignored as they are expected to be defined by the attributes parameter. * @param list list to create the vector from (names are ignored - use {@link #REXPGenericVector(RList)} or the "names" attribute for named lists * @param attr attributes */ public REXPGenericVector(RList list, REXPList attr) { super(attr); payload=(list==null)?new RList():list; } /* generic vectors are converted either to a Map (if it is a named vector and there are no duplicate names) or a Vector. The contained elements are converted using asNativeJavaObject recursively. */ public Object asNativeJavaObject() throws REXPMismatchException { // we need to convert the inside as well int n = payload.size(); // named list -> map but only if // a) all names are present // b) there are no duplicates in the names if (payload.isNamed()) { String[] names = payload.keys(); if (names.length == n) { HashMap map = new HashMap(); boolean valid = true; for (int i = 0; i < n; i++) { if (map.containsKey(names[i])) { valid = false; break; } Object value = payload.elementAt(i); if (value != null) value = ((REXP) value).asNativeJavaObject(); map.put(value, names[i]); } if (valid) return map; } } // otherwise drop names and use just a vector Vector v = new Vector(); for (int i = 0; i < n; i++) { Object value = payload.elementAt(i); if (value != null) value = ((REXP) value).asNativeJavaObject(); v.addElement(value); } return v; } public int length() { return payload.size(); } public boolean isList() { return true; } public boolean isRecursive() { return true; } public RList asList() { return payload; } public String toString() { return super.toString()+(asList().isNamed()?"named":""); } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.size() && i < maxDebugItems) { if (i>0) sb.append(",\n"); sb.append(payload.at(i).toDebugString()); i++; } if (i < payload.size()) sb.append(",.."); return sb.toString()+"}"; } } Rserve/clients/java/REXPJavaReference.java0000644000176000001440000000164212205226215020174 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPJavaReference is a reference to a Java object that has been resolved from is R wrapper. Note that not all engines support references. */ public class REXPJavaReference extends REXP { /** the referenced Java object */ Object object; /** creates a new Java reference R object * @param o Java object referenced by the REXP */ public REXPJavaReference(Object o) { super(); this.object = o; } /** creates a new Java reference R object * @param o Java object referenced by the REXP * @param attr attributes (of the R wrapper) */ public REXPJavaReference(Object o, REXPList attr) { super(attr); this.object = o; } /** returns the Java object referenced by this REXP * @return Java object */ public Object getObject() { return object; } public Object asNativeJavaObject() { return object; } public String toString() { return super.toString() + "[" + object + "]"; } } Rserve/clients/java/REXPInteger.java0000644000176000001440000000415712205226215017075 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPDouble represents a vector of integer values. */ public class REXPInteger extends REXPVector { protected int[] payload; /** NA integer value as defined in R. Unlike its real equivalent this one can be used in comparisons, although {@link #isNA(int) } is provided for consistency. */ public static final int NA = -2147483648; public static boolean isNA(int value) { return (value == NA); } /** create integer vector of the length 1 with the given value as its first (and only) element */ public REXPInteger(int load) { super(); payload=new int[] { load }; } /** create integer vector with the payload specified by load */ public REXPInteger(int[] load) { super(); payload=(load==null)?new int[0]:load; } /** create integer vector with the payload specified by load and attributes attr */ public REXPInteger(int[] load, REXPList attr) { super(attr); payload=(load==null)?new int[0]:load; } public Object asNativeJavaObject() { return payload; } public int length() { return payload.length; } public boolean isInteger() { return true; } public boolean isNumeric() { return true; } public int[] asIntegers() { return payload; } /** returns the contents of this vector as doubles */ public double[] asDoubles() { double[] d = new double[payload.length]; int i = 0; while (i < payload.length) { d[i] = (double) payload[i]; i++; } return d; } /** returns the contents of this vector as strings */ public String[] asStrings() { String[] s = new String[payload.length]; int i = 0; while (i < payload.length) { s[i] = ""+payload[i]; i++; } return s; } public boolean[] isNA() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = (payload[i]==NA); i++; } return a; } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.length && i < maxDebugItems) { if (i>0) sb.append(","); sb.append(payload[i]); i++; } if (i < payload.length) sb.append(",.."); return sb.toString()+"}"; } } Rserve/clients/java/REXPExpressionVector.java0000644000176000001440000000137512205226215021021 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPExpressionVector represents a vector of expressions in R. It is essentially a special kind of generic vector - its elements are expected to be valid R expressions. */ public class REXPExpressionVector extends REXPGenericVector { /** create a new vector of expressions from a list of expressions. * @param list list of expressions to store in this vector */ public REXPExpressionVector(RList list) { super(list); } /** create a new vector of expressions from a list of expressions. * @param list list of expressions to store in this vector * @param attr attributes for the R object */ public REXPExpressionVector(RList list, REXPList attr) { super(list, attr); } public boolean isExpression() { return true; } } Rserve/clients/java/REXPVector.java0000644000176000001440000000165612205226215016743 0ustar ripleyuserspackage org.rosuda.REngine; /** abstract class representing all vectors in R */ public abstract class REXPVector extends REXP { public REXPVector() { super(); } public REXPVector(REXPList attr) { super(attr); } /** returns the length of the vector (i.e. the number of elements) * @return length of the vector */ public abstract int length(); public boolean isVector() { return true; } /** returns a boolean vector of the same length as this vector with true for NA values and false for any other values * @return a boolean vector of the same length as this vector with true for NA values and false for any other values */ public boolean[] isNA() { boolean a[] = new boolean[length()]; return a; } public String toString() { return super.toString()+"["+length()+"]"; } public String toDebugString() { return super.toDebugString()+"["+length()+"]"; } } Rserve/clients/java/JRI/0000755000176000001440000000000012205226215014553 5ustar ripleyusersRserve/clients/java/JRI/Makefile0000644000176000001440000000130713442516164016225 0ustar ripleyusers## there are two ways to compile JRIEngine - either use ## already installed REngine and JRI and then just ## compile JRIEngine against those jars or use this ## Makefile with all org sources checked out ## in which case the JRIEngine.jar will implicitly ## contain org.rosuda.JRI classes as well ## However, that requires both: ## org/rosuda/JRI ## org/rosuda/REngine JRI_MAIN_SRC=$(wildcard ../../JRI/*.java) JRIENGINE_SRC=JRIEngine.java JAVAC=javac JAR=jar JFLAGS=-source 1.4 -target 1.4 all: JRIEngine.jar JRIEngine.jar: $(JRI_MAIN_SRC) $(JRIENGINE_SRC) rm -rf org $(JAVAC) $(JFLAGS) -classpath ../REngine.jar -d . $^ $(JAR) fc $@ org clean: rm -rf org *~ JRIEngine.jar *.class make -C test clean Rserve/clients/java/JRI/JRIEngine.java0000644000176000001440000010136512205226215017176 0ustar ripleyusers// JRIEngine - REngine-based interface to JRI // Copyright(c) 2009 Simon Urbanek // // Currently it uses low-level calls from org.rosuda.JRI.Rengine, but // all REXP representations are created based on the org.rosuda.REngine API package org.rosuda.REngine.JRI; import org.rosuda.JRI.Rengine; import org.rosuda.JRI.Mutex; import org.rosuda.JRI.RMainLoopCallbacks; import org.rosuda.REngine.*; /** JRIEngine is a REngine implementation using JRI (Java/R Interface).

Note that at most one JRI instance can exist in a given JVM process, because R does not support multiple threads. JRIEngine itself is thread-safe, so it is possible to invoke its methods from any thread. However, this is achieved by serializing all entries into R, so be aware of possible deadlock conditions if your R code calls back into Java (JRIEngine is re-entrant from the same thread so deadlock issues can arise only with multiple threads inteacting thorugh R). */ public class JRIEngine extends REngine implements RMainLoopCallbacks { // internal R types as defined in Rinternals.h static final int NILSXP = 0; /* nil = NULL */ static final int SYMSXP = 1; /* symbols */ static final int LISTSXP = 2; /* lists of dotted pairs */ static final int CLOSXP = 3; /* closures */ static final int ENVSXP = 4; /* environments */ static final int PROMSXP = 5; /* promises: [un]evaluated closure arguments */ static final int LANGSXP = 6; /* language constructs */ static final int SPECIALSXP = 7; /* special forms */ static final int BUILTINSXP = 8; /* builtin non-special forms */ static final int CHARSXP = 9; /* "scalar" string type (internal only) */ static final int LGLSXP = 10; /* logical vectors */ static final int INTSXP = 13; /* integer vectors */ static final int REALSXP = 14; /* real variables */ static final int CPLXSXP = 15; /* complex variables */ static final int STRSXP = 16; /* string vectors */ static final int DOTSXP = 17; /* dot-dot-dot object */ static final int ANYSXP = 18; /* make "any" args work */ static final int VECSXP = 19; /* generic vectors */ static final int EXPRSXP = 20; /* expressions vectors */ static final int BCODESXP = 21; /* byte code */ static final int EXTPTRSXP = 22; /* external pointer */ static final int WEAKREFSXP = 23; /* weak reference */ static final int RAWSXP = 24; /* raw bytes */ static final int S4SXP = 25; /* S4 object */ /** minimal JRI API version that is required by this class in order to work properly (currently API 1.10, corresponding to JRI 0.5-1 or higher) */ static public final long requiredAPIversion = 0x010a; /** currently running JRIEngine - there can be only one and we store it here. Essentially if it is null then R was not initialized. */ static JRIEngine jriEngine = null; /** reference to the underlying low-level JRI (RNI) engine */ Rengine rni = null; /** event loop callbacks associated with this engine. */ REngineCallbacks callbacks = null; /** mutex synchronizing access to R through JRIEngine.

NOTE: only access through this class is synchronized. Any other access (e.g. using RNI directly) is NOT. */ Mutex rniMutex = null; // cached pointers of special objects in R long R_UnboundValue, R_NilValue; /** special, global references */ public REXPReference globalEnv, emptyEnv, baseEnv, nullValueRef; /** canonical NULL object */ public REXPNull nullValue; /** class used for wrapping raw pointers such that they are adequately protected and released according to the lifespan of the Java object */ class JRIPointer { long ptr; JRIPointer(long ptr, boolean preserve) { this.ptr = ptr; if (preserve && ptr != 0 && ptr != R_NilValue) { boolean obtainedLock = rniMutex.safeLock(); // this will inherently wait for R to become ready try { rni.rniPreserve(ptr); } finally { if (obtainedLock) rniMutex.unlock(); } } } protected void finalize() throws Throwable { try { if (ptr != 0 && ptr != R_NilValue) { boolean obtainedLock = rniMutex.safeLock(); try { rni.rniRelease(ptr); } finally { if (obtainedLock) rniMutex.unlock(); } } } finally { super.finalize(); } } long pointer() { return ptr; } } /** factory method called by engineForClass @return new or current engine (new if there is none, current otherwise since R allows only one engine at any time) */ public static REngine createEngine() throws REngineException { // there can only be one JRI engine in a process if (jriEngine == null) jriEngine = new JRIEngine(); return jriEngine; } public static REngine createEngine(String[] args, REngineCallbacks callbacks, boolean runREPL) throws REngineException { if (jriEngine != null) throw new REngineException(jriEngine, "engine already running - cannot use extended constructor on a running instance"); return jriEngine = new JRIEngine(args, callbacks, runREPL); } public Rengine getRni() { return rni; } /** default constructor - this constructor is also used via createEngine factory call and implies --no-save R argument, no callbacks and no REPL.

This is equivalent to JRIEngine(new String[] { "--no-save" }, null, false) */ public JRIEngine() throws REngineException { this(new String[] { "--no-save" }, (REngineCallbacks) null, false); } /** create JRIEngine with specified R command line arguments, no callbacks and no REPL.

This is equivalent to JRIEngine(args, null, false) */ public JRIEngine(String args[]) throws REngineException { this(args, (REngineCallbacks) null, false); } /** creates a JRI engine with specified delegate for callbacks (JRI compatibility mode ONLY!). The event loop is started if callbacks in not null. * @param args arguments to pass to R (note that R usually requires something like --no-save!) * @param callbacks delegate class to process event loop callback from R or null if no event loop is desired **/ public JRIEngine(String args[], RMainLoopCallbacks callbacks) throws REngineException { this(args, callbacks, (callbacks == null) ? false : true); } /** creates a JRI engine with specified delegate for callbacks * @param args arguments to pass to R (note that R usually requires something like --no-save!) * @param callback delegate class to process callbacks from R or null if no callbacks are desired * @param runREPL if set to true then the event loop (REPL) will be started, otherwise the engine is in direct operation mode. */ public JRIEngine(String args[], REngineCallbacks callbacks, boolean runREPL) throws REngineException { // if Rengine hasn't been able to load the native JRI library in its static // initializer, throw an exception if (!Rengine.jriLoaded) throw new REngineException (null, "Cannot load JRI native library"); if (Rengine.getVersion() < requiredAPIversion) throw new REngineException(null, "JRI API version is too old, update rJava/JRI to match the REngine API"); this.callbacks = callbacks; // the default modus operandi is without event loop and with --no-save option rni = new Rengine(args, runREPL, (callbacks == null) ? null : this); rniMutex = rni.getRsync(); boolean obtainedLock = rniMutex.safeLock(); // this will inherently wait for R to become ready try { if (!rni.waitForR()) throw(new REngineException(this, "Unable to initialize R")); if (rni.rniGetVersion() < requiredAPIversion) throw(new REngineException(this, "JRI API version is too old, update rJava/JRI to match the REngine API")); globalEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_GlobalEnv))); nullValueRef = new REXPReference(this, new Long(R_NilValue = rni.rniSpecialObject(Rengine.SO_NilValue))); emptyEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_EmptyEnv))); baseEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_BaseEnv))); nullValue = new REXPNull(); R_UnboundValue = rni.rniSpecialObject(Rengine.SO_UnboundValue); } finally { if (obtainedLock) rniMutex.unlock(); } // register ourself as the main and last engine lastEngine = this; if (jriEngine == null) jriEngine = this; } /** creates a JRI engine with specified delegate for callbacks (JRI compatibility mode ONLY! Will be deprecated soon!) * @param args arguments to pass to R (note that R usually requires something like --no-save!) * @param callback delegate class to process callbacks from R or null if no callbacks are desired * @param runREPL if set to true then the event loop (REPL) will be started, otherwise the engine is in direct operation mode. */ public JRIEngine(String args[], RMainLoopCallbacks callbacks, boolean runREPL) throws REngineException { // if Rengine hasn't been able to load the native JRI library in its static // initializer, throw an exception if (!Rengine.jriLoaded) throw new REngineException (null, "Cannot load JRI native library"); if (Rengine.getVersion() < requiredAPIversion) throw new REngineException(null, "JRI API version is too old, update rJava/JRI to match the REngine API"); // the default modus operandi is without event loop and with --no-save option rni = new Rengine(args, runREPL, callbacks); rniMutex = rni.getRsync(); boolean obtainedLock = rniMutex.safeLock(); // this will inherently wait for R to become ready try { if (!rni.waitForR()) throw(new REngineException(this, "Unable to initialize R")); if (rni.rniGetVersion() < requiredAPIversion) throw(new REngineException(this, "JRI API version is too old, update rJava/JRI to match the REngine API")); globalEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_GlobalEnv))); nullValueRef = new REXPReference(this, new Long(R_NilValue = rni.rniSpecialObject(Rengine.SO_NilValue))); emptyEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_EmptyEnv))); baseEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_BaseEnv))); nullValue = new REXPNull(); R_UnboundValue = rni.rniSpecialObject(Rengine.SO_UnboundValue); } finally { if (obtainedLock) rniMutex.unlock(); } // register ourself as the main and last engine lastEngine = this; if (jriEngine == null) jriEngine = this; } /** WARNING: legacy fallback for hooking from R into an existing Rengine - do NOT use for creating a new Rengine - it will go away eventually */ public JRIEngine(Rengine eng) throws REngineException { // if Rengine hasn't been able to load the native JRI library in its static // initializer, throw an exception if (!Rengine.jriLoaded) throw new REngineException (null, "Cannot load JRI native library"); rni = eng; if (rni.rniGetVersion() < 0x109) throw(new REngineException(this, "R JRI engine is too old - RNI API 1.9 (JRI 0.5) or newer is required")); rniMutex = rni.getRsync(); boolean obtainedLock = rniMutex.safeLock(); try { globalEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_GlobalEnv))); nullValueRef = new REXPReference(this, new Long(R_NilValue = rni.rniSpecialObject(Rengine.SO_NilValue))); emptyEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_EmptyEnv))); baseEnv = new REXPReference(this, new Long(rni.rniSpecialObject(Rengine.SO_BaseEnv))); nullValue = new REXPNull(); R_UnboundValue = rni.rniSpecialObject(Rengine.SO_UnboundValue); } finally { if (obtainedLock) rniMutex.unlock(); } // register ourself as the main and last engine lastEngine = this; if (jriEngine == null) jriEngine = this; } public REXP parse(String text, boolean resolve) throws REngineException { REXP ref = null; boolean obtainedLock = rniMutex.safeLock(); try { long pr = rni.rniParse(text, -1); if (pr == 0 || pr == R_NilValue) throw(new REngineException(this, "Parse error")); rni.rniPreserve(pr); ref = new REXPReference(this, new Long(pr)); if (resolve) try { ref = resolveReference(ref); } catch (REXPMismatchException me) { }; } finally { if (obtainedLock) rniMutex.unlock(); } return ref; } public REXP eval(REXP what, REXP where, boolean resolve) throws REngineException, REXPMismatchException { REXP ref = null; long rho = 0; if (where != null && !where.isReference()) { if (!where.isEnvironment() || ((REXPEnvironment)where).getHandle() == null) throw(new REXPMismatchException(where, "environment")); else rho = ((JRIPointer)((REXPEnvironment)where).getHandle()).pointer(); } else if (where != null) rho = ((Long)((REXPReference)where).getHandle()).longValue(); if (what == null) throw(new REngineException(this, "null object to evaluate")); if (!what.isReference()) { if (what.isExpression() || what.isLanguage()) what = createReference(what); else throw(new REXPMismatchException(where, "reference, expression or language")); } boolean obtainedLock = rniMutex.safeLock(); try { long pr = rni.rniEval(((Long)((REXPReference)what).getHandle()).longValue(), rho); /* handling problems */ if (pr == REngineEvalException.INVALID_INPUT){ throw new REngineEvalException(this, "Eval error (invalid input)", REngineEvalException.INVALID_INPUT ); } if (pr == REngineEvalException.ERROR) { throw new REngineEvalException( this, "error during evaluation", REngineEvalException.ERROR ) ; } rni.rniPreserve(pr); ref = new REXPReference(this, new Long(pr)); if (resolve) ref = resolveReference(ref); } finally { if (obtainedLock) rniMutex.unlock(); } return ref; } public void assign(String symbol, REXP value, REXP env) throws REngineException, REXPMismatchException { long rho = 0; if (env != null && !env.isReference()) { if (!env.isEnvironment() || ((REXPEnvironment)env).getHandle() == null) throw(new REXPMismatchException(env, "environment")); else rho = ((JRIPointer)((REXPEnvironment)env).getHandle()).pointer(); } else if (env != null) rho = ((Long)((REXPReference)env).getHandle()).longValue(); if (value == null) value = nullValueRef; if (!value.isReference()) value = createReference(value); // if value is not a reference, we have to create one boolean obtainedLock = rniMutex.safeLock(), succeeded = false; try { succeeded = rni.rniAssign(symbol, ((Long)((REXPReference)value).getHandle()).longValue(), rho); } finally { if (obtainedLock) rniMutex.unlock(); } if (!succeeded) throw new REngineException(this, "assign failed (probably locked binding"); } public REXP get(String symbol, REXP env, boolean resolve) throws REngineException, REXPMismatchException { REXP ref = null; long rho = 0; if (env != null && !env.isReference()) { if (!env.isEnvironment() || ((REXPEnvironment)env).getHandle() == null) throw(new REXPMismatchException(env, "environment")); else rho = ((JRIPointer)((REXPEnvironment)env).getHandle()).pointer(); } else if (env != null) rho = ((Long)((REXPReference)env).getHandle()).longValue(); boolean obtainedLock = rniMutex.safeLock(); try { long pr = rni.rniFindVar(symbol, rho); if (pr == R_UnboundValue || pr == 0) return null; rni.rniPreserve(pr); ref = new REXPReference(this, new Long(pr)); if (resolve) try { ref = resolveReference(ref); } catch (REXPMismatchException me) { }; } finally { if (obtainedLock) rniMutex.unlock(); } return ref; } public REXP resolveReference(REXP ref) throws REngineException, REXPMismatchException { REXP res = null; if (ref == null) throw(new REngineException(this, "resolveReference called on NULL input")); if (!ref.isReference()) throw(new REXPMismatchException(ref, "reference")); long ptr = ((Long)((REXPReference)ref).getHandle()).longValue(); if (ptr == 0) return nullValue; return resolvePointer(ptr); } /** * Turn an R pointer (long) into a REXP object. * * This is the actual implementation of resolveReference but it works directly on the long pointers to be more efficient when performing recursive de-referencing */ REXP resolvePointer(long ptr) throws REngineException, REXPMismatchException { if (ptr == 0) return nullValue; REXP res = null; boolean obtainedLock = rniMutex.safeLock(); try { int xt = rni.rniExpType(ptr); String an[] = rni.rniGetAttrNames(ptr); REXPList attrs = null; if (an != null && an.length > 0) { // are there attributes? Then we need to resolve them first // we allow special handling for Java references so we need the class and jobj long jobj = 0; String oclass = null; RList attl = new RList(); for (int i = 0; i < an.length; i++) { long aptr = rni.rniGetAttr(ptr, an[i]); if (aptr != 0 && aptr != R_NilValue) { if (an[i].equals("jobj")) jobj = aptr; REXP av = resolvePointer(aptr); if (av != null && av != nullValue) { attl.put(an[i], av); if (an[i].equals("class") && av.isString()) oclass = av.asString(); } } } if (attl.size() > 0) attrs = new REXPList(attl); // FIXME: in general, we could allow arbitrary convertors here ... // Note that the jobj hack is only needed because we don't support EXTPTRSXP conversion // (for a good reason - we can't separate the PTR from the R object so the only way it can // live is as a reference and we don't want resolvePointer to ever return REXPReference as // that could trigger infinite recursions), but if we did, we could allow post-processing // based on the class attribute on the converted REXP.. (better, we can leverage REXPUnknown // and pass the ptr to the convertor so it can pull things like EXTPTR via rni) if (jobj != 0 && oclass != null && (oclass.equals("jobjRef") || oclass.equals("jarrayRef") || oclass.equals("jrectRef"))) return new REXPJavaReference(rni.rniXrefToJava(jobj), attrs); } switch (xt) { case NILSXP: return nullValue; case STRSXP: String[] s = rni.rniGetStringArray(ptr); res = new REXPString(s, attrs); break; case INTSXP: if (rni.rniInherits(ptr, "factor")) { long levx = rni.rniGetAttr(ptr, "levels"); if (levx != 0) { String[] levels = null; // we're using low-level calls here (FIXME?) int rlt = rni.rniExpType(levx); if (rlt == STRSXP) { levels = rni.rniGetStringArray(levx); int[] ids = rni.rniGetIntArray(ptr); res = new REXPFactor(ids, levels, attrs); } } } // if it's not a factor, then we use int[] instead if (res == null) res = new REXPInteger(rni.rniGetIntArray(ptr), attrs); break; case REALSXP: res = new REXPDouble(rni.rniGetDoubleArray(ptr), attrs); break; case LGLSXP: { int ba[] = rni.rniGetBoolArrayI(ptr); byte b[] = new byte[ba.length]; for (int i = 0; i < ba.length; i++) b[i] = (ba[i] == 0 || ba[i] == 1) ? (byte) ba[i] : REXPLogical.NA; res = new REXPLogical(b, attrs); } break; case VECSXP: { long l[] = rni.rniGetVector(ptr); REXP rl[] = new REXP[l.length]; long na = rni.rniGetAttr(ptr, "names"); String[] names = null; if (na != 0 && rni.rniExpType(na) == STRSXP) names = rni.rniGetStringArray(na); for (int i = 0; i < l.length; i++) rl[i] = resolvePointer(l[i]); RList list = (names == null) ? new RList(rl) : new RList(rl, names); res = new REXPGenericVector(list, attrs); } break; case RAWSXP: res = new REXPRaw(rni.rniGetRawArray(ptr), attrs); break; case LISTSXP: case LANGSXP: { RList l = new RList(); // we need to plow through the list iteratively - the recursion occurs at the value level long cdr = ptr; while (cdr != 0 && cdr != R_NilValue) { long car = rni.rniCAR(cdr); long tag = rni.rniTAG(cdr); String name = null; if (rni.rniExpType(tag) == SYMSXP) name = rni.rniGetSymbolName(tag); REXP val = resolvePointer(car); if (name == null) l.add(val); else l.put(name, val); cdr = rni.rniCDR(cdr); } res = (xt == LANGSXP) ? new REXPLanguage(l, attrs) : new REXPList(l, attrs); } break; case SYMSXP: res = new REXPSymbol(rni.rniGetSymbolName(ptr)); break; case ENVSXP: if (ptr != 0) rni.rniPreserve(ptr); res = new REXPEnvironment(this, new JRIPointer(ptr, false)); break; case S4SXP: res = new REXPS4(attrs); break; default: res = new REXPUnknown(xt, attrs); break; } } finally { if (obtainedLock) rniMutex.unlock(); } return res; } public REXP createReference(REXP value) throws REngineException, REXPMismatchException { if (value == null) throw(new REngineException(this, "createReference from a NULL value")); if (value.isReference()) return value; long ptr = createReferencePointer(value); if (ptr == 0) return null; boolean obtainedLock = rniMutex.safeLock(); try { rni.rniPreserve(ptr); } finally { if (obtainedLock) rniMutex.unlock(); } return new REXPReference(this, new Long(ptr)); } /** * Create an R object, returning its pointer, from an REXP java object. * * @param value * @return long R pointer * @throws REngineException if any of the RNI calls fails * @throws REXPMismatchException only if some internal inconsistency happens. The internal logic should prevent invalid access to valid objects. */ long createReferencePointer(REXP value) throws REngineException, REXPMismatchException { if (value.isReference()) { // if it's reference, return the handle if it's from this engine REXPReference vref = (REXPReference) value; if (vref.getEngine() != this) throw new REXPMismatchException(value, "reference (cross-engine reference is invalid)"); return ((Long)vref.getHandle()).longValue(); } boolean obtainedLock = rniMutex.safeLock(); int upp = 0; try { long ptr = 0; if (value.isNull()) // NULL cannot have attributes, hence get out right away return R_NilValue; else if (value.isLogical()) { int v[] = value.asIntegers(); for (int i = 0; i < v.length; i++) v[i] = (v[i] < 0) ? 2 : ((v[i] == 0) ? 0 : 1); // convert to logical NAs as used by R ptr = rni.rniPutBoolArrayI(v); } else if (value.isInteger()) ptr = rni.rniPutIntArray(value.asIntegers()); else if (value.isRaw()) ptr = rni.rniPutRawArray(value.asBytes()); else if (value.isNumeric()) ptr = rni.rniPutDoubleArray(value.asDoubles()); else if (value.isString()) ptr = rni.rniPutStringArray(value.asStrings()); else if (value.isEnvironment()) { JRIPointer l = (JRIPointer) ((REXPEnvironment)value).getHandle(); if (l == null) { // no associated reference, create a new environemnt long p = rni.rniParse("new.env(parent=baseenv())", 1); ptr = rni.rniEval(p, 0); /* TODO: should we handle REngineEvalException.ERROR and REngineEvalException.INVALID_INPUT here, for completeness */ } else ptr = l.pointer(); } else if (value.isPairList()) { // LISTSXP / LANGSXP boolean lang = value.isLanguage(); RList rl = value.asList(); ptr = R_NilValue; int j = rl.size(); if (j == 0) ptr = rni.rniCons(R_NilValue, 0, 0, lang); else // we are in a somewhat unfortunate situation because we cannot append to the list (RNI has no rniSetCDR!) so we have to use Preserve and bulild the list backwards which may be a bit slower ... for (int i = j - 1; i >= 0; i--) { REXP v = rl.at(i); String n = rl.keyAt(i); long sn = 0; if (n != null) sn = rni.rniInstallSymbol(n); long vptr = createReferencePointer(v); if (vptr == 0) vptr = R_NilValue; long ent = rni.rniCons(vptr, ptr, sn, (i == 0) && lang); /* only the head should be LANGSXP I think - verify ... */ rni.rniPreserve(ent); // preserve current head rni.rniRelease(ptr); // release previous head (since it's part of the new one already) ptr = ent; } } else if (value.isList()) { // VECSXP int init_upp = upp; RList rl = value.asList(); long xl[] = new long[rl.size()]; for (int i = 0; i < xl.length; i++) { REXP rv = rl.at(i); if (rv == null || rv.isNull()) xl[i] = R_NilValue; else { long lv = createReferencePointer(rv); if (lv != 0 && lv != R_NilValue) { rni.rniProtect(lv); upp++; } else lv = R_NilValue; xl[i] = lv; } } ptr = rni.rniPutVector(xl); if (init_upp > upp) { rni.rniUnprotect(upp - init_upp); upp = init_upp; } } else if (value.isSymbol()) return rni.rniInstallSymbol(value.asString()); // symbols need no attribute handling, hence get out right away else if (value instanceof REXPJavaReference) { // we wrap Java references by calling new("jobjRef", ...) Object jval = ((REXPJavaReference)value).getObject(); long jobj = rni.rniJavaToXref(jval); rni.rniProtect(jobj); long jobj_sym = rni.rniInstallSymbol("jobj"); long jclass_sym = rni.rniInstallSymbol("jclass"); String clname = "java/lang/Object"; if (jval != null) { clname = jval.getClass().getName(); clname = clname.replace('.', '/'); } long jclass = rni.rniPutString(clname); rni.rniProtect(jclass); long jobjRef = rni.rniPutString("jobjRef"); rni.rniProtect(jobjRef); long ro = rni.rniEval(rni.rniLCons(rni.rniInstallSymbol("new"), rni.rniCons(jobjRef, rni.rniCons(jobj, rni.rniCons(jclass, R_NilValue, jclass_sym, false), jobj_sym, false)) ), 0); rni.rniUnprotect(3); ptr = ro; } if (ptr == R_NilValue) return ptr; if (ptr != 0) { REXPList att = value._attr(); if (att == null || !att.isPairList()) return ptr; // no valid attributes? the we're done RList al = att.asList(); if (al == null || al.size() < 1 || !al.isNamed()) return ptr; // again - no valid list, get out rni.rniProtect(ptr); // symbols and other exotic creatures are already out by now, so it's ok to protect upp++; for (int i = 0; i < al.size(); i++) { REXP v = al.at(i); String n = al.keyAt(i); if (n != null) { long vptr = createReferencePointer(v); if (vptr != 0 && vptr != R_NilValue) rni.rniSetAttr(ptr, n, vptr); } } return ptr; } } finally { if (upp > 0) rni.rniUnprotect(upp); if (obtainedLock) rniMutex.unlock(); } // we fall thgough here if the object cannot be handled or something went wrong return 0; } public void finalizeReference(REXP ref) throws REngineException, REXPMismatchException { if (ref != null && ref.isReference()) { long ptr = ((Long)((REXPReference)ref).getHandle()).longValue(); boolean obtainedLock = rniMutex.safeLock(); try { rni.rniRelease(ptr); } finally { if (obtainedLock) rniMutex.unlock(); } } } public REXP getParentEnvironment(REXP env, boolean resolve) throws REngineException, REXPMismatchException { REXP ref = null; long rho = 0; if (env != null && !env.isReference()) { if (!env.isEnvironment() || ((REXPEnvironment)env).getHandle() == null) throw(new REXPMismatchException(env, "environment")); else rho = ((JRIPointer)((REXPEnvironment)env).getHandle()).pointer(); } else if (env != null) rho = ((Long)((REXPReference)env).getHandle()).longValue(); boolean obtainedLock = rniMutex.safeLock(); try { long pr = rni.rniParentEnv(rho); if (pr == 0 || pr == R_NilValue) return null; // this should never happen, really rni.rniPreserve(pr); ref = new REXPReference(this, new Long(pr)); if (resolve) ref = resolveReference(ref); } finally { if (obtainedLock) rniMutex.unlock(); } return ref; } public REXP newEnvironment(REXP parent, boolean resolve) throws REXPMismatchException, REngineException { REXP ref = null; boolean obtainedLock = rniMutex.safeLock(); try { long rho = 0; if (parent != null && !parent.isReference()) { if (!parent.isEnvironment() || ((REXPEnvironment)parent).getHandle() == null) throw(new REXPMismatchException(parent, "environment")); else rho = ((JRIPointer)((REXPEnvironment)parent).getHandle()).pointer(); } else if (parent != null) rho = ((Long)((REXPReference)parent).getHandle()).longValue(); if (rho == 0) rho = ((Long)((REXPReference)globalEnv).getHandle()).longValue(); long p = rni.rniEval(rni.rniLCons(rni.rniInstallSymbol("new.env"), rni.rniCons(rho, R_NilValue, rni.rniInstallSymbol("parent"), false)), 0); /* TODO: should we handle REngineEvalException.INVALID_INPUT and REngineEvalException.ERROR here, for completeness */ if (p != 0) rni.rniPreserve(p); ref = new REXPReference(this, new Long(p)); if (resolve) ref = resolveReference(ref); } finally { if (obtainedLock) rniMutex.unlock(); } return ref; } public boolean close() { if (rni == null) return false; rni.end(); return true; } /** attempts to obtain a lock for this R engine synchronously (without waiting for it). @return 0 if the lock could not be obtained (R is busy) and some other value otherwise (1 = lock obtained, 2 = the current thread already holds a lock) -- the returned value must be used in a matching call to {@link #unlock(int)}. */ public synchronized int tryLock() { int res = rniMutex.tryLock(); return (res == 1) ? 0 : ((res == -1) ? 2 : 1); } /** obains a lock for this R engine, waiting until it becomes available. @return value that must be passed to {@link #unlock} in order to release the lock */ public synchronized int lock() { return rniMutex.safeLock() ? 1 : 2; } /** releases a lock previously obtained by {@link #lock()} or {@link #tryLock()}. @param lockValue value returned by {@link #lock()} or {@link #tryLock()}. */ public synchronized void unlock(int lockValue) { if (lockValue == 1) rniMutex.unlock(); } public boolean supportsReferences() { return true; } public boolean supportsEnvironments() { return true; } // public boolean supportsREPL() { return true; } public boolean supportsLocking() { return true; } /** * creates a jobjRef reference in R via rJava.
Important: rJava must be loaded and intialized in R (e.g. via eval("{library(rJava);.jinit()}",false), otherwise this will fail. Requires rJava 0.4-13 or higher! * * @param o object to push to R * * @return unresolved REXPReference of the newly created jobjRef object * or null upon failure */ public REXPReference createRJavaRef(Object o) throws REngineException { /* precaution */ if( o == null ){ return null ; } /* call Rengine api and make REXPReference from the result */ REXPReference ref = null ; boolean obtainedLock = rniMutex.safeLock(); try { org.rosuda.JRI.REXP rx = rni.createRJavaRef( o ); if( rx == null){ throw new REngineException( this, "Could not push java Object to R" ) ; } else{ long p = rx.xp; rni.rniPreserve(p) ; ref = new REXPReference( this, new Long(p) ) ; } } finally { if (obtainedLock) rniMutex.unlock(); } return ref ; } /** JRI callbacks forwarding */ public void rWriteConsole (Rengine re, String text, int oType) { if (callbacks != null && callbacks instanceof REngineOutputInterface) ((REngineOutputInterface)callbacks).RWriteConsole(this, text, oType); } public void rBusy (Rengine re, int which) { if (callbacks != null && callbacks instanceof REngineUIInterface) ((REngineUIInterface)callbacks).RBusyState(this, which); } public synchronized String rReadConsole (Rengine re, String prompt, int addToHistory) { if (callbacks != null && callbacks instanceof REngineInputInterface) return ((REngineInputInterface)callbacks).RReadConsole(this, prompt, addToHistory); try { wait(); } catch (Exception e) {} return ""; } public void rShowMessage (Rengine re, String message) { if (callbacks != null && callbacks instanceof REngineOutputInterface) ((REngineOutputInterface)callbacks).RShowMessage(this, message); } public String rChooseFile (Rengine re, int newFile) { if (callbacks != null && callbacks instanceof REngineUIInterface) return ((REngineUIInterface)callbacks).RChooseFile(this, (newFile == 0)); return null; } public void rFlushConsole (Rengine re) { if (callbacks != null && callbacks instanceof REngineOutputInterface) ((REngineOutputInterface)callbacks).RFlushConsole(this); } public void rSaveHistory (Rengine re, String filename) { if (callbacks != null && callbacks instanceof REngineConsoleHistoryInterface) ((REngineConsoleHistoryInterface)callbacks).RSaveHistory(this, filename); } public void rLoadHistory (Rengine re, String filename) { if (callbacks != null && callbacks instanceof REngineConsoleHistoryInterface) ((REngineConsoleHistoryInterface)callbacks).RLoadHistory(this, filename); } } Rserve/clients/java/JRI/test/0000755000176000001440000000000012205226215015532 5ustar ripleyusersRserve/clients/java/JRI/test/Makefile0000644000176000001440000000122013442516164017176 0ustar ripleyusers## NOTE: the tests require rJava to be installed in the current R ## since they also test the JRI/rJava connectivity CP=../../REngine.jar:../JRIEngine.jar:$(RJAVA)/java/boot:$(RJAVA)/jri/JRI.jar JFLAGS=-source 1.4 -target 1.4 RJAVA=$(shell echo "cat(system.file(package='rJava'))"|R --slave --no-save) JRI=$(shell if test -e ../../../JRI/src/JRI.jar; then echo ../../../JRI/src; else echo $(RJAVA)/jri; fi) JRT=-Djava.library.path=$(JRI):. JAVAC=javac JAVA=java all: run RTest.class: RTest.java $(JAVAC) $(JFLAGS) -classpath $(CP) $^ run: RTest.class R CMD $(JAVA) -cp $(CP):. $(JRT) RTest clean: rm -rf org *.class *~ .PHONY: run clean Rserve/clients/java/JRI/test/RTest.java0000644000176000001440000004134412205226215017444 0ustar ripleyusersimport org.rosuda.REngine.*; class TestException extends Exception { public TestException(String msg) { super(msg); } } // This is the same test as in Rserve but it's using JRI instead public class RTest { public static void main(String[] args) { try { // the simple initialization is done using // REngine eng = REngine.engineForClass("org.rosuda.REngine.JRI.JRIEngine"); // but the one below allows us to see all output from R via REngineStdOutput() // However, it won't succeed if the engine doesn't support callbacks, so be prepared to fall back REngine eng = REngine.engineForClass("org.rosuda.REngine.JRI.JRIEngine", args, new REngineStdOutput(), false); if (args.length > 0 && args[0].equals("--debug")) { // --debug waits for so a debugger can be attached System.out.println("R Version: " + eng.parseAndEval("R.version.string").asString()); System.out.println("ok, connected, press to continue\n"); System.in.read(); } { System.out.println("* Test string and list retrieval"); RList l = eng.parseAndEval("{d=data.frame(\"huhu\",c(11:20)); lapply(d,as.character)}").asList(); int cols = l.size(); int rows = l.at(0).length(); String[][] s = new String[cols][]; for (int i=0; i { .env <- new.env(); .env$x <- 2 }" ); System.out.println( " env = eng.get(\".env\", null, false ) " ); System.out.print( " parseAndEval( \"x+1\", env, true)" ); if( !( x instanceof REXPDouble ) || x.asDouble() != 3.0 ) throw new TestException("eval within environment failed") ; System.out.println( " == 3.0 : ok" ); System.out.println("PASSED"); } /* SU: wrap() tests removed since they didn't even compile ... */ { System.out.println("* Test generation of exceptions"); /* parse exceptions */ String cmd = "rnorm(10))" ; // syntax error System.out.println(" eng.parse(\"rnorm(10))\", false ) -> REngineException( \"Parse Error\" ) " ) ; boolean ok = false; try{ eng.parse( cmd, false ) ; } catch( REngineException e){ ok = true ; } if( !ok ){ throw new TestException( "parse did not generate an exception on syntax error" ) ; } System.out.println(" eng.parseAndEval(\"rnorm(10))\" ) -> REngineException( \"Parse Error\" ) " ) ; ok = false; try{ eng.parseAndEval( cmd ) ; } catch( REngineException e){ ok = true ; } if( !ok ){ throw new TestException( "parseAndEval did not generate an exception on syntax error" ) ; } /* eval exceptions */ cmd = "rnorm(5); stop('error'); rnorm(2)" ; System.out.print(" " + cmd ) ; ok = false; try{ eng.parseAndEval( cmd ) ; } catch( REngineException e){ if( e instanceof REngineEvalException ){ ok = true ; } } if( !ok ){ throw new TestException( "error in R did not generate REngineEvalException" ) ; } System.out.println( " -> REngineEvalException : ok" ) ; System.out.println("PASSED"); } { System.out.println("* Test creation of references to java objects"); if (!((REXPLogical)eng.parseAndEval("require(rJava)")).isTRUE()[0]) { System.out.println(" - rJava is not available, skipping test\n"); } else if (!(eng instanceof org.rosuda.REngine.JRI.JRIEngine)) { System.out.println(" - the used engine is not JRIEngine, skipping test\n"); } else { /* try to use rJava before it is initialized */ System.out.print(" checking that rJava generate error if not yet loaded" ) ; boolean error = false; try{ eng.parseAndEval( "p <- .jnew( 'java/awt/Point' ) " ) ; } catch( REngineException e){ error = true ; } if( !error ){ throw new TestException( "rJava not initiliazed, but did not generate error" ) ; } System.out.println( " : ok" ) ; eng.parseAndEval(".jinit()"); REXPReference ref = ((org.rosuda.REngine.JRI.JRIEngine)eng).createRJavaRef( null ); if( ref != null ){ throw new TestException( "null object should create null REXPReference" ) ; } System.out.println(" eng.createRJavaRef(null) -> null : ok" ) ; System.out.println( " pushing a java.awt.Point to R " ) ; java.awt.Point p = new java.awt.Point( 10, 10) ; ref = ((org.rosuda.REngine.JRI.JRIEngine)eng).createRJavaRef( p ); eng.assign( "p", ref ) ; String cmd = "exists('p') && inherits( p, 'jobjRef') && .jclass(p) == 'java.awt.Point' " ; System.out.println( " test if the object was pushed correctly " ) ; boolean ok = ((REXPLogical)eng.parseAndEval( cmd )).isTRUE()[0] ; if( !ok ){ throw new TestException( "could not push java object to R" ) ; } System.out.println( " R> " + cmd + " : ok " ) ; eng.parseAndEval( ".jcall( p, 'V', 'move', 20L, 20L )" ) ; System.out.println(" manipulate the object " ) ; if( p.x != 20 || p.y != 20 ){ throw new TestException( "not modified the java object with R" ) ; } System.out.println(" R> .jcall( p, 'V', 'move', 20L, 20L ) -> p.x == 20 ,p.y == 20 : ok " ) ; /* bug #126, use of .jfield with guess of the return class using reflection */ System.out.print(" using .jfield with reflection (bug #126)" ) ; eng.parseAndEval( ".jfield( p, , 'x')" ) ; /* used to crash the jvm; (not really - the code in the bgu just forgot to init rJava) */ System.out.println(" : ok " ) ; System.out.println("PASSED"); } } /* setEncoding is Rserve's extension - with JRI you have to use UTF-8 locale so this test will fail unless run in UTF-8 { // string encoding test (will work with Rserve 0.5-3 and higher only) System.out.println("* Test string encoding support ..."); String t = "ひらがな"; // hiragana (literally, in hiragana ;)) eng.setStringEncoding("utf8"); // -- Just in case the console is not UTF-8 don't display it //System.out.println(" unicode text: "+t); eng.assign("s", t); REXP x = eng.parseAndEval("nchar(s)"); System.out.println(" nchar = " + x); if (x == null || !x.isInteger() || x.asInteger() != 4) throw new TestException("UTF-8 encoding string length test failed"); // we cannot really test any other encoding .. System.out.println("PASSED"); } */ eng.close(); // close the engine connection System.out.println("Done."); } catch (REXPMismatchException me) { // some type is different from what you (the programmer) expected System.err.println("Type mismatch: "+me); me.printStackTrace(); System.exit(1); } catch (REngineException ee) { // something went wring in the engine System.err.println("REngine exception: "+ee); ee.printStackTrace(); System.exit(1); } catch (ClassNotFoundException cnfe) { // class not found is thrown by engineForClass System.err.println("Cannot find JRIEngine class - please fix your class path!\n"+cnfe); System.exit(1); } catch (Exception e) { // some other exception ... System.err.println("Exception: "+e); e.printStackTrace(); System.exit(1); } } } Rserve/clients/java/JRI/package-info.java0000644000176000001440000000035012205226215017740 0ustar ripleyusers/** * REngine-based interface to JRI * *

* Currently it uses low-level calls from org.rosuda.JRI.Rengine, but * all REXP representations are created based on the org.rosuda.REngine API */ package org.rosuda.REngine.JRI ; Rserve/clients/java/REngineEvalException.java0000644000176000001440000000235012205226215021010 0ustar ripleyuserspackage org.rosuda.REngine ; /** * Exception thrown when an error occurs during eval. * *

* This class is a placeholder and should be extended when more information * can be extracted from R (call stack, etc ... ) *

*/ public class REngineEvalException extends REngineException { /** * Value returned by the rniEval native method when the input passed to eval * is invalid */ public static final int INVALID_INPUT = -1 ; /** * Value returned by the rniEval native method when an error occured during * eval (stop, ...) */ public static final int ERROR = -2 ; /** * Type of eval error */ protected int type ; /** * Constructor * * @param eng associated REngine * @param message error message * @param type type of error (ERROR or INVALID_INPUT) */ public REngineEvalException( REngine eng, String message, int type ){ super( eng, message ); this.type = type ; } /** * Constructor using ERROR type * * @param eng associated REngine * @param message error message */ public REngineEvalException( REngine eng, String message){ this( eng, message, ERROR ); } /** * @return the type of error (ERROR or INVALID_INPUT) */ public int getType(){ return type ; } } Rserve/clients/java/REngineConsoleHistoryInterface.java0000644000176000001440000000117212205226215023050 0ustar ripleyuserspackage org.rosuda.REngine; /** interface defining delegate methods used by {@link REngine} to forward console history callbacks from R. */ public interface REngineConsoleHistoryInterface { /** called when R wants to save the history content. * @param eng calling engine * @param filename name of the file to save command history to */ public void RSaveHistory (REngine eng, String filename); /** called when R wants to load the history content. * @param eng calling engine * @param filename name of the file to load the command history from */ public void RLoadHistory (REngine eng, String filename); } Rserve/clients/java/REngine.java0000644000176000001440000003023612205226215016325 0ustar ripleyuserspackage org.rosuda.REngine; import java.lang.reflect.Method; /** REngine is an abstract base class for all implementations of R engines. Subclasses can implement interfaces to R in many different ways. Clients should always use methods this class instead of its direct subclasses in order to maintian compatibility with any R engine implementation. The canonical way of obtaining a new engine is to call {@link #engineForClass}. All subclasses must implement createEngine() method. */ public abstract class REngine { /** last created engine or null if there is none */ protected static REngine lastEngine = null; /** this is the designated constructor for REngine classes. It uses reflection to call createEngine method on the given REngine class. @param klass fully qualified class-name of a REngine implementation @return REngine implementation or null if createEngine invokation failed */ public static REngine engineForClass(String klass) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, java.lang.reflect.InvocationTargetException { Class cl=Class.forName(klass); if (cl==null) throw(new ClassNotFoundException("can't find engine class "+klass)); Method m=cl.getMethod("createEngine",(Class[])null); Object o=m.invoke(null,(Object[])null); return lastEngine=(REngine)o; } /** This is the extended constructor for REngine classes. It uses reflection to call createEngine method on the given REngine class with some additional control over the engine. Note that not all engines may support the extended version. @param klass fully qualified class-name of a REngine implementation @param args arguments to pass to R for initialization @param callbacks delegate for REngine callbacks or null if callbacks won't be serviced (engine may not support callbacks) @param runREPL if true then REPL will be started (if supported by the engine) @return REngine implementation or null if createEngine invokation failed */ public static REngine engineForClass(String klass, String[] args, REngineCallbacks callbacks, boolean runREPL) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, java.lang.reflect.InvocationTargetException { Class cl = Class.forName(klass); if (cl == null) throw new ClassNotFoundException("can't find engine class " + klass); Method m = cl.getMethod("createEngine", new Class[] { String[].class, REngineCallbacks.class, Boolean.TYPE }); Object o = m.invoke(null, new Object[] { args, callbacks, new Boolean(runREPL) }); return lastEngine = (REngine)o; } /** retrieve the last created engine @return last created engine or null if no engine was created yet */ public static REngine getLastEngine() { return lastEngine; } /** parse a string into an expression vector @param text string to parse @param resolve resolve the resulting REXP (true) or just return a reference (false) @return parsed expression */ public abstract REXP parse(String text, boolean resolve) throws REngineException; /** evaluate an expression vector @param what an expression (or vector of such) to evaluate @param where environment to evaluate in (use null for the global environemnt and/or if environments are not supported by the engine) @param resolve resolve the resulting REXP or just return a reference @return the result of the evaluation of the last expression */ public abstract REXP eval(REXP what, REXP where, boolean resolve) throws REngineException, REXPMismatchException; /** assign into an environment @param symbol symbol name @param value value to assign @param env environment to assign to (use null for the global environemnt and/or if environments are not supported by the engine) */ public abstract void assign(String symbol, REXP value, REXP env) throws REngineException, REXPMismatchException; /** get a value from an environment @param symbol symbol name @param env environment (use null for the global environemnt and/or if environments are not supported by the engine) @param resolve resolve the resulting REXP or just return a reference @return value */ public abstract REXP get(String symbol, REXP env, boolean resolve) throws REngineException, REXPMismatchException; /** fetch the contents of the given reference. The resulting REXP may never be REXPReference. The engine should raise a {@link #REngineException} exception if {@link #supportsReferences()} returns false. @param ref reference to resolve @return resolved reference */ public abstract REXP resolveReference(REXP ref) throws REngineException, REXPMismatchException; /** create a reference by pushing local data to R and returning a reference to the data. If ref is a reference it is returned as-is. The engine should raise a {@link #REngineException} exception if {@link #supportsReferences()} returns false. @param value to create reference to @return reference to the value */ public abstract REXP createReference(REXP value) throws REngineException, REXPMismatchException; /** removes reference from the R side. This method is called automatically by the finalizer of REXPReference and should never be called directly. @param ref reference to finalize */ public abstract void finalizeReference(REXP ref) throws REngineException, REXPMismatchException; /** get the parent environemnt of an environemnt @param env environment to query @param resolve whether to resolve the resulting environment reference @return parent environemnt of env */ public abstract REXP getParentEnvironment(REXP env, boolean resolve) throws REngineException, REXPMismatchException; /** create a new environemnt @param parent parent environment @param resolve whether to resolve the reference to the environemnt (usually false since the returned environment will be empty) @return resulting environment */ public abstract REXP newEnvironment(REXP parent, boolean resolve) throws REngineException, REXPMismatchException; /** convenince method equivalent to eval(parse(text, false), where, resolve); @param text to parse (see {@link #parse}) @param where environment to evaluate in (see {@link #eval}) @param resolve whether to resolve the resulting reference or not (see {@link #eval}) @return result */ public REXP parseAndEval(String text, REXP where, boolean resolve) throws REngineException, REXPMismatchException { REXP p = parse(text, false); return eval(p, where, resolve); } /** convenince method equivalent to eval(parse(cmd, false), null, true); @param cmd expression to parse (see {@link #parse}) @return result */ public REXP parseAndEval(String cmd) throws REngineException, REXPMismatchException { return parseAndEval(cmd, null, true); }; /** performs a close operation on engines that support it. The engine may not be used after close() returned true. This operation is optional and will always return false if not implemented. @return true if the close opetaion was successful, false otherwise. */ public boolean close() { return false; } //--- capabilities --- /** check whether this engine supports references to R objects @return true if this engine supports references, false/code> otherwise */ public boolean supportsReferences() { return false; } /** check whether this engine supports handing of environments (if not, {@link #eval} and {@link #assign} only support the global environment denoted by null). @return true if this engine supports environments, false/code> otherwise */ public boolean supportsEnvironments() { return false; } /** check whether this engine supports REPL (Read-Evaluate-Print-Loop) and corresponding callbacks. @return true if this engine supports REPL, false/code> otherwise */ public boolean supportsREPL() { return false; } /** check whether this engine supports locking ({@link #lock}, {@link #tryLock} and {@link #unlock}). @return true if this engine supports REPL, false/code> otherwise */ public boolean supportsLocking() { return false; } //--- convenience methods --- (the REXPMismatchException catches should be no-ops since the value type is guaranteed in the call to assign) /** convenience method equivalent to assign(symbol, new REXPDouble(d), null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d values to assign */ public void assign(String symbol, double[] d) throws REngineException { try { assign(symbol, new REXPDouble(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,double[]): "+e)); } } /** convenience method equivalent to assign(symbol, new REXPInteger(d), null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d values to assign */ public void assign(String symbol, int[] d) throws REngineException { try { assign(symbol, new REXPInteger(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,int[]): "+e)); } } /** convenience method equivalent to assign(symbol, new REXPString(d), null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d values to assign */ public void assign(String symbol, String[] d) throws REngineException { try { assign(symbol, new REXPString(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,String[]): "+e)); } } /** convenience method equivalent to assign(symbol, new REXPRaw(d), null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d values to assign */ public void assign(String symbol, byte[] d) throws REngineException { try { assign(symbol, new REXPRaw(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,byte[]): "+e)); } } /** convenience method equivalent to assign(symbol, new REXPString(d), null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d value to assign */ public void assign(String symbol, String d) throws REngineException { try { assign(symbol, new REXPString(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,String[]): "+e)); } } /** convenience method equivalent to assign(symbol, value, null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param value values to assign */ public void assign(String symbol, REXP value) throws REngineException, REXPMismatchException { assign(symbol, value, null); } //--- locking API --- /** attempts to obtain a lock for this R engine synchronously (without waiting for it).
Note: check for {@link #supportsLocking()} before relying on this capability. If not implemented, always returns 0. @return 0 if the lock could not be obtained (R engine is busy) and some other value otherwise -- the returned value must be used in a matching call to {@link #unlock(int)}. */ public synchronized int tryLock() { return 0; } /** obtains a lock for this R engine, waiting until it becomes available.
Note: check for {@link #supportsLocking()} before relying on this capability. If not implemented, always returns 0. @return value that must be passed to {@link #unlock} in order to release the lock */ public synchronized int lock() { return 0; } /** releases a lock previously obtained by {@link #lock()} or {@link #tryLock()}.
Note: check for {@link #supportsLocking()} before relying on this capability. If not implemented, has no effect. @param lockValue value returned by {@link #lock()} or {@link #tryLock()}. */ public synchronized void unlock(int lockValue) {} public String toString() { return super.toString()+((lastEngine==this)?"{last}":""); } public REXP wrap(Object o){ return REXPWrapper.wrap(o); } } Rserve/clients/java/REXP.java0000644000176000001440000003456412205226215015564 0ustar ripleyuserspackage org.rosuda.REngine; /** Basic class representing an object of any type in R. Each type in R in represented by a specific subclass.

This class defines basic accessor methods (asXXX), type check methods (isXXX), gives access to attributes ({@link #getAttribute}, {@link #hasAttribute}) as well as several convenience methods. If a given method is not applicable to a particular type, it will throw the {@link REXPMismatchException} exception.

This root class will throw on any accessor call and returns false for all type methods. This allows subclasses to override accessor and type methods selectively. */ public class REXP { /** attribute list. This attribute should never be accessed directly. */ protected REXPList attr; /** public root contrsuctor, same as new REXP(null) */ public REXP() { } /** public root constructor @param attr attribute list object (can be null */ public REXP(REXPList attr) { this.attr=attr; } // type checks /** check whether the REXP object is a character vector (string) @return true if the receiver is a character vector, false otherwise */ public boolean isString() { return false; } /** check whether the REXP object is a numeric vector @return true if the receiver is a numeric vector, false otherwise */ public boolean isNumeric() { return false; } /** check whether the REXP object is an integer vector @return true if the receiver is an integer vector, false otherwise */ public boolean isInteger() { return false; } /** check whether the REXP object is NULL @return true if the receiver is NULL, false otherwise */ public boolean isNull() { return false; } /** check whether the REXP object is a factor @return true if the receiver is a factor, false otherwise */ public boolean isFactor() { return false; } /** check whether the REXP object is a list (either generic vector or a pairlist - i.e. {@link #asList()} will succeed) @return true if the receiver is a generic vector or a pair-list, false otherwise */ public boolean isList() { return false; } /** check whether the REXP object is a pair-list @return true if the receiver is a pair-list, false otherwise */ public boolean isPairList() { return false; } /** check whether the REXP object is a logical vector @return true if the receiver is a logical vector, false otherwise */ public boolean isLogical() { return false; } /** check whether the REXP object is an environment @return true if the receiver is an environment, false otherwise */ public boolean isEnvironment() { return false; } /** check whether the REXP object is a language object @return true if the receiver is a language object, false otherwise */ public boolean isLanguage() { return false; } /** check whether the REXP object is an expression vector @return true if the receiver is an expression vector, false otherwise */ public boolean isExpression() { return false; } /** check whether the REXP object is a symbol @return true if the receiver is a symbol, false otherwise */ public boolean isSymbol() { return false; } /** check whether the REXP object is a vector @return true if the receiver is a vector, false otherwise */ public boolean isVector() { return false; } /** check whether the REXP object is a raw vector @return true if the receiver is a raw vector, false otherwise */ public boolean isRaw() { return false; } /** check whether the REXP object is a complex vector @return true if the receiver is a complex vector, false otherwise */ public boolean isComplex() { return false; } /** check whether the REXP object is a recursive obejct @return true if the receiver is a recursive object, false otherwise */ public boolean isRecursive() { return false; } /** check whether the REXP object is a reference to an R object @return true if the receiver is a reference, false otherwise */ public boolean isReference() { return false; } // basic accessor methods /** returns the contents as an array of Strings (if supported by the represented object) */ public String[] asStrings() throws REXPMismatchException { throw new REXPMismatchException(this, "String"); } /** returns the contents as an array of integers (if supported by the represented object) */ public int[] asIntegers() throws REXPMismatchException { throw new REXPMismatchException(this, "int"); } /** returns the contents as an array of doubles (if supported by the represented object) */ public double[] asDoubles() throws REXPMismatchException { throw new REXPMismatchException(this, "double"); } /** returns the contents as an array of bytes (if supported by the represented object) */ public byte[] asBytes() throws REXPMismatchException { throw new REXPMismatchException(this, "byte"); } /** returns the contents as a (named) list (if supported by the represented object) */ public RList asList() throws REXPMismatchException { throw new REXPMismatchException(this, "list"); } /** returns the contents as a factor (if supported by the represented object) */ public RFactor asFactor() throws REXPMismatchException { throw new REXPMismatchException(this, "factor"); } /** attempt to represent the REXP by a native Java object and return it. Note that this may lead to loss of information (e.g., factors may be returned as a string array) and attributes are ignored. Not all R types can be converted to native Java objects. Also note that R has no concept of scalars, so vectors of length 1 will always be returned as an arrays (i.e., int[1] and not Integer). */ public Object asNativeJavaObject() throws REXPMismatchException { throw new REXPMismatchException(this, "native Java Object"); } /** returns the length of a vector object. Note that we use R semantics here, i.e. a matrix will have a length of m * n since it is represented by a single vector (see {@link #dim} for retrieving matrix and multidimentional-array dimensions). * @return length (number of elements) in a vector object * @throws REXPMismatchException if this is not a vector object */ public int length() throws REXPMismatchException { throw new REXPMismatchException(this, "vector"); } /** returns a boolean vector of the same length as this vector with true for NA values and false for any other values * @return a boolean vector of the same length as this vector with true for NA values and false for any other values * @throws REXPMismatchException if this is not a vector object */ public boolean[] isNA() throws REXPMismatchException { throw new REXPMismatchException(this, "vector"); } // convenience accessor methods /** convenience method corresponding to asIntegers()[0] @return first entry returned by {@link #asInteger} */ public int asInteger() throws REXPMismatchException { int[] i = asIntegers(); return i[0]; } /** convenience method corresponding to asDoubles()[0] @return first entry returned by {@link #asDoubles} */ public double asDouble() throws REXPMismatchException { double[] d = asDoubles(); return d[0]; } /** convenience method corresponding to asStrings()[0] @return first entry returned by {@link #asStrings} */ public String asString() throws REXPMismatchException { String[] s = asStrings(); return s[0]; } // methods common to all REXPs /** retrieve an attribute of the given name from this object * @param name attribute name * @return attribute value or null if the attribute does not exist */ public REXP getAttribute(String name) { final REXPList a = _attr(); if (a==null || !a.isList()) return null; return a.asList().at(name); } /** checks whether this obejct has a given attribute * @param name attribute name * @return true if the attribute exists, false otherwise */ public boolean hasAttribute(String name) { final REXPList a = _attr(); return (a!=null && a.isList() && a.asList().at(name)!=null); } // helper methods common to all REXPs /** returns dimensions of the object (as determined by the "dim" attribute) * @return an array of integers with corresponding dimensions or null if the object has no dimension attribute */ public int[] dim() { try { return hasAttribute("dim")?_attr().asList().at("dim").asIntegers():null; } catch (REXPMismatchException me) { } return null; } /** determines whether this object inherits from a given class in the same fashion as the inherits() function in R does (i.e. ignoring S4 inheritance) * @param klass class name * @return true if this object is of the class klass, false otherwise */ public boolean inherits(String klass) { if (!hasAttribute("class")) return false; try { String c[] = getAttribute("class").asStrings(); if (c != null) { int i = 0; while (i < c.length) { if (c[i]!=null && c[i].equals(klass)) return true; i++; } } } catch (REXPMismatchException me) { } return false; } /** this method allows a limited access to object's attributes - {@link #getAttribute} should be used instead to access specific attributes!. Note that the {@link #attr} attribute should never be used directly incase the REXP implements a lazy access (e.g. via a reference) @return list of attributes or null if the object has no attributes */ public REXPList _attr() { return attr; } /** returns a string description of the object @return string describing the object - it can be of an arbitrary form and used only for debugging (do not confuse with {@link #asString()} for accessing string REXPs) */ public String toString() { return super.toString()+((attr!=null)?"+":""); } /** returns representation that it useful for debugging (e.g. it includes attributes and may include vector values -- see {@link #maxDebugItems}) @return extended description of the obejct -- it may include vector values */ public String toDebugString() { return (attr!=null)?(("<"+attr.toDebugString()+">")+super.toString()):super.toString(); } //======= complex convenience methods /** returns the content of the REXP as a matrix of doubles (2D-array: m[rows][cols]). This is the same form as used by popular math packages for Java, such as JAMA. This means that following leads to desired results:
Matrix m=new Matrix(c.eval("matrix(c(1,2,3,4,5,6),2,3)").asDoubleMatrix());
@return 2D array of doubles in the form double[rows][cols] or null if the contents is no 2-dimensional matrix of doubles */ public double[][] asDoubleMatrix() throws REXPMismatchException { double[] ct = asDoubles(); REXP dim = getAttribute("dim"); if (dim == null) throw new REXPMismatchException(this, "matrix (dim attribute missing)"); int[] ds = dim.asIntegers(); if (ds.length != 2) throw new REXPMismatchException(this, "matrix (wrong dimensionality)"); int m = ds[0], n = ds[1]; double[][] r = new double[m][n]; // R stores matrices as matrix(c(1,2,3,4),2,2) = col1:(1,2), col2:(3,4) // we need to copy everything, since we create 2d array from 1d array int k = 0; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) r[j][i] = ct[k++]; return r; } /** creates a REXP that represents a double matrix in R based on matrix of doubles (2D-array: m[rows][cols]). This is the same form as used by popular math packages for Java, such as JAMA. The result of this function can be used in {@link REngine.assign} to store a matrix in R. @param matrix array double[rows][colums] containing the matrix to convert into a REXP. If matrix is null or either of the dimensions is 0 then the resulting matrix will have the dimensions 0 x 0 (Note: Java cannot represent 0 x n matrices for n > 0, so special matrices with one dimension of 0 can only be created by setting dimensions directly). @return REXPDouble with "dim" attribute which constitutes a matrix in R */ public static REXP createDoubleMatrix(double[][] matrix) { int m = 0, n = 0; double a[]; if (matrix != null && matrix.length != 0 && matrix[0].length != 0) { m = matrix.length; n = matrix[0].length; a = new double[m * n]; int k = 0; for (int j = 0; j < n; j++) for (int i = 0; i < m; i++) a[k++] = matrix[i][j]; } else a = new double[0]; return new REXPDouble(a, new REXPList( new RList( new REXP[] { new REXPInteger(new int[] { m, n }) }, new String[] { "dim" }) ) ); } //======= tools /** creates a data frame object from a list object using integer row names * @param l a (named) list of vectors ({@link REXPVector} subclasses), each element corresponds to a column and all elements must have the same length * @return a data frame object * @throws REXPMismatchException if the list is empty or any of the elements is not a vector */ public static REXP createDataFrame(RList l) throws REXPMismatchException { if (l == null || l.size() < 1) throw new REXPMismatchException(new REXPList(l), "data frame (must have dim>0)"); if (!(l.at(0) instanceof REXPVector)) throw new REXPMismatchException(new REXPList(l), "data frame (contents must be vectors)"); REXPVector fe = (REXPVector) l.at(0); return new REXPGenericVector(l, new REXPList( new RList( new REXP[] { new REXPString("data.frame"), new REXPString(l.keys()), new REXPInteger(new int[] { REXPInteger.NA, -fe.length() }) }, new String[] { "class", "names", "row.names" }))); } /** specifies how many items of a vector or list will be displayed in {@link #toDebugString} */ public static int maxDebugItems = 32; } Rserve/clients/java/REXPLogical.java0000644000176000001440000001251712205226215017051 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPLogical represents a vector of logical values (TRUE, FALSE or NA). Unlike Java's boolean type R's logicals support NA values therefore either of {@link #isTRUE()}, {@link #isFALSE()} or {@link #isNA()} must be used to convert logicals to boolean values. */ public class REXPLogical extends REXPVector { protected byte[] payload; /** NA integer value as defined in R. Unlike its real equivalent this one can be used in comparisons, although {@link #isNA(int) } is provided for consistency. */ static final int NA_internal = -2147483648; /** NA boolean value as used in REXPLogical implementation. This differs from the value used in R since R uses int data type and we use byte. Unlike its real equivalent this one can be used in comparisons, although {@link #isNA(byte) } is provided for consistency. */ public static final byte NA = -128; public static final byte TRUE = 1; public static final byte FALSE = 0; public static boolean isNA(byte value) { return (value == NA); } /** create logical vector of the length 1 with the given value as its first (and only) element */ public REXPLogical(boolean load) { super(); payload = new byte[] { load ? TRUE : FALSE }; } /** create logical vector of the length 1 with the given value as its first (and only) element */ public REXPLogical(byte load) { super(); payload = new byte[] { load }; } /** create logical vector with the payload specified by load */ public REXPLogical(byte[] load) { super(); payload = (load==null) ? new byte[0]:load; } /** create logical vector with the payload specified by load */ public REXPLogical(boolean[] load) { super(); payload = new byte[(load == null) ? 0 : load.length]; if (load != null) for (int i = 0; i < load.length; i++) payload[i] = load[i] ? TRUE : FALSE; } /** create integer vector with the payload specified by load and attributes attr */ public REXPLogical(byte[] load, REXPList attr) { super(attr); payload = (load==null) ? new byte[0] : load; } /** create integer vector with the payload specified by load and attributes attr */ public REXPLogical(boolean[] load, REXPList attr) { super(attr); payload = new byte[(load == null) ? 0 : load.length]; if (load != null) for (int i = 0; i < load.length; i++) payload[i] = load[i] ? TRUE : FALSE; } public int length() { return payload.length; } public boolean isLogical() { return true; } public Object asNativeJavaObject() { return payload; } public int[] asIntegers() { int p[] = new int[payload.length]; for (int i = 0; i < payload.length; i++) // map bytes to integers including NA representation p[i] = (payload[i] == NA) ? REXPInteger.NA : ((payload[i] == FALSE) ? 0 : 1); return p; } public byte[] asBytes() { return payload; } /** returns the contents of this vector as doubles */ public double[] asDoubles() { double[] d = new double[payload.length]; for (int i = 0; i < payload.length; i++) d[i] = (payload[i] == NA) ? REXPDouble.NA : ((payload[i] == FALSE) ? 0.0 : 1.0); return d; } /** returns the contents of this vector as strings */ public String[] asStrings() { String[] s = new String[payload.length]; for (int i = 0; i < payload.length; i++) s[i] = (payload[i] == NA) ? "NA" : ((payload[i] == FALSE) ? "FALSE" : "TRUE"); return s; } public boolean[] isNA() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = (payload[i] == NA); i++; } return a; } /** returns a boolean array of the same langth as the receiver with true for TRUE values and false for FALSE and NA values. @return boolean array */ public boolean[] isTRUE() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = (payload[i] != NA && payload[i] != FALSE); i++; } return a; } /** returns a boolean array of the same langth as the receiver with true for FALSE values and false for TRUE and NA values. @return boolean array */ public boolean[] isFALSE() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = (payload[i] == FALSE); i++; } return a; } /** returns a boolean array of the same langth as the receiver with true for TRUE values and false for FALSE and NA values. @return boolean array @deprecated replaced by {@link #isTRUE()} for consistency with R nomenclature. */ public boolean[] isTrue() { return isTRUE(); } /** returns a boolean array of the same langth as the receiver with true for FALSE values and false for TRUE and NA values. @return boolean array @deprecated replaced by {@link #isTRUE()} for consistency with R nomenclature. */ public boolean[] isFalse() { return isFALSE(); } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.length && i < maxDebugItems) { if (i>0) sb.append(","); sb.append((payload[i] == NA) ? "NA" : ((payload[i] == FALSE) ? "FALSE" : "TRUE")); i++; } if (i < payload.length) sb.append(",.."); return sb.toString()+"}"; } } Rserve/clients/java/REngineOutputInterface.java0000644000176000001440000000143512205226215021366 0ustar ripleyuserspackage org.rosuda.REngine; /** interface defining delegate methods used by {@link REngine} to forward output callbacks from R. */ public interface REngineOutputInterface { /** called when R prints output to the console. * @param eng calling engine * @param text text to display in the console * @param oType output type (0=regular, 1=error/warning) */ public void RWriteConsole(REngine eng, String text, int oType); /** called when R wants to show a warning/error message box (not console-related). * @param eng calling engine * @param text text to display in the message */ public void RShowMessage(REngine eng, String text); /** called by R to flush (display) any pending console output. * @param eng calling engine */ public void RFlushConsole(REngine eng); } Rserve/clients/java/REXPFactor.java0000644000176000001440000000455212205226215016715 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPFactor represents a factor in R. It is an integer vector with levels for each contained category. */ // FIXME: this is currently somehow screwed - the concept of RFactor and REXPFactor is duplicate - we need to remove this historical baggage public class REXPFactor extends REXPInteger { private String[] levels; private RFactor factor; /** create a new factor REXP * @param ids indices (one-based!) * @param levels levels */ public REXPFactor(int[] ids, String[] levels) { super(ids); this.levels = (levels==null)?(new String[0]):levels; factor = new RFactor(this.payload, this.levels, false, 1); attr = new REXPList( new RList( new REXP[] { new REXPString(this.levels), new REXPString("factor") }, new String[] { "levels", "class" })); } /** create a new factor REXP * @param ids indices (one-based!) * @param levels levels * @param attr attributes */ public REXPFactor(int[] ids, String[] levels, REXPList attr) { super(ids, attr); this.levels = (levels==null)?(new String[0]):levels; factor = new RFactor(this.payload, this.levels, false, 1); } /** create a new factor REXP from an existing RFactor * @param factor factor object (can be of any index base, the contents will be pulled with base 1) */ public REXPFactor(RFactor factor) { super(factor.asIntegers(1)); this.factor = factor; this.levels = factor.levels(); attr = new REXPList( new RList( new REXP[] { new REXPString(this.levels), new REXPString("factor") }, new String[] { "levels", "class" })); } /** create a new factor REXP from an existing RFactor * @param factor factor object (can be of any index base, the contents will be pulled with base 1) * @param attr attributes */ public REXPFactor(RFactor factor, REXPList attr) { super(factor.asIntegers(1), attr); this.factor = factor; this.levels = factor.levels(); } public boolean isFactor() { return true; } /** return the contents as a factor - the factor is guaranteed to have index base 1 * @return the contents as a factor */ public RFactor asFactor() { return factor; } public String[] asStrings() { return factor.asStrings(); } public Object asNativeJavaObject() { return asStrings(); } public String toString() { return super.toString()+"["+levels.length+"]"; } } Rserve/clients/java/REXPSymbol.java0000644000176000001440000000134212205226215016736 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPSymbol represents a symbol in R. */ public class REXPSymbol extends REXP { /** name of the symbol */ private String name; /** create a new symbol of the given name */ public REXPSymbol(String name) { super(); this.name=(name==null)?"":name; } public boolean isSymbol() { return true; } /** returns the name of the symbol * @return name of the symbol */ public String asString() { return name; } public String[] asStrings() { return new String[] { name }; } public String toString() { return getClass().getName()+"["+name+"]"; } public String toDebugString() { return super.toDebugString()+"["+name+"]"; } public Object asNativeJavaObject() { return name; } } Rserve/clients/java/REXPRaw.java0000644000176000001440000000151412205226215016223 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPRaw represents a raw vector in R - essentially a sequence of bytes. */ public class REXPRaw extends REXPVector { private byte[] payload; /** create a new raw vector with the specified payload * @param load payload of the raw vector */ public REXPRaw(byte[] load) { super(); payload=(load==null)?new byte[0]:load; } /** create a new raw vector with the specified payload and attributes * @param load payload of the raw vector * @param attr attributes for the resulting R object */ public REXPRaw(byte[] load, REXPList attr) { super(attr); payload=(load==null)?new byte[0]:load; } public int length() { return payload.length; } public boolean isRaw() { return true; } public byte[] asBytes() { return payload; } public Object asNativeJavaObject() { return payload; } } Rserve/clients/java/REXPWrapper.java0000644000176000001440000001614412205226215017117 0ustar ripleyuserspackage org.rosuda.REngine ; /** * Utility class to wrap an Object into a REXP object. * * This facilitates wrapping native java objects and arrays * into REXP objects that can be pushed to R * * @author Romain Francois */ public class REXPWrapper { /* various classes */ private static Class byte_ARRAY ; private static Class short_ARRAY ; private static Class int_ARRAY ; private static Class long_ARRAY ; private static Class float_ARRAY ; private static Class double_ARRAY ; private static Class boolean_ARRAY ; private static Class String_ARRAY ; private static Class Byte_ARRAY ; private static Class Short_ARRAY; private static Class Integer_ARRAY ; private static Class Long_ARRAY ; private static Class Float_ARRAY ; private static Class Double_ARRAY ; private static Class Boolean_ARRAY ; static{ try{ byte_ARRAY = Class.forName("[B") ; short_ARRAY = Class.forName("[S" ); int_ARRAY = Class.forName("[I" ); long_ARRAY = (new long[1]).getClass() ; /* FIXME */ float_ARRAY = Class.forName("[F" ) ; double_ARRAY = Class.forName("[D" ); boolean_ARRAY = Class.forName("[Z" ) ; String_ARRAY = Class.forName( "[Ljava.lang.String;") ; Byte_ARRAY = Class.forName( "[Ljava.lang.Byte;" ) ; Short_ARRAY = Class.forName( "[Ljava.lang.Short;" ) ; Integer_ARRAY = Class.forName( "[Ljava.lang.Integer;" ) ; Long_ARRAY = Class.forName( "[Ljava.lang.Long;" ) ; Float_ARRAY = Class.forName( "[Ljava.lang.Float;" ) ; Double_ARRAY = Class.forName( "[Ljava.lang.Double;" ) ; Boolean_ARRAY = Class.forName( "[Ljava.lang.Boolean;" ) ; } catch( Exception e){ // should never happen e.printStackTrace(); System.err.println( "problem while initiating the classes" ) ; } } /** * Wraps an Object into a REXP * *

Conversion :

* *
    *
  • Byte (byte) : REXPRaw
  • *
  • Short (short) : REXPInteger
  • *
  • Integer (int) : REXPInteger
  • *
  • Long (long) : REXPInteger
  • *
  • Float (float) : REXPDouble
  • *
  • Double (double) : REXPDouble
  • *
  • Boolean (boolean) : REXPLogical
  • *
  • --
  • *
  • String : REXPString
  • *
  • String[] : REXPString
  • *
  • --
  • *
  • byte[] or Byte[] : REXPRaw
  • *
  • short[] or Short[] : REXPInteger
  • *
  • int[] or Integer[] : REXPInteger
  • *
  • long[] or Long[] : REXPInteger
  • *
  • float[] or Float[] : REXPDouble
  • *
  • double[] or Double[] : REXPDouble
  • *
  • boolean[] or Boolean[]: REXPLogical
  • *
  • --
  • *
  • null for anything else
  • *
* * @param o object to wrap * @return REXP object that represents o or null if the conversion is not possible */ public static REXP wrap( Object o ) { /* nothing to do in that case */ if( o instanceof REXP){ return (REXP)o; } Class clazz = o.getClass() ; /* primitives */ if( clazz == Byte.class ){ byte[] load = new byte[1]; load[0] = ((Byte)o).byteValue() ; return new REXPRaw( load ); } if( clazz == Short.class ){ return new REXPInteger( ((Short)o).intValue() ) ; } if( clazz == Integer.class ){ return new REXPInteger( ((Integer)o).intValue() ) ; } if( clazz == Long.class ){ return new REXPInteger( ((Long)o).intValue() ) ; } if( clazz == Float.class ){ return new REXPDouble( ((Float)o).doubleValue() ) ; } if( clazz == Double.class ){ return new REXPDouble( ((Double)o).doubleValue() ) ; } if( clazz == Boolean.class ){ return new REXPLogical( ((Boolean)o).booleanValue() ) ; } /* Strings -> REXPString */ if( clazz == String.class ){ return new REXPString( (String)o ) ; } if( clazz == String_ARRAY ){ /* String[] */ return new REXPString( (String[])o ); } /* array of byte or Bytes -> REXPRaw */ if( clazz == byte_ARRAY ){ /* byte[] */ return new REXPRaw( (byte[])o ) ; } if( clazz == Byte_ARRAY ){ /* Byte[] */ Byte[] b = (Byte[])o; int n = b.length ; byte[] bytes = new byte[b.length]; for( int i=0; i REXPInteger */ if( clazz == short_ARRAY ){ /* short[] */ short[] shorts = (short[])o ; int[] ints = new int[ shorts.length ]; int n = ints.length; for( int i=0; i REXPInteger */ if( clazz == int_ARRAY ){ /* int[] */ return new REXPInteger( (int[])o ) ; } if( clazz == Integer_ARRAY ){ /* Integer[] */ Integer[] integers = (Integer[])o; int n = integers.length ; int[] ints = new int[integers.length]; for( int i=0; i REXPInteger */ if( clazz == long_ARRAY ){ /* long[] */ long[] longs = (long[])o; int n = longs.length ; int[] ints = new int[longs.length]; for( int i=0; i REXPDouble */ if( clazz == float_ARRAY ){ /* float[] */ float[] floats = (float[])o; int n = floats.length ; double[] doubles = new double[floats.length]; for( int i=0; i REXPDouble */ if(clazz == double_ARRAY ) { /* double[] */ return new REXPDouble( (double[])o ) ; } if( clazz == Double_ARRAY ){ /* Double[] */ Double[] doubles = (Double[])o; double n = doubles.length ; double[] d = new double[doubles.length]; for( int i=0; i REXPLogical */ if( clazz == boolean_ARRAY ){ /* boolean[] */ return new REXPLogical( (boolean[])o ) ; } if( clazz == Boolean_ARRAY ){ /* Boolean[] */ Boolean[] booleans = (Boolean[])o; int n = booleans.length ; boolean[] b = new boolean[booleans.length]; for( int i=0; ifalse
returns a reference to the object, if false the reference is resolved * @return value corresponding to the symbol name or possibly null if the value is unbound (the latter is currently engine-specific) */ public REXP get(String name, boolean resolve) throws REngineException { try { return eng.get(name, this, resolve); } catch (REXPMismatchException e) { // this should never happen because this is always guaranteed to be REXPEnv throw(new REngineException(eng, "REXPMismatchException:"+e+" in get()")); } } /** get a value from this environment - equavalent to get(name, true). * @param name name of the value * @return value (see {@link #get(String,boolean)}) */ public REXP get(String name) throws REngineException { return get(name, true); } /** assigns a value to a given symbol name * @param name symbol name * @param value value */ public void assign(String name, REXP value) throws REngineException, REXPMismatchException { eng.assign(name, value, this); } /** returns the parent environment or a reference to it * @param resolve if true returns the environemnt, otherwise a reference. * @return parent environemnt (or a reference to it) */ public REXP parent(boolean resolve) throws REngineException { try { return eng.getParentEnvironment(this, resolve); } catch (REXPMismatchException e) { // this should never happen because this is always guaranteed to be REXPEnv throw(new REngineException(eng, "REXPMismatchException:"+e+" in parent()")); } } /** returns the parent environment. This is equivalent to parent(true). * @return parent environemnt */ public REXPEnvironment parent() throws REngineException { return (REXPEnvironment) parent(true); } } Rserve/clients/java/REXPNull.java0000644000176000001440000000174012205226215016405 0ustar ripleyuserspackage org.rosuda.REngine; /** represents a NULL object in R.

Note: there is a slight asymmetry - in R NULL is represented by a zero-length pairlist. For this reason REXPNull returns true for {@link #isList()} and {@link #asList()} will return an empty list. Nonetheless REXPList of the length 0 will NOT return true in {@link #isNull()} (currently), becasue it is considered a different object in Java. These nuances are still subject to change, because it's not clear how it should be treated. At any rate use REXPNull instead of empty REXPList if NULL is the intended value. */ public class REXPNull extends REXP { public REXPNull() { super(); } public REXPNull(REXPList attr) { super(attr); } public boolean isNull() { return true; } public boolean isList() { return true; } // NULL is a list public RList asList() { return new RList(); } public Object asNativeJavaObject() { return null; } } Rserve/clients/java/REXPReference.java0000644000176000001440000000727712205226215017404 0ustar ripleyuserspackage org.rosuda.REngine; /** this class represents a reference (proxy) to an R object.

The reference semantics works by calling {@link #resolve()} (which in turn uses {@link REngine#resolveReference(REXP)} on itself) whenever any methods are accessed. The implementation is not finalized yat and may change as we approach the JRI interface which is more ameanable to reference-style access. Subclasses are free to implement more efficient implementations. */ public class REXPReference extends REXP { /** engine which will be used to resolve the reference */ protected REngine eng; /** an opaque (optional) handle */ protected Object handle; /** resolved (cached) object */ protected REXP resolvedValue; /** create an external REXP reference using given engine and handle. The handle value is just an (optional) identifier not used by the implementation directly. */ public REXPReference(REngine eng, Object handle) { super(); this.eng = eng; this.handle = handle; } /** shortcut for REXPReference(eng, new Long(handle)) that is used by native code */ REXPReference(REngine eng, long handle) { this(eng, new Long(handle)); } /** resolve the external REXP reference into an actual REXP object. In addition, the value (if not null) will be cached for subsequent calls to resolve until invalidate is called. */ public REXP resolve() { if (resolvedValue != null) return resolvedValue; try { resolvedValue = eng.resolveReference(this); return resolvedValue; } catch (REXPMismatchException me) { // this should never happen since we are REXPReference } catch(REngineException ee) { // FIXME: what to we do? } return null; } /** invalidates any cached representation of the reference */ public void invalidate() { resolvedValue = null; } /** finalization that notifies the engine when a reference gets collected */ protected void finalize() throws Throwable { try { eng.finalizeReference(this); } finally { super.finalize(); } } // type checks public boolean isString() { return resolve().isString(); } public boolean isNumeric() { return resolve().isNumeric(); } public boolean isInteger() { return resolve().isInteger(); } public boolean isNull() { return resolve().isNull(); } public boolean isFactor() { return resolve().isFactor(); } public boolean isList() { return resolve().isList(); } public boolean isLogical() { return resolve().isLogical(); } public boolean isEnvironment() { return resolve().isEnvironment(); } public boolean isLanguage() { return resolve().isLanguage(); } public boolean isSymbol() { return resolve().isSymbol(); } public boolean isVector() { return resolve().isVector(); } public boolean isRaw() { return resolve().isRaw(); } public boolean isComplex() { return resolve().isComplex(); } public boolean isRecursive() { return resolve().isRecursive(); } public boolean isReference() { return true; } // basic accessor methods public String[] asStrings() throws REXPMismatchException { return resolve().asStrings(); } public int[] asIntegers() throws REXPMismatchException { return resolve().asIntegers(); } public double[] asDoubles() throws REXPMismatchException { return resolve().asDoubles(); } public RList asList() throws REXPMismatchException { return resolve().asList(); } public RFactor asFactor() throws REXPMismatchException { return resolve().asFactor(); } public int length() throws REXPMismatchException { return resolve().length(); } public REXPList _attr() { return resolve()._attr(); } public Object getHandle() { return handle; } public REngine getEngine() { return eng; } public String toString() { return super.toString()+"{eng="+eng+",h="+handle+"}"; } } Rserve/clients/java/REXPList.java0000644000176000001440000000417012205226215016406 0ustar ripleyuserspackage org.rosuda.REngine; /** Represents a pairlist in R. Unlike the actual internal R implementation this one does not use CAR/CDR/TAG linked representation but a @link{RList} object. */ public class REXPList extends REXPVector { private RList payload; /* create a new pairlist with the contents of a named R list and no attributes. @param list named list with the contents */ public REXPList(RList list) { super(); payload=(list==null)?new RList():list; } /* create a new pairlist with the contents of a named R list and attributes. @param list named list with the contents @param attr attributes */ public REXPList(RList list, REXPList attr) { super(attr); payload=(list==null)?new RList():list; } /* create a pairlist containing just one pair comprising of one value and one name. This is a convenience constructor most commonly used to create attribute pairlists. @param value of the element in the pairlist (must not be null) @param name of the element in the pairlist (must not be null) */ public REXPList(REXP value, String name) { super(); payload = new RList(new REXP[] { value }, new String[] { name }); } public Object asNativeJavaObject() throws REXPMismatchException { // since REXPGenericVector does the hard work, we just cheat and use it in turn REXPGenericVector v = new REXPGenericVector(payload); return v.asNativeJavaObject(); } public int length() { return payload.size(); } public boolean isList() { return true; } public boolean isPairList() { return true; } public boolean isRecursive() { return true; } public RList asList() { return payload; } public String toString() { return super.toString()+(asList().isNamed()?"named":""); } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.size() && i < maxDebugItems) { if (i>0) sb.append(",\n"); String name = payload.keyAt(i); if (name!=null) sb.append(name+"="); sb.append(payload.at(i).toDebugString()); i++; } if (i < payload.size()) sb.append(",.."); return sb.toString()+"}"; } } Rserve/clients/java/REXPString.java0000644000176000001440000000270212205226215016740 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPString represents a character vector in R. */ public class REXPString extends REXPVector { /** payload */ private String[] payload; /** create a new character vector of the length one * @param load first (and only) element of the vector */ public REXPString(String load) { super(); payload=new String[] { load }; } /** create a new character vector * @param load string elements of the vector */ public REXPString(String[] load) { super(); payload=(load==null)?new String[0]:load; } /** create a new character vector with attributes * @param load string elements of the vector * @param attr attributes */ public REXPString(String[] load, REXPList attr) { super(attr); payload=(load==null)?new String[0]:load; } public int length() { return payload.length; } public boolean isString() { return true; } public Object asNativeJavaObject() { return payload; } public String[] asStrings() { return payload; } public boolean[] isNA() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = (payload[i]==null); i++; } return a; } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.length && i < maxDebugItems) { if (i>0) sb.append(","); sb.append("\""+payload[i]+"\""); i++; } if (i < payload.length) sb.append(",.."); return sb.toString()+"}"; } } Rserve/clients/java/RList.java0000644000176000001440000002212512205226215016031 0ustar ripleyuserspackage org.rosuda.REngine; // REngine library - Java client interface to R // Copyright (C) 2004,2007,2008 Simon Urbanek import java.util.*; /** implementation of R-lists
All lists (dotted-pair lists, language lists, expressions and vectors) are regarded as named generic vectors. Note: This implementation has changed radically in Rserve 0.5! This class inofficially implements the Map interface. Unfortunately a conflict in the Java iterface classes Map and List doesn't allow us to implement both officially. Most prominently the Map 'remove' method had to be renamed to removeByKey. @version $Id$ */ public class RList extends Vector implements List { public Vector names; /** constructs an empty list */ public RList() { super(); names=null; } /** constructs an initialized, unnamed list * @param contents - an array of {@link REXP}s to use as contents of this list */ public RList(REXP[] contents) { super(contents.length); int i=0; while (i0) { this.names=new Vector(names.length); int i = 0; while (i < names.length) this.names.add(names[i++]); while (this.names.size()0) { this.names=new Vector(names.length); int i = 0; while (i < names.length) this.names.add(names[i++]); while (this.names.size()0) { this.names=new Vector(names); while (this.names.size()true
if this list is named, false otherwise */ public boolean isNamed() { return names!=null; } /** get xpression given a key @param v key @return value which corresponds to the given key or null if the list is unnamed or key not found */ public REXP at(String v) { if (names==null) return null; int i = names.indexOf(v); if (i < 0) return null; return (REXP)elementAt(i); } /** get element at the specified position @param i index @return value at the index or null if the index is out of bounds */ public REXP at(int i) { return (i>=0 && inull is the list is unnamed or the index is out of range */ public String keyAt(int i) { return (names==null || i<0 || i>=names.size())?null:(String)names.get(i); } /** set key at the given index. Using this method automatically makes the list a named one even if the key is null. Out of range operations are undefined (currently no-ops) @param i index @param value key name */ public void setKeyAt(int i, String value) { if (i < 0) return; if (names==null) names = new Vector(); if (names.size() < size()) names.setSize(size()); if (i < size()) names.set(i, value); } /** returns all keys of the list * @return array containing all keys or null if list unnamed */ public String[] keys() { if (names==null) return null; int i = 0; String k[] = new String[names.size()]; while (i < k.length) { k[i] = keyAt(i); i++; }; return k; } // --- overrides that sync names public void add(int index, Object element) { super.add(index, element); if (names==null) return; names.add(index, null); } public boolean add(Object element) { super.add(element); if (names != null) names.add(null); return true; } public boolean addAll(Collection c) { boolean ch = super.addAll(c); if (names==null) return ch; int l = size(); while (names.size() 0) names.add(index, null); return ch; } public void clear() { super.clear(); names=null; } public Object clone() { return new RList(this, names); } public Object remove(int index) { Object o = super.remove(index); if (names != null) { names.remove(index); if (size()==0) names=null; } return o; } public boolean remove(Object elem) { int i = indexOf(elem); if (i<0) return false; remove(i); if (size()==0) names=null; return true; } public boolean removeAll(Collection c) { if (names==null) return super.removeAll(c); boolean changed=false; Iterator it = c.iterator(); while (it.hasNext()) changed|=remove(it.next()); return changed; } public boolean retainAll(Collection c) { if (names==null) return super.retainAll(c); boolean rm[] = new boolean[size()]; boolean changed=false; int i = 0; while (i0) { i--; if (rm[i]) remove(i); } return changed; } // --- old API mapping public void removeAllElements() { clear(); } public void insertElementAt(Object obj, int index) { add(index, obj); } public void addElement(Object obj) { add(obj); } public void removeElementAt(int index) { remove(index); } public boolean removeElement(Object obj) { return remove(obj); } // --- Map interface public boolean containsKey(Object key) { return (names==null)?false:names.contains(key); } public boolean containsValue(Object value) { return contains(value); } /** NOTE: THIS IS UNIMPLEMENTED and always returns null! Due to the fact that R lists are not proper maps we canot maintain a set-view of the list */ public Set entrySet() { return null; } public Object get(Object key) { return at((String)key); } /** Note: sinde RList is not really a Map, the returned set is only an approximation as it cannot reference duplicate or null names that may exist in the list */ public Set keySet() { if (names==null) return null; return new HashSet(names); } public Object put(Object key, Object value) { if (key==null) { add(value); return null; } if (names != null) { int p = names.indexOf(key); if (p >= 0) return super.set(p, value); } int i = size(); super.add(value); if (names==null) names = new Vector(i+1); while (names.size() < i) names.add(null); names.add(key); return null; } public void putAll(Map t) { if (t==null) return; // NOTE: this if branch is dead since RList cannot inherit from Map if (t instanceof RList) { // we need some more sophistication for RLists as they may have null-names which we append RList l = (RList) t; if (names==null) { addAll(l); return; } int n = l.size(); int i = 0; while (i < n) { String key = l.keyAt(i); if (key==null) add(l.at(i)); else put(key, l.at(i)); i++; } } else { Set ks = t.keySet(); Iterator i = ks.iterator(); while (i.hasNext()) { Object key = i.next(); put(key, t.get(key)); } } } public void putAll(RList t) { if (t == null) return; RList l = (RList) t; if (names==null) { addAll(l); return; } int n = l.size(); int i = 0; while (i < n) { String key = l.keyAt(i); if (key == null) add(l.at(i)); else put(key, l.at(i)); i++; } } public Object removeByKey(Object key) { if (names==null) return null; int i = names.indexOf(key); if (i<0) return null; Object o = elementAt(i); removeElementAt(i); names.removeElementAt(i); return o; } public Collection values() { return this; } // other public String toString() { return "RList"+super.toString()+"{"+(isNamed()?"named,":"")+size()+"}"; } } Rserve/clients/java/RFactor.java0000644000176000001440000001355112205226215016337 0ustar ripleyuserspackage org.rosuda.REngine; // REngine // Copyright (C) 2007 Simon Urbanek // --- for licensing information see LICENSE file in the original distribution --- import java.util.*; /** representation of a factor variable. In R there is no actual object type called "factor", instead it is coded as an int vector with a list attribute. The parser code of REXP converts such constructs directly into the RFactor objects and defines an own XT_FACTOR type @version $Id$ */ public class RFactor { int ids[]; String levels[]; int index_base; /** create a new, empty factor var */ public RFactor() { ids=new int[0]; levels=new String[0]; } /** create a new factor variable, based on the supplied arrays. @param i array of IDs (inde_base..v.length+index_base-1) @param v values - cotegory names @param copy copy above vaules or just retain them @param index_base index of the first level element (1 for R factors, cannot be negtive) */ public RFactor(int[] i, String[] v, boolean copy, int index_base) { if (i==null) i = new int[0]; if (v==null) v = new String[0]; if (copy) { ids=new int[i.length]; System.arraycopy(i,0,ids,0,i.length); levels=new String[v.length]; System.arraycopy(v,0,levels,0,v.length); } else { ids=i; levels=v; } this.index_base = index_base; } /** create a new factor variable by factorizing a given string array. The levels will be created in the orer of appearance. @param c contents @param index_base base of the level index */ public RFactor(String c[], int index_base) { this.index_base = index_base; if (c == null) c = new String[0]; Vector lv = new Vector(); ids = new int[c.length]; int i = 0; while (i < c.length) { int ix = (c[i]==null)?-1:lv.indexOf(c[i]); if (ix<0 && c[i]!=null) { ix = lv.size(); lv.add(c[i]); } ids[i] = (ix<0)?REXPInteger.NA:(ix+index_base); i++; } levels = new String[lv.size()]; i = 0; while (i < levels.length) { levels[i] = (String) lv.elementAt(i); i++; } } /** same as RFactor(c, 1) */ public RFactor(String c[]) { this(c, 1); } /** same as RFactor(i,v, true, 1) */ public RFactor(int[] i, String[] v) { this(i, v, true, 1); } /** returns the level of a given case @param i case number @return name. may throw exception if out of range */ public String at(int i) { int li = ids[i] - index_base; return (li<0||li>levels.length)?null:levels[li]; } /** returns true if the data contain the given level index */ public boolean contains(int li) { int i = 0; while (i < ids.length) { if (ids[i] == li) return true; i++; } return false; } /** return true if the factor contains the given level (it is NOT the same as levelIndex==-1!) */ public boolean contains(String name) { int li = levelIndex(name); if (li<0) return false; int i = 0; while (i < ids.length) { if (ids[i] == li) return true; i++; } return false; } /** count the number of occurences of a given level index */ public int count(int levelIndex) { int i = 0; int ct = 0; while (i < ids.length) { if (ids[i] == levelIndex) ct++; i++; } return ct; } /** count the number of occurences of a given level name */ public int count(String name) { return count(levelIndex(name)); } /** return an array with level counts. */ public int[] counts() { int[] c = new int[levels.length]; int i = 0; while (i < ids.length) { final int li = ids[i] - index_base; if (li>=0 && lilevels.length)?null:levels[li]; } /** return the level index for a given case */ public int indexAt(int i) { return ids[i]; } /** return the factor as an array of strings */ public String[] asStrings() { String[] s = new String[ids.length]; int i = 0; while (i < ids.length) { s[i] = at(i); i++; } return s; } /** return the base of the levels index */ public int indexBase() { return index_base; } /** returns the number of cases */ public int size() { return ids.length; } public String toString() { return super.toString()+"["+ids.length+","+levels.length+",#"+index_base+"]"; } /** displayable representation of the factor variable public String toString() { //return "{"+((val==null)?";":("levels="+val.size()+";"))+((id==null)?"":("cases="+id.size()))+"}"; StringBuffer sb=new StringBuffer("{levels=("); if (val==null) sb.append("null"); else for (int i=0;i0)?",\"":"\""); sb.append((String)val.elementAt(i)); sb.append("\""); }; sb.append("),ids=("); if (id==null) sb.append("null"); else for (int i=0;i0) sb.append(","); sb.append((Integer)id.elementAt(i)); }; sb.append(")}"); return sb.toString(); } */ } Rserve/clients/java/REXPDouble.java0000644000176000001440000000556012205226215016711 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPDouble represents a vector of double precision floating point values. */ public class REXPDouble extends REXPVector { private double[] payload; /** NA real value as defined in R. Note: it can NOT be used in comparisons, you must use {@link #isNA(double)} instead. */ public static final double NA = Double.longBitsToDouble(0x7ff00000000007a2L); /** Java screws up the bits in NA real values, so we cannot compare to the real bits used by R (0x7ff00000000007a2L) but use this value which is obtained by passing the bits through Java's double type */ static final long NA_bits = Double.doubleToRawLongBits(Double.longBitsToDouble(0x7ff00000000007a2L)); /** checks whether a given double value is a NA representation in R. Note that NA is NaN but not all NaNs are NA. */ public static boolean isNA(double value) { /* on OS X i386 the MSB of the fraction is set even though R doesn't set it. Although this is technically a good idea (to make it a QNaN) it's not what R does and thus makes the comparison tricky */ return (Double.doubleToRawLongBits(value) & 0xfff7ffffffffffffL) == (NA_bits & 0xfff7ffffffffffffL); } /** create real vector of the length 1 with the given value as its first (and only) element */ public REXPDouble(double load) { super(); payload=new double[] { load }; } public REXPDouble(double[] load) { super(); payload=(load==null)?new double[0]:load; } public REXPDouble(double[] load, REXPList attr) { super(attr); payload=(load==null)?new double[0]:load; } public int length() { return payload.length; } public Object asNativeJavaObject() { return payload; } /** return true */ public boolean isNumeric() { return true; } /** returns the values represented by this vector */ public double[] asDoubles() { return payload; } /** converts the values of this vector into integers by cast */ public int[] asIntegers() { int[] a = new int[payload.length]; int i = 0; while (i < payload.length) { a[i] = (int) payload[i]; i++; } return a; } /** converts the values of this vector into strings */ public String[] asStrings() { String[] s = new String[payload.length]; int i = 0; while (i < payload.length) { s[i] = ""+payload[i]; i++; } return s; } /** returns a boolean vector of the same length as this vector with true for NA values and false for any other values (including NaNs) */ public boolean[] isNA() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = isNA(payload[i]); i++; } return a; } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.length && i < maxDebugItems) { if (i>0) sb.append(","); sb.append(payload[i]); i++; } if (i < payload.length) sb.append(",.."); return sb.toString()+"}"; } } Rserve/clients/java/LICENSE0000644000176000001440000000140212205226215015131 0ustar ripleyusersREngine - Java interface to R Copyright (C) 2004,5,6,7 Simon Urbanek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Rserve/clients/java/MutableREXP.java0000644000176000001440000000016212205226215017061 0ustar ripleyuserspackage org.rosuda.REngine; public interface MutableREXP { public void setAttribute(String name, REXP value); } Rserve/clients/java/Rserve/0000755000176000001440000000000012205226222015373 5ustar ripleyusersRserve/clients/java/Rserve/Makefile0000644000176000001440000000073613442516164017054 0ustar ripleyusersRENG_SRC=$(wildcard ../*.java) RSRV_SRC=$(wildcard *.java) $(wildcard protocol/*.java) TARGETS=Rserve.jar all: $(TARGETS) JAVAC=javac JFLAGS=-encoding utf8 -source 1.4 -target 1.4 ../REngine.jar: $(RENG_SRC) make -C .. REngine.jar Rserve.jar: $(RSRV_SRC) ../REngine.jar @rm -rf org $(JAVAC) -d . -cp ../REngine.jar $(RSRV_SRC) jar fc $@ org rm -rf org clean: rm -rf org *~ protocol/*~ $(TARGETS) make -C test clean test: make -C test test .PHONY: clean all test Rserve/clients/java/Rserve/Rserve.jar0000644000176000001440000007211412205226222017344 0ustar ripleyusersPK3C META-INF/PKPK3CMETA-INF/MANIFEST.MFMLK-. K-*ϳR03r.JM,IMu )h)f&W+x%irrPK'GGPK 3Corg/PK 3C org/rosuda/PK 3Corg/rosuda/REngine/PK 3Corg/rosuda/REngine/Rserve/PK3C0org/rosuda/REngine/Rserve/RFileInputStream.classUrV=O-(qb!B+1hPB*0IMڐ.*q$W~@w]tM,&΀3S:+鲟oԽ9&d{s9 c>Ź0c",.%"§|oM)>\#W0j3wJs5+Ss*U=wn-S(Y)`65vA\uiYLr*UTrAul<ܸg{%^"E*߲b-Tq!:]拄&-JN55vOxD$LhXĒH򧂆"J 1a: 6'ܺpW_Pޚ^v3]Kv^.I0x@F&#*h>6hI$jIZ/[DYԊMRXiT7u0仯HoJ1dQ'Ws us5^I}(F#M#yL 'py䶱fB2@D[/N+EueZbP Z [8!?"QRb*# c*cI,)ڽ CAEŇ*N8AtNAgCnJ%})֩H,$cGH)9a!]_ . t!6U*7MNQsx~.V4*xC^C:4ФW^P\Žqe[c'vI˗Óx%†B K`,<h,M< fK?ο!5ABD*yb!Pfl:\p?QC8q}6FHnE8DQ !=ʥ0ݔ_2/􉲿kH>EK/R{G x0XngP"w 5A8]XBr7ҢPKMZP PK3C1org/rosuda/REngine/Rserve/RFileOutputStream.classTsUnvM-mCR4ʲ4665H.׆ݰـ<;##3C<&4-NI:sso<p(Nb:Q+ P0|Y>Q1^Ru _{&,"\k߻cyY7|j6Z_QPPCtmi1zOdJ E@g4hn۫Z6lRo}g8Z)dT$q.W1tU1nP Eq*_}7ݫDIѩv'Koۍ1$Ӟ=']̤UlC&>n8 3riv\?6-Ggnѕ<gƫ:a_AEQEI}w7vp#HDr+5EH# W WB%/z_^ ޠ7$Hj$}ɍΐ,Lct e!@  =B G:?ԁK17Mzn0Aqd),#G&QQVpN +PL0Eb!A If&ѨʿW$w0A2ОY an ~IbFtC2 }E~Y*S?LPOTP2 Cɐ#$C}>N!{\#|c(6VqkJ^ =OQ|"<,d T.'8+u1~'|1^A~WsYdc#x {3_p>=-td ` .CI,HUkz賄 IA== ܿPKPK3C+org/rosuda/REngine/Rserve/RConnection.classZ |Tՙܛ̓ P#`(#CrIF8@ZQ|UaUW| $ZVkv۵mnEs4s9^;o~g,Oo7U 7E|zK5T۪j~ߨn4w4exSU7JG'7J"/yW1E5jsռS'9"nqH.N] )T\hnT"]ܪ/Х-RF~)e.LեR.t*xe.'e.'2[-s)2GD/2On.Pպ,ԥFZ76M6RzMhF]WZD-{ZFGO(٧f.9SͽҥIn\*+4YFe8[sTZf]r[Zd.tYK.t٨&]66MIdr2]mtr.ە.BMvhK8 *6]7=ۢ@g@")mcF9^ ͮM =q@58R'#i-hE{+z0)UP"s8* 4CX%3ڪ/17z> t 4)(Mkr^1eD%݌ P\s]>]c \u94)[P?a^'že1mߐrnb& R36ɪRG&W5"W#"b6C@=vR;S"ͱ݌mO97(uXSj-P7{zU_G@dM*CM{S\Aޔz#-˶P,EkrWSE-q' 4,$q&byOJR/fQ9C. ˆneNJdtI!6pn4Gz ܄yڲi _ X٤'Vhr!{? r^*6 GJ`w׿gr%]CQ35x^led鬝Ղ!WuԬOh,l&׫Em\}d/ڄ7h1$*aV]?VjGg%_,Bp|/!_d茜Qy.ΩX06 (IP)IՌuV_:}C>%H \>X!1&} ɕS-ImsHűerϱΐAYq+C\# bW>3E %Æ\+逩.EB̖̐u51}QVŋHtw(-"">4wEC!C 9 7$]@6Ff%`}PvEiZ2&orGhxy2~dȭxzLbq.CO+0ʴ5L>*Dԟ;[Jn$j;UcꑤTGSpD; |GU$JX $z"9,+ssZ2v}\) ."el<gJhPq-y8"񅢽 VjiXg( Kq3Gy9 r~3 | 1_I9ex٪[Ҵ$0iL|3SGP|^"/q%tގйfHRbgsg/#iflUf7KJnrdjrdGVlVwʙխTgQVQ$+bmZuk~F2F[QG;UPVqa!G}̵GDiR [6ݰa!ٲGɤĿ}KMRFO#؅*R,ͥC's]_'g*(a[~b ^\ͧIj_Gum2=QɑCOpľNX߮rsI[dXԗ[_Ǟx;Dr6z)(oB[X=/EV :a*Ym6/LV~5_^|OفOOp>//f;ȷ(;ன)UF8b}N'5F+^>99^jqGnESTS48=>TzMLAA6 hX ޟx6o3yd>u̹"5#pQK5jt5VwSpcu0P!krC鎚c(1)è:10*G9^J´Ml=G%3Gp)9!5q dqQƲ `.7WT{For:)rB%ϕ!oʐ),_|N{ 9^6m5è2m ix.\'h>j=4чanvD%!RYPYcٔÚ_N(#9X3QLw?M!e{ <ݎ~J79rMz FN㤒3SQ/faWYEY\M؀ b3І^lE?CDdxvLUN<2/7(R]R.1`tnYe H'er%Br/'Èʗ1(^ErLÕr,uڱ:c\hVIZ?n6nv-ns܄wce|>xw9^f2}J۳F4|V4< ϧV텪et4<{{9xeY'P 'W6k84bh]LqlUrX tSr R~J IH% Y=dsY}Ib*V)_!/Us>Ia88ǞQ{#' dPTJvH3*ώ0\놱8YFu4|xH/}1lq} 4Kӓ>KnK+_<>:Bweqs-pвOk,NX%D,W9c3n!/380iA3`%akrlX/8}?T~HJ Li"}̸+럝0Volrz36Vؒ!qKchGIf7}-DO6U SwW~^'׿3|=!(~Ⱥ?-Ք>ZGkxj~eqn]{^˺7lyjطm4 &}8oc-~u7m#MneqQYG!t49uv.+:Uk4{\wWZթuL هP/+ E/eDޢ no@'O,.<tCxJ7^OāPzO)Q\e meP>JǬX<^_1K dG9 qeqvz; Td\5uz ;,Yʶ^89^=f0'l@D8Zѷo}+X J R9RjR%ƒR{ċC,Ix2 o̶ eڔX2(c!DF@3AIiMlJeO\cTn^z.;y(˂$q}?!3g69+9+ӠKie8U"93=Mˎ%/ar4BwTK$Hks YI$/Ktt$HG2h"o`q}9l D KdK:l4/$mmn#2eI0~̓]X,]`gy1y)#H>P#WݻI>OE$ ݰY7,/yraU|I]>΢KI?N Jd DpDq We^!(Kܕ'joU{} K|êZ߇n1.]^M֠|Z٪AjPNNrhp܈V)̪A[~pe4vIe~Kx9iav4o'F[Qm.X H~_ÿdXChd7͜ ֟L4V?M~:~БL.gV$PKRLv\_/PK 3C#org/rosuda/REngine/Rserve/protocol/PK3C/org/rosuda/REngine/Rserve/protocol/jcrypt.classmZ |\E՟{wIfdIvhMmW6J6mIMSh!P ꧨP*E@B >?A$}ȯg̙sΝsW}@)j6ō5qSn:rA+#J:~BjRM!J*"uONNHe1IjE}'nfY\U/]s 5]sZ\Uӡ}zV΄l5ZKE(sRJ6pIhuE+d\R*-- .Z]h %2d%,JJʅ_P PR1bD@@@"DJJbT@*P(AVʁJzPAJ@=PP+J~=s`X8x04x 7 lEMGڳ}-GTkF6\9#KHwO! +[d94˶|-GyZz冾UZn9g{1qb)2gÞ ;ˣ,y҆eg,]nƎ uq6 o!]760#wSh s+v \4вk`h[˚ёC:((j!lvnUz̓'o `0Y3-ajLmԙ 3 `fLJj@ɓ9ۜ;]w-# 7a֛x֭DlipxKœo6$FCALE49 3״&,3;a2Bm-#{nhYlhM{G.l=2<:yxWˎ6̳pkQkph:|ܛPU,t`b._JҢ([~"#$fӀQ _Vf߄өU 7ܭmTx{ &͊j;xӰU׫haV'x ^qt13NGWT\Dshg]P}P{+ZwĉUj% B|\R]=Nal)ۄ7f]TWKٺcV+^*j}jWERoyߠ*3V} ;^W™}:Si'T՗vVR1^Z0ߧRjUQ2aBl6"޲@f*{ ؁R'ת}<+f=C=*%;Ls=*L6wS]GEBw6x뵲bDŽ]bJfD+DKG&3^xW ܔk!]q*KmתLx,chdcYT!a5 ݷPk.oCXd3_:sW"S*?MtF%g9WmթNַUjPY ;~}^Q7M6uuzH[=V_Gӗ_YRߩ_sg3>bQU&h%KLGq.UfȦTܔ3Nh*J#s@:i>rHH*}4U+iEPt2๨cU"VrV,Q>3 =#{&jqE7gU~R4Z_Ti7SߡP !Uܭ+Bwi ai eRӛh *6cA RNst_]tCԏqq]m$TucʅR1gբDv7)=fcd:qZgc(-JBDRMJS%Z* 29zRξBy:JJǯU1LPk3FJS%{7Jn˛'cNWNӧ4w̙sza֩I:0ZblԾЕfIFF5[y&3ϴIՅ5l>+`>ЂFseBeT4{T1K^R޿is͂GFEɓ ؑPoCao~]X,Wc8 H<H*S4 P iPfffrz@h80Ak%gQo!(XHB'\dK!`NVbnV\̊=kKl)R[Fx-'\f-6IxO>r;4"l`3`gn 7[O8hFm;pm&a[w<.;BJ8d[mp. cE{m;EbIv݄ń1eqB}w#M~NFץ_E Mc@P (Peֽ_Z=G=GhL\C0$QC&]y+P()BNyg"*o GVyg!*ldw[EZyVyH+-H+5486@ a$lb63 [@3 d0[mLLv`(H: -:$b.da&a7l{+8H9LIe2 1 3 L%L¥Lp0$I`.g0 og2 W0 W2 `$I&L{2 c$\$\$|I !&DB8 #࣠ZPpSp=S1PU68p &LCLaFs| p#Y&0p` gp3y&& L[/113w0_fdbfaag`d| : &Lo33a| x >" rB<,М?$ ޏ@ARAZ!CR "t 3``db~< lǒZa=ڈGX kq H],O/vwۘw7.ĽM.qo qWpW )aJa܍;w ssIO0na=U{ s> }P0aa#Gk넹녹 sn>!}̝J״G6l.m㾾QHF;,$a/}}y!g)C}Ax@e2/ o o8dAveN-.w ow o8*%]#}EW)I#BBMɜ* #?u!Bn-!!!\ =,}GcF2W+}O{D~ߚ;Tk^~|0H`׏28uGL%~",b* c,>&,Tg"+rm -/υDž_HPH|LH$:%¬&nl!aI39Yjh@XmWMs$fHy3W:M'1_$n!GHEC/]Oij{[+N"")@Jᗐ.n'~%tZ(Ӆ%"ɯ& `xGTrZd52e$65]|s u1S4f! bkb6JMVh3-U^VicBϓBύ^bs;ho`'Jf=%x-tRv|4!=o9~㵒Pz~/ s L%$=#=+I2 crгO[frPH焤?ItˌD#ttix f:4S%vfɍtmӍI簏fE\5Dc{/PBJI*=+I%'X0qy&^Ga/ R~K_I"aoTI1!a 7e|/g Sx6 Q^dpWUA<ñbՃi/~=*DAV#}kY6CW3,xW=8U(zUL6Qs׭mm懅#]$q)vnw1{Ic/ƾ'gԿxKa$[BTTndiPŖeUr.iaZ::_77X^7F5fv.,˒Vl㧙:#-G9)EΚI'kvIlz1?RNRM9?7p\Xyc>#|[ZpmO*s%>?' _ᕉ\'v>(~b8~f8W|rN6\ 'eEay VTfHuL0K:X/$b Hy4ϕ"j|qXG] ʓ,vQ]-*_|\x:%ou`38qD|#{'~3g7q o7%XBSt-TRT<1ZpJ:W:6\^]%f9^: a:9[jVluL*$~rb^\4HXdƛE"y1;=ʃybxx,Kmqv*l-0 mhDXnGUttRYrxouQ-ecu]0$6oZ/lNP3+X*FPE i0[Sn]XQy+8p[Cb@5\'>2=^U3['Yrw-{gz37[y>u-iFBǍFrIyXf_L~R#a qE:!D:c|7Jd4= #xN wg%09NvStlCS=+dix-4g|g21̞gr6n6b &>%;O<ΑA?L<'LjemȼOJf㋿Oc3OԆJQf =; ddd܀@PK+7]%PK3C.org/rosuda/REngine/Rserve/protocol/RTalk.classWkp>zZ QC !$AJc;&NM Ԗ#"i$@M@)ohRBi `Rȸs-E~j%oMI~νy9ŷ!t$@ad=-yLȃʯi> rgy iRZ!H =/$ =У }E`o@H j̢6|ɀ-$)ѵ#ŰNP=ຍWut3S!}: tD_EJ5T ӑZ/Юuyk$g |eylehȩ\)(YkWu5fzM=nYIsdH5XdW̜}ofA.+kiF@z84mn$3{!R#IIGv$B_6%mVdđ8lL,Qxb#5Rj`P2I. #XʦS&ў*q}`Vʷ6.FpV#㣂.dNXpjsuDH;^sbt~*e̽ 5\ΖHdXnBЍAiҝt(xF_aJ'$}EOV4r6ݻ3Ƙj4R o =K pv5+u,T'67<Ο l"dEioej ٞmOTHhZ[@!ݭn\#& i;kG@#zgP0{lA)ī Bt:|{K\L\x){\ls\\ /y1/}_1GJ^| _pዀ/vv5/uuN^z .܅q^>ɅNp?\x3s# _ Յt! g\8 lvswpxԅMhW厅kE1ڱΦ3$=Muy_4q\ /4N0_*^pSy⾁ M|6BY _(`-B"*%⛏IMf IzBGŽ r^3&xyeP"ޒ M8^srSrD]yzulfRXn&Gu ɑUh;$'{o4s_C5rAvb%jbgEnR2+9 XqoK`HŠ^wY4|h- ..jKgɭ<>^YՃԀ|!ڇ^o;cw,\̂bmMByDNĭ"\if4Ʃc@19$r ')IfiԜ<%#(oG8ȧǩV&1KB껧Rv:7~C_I&Ugto 7ӽߓ>t_;JM}_ӎpHAuHQԄvBT1Y~-\VF"OH jM05B:O&嫠ԅiiy*B]}>* }F`k'ԃz!45'1oJ'/?G-[P3:U VY1ùIEI\92 B໸ۿyܑGqO}i?D|?'3 p\K~K?a|~G8Ax8E E,WWHkE8-x#2F'K* :MzHWuQKsropZ'$6M 3!d׏vԽ͡ Ebu$?>sZC>ݯ uHWu=@+tOwE|%F!WS_r&\ #%gSA*?q+ 5:L[u_v[_ɿ-c|i1{z9LY?ximzD;=ιU⎱qicg]E 'TT]=- UڿPKU PK3C4org/rosuda/REngine/Rserve/protocol/REXPFactory.class: \Uu`PbjX((`2&Dq |IJKmBKm^kޭ629fϯ9{9{9^=~;@sLp3hp 6qBР :q R 'LGECUCv 5 u :5tih805LpM-&'?N'!$'q(4'0!Չ>LqqN`#$y$srG8FDZNPPj1uqJqqB.N4' 'g*=?Ni,rggrwk8 gp:ѳXasac1x kx:! KXL;!Ku,c7,<',r'$`J, -O??KpGCxą̲j0VǀXJu\jt\cPFtXf[t تZ^ :n/qY6 /GЖT./]XRqs-!0PhXK+C\-[XXR$WT3J JbTU²F6&NeD3.*SY&%-IrDSRVh\Z0_L[K* \Nc}|->|Bˋ,Δ~ͩuTݔsVF45|;ǾYGss(ӡ2gAcfa鹥eKgyan6=byAE 5#L*ilinliꃁ@@NSsc, 56oN#k!#XPI} 4!99sB Yhh !c &kV7ɱX3|%s"_fL-K5P=# 7[-̥(\a?'# j!kHyCI XZ)9$_hj!?OFPs}n`Pd?1yPP y̓Y<,dPEcksM`^=ـ7-^7hNf>b64x 0Xx-p -z,UȴVY2*Y`fQfV1aX Zq0  s[&E7} 5+Š֮ߠހ7Ҷ:y [jYQYYYQNo I5דʹBބ7o4;N 2fgyޣ­ލhxp; M^+}^Ao oYլtNq'b BFdƆ>XAocԁK.:e HqGUg1=;YGV*epNJ v'XғY@;p>t 'n$J VYhG+fA.ZQb)GiF^--goYlimjjlj54qOmo%@з[hHuKo;` -Y\6j͓Ge_aU}0Mo l%Y,j~!Ҭs eWMvȑѳR v3L%.>`03Jf6j,yVUGȌMb\zI׶L3H3 M} _.? !BzJ;t)zf:O \?b-OůpPAM59@E1V䛽߰13/X˩^I#kWnu74rvjl w猣 0"sܟ !Ʀ YxbsL4 Ny[j\oh9i[|<<~Ry%0hkh4eg թpT [?wiP@ (i&V'[X5Ћ,R 5;#ȻuNcCuS>Y7;F>fTMV*3B`E9+D!KZh/~J] z#≌̟>j[ 7-|qx,+;rkɏ}lsAfN4x(&Ϟ]K{@,.埜1R#0]}-SɣQtY:f[H}X׹봖p2ϑ t_! pI]Qx[ ' mQv;_~_~?D( ?B(Q?F(qŸŸ$(i»݄Ÿ!(|/?O Q: /E%@~W ^G_*l+lR-[ ^>ҨE~hz p|#?*RfNX8vA4PvƞWP󖠌ȜA}<2\*,N = j7ݠ~pH zxD`W48=B8]Y{15d-NHC4X`dBx5_J[o kbzl#4afȫ!&I?􀗖<j'|Kkۿ}Kb P _#H,mپ=0,?7%.MUU=1>\]/:Wr+ᴓG0z69>}Ǿe.ꆌ@+ytuV UmtCNҤn8-&3fx] k,$M; %oynf*{soεS"-t|ا;aJlqU^xؠ0vHf0!uV0 a\^=|rX520{ҷfnx ̧fSh UWw0^ۑO1 ٢z̉ZD:  \|8Ͳy檹&3lwCQ.~Y&Q!uWifZ4G4y%v a˔.HbSz x[ޚ+ rIq{,R<]1$tqWs]Nޛ<Fydge^ tԺx%a>jcsPTri hWKSxqϫL{G δXSՔ*##+|D'љv=:S~ӮNG<ݣoKMF&[NLZMcE2J$qԪOݰ(""|F%4OuPP꽉eRdGWuO/ =EG?Zk 糉:éW8a PZ!J= rlNaYt `R> ' cr,IMsHu6NDR8HAl݅d) |( Ó:G˫d4U0 G%l+(aػ|;A;P8f,׾ҎR&S92ra\cZȁ`%iyp=̂a!D͔B ٭mT]MmTIEٽT=HC=C^*~MTlCETd&/:J\B@ x Saq:<%$SeЍ؍+\{b؇9l/+k> ^#b(ND6!N7E>%%𶨆wD Q=u+#q=|,n?;q|*.LIBo—s8"z+ Q[e8[Q&I +2~P*GY'Kv(܁6eڕ)ON01Vc:i8H=pZCUbz!:LSpczPoǑ8JǨ/XS,l:N9qm(NeTX<6 smg4[!a+3mbag6l&,݈;qmε=EGq _OaCm =Hx T|=$H hpx8Kאa~ l񸑲4Ɲ!PPsSO@F}42͑t QJER, pEOauT$!'`IDrdIZ@K3= {g8!+#' &+zaTkU)8̙L qo} =HG<䶯u&$Xǐ4Qy@`m1P'++?ͲRK}.*_WfLD@i|+Nu::aDT)]XPgs$ϔ`TSzTEl;@m`S(J墳jgvpqǣ{~i@?,7><G Jrvd֎jЎz^ 쯮jlRSUUfuyBV8/H :+դV2c+u1䎸̚%E:ٕ\ͣy.v yzW'4ҋ3 NJє\ɹ{TSNjWxvR{d>V:L@<;L-;ݰ`]I30O"}ϳG7ZNZ[lҟ(G9p?_2=_%tkЂ:|.7q<|Owp:=lI6ďD :%/ G$1i_)xTb.KK{D! W !*١m&:_!N0 -^I(>Naj F)>!ls)`Q1v 1d0p'x; I0-]iR&!An~&PMFaGתЉ[Ҿ tiN16?ELɵd<ڊ4vJTM&ONY! qccN偭Ɗ{MjYꪞܑLCFEG!=BgI i^<7xxNR=b%.3=f5u8x4sOK`E9]\|>݅=l7ԮVxsr+bK%x>`CϖcI1FeO(mM!7W8y\:poSORgi8kn]E4buvA(*du/ɃGAHVЋQ덓AE󐒢pUVG&'fx[$w$$× _.~o`:% .)s GwB6AuiKt&rS^Eftu'myc-8dhC%f*iM IG T1t'F1QZXxTd^*^YpWKL_PS1q:FL |SD>~(fb6 f (cb(/ yBQ.E]"bX"DJ/nKIe/\<.3/~+VE-U'j# U ZCA!6(بx%JTI2eج6L\,W(ŕ&Ѯ)W-MF_ 9Q lՊp<)t` 8O桼V<&iQ !J&%O=R*,2~x^</{<| ^:ޥ?]iX6}PK( 4PK3C/org/rosuda/REngine/Rserve/RserveException.classV sE}Y2e10 B%& 4  9; ^HIaiaZC IgigiOXe|=9HQLutu}Y\lbӯa@àC4 k8ሆ G50aLq '4pJCNø) gel^͹⼆WdW5&|ބBE:Kf1RvTȇU39_,O8FŮX2w+2Um:N[AZ7\LI4vJ7oN aF@+[9 miTЧ进_ʶ/ZRl} G3>wK 7#5ޱePMV^ymK] Z Zs58fV`#($6%^"kŶ_i!e\!x56Q5WJ4Opu ?8QG &1H|H">& 0)q&Fψ1kb#''S/z]'#}YGZ7Dz*җGz:WDS+#}UX}n-z4֬X+Zv юwc>[lml>CQ/)7;~D3O7%z(9Sbbf$F,qms4ّM,W_Q-8u BŮY)*oIC\-YJ-՝#zwco cF.XEfby.zlKN}`̫ ,?b)q=q"bҵ)5qilK,,qH2MS{YIyx6N]H]~ۃqPKLW PK3C(org/rosuda/REngine/Rserve/RSession.classTmsU=7M{ yF$]D^ԖVBD>m;a۰w7'A2Cz68s=Qq.ףztA.%>ħ&h` e|fs|!l0`EG]V%$J:M~v0/H^:3_k0Nfkޮt4ڋ+02wL/Iֽ^kGqR qosAS']t0 [aǩfΩ(v&O.3Ujp%R35XTцJR@f\|21ߠ^7J,JZdZdF Ԛ5 k &Nb8nkl*dBڽ&Pv]o#wUCfͭo{*N4jM⺉u0LMPIN0&ZjZ?f&C:Ե/ ȶJHU],y^[|v5uw-/ilʼn/k]^ ۪ZE\MP3#y_33k='L-Lmm[zҞb6z:?!Sٌ 1-<`;ͳ b Y<~8ׁƋ8c}du?DzϘ~;cUS}vdj"?V(>T&)Ge9J-Q9J*)Ӈ-QHT)<;3)11aj#RRWjq4YS/0%|_PKSRhPK3C META-INF/PK3C'GG=META-INF/MANIFEST.MFPK 3Corg/PK 3C org/rosuda/PK 3Corg/rosuda/REngine/PK 3CBorg/rosuda/REngine/Rserve/PK3CMZP 0zorg/rosuda/REngine/Rserve/RFileInputStream.classPK3C1org/rosuda/REngine/Rserve/RFileOutputStream.classPK3CRLv\_/+n org/rosuda/REngine/Rserve/RConnection.classPK 3C##org/rosuda/REngine/Rserve/protocol/PK3Cꐈ6/dorg/rosuda/REngine/Rserve/protocol/jcrypt.classPK3C+7]%0f<org/rosuda/REngine/Rserve/protocol/RPacket.classPK3CU .!?org/rosuda/REngine/Rserve/protocol/RTalk.classPK3C( 44hIorg/rosuda/REngine/Rserve/protocol/REXPFactory.classPK3CLW /eorg/rosuda/REngine/Rserve/RserveException.classPK3CSRh(korg/rosuda/REngine/Rserve/RSession.classPK2oRserve/clients/java/Rserve/RConnection.java0000644000176000001440000005513512205226215020472 0ustar ripleyuserspackage org.rosuda.REngine.Rserve; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004-08 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- import java.util.*; import java.io.*; import java.net.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.protocol.*; /** class providing TCP/IP connection to an Rserve @version $Id$ */ public class RConnection extends REngine { /** last error string */ String lastError=null; Socket s; boolean connected=false; InputStream is; OutputStream os; boolean authReq=false; int authType=AT_plain; String Key=null; RTalk rt=null; String host; int port; /** This static variable specifies the character set used to encode string for transfer. Under normal circumstances there should be no reason for changing this variable. The default is UTF-8, which makes sure that 7-bit ASCII characters are sent in a backward-compatible fashion. Currently (Rserve 0.1-7) there is no further conversion on Rserve's side, i.e. the strings are passed to R without re-coding. If necessary the setting should be changed before connecting to the Rserve in case later Rserves will provide a possibility of setting the encoding during the handshake. */ public static String transferCharset="UTF-8"; /** authorization type: plain text */ public static final int AT_plain = 0; /** authorization type: unix crypt */ public static final int AT_crypt = 1; /** version of the server (as reported in IDstring just after Rsrv) */ protected int rsrvVersion; /** make a new local connection on default port (6311) */ public RConnection() throws RserveException { this("127.0.0.1",6311); } /** make a new connection to specified host on default port (6311) @param host host name/IP */ public RConnection(String host) throws RserveException { this(host,6311); } /** make a new connection to specified host and given port. * Make sure you check {@link #isConnected} to ensure the connection was successfully created. * @param host host name/IP * @param port TCP port */ public RConnection(String host, int port) throws RserveException { this(host, port, null); } /** restore a connection based on a previously detached session * @param session detached session object */ RConnection(RSession session) throws RserveException { this(null, 0, session); } RConnection(String host, int port, RSession session) throws RserveException { try { if (connected) s.close(); s=null; } catch (Exception e) { throw new RserveException(this,"Cannot connect: "+e.getMessage()); } if (session!=null) { host=session.host; port=session.port; } connected=false; this.host=host; this.port=port; try { s=new Socket(host,port); // disable Nagle's algorithm since we really want immediate replies s.setTcpNoDelay(true); } catch (Exception sce) { throw new RserveException(this,"Cannot connect: "+sce.getMessage()); } try { is=s.getInputStream(); os=s.getOutputStream(); } catch (Exception gse) { throw new RserveException(this,"Cannot get io stream: "+gse.getMessage()); } rt=new RTalk(is,os); if (session==null) { byte[] IDs=new byte[32]; int n=-1; try { n=is.read(IDs); } catch (Exception sre) { throw new RserveException(this,"Error while receiving data: "+sre.getMessage()); } try { if (n!=32) { throw new RserveException(this,"Handshake failed: expected 32 bytes header, got "+n); } String ids=new String(IDs); if (ids.substring(0,4).compareTo("Rsrv")!=0) throw new RserveException(this,"Handshake failed: Rsrv signature expected, but received \""+ids+"\" instead."); try { rsrvVersion=Integer.parseInt(ids.substring(4,8)); } catch (Exception px) {} // we support (knowingly) up to 103 if (rsrvVersion>103) throw new RserveException(this,"Handshake failed: The server uses more recent protocol than this client."); if (ids.substring(8,12).compareTo("QAP1")!=0) throw new RserveException(this,"Handshake failed: unupported transfer protocol ("+ids.substring(8,12)+"), I talk only QAP1."); for (int i=12;i<32;i+=4) { String attr=ids.substring(i,i+4); if (attr.compareTo("ARpt")==0) { if (!authReq) { // this method is only fallback when no other was specified authReq=true; authType=AT_plain; } } if (attr.compareTo("ARuc")==0) { authReq=true; authType=AT_crypt; } if (attr.charAt(0)=='K') { Key=attr.substring(1,3); } } } catch (RserveException innerX) { try { s.close(); } catch (Exception ex01) {}; is=null; os=null; s=null; throw innerX; } } else { // we have a session to take care of try { os.write(session.key,0,32); } catch (Exception sre) { throw new RserveException(this,"Error while sending session key: "+sre.getMessage()); } rsrvVersion = session.rsrvVersion; } connected=true; lastError="OK"; } public void finalize() { close(); is=null; os=null; } /** get server version as reported during the handshake. @return server version as integer (Rsrv0100 will return 100) */ public int getServerVersion() { return rsrvVersion; } /** closes current connection */ public boolean close() { try { if (s != null) s.close(); connected = false; return true; } catch(Exception e) { }; return false; } /** evaluates the given command, but does not fetch the result (useful for assignment operations) @param cmd command/expression string */ public void voidEval(String cmd) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_voidEval,cmd+"\n"); if (rp!=null && rp.isOk()) return; throw new RserveException(this,"voidEval failed",rp); } /** evaluates the given command, detaches the session (see @link{detach()}) and closes connection while the command is being evaluted (requires Rserve 0.4+). Note that a session cannot be attached again until the commad was successfully processed. Techincally the session is put into listening mode while the command is being evaluated but accept is called only after the command was evaluated. One commonly used techique to monitor detached working sessions is to use second connection to poll the status (e.g. create a temporary file and return the full path before detaching thus allowing new connections to read it). @param cmd command/expression string @return session object that can be use to attach back to the session once the command completed */ public RSession voidEvalDetach(String cmd) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_detachedVoidEval,cmd+"\n"); if (rp==null || !rp.isOk()) throw new RserveException(this,"detached void eval failed",rp); RSession s = new RSession(this, rp); close(); return s; } REXP parseEvalResponse(RPacket rp) throws RserveException { int rxo=0; byte[] pc=rp.getCont(); if (rsrvVersion>100) { /* since 0101 eval responds correctly by using DT_SEXP type/len header which is 4 bytes long */ rxo=4; /* we should check parameter type (should be DT_SEXP) and fail if it's not */ if (pc[0]!=RTalk.DT_SEXP && pc[0]!=(RTalk.DT_SEXP|RTalk.DT_LARGE)) throw new RserveException(this,"Error while processing eval output: SEXP (type "+RTalk.DT_SEXP+") expected but found result type "+pc[0]+"."); if (pc[0]==(RTalk.DT_SEXP|RTalk.DT_LARGE)) rxo=8; // large data need skip of 8 bytes /* warning: we are not checking or using the length - we assume that only the one SEXP is returned. This is true for the current CMD_eval implementation, but may not be in the future. */ } if (pc.length>rxo) { try { REXPFactory rx=new REXPFactory(); rx.parseREXP(pc, rxo); return rx.getREXP(); } catch (REXPMismatchException me) { me.printStackTrace(); throw new RserveException(this, "Error when parsing response: "+me.getMessage()); } } return null; } /** evaluates the given command and retrieves the result @param cmd command/expression string @return R-xpression or null if an error occured */ public REXP eval(String cmd) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_eval,cmd+"\n"); if (rp!=null && rp.isOk()) return parseEvalResponse(rp); throw new RserveException(this,"eval failed",rp); } /** assign a string value to a symbol in R. The symbol is created if it doesn't exist already. @param sym symbol name. Currently assign uses CMD_setSEXP command of Rserve, i.e. the symbol value is NOT parsed. It is the responsibility of the user to make sure that the symbol name is valid in R (recall the difference between a symbol and an expression!). In fact R will always create the symbol, but it may not be accessible (examples: "bar\nfoo" or "bar$foo"). @param ct contents */ public void assign(String sym, String ct) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); byte[] symn=sym.getBytes(); byte[] ctn=ct.getBytes(); int sl=symn.length+1; int cl=ctn.length+1; if ((sl&3)>0) sl=(sl&0xfffffc)+4; // make sure the symbol length is divisible by 4 if ((cl&3)>0) cl=(cl&0xfffffc)+4; // make sure the content length is divisible by 4 byte[] rq=new byte[sl+4+cl+4]; int ic; for(ic=0;ic0) sl=(sl&0xfffffc)+4; // make sure the symbol length is divisible by 4 byte[] rq=new byte[sl+rl+((rl>0xfffff0)?12:8)]; int ic; for(ic=0;ic0xfffff0)?12:8)); RPacket rp=rt.request(RTalk.CMD_setSEXP,rq); if (rp!=null && rp.isOk()) return; throw new RserveException(this,"assign failed",rp); } catch (REXPMismatchException me) { throw new RserveException(this, "Error creating binary representation: "+me.getMessage()); } } /** open a file on the Rserve for reading @param fn file name. should not contain any path delimiters, since Rserve may restrict the access to local working directory. @return input stream to be used for reading. Note that the stream is read-once only, there is no support for seek or rewind. */ public RFileInputStream openFile(String fn) throws IOException { return new RFileInputStream(rt,fn); } /** create a file on the Rserve for writing @param fn file name. should not contain any path delimiters, since Rserve may restrict the access to local working directory. @return output stream to be used for writinging. Note that the stream is write-once only, there is no support for seek or rewind. */ public RFileOutputStream createFile(String fn) throws IOException { return new RFileOutputStream(rt,fn); } /** remove a file on the Rserve @param fn file name. should not contain any path delimiters, since Rserve may restrict the access to local working directory. */ public void removeFile(String fn) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_removeFile,fn); if (rp!=null && rp.isOk()) return; throw new RserveException(this,"removeFile failed",rp); } /** shutdown remote Rserve. Note that some Rserves cannot be shut down from the client side. */ public void shutdown() throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_shutdown); if (rp!=null && rp.isOk()) return; throw new RserveException(this,"shutdown failed",rp); } /** Sets send buffer size of the Rserve (in bytes) for the current connection. All responses send by Rserve are stored in the send buffer before transmitting. This means that any objects you want to get from the Rserve need to fit into that buffer. By default the size of the send buffer is 2MB. If you need to receive larger objects from Rserve, you will need to use this function to enlarge the buffer. In order to save memory, you can also reduce the buffer size once it's not used anymore. Currently the buffer size is only limited by the memory available and/or 1GB (whichever is smaller). Current Rserve implementations won't go below buffer sizes of 32kb though. If the specified buffer size results in 'out of memory' on the server, the corresponding error is sent and the connection is terminated.
Note: This command may go away in future versions of Rserve which will use dynamic send buffer allocation. @param sbs send buffer size (in bytes) min=32k, max=1GB */ public void setSendBufferSize(long sbs) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_setBufferSize,(int)sbs); if (rp!=null && rp.isOk()) return; throw new RserveException(this,"setSendBufferSize failed",rp); } /** set string encoding for this session. It is strongly * recommended to make sure the encoding is always set to UTF-8 * because that is the only encoding supported by this Java * client. It can be done either by uisng the * encoding option in the server or by calling * setStringEncoding("utf8") at the beginning of a session (but * after login). @param enc name of the encoding as defined by Rserve - as of Rserve version 0.5-3 valid values are "utf8", "latin1" and "native" (case-sensitive) @since Rserve 0.5-3 */ public void setStringEncoding(String enc) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp = rt.request(RTalk.CMD_setEncoding, enc); if (rp != null && rp.isOk()) return; throw new RserveException(this,"setStringEncoding failed", rp); } /** login using supplied user/pwd. Note that login must be the first command if used @param user username @param pwd password */ public void login(String user, String pwd) throws RserveException { if (!authReq) return; if (!connected || rt==null) throw new RserveException(this,"Not connected"); if (authType==AT_crypt) { if (Key==null) Key="rs"; RPacket rp=rt.request(RTalk.CMD_login,user+"\n"+jcrypt.crypt(Key,pwd)); if (rp!=null && rp.isOk()) return; try { s.close(); } catch(Exception e) {}; is=null; os=null; s=null; connected=false; throw new RserveException(this,"login failed",rp); } RPacket rp=rt.request(RTalk.CMD_login,user+"\n"+pwd); if (rp!=null && rp.isOk()) return; try {s.close();} catch (Exception e) {}; is=null; os=null; s=null; connected=false; throw new RserveException(this,"login failed",rp); } /** detaches the session and closes the connection (requires Rserve 0.4+). The session can be only resumed by calling @link{RSession.attach} */ public RSession detach() throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_detachSession); if (rp==null || !rp.isOk()) throw new RserveException(this,"Cannot detach",rp); RSession s = new RSession(this, rp); close(); return s; } /** check connection state. Note that currently this state is not checked on-the-spot, that is if connection went down by an outside event this is not reflected by the flag @return true if this connection is alive */ public boolean isConnected() { return connected; } /** check authentication requirement sent by server @return true is server requires authentication. In such case first command after connecting must be {@link #login}. */ public boolean needLogin() { return authReq; } /** get last error string @return last error string */ public String getLastError() { return lastError; } /** evaluates the given command in the master server process asynchronously (control command). Note that control commands are always asynchronous, i.e., the expression is enqueued for evaluation in the master process and the method returns before the expression is evaluated (in non-parallel builds the client has to close the connection before the expression can be evaluated). There is no way to check for errors and control commands should be sent with utmost care as they can abort the server process. The evaluation has no immediate effect on the client session. * @param cmd command/expression string * @since Rserve 0.6-0 */ public void serverEval(String cmd) throws RserveException { if (!connected || rt == null) throw new RserveException(this, "Not connected"); RPacket rp = rt.request(RTalk.CMD_ctrlEval, cmd+"\n"); if (rp != null && rp.isOk()) return; throw new RserveException(this,"serverEval failed",rp); } /** sources the given file (the path must be local to the server!) in the master server process asynchronously (control command). See {@link #serverEval()} for details on control commands. * @param serverFile path to a file on the server (it is recommended to always use full paths, because the server process has a different working directory than the client child process!). * @since Rserve 0.6-0 */ public void serverSource(String serverFile) throws RserveException { if (!connected || rt == null) throw new RserveException(this, "Not connected"); RPacket rp = rt.request(RTalk.CMD_ctrlSource, serverFile); if (rp != null && rp.isOk()) return; throw new RserveException(this,"serverSource failed",rp); } /** attempt to shut down the server process cleanly. Note that there is a fundamental difference between the {@link shutdown()} method and this method: serverShutdown() is a proper control command and thus fully authentication controllable, whereas {@link shutdown()} is a client-side command sent to the client child process and thus relying on the ability of the client to signal the server process which may be disabled. Therefore serverShutdown() is preferred and more reliable for Rserve 0.6-0 and higher. * @since Rserve 0.6-0 */ public void serverShutdown() throws RserveException { if (!connected || rt == null) throw new RserveException(this, "Not connected"); RPacket rp = rt.request(RTalk.CMD_ctrlShutdown); if (rp != null && rp.isOk()) return; throw new RserveException(this,"serverShutdown failed",rp); } //========= REngine interface API public REXP parse(String text, boolean resolve) throws REngineException { throw new REngineException(this, "Rserve doesn't support separate parsing step."); } public REXP eval(REXP what, REXP where, boolean resolve) throws REngineException { return new REXPNull(); } public REXP parseAndEval(String text, REXP where, boolean resolve) throws REngineException { if (where!=null) throw new REngineException(this, "Rserve doesn't support environments other than .GlobalEnv"); try { return eval(text); } catch (RserveException re) { throw new REngineException(this, re.getMessage()); } } /** assign into an environment @param symbol symbol name @param value value to assign @param env environment to assign to */ public void assign(String symbol, REXP value, REXP env) throws REngineException { if (env!=null) throw new REngineException(this, "Rserve doesn't support environments other than .GlobalEnv"); try { assign(symbol, value); } catch (RserveException re) { throw new REngineException(this, re.getMessage()); } } /** get a value from an environment @param symbol symbol name @param env environment @param resolve resolve the resulting REXP or just return a reference @return value */ public REXP get(String symbol, REXP env, boolean resolve) throws REngineException { if (!resolve) throw new REngineException(this, "Rserve doesn't support references"); try { return eval("get(\""+symbol+"\")"); } catch (RserveException re) { throw new REngineException(this, re.getMessage()); } } /** fetch the contents of the given reference. The resulting REXP may never be REXPReference. @param ref reference to resolve @return resolved reference */ public REXP resolveReference(REXP ref) throws REngineException { throw new REngineException(this, "Rserve doesn't support references"); } public REXP createReference(REXP ref) throws REngineException { throw new REngineException(this, "Rserve doesn't support references"); } public void finalizeReference(REXP ref) throws REngineException { throw new REngineException(this, "Rserve doesn't support references"); } public REXP getParentEnvironment(REXP env, boolean resolve) throws REngineException { throw new REngineException(this, "Rserve doesn't support environments other than .GlobalEnv"); } public REXP newEnvironment(REXP parent, boolean resolve) throws REngineException { throw new REngineException(this, "Rserve doesn't support environments other than .GlobalEnv"); } } Rserve/clients/java/Rserve/protocol/0000755000176000001440000000000012205226215017236 5ustar ripleyusersRserve/clients/java/Rserve/protocol/RTalk.java0000644000176000001440000002353712205226215021130 0ustar ripleyuserspackage org.rosuda.REngine.Rserve.protocol; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- import java.util.*; import java.io.*; import java.net.*; import org.rosuda.REngine.Rserve.RConnection; /** This class encapsulates the QAP1 protocol used by Rserv. it is independent of the underying protocol(s), therefore RTalk can be used over any transport layer

The current implementation supports long (0.3+/0102) data format only up to 32-bit and only for incoming packets.

@version $Id$ */ public class RTalk { public static final int DT_INT=1; public static final int DT_CHAR=2; public static final int DT_DOUBLE=3; public static final int DT_STRING=4; public static final int DT_BYTESTREAM=5; public static final int DT_SEXP=10; public static final int DT_ARRAY=11; /** this is a flag saying that the contents is large (>0xfffff0) and hence uses 56-bit length field */ public static final int DT_LARGE=64; public static final int CMD_login=0x001; public static final int CMD_voidEval=0x002; public static final int CMD_eval=0x003; public static final int CMD_shutdown=0x004; public static final int CMD_openFile=0x010; public static final int CMD_createFile=0x011; public static final int CMD_closeFile=0x012; public static final int CMD_readFile=0x013; public static final int CMD_writeFile=0x014; public static final int CMD_removeFile=0x015; public static final int CMD_setSEXP=0x020; public static final int CMD_assignSEXP=0x021; public static final int CMD_setBufferSize=0x081; public static final int CMD_setEncoding=0x082; public static final int CMD_detachSession=0x030; public static final int CMD_detachedVoidEval=0x031; public static final int CMD_attachSession=0x032; // control commands since 0.6-0 public static final int CMD_ctrlEval=0x42; public static final int CMD_ctrlSource=0x45; public static final int CMD_ctrlShutdown=0x44; // errors as returned by Rserve public static final int ERR_auth_failed=0x41; public static final int ERR_conn_broken=0x42; public static final int ERR_inv_cmd=0x43; public static final int ERR_inv_par=0x44; public static final int ERR_Rerror=0x45; public static final int ERR_IOerror=0x46; public static final int ERR_not_open=0x47; public static final int ERR_access_denied=0x48; public static final int ERR_unsupported_cmd=0x49; public static final int ERR_unknown_cmd=0x4a; public static final int ERR_data_overflow=0x4b; public static final int ERR_object_too_big=0x4c; public static final int ERR_out_of_mem=0x4d; public static final int ERR_ctrl_closed=0x4e; public static final int ERR_session_busy=0x50; public static final int ERR_detach_failed=0x51; InputStream is; OutputStream os; /** constructor; parameters specify the streams @param sis socket input stream @param sos socket output stream */ public RTalk(InputStream sis, OutputStream sos) { is=sis; os=sos; } /** writes bit-wise int to a byte buffer at specified position in Intel-endian form @param v value to be written @param buf buffer @param o offset in the buffer to start at. An int takes always 4 bytes */ public static void setInt(int v, byte[] buf, int o) { buf[o]=(byte)(v&255); o++; buf[o]=(byte)((v&0xff00)>>8); o++; buf[o]=(byte)((v&0xff0000)>>16); o++; buf[o]=(byte)((v&0xff000000)>>24); } /** writes cmd/resp/type byte + 3/7 bytes len into a byte buffer at specified offset. @param ty type/cmd/resp byte @param len length @param buf buffer @param o offset @return offset in buf just after the header. Please note that since Rserve 0.3 the header can be either 4 or 8 bytes long, depending on the len parameter. */ public static int setHdr(int ty, int len, byte[] buf, int o) { buf[o]=(byte)((ty&255)|((len>0xfffff0)?DT_LARGE:0)); o++; buf[o]=(byte)(len&255); o++; buf[o]=(byte)((len&0xff00)>>8); o++; buf[o]=(byte)((len&0xff0000)>>16); o++; if (len>0xfffff0) { // for large data we need to set the next 4 bytes as well buf[o]=(byte)((len&0xff000000)>>24); o++; buf[o]=0; o++; // since len is int, we get 32-bits only buf[o]=0; o++; buf[o]=0; o++; } return o; } /** creates a new header according to the type and length of the parameter @param ty type/cmd/resp byte @param len length */ public static byte[] newHdr(int ty, int len) { byte[] hdr=new byte[(len>0xfffff0)?8:4]; setHdr(ty,len,hdr,0); return hdr; } /** converts bit-wise stored int in Intel-endian form into Java int @param buf buffer containg the representation @param o offset where to start (4 bytes will be used) @return the int value. no bounds checking is done so you need to make sure that the buffer is big enough */ public static int getInt(byte[] buf, int o) { return ((buf[o]&255)|((buf[o+1]&255)<<8)|((buf[o+2]&255)<<16)|((buf[o+3]&255)<<24)); } /** converts bit-wise stored length from a header. "long" format is supported up to 32-bit @param buf buffer @param o offset of the header (length is at o+1) @return length */ public static int getLen(byte[] buf, int o) { return ((buf[o]&64)>0)? // "long" format; still - we support 32-bit only ((buf[o+1]&255)|((buf[o+2]&255)<<8)|((buf[o+3]&255)<<16)|((buf[o+4]&255)<<24)) : ((buf[o+1]&255)|((buf[o+2]&255)<<8)|((buf[o+3]&255)<<16)); } /** converts bit-wise Intel-endian format into long @param buf buffer @param o offset (8 bytes will be used) @return long value */ public static long getLong(byte[] buf, int o) { long low=((long)getInt(buf,o))&0xffffffffL; long hi=((long)getInt(buf,o+4))&0xffffffffL; hi<<=32; hi|=low; return hi; } public static void setLong(long l, byte[] buf, int o) { setInt((int)(l&0xffffffffL),buf,o); setInt((int)(l>>32),buf,o+4); } /** sends a request with no attached parameters @param cmd command @return returned packet or null if something went wrong */ public RPacket request(int cmd) { byte[] d = new byte[0]; return request(cmd,d); } /** sends a request with attached parameters @param cmd command @param cont contents - parameters @return returned packet or null if something went wrong */ public RPacket request(int cmd, byte[] cont) { return request(cmd,null,cont,0,(cont==null)?0:cont.length); } /** sends a request with attached prefix and parameters. Both prefix and cont can be null. Effectively request(a,b,null) and request(a,null,b) are equivalent. @param cmd command - a special command of -1 prevents request from sending anything @param prefix - this content is sent *before* cont. It is provided to save memory copy operations where a small header precedes a large data chunk (usually prefix conatins the parameter header and cont contains the actual data). @param cont contents @param offset offset in cont where to start sending (if <0 then 0 is assumed, if >cont.length then no cont is sent) @param len number of bytes in cont to send (it is clipped to the length of cont if necessary) @return returned packet or null if something went wrong */ public RPacket request(int cmd, byte[] prefix, byte[] cont, int offset, int len) { if (cont!=null) { if (offset>=cont.length) { cont=null; len=0; } else if (len>cont.length-offset) len=cont.length-offset; } if (offset<0) offset=0; if (len<0) len=0; int contlen=(cont==null)?0:len; if (prefix!=null && prefix.length>0) contlen+=prefix.length; byte[] hdr=new byte[16]; setInt(cmd,hdr,0); setInt(contlen,hdr,4); for(int i=8;i<16;i++) hdr[i]=0; try { if (cmd!=-1) { os.write(hdr); if (prefix!=null && prefix.length>0) os.write(prefix); if (cont!=null && cont.length>0) os.write(cont,offset,len); } byte[] ih=new byte[16]; if (is.read(ih)!=16) return null; int rep=getInt(ih,0); int rl =getInt(ih,4); if (rl>0) { byte[] ct=new byte[rl]; int n=0; while (nnull if something went wrong */ public RPacket request(int cmd, String par) { try { byte[] b=par.getBytes(RConnection.transferCharset); int sl=b.length+1; if ((sl&3)>0) sl=(sl&0xfffffc)+4; // make sure the length is divisible by 4 byte[] rq=new byte[sl+5]; int i; for(i=0;inull if something went wrong */ public RPacket request(int cmd, int par) { try { byte[] rq=new byte[8]; setInt(par,rq,4); setHdr(DT_INT,4,rq,0); return request(cmd,rq); } catch (Exception e) { }; return null; } } Rserve/clients/java/Rserve/protocol/RPacket.java0000644000176000001440000000242412205226215021434 0ustar ripleyuserspackage org.rosuda.REngine.Rserve.protocol; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- /** small class encapsulating packets from/to Rserv @version $Id$ */ public class RPacket { int cmd; byte[] cont; /** construct new packet @param Rcmd command @param Rcont content */ public RPacket(int Rcmd, byte[] Rcont) { cmd=Rcmd; cont=Rcont; } /** get command @return command */ public int getCmd() { return cmd; } /** check last response for RESP_OK @return true if last response was OK */ public boolean isOk() { return ((cmd&15)==1); } /** check last response for RESP_ERR @return true if last response was ERROR */ public boolean isError() { return ((cmd&15)==2); } /** get status code of last response @return status code returned on last response */ public int getStat() { return ((cmd>>24)&127); } /** get content @return inner package content */ public byte[] getCont() { return cont; } public String toString() { return "RPacket[cmd="+cmd+",len="+((cont==null)?"":(""+cont.length))+"]"; } } Rserve/clients/java/Rserve/protocol/jcrypt.java0000644000176000001440000005731612205226215021430 0ustar ripleyuserspackage org.rosuda.REngine.Rserve.protocol; /**************************************************************************** * jcrypt.java * * Java-based implementation of the unix crypt command * * Based upon C source code written by Eric Young, eay@psych.uq.oz.au * ****************************************************************************/ public class jcrypt { private static final int ITERATIONS = 16; private static final int con_salt[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, }; private static final boolean shifts2[] = { false, false, true, true, true, true, true, true, false, true, true, true, true, true, true, false }; private static final int skb[][] = { { /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ 0x00000000, 0x00000010, 0x20000000, 0x20000010, 0x00010000, 0x00010010, 0x20010000, 0x20010010, 0x00000800, 0x00000810, 0x20000800, 0x20000810, 0x00010800, 0x00010810, 0x20010800, 0x20010810, 0x00000020, 0x00000030, 0x20000020, 0x20000030, 0x00010020, 0x00010030, 0x20010020, 0x20010030, 0x00000820, 0x00000830, 0x20000820, 0x20000830, 0x00010820, 0x00010830, 0x20010820, 0x20010830, 0x00080000, 0x00080010, 0x20080000, 0x20080010, 0x00090000, 0x00090010, 0x20090000, 0x20090010, 0x00080800, 0x00080810, 0x20080800, 0x20080810, 0x00090800, 0x00090810, 0x20090800, 0x20090810, 0x00080020, 0x00080030, 0x20080020, 0x20080030, 0x00090020, 0x00090030, 0x20090020, 0x20090030, 0x00080820, 0x00080830, 0x20080820, 0x20080830, 0x00090820, 0x00090830, 0x20090820, 0x20090830, }, { /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ 0x00000000, 0x02000000, 0x00002000, 0x02002000, 0x00200000, 0x02200000, 0x00202000, 0x02202000, 0x00000004, 0x02000004, 0x00002004, 0x02002004, 0x00200004, 0x02200004, 0x00202004, 0x02202004, 0x00000400, 0x02000400, 0x00002400, 0x02002400, 0x00200400, 0x02200400, 0x00202400, 0x02202400, 0x00000404, 0x02000404, 0x00002404, 0x02002404, 0x00200404, 0x02200404, 0x00202404, 0x02202404, 0x10000000, 0x12000000, 0x10002000, 0x12002000, 0x10200000, 0x12200000, 0x10202000, 0x12202000, 0x10000004, 0x12000004, 0x10002004, 0x12002004, 0x10200004, 0x12200004, 0x10202004, 0x12202004, 0x10000400, 0x12000400, 0x10002400, 0x12002400, 0x10200400, 0x12200400, 0x10202400, 0x12202400, 0x10000404, 0x12000404, 0x10002404, 0x12002404, 0x10200404, 0x12200404, 0x10202404, 0x12202404, }, { /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ 0x00000000, 0x00000001, 0x00040000, 0x00040001, 0x01000000, 0x01000001, 0x01040000, 0x01040001, 0x00000002, 0x00000003, 0x00040002, 0x00040003, 0x01000002, 0x01000003, 0x01040002, 0x01040003, 0x00000200, 0x00000201, 0x00040200, 0x00040201, 0x01000200, 0x01000201, 0x01040200, 0x01040201, 0x00000202, 0x00000203, 0x00040202, 0x00040203, 0x01000202, 0x01000203, 0x01040202, 0x01040203, 0x08000000, 0x08000001, 0x08040000, 0x08040001, 0x09000000, 0x09000001, 0x09040000, 0x09040001, 0x08000002, 0x08000003, 0x08040002, 0x08040003, 0x09000002, 0x09000003, 0x09040002, 0x09040003, 0x08000200, 0x08000201, 0x08040200, 0x08040201, 0x09000200, 0x09000201, 0x09040200, 0x09040201, 0x08000202, 0x08000203, 0x08040202, 0x08040203, 0x09000202, 0x09000203, 0x09040202, 0x09040203, }, { /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ 0x00000000, 0x00100000, 0x00000100, 0x00100100, 0x00000008, 0x00100008, 0x00000108, 0x00100108, 0x00001000, 0x00101000, 0x00001100, 0x00101100, 0x00001008, 0x00101008, 0x00001108, 0x00101108, 0x04000000, 0x04100000, 0x04000100, 0x04100100, 0x04000008, 0x04100008, 0x04000108, 0x04100108, 0x04001000, 0x04101000, 0x04001100, 0x04101100, 0x04001008, 0x04101008, 0x04001108, 0x04101108, 0x00020000, 0x00120000, 0x00020100, 0x00120100, 0x00020008, 0x00120008, 0x00020108, 0x00120108, 0x00021000, 0x00121000, 0x00021100, 0x00121100, 0x00021008, 0x00121008, 0x00021108, 0x00121108, 0x04020000, 0x04120000, 0x04020100, 0x04120100, 0x04020008, 0x04120008, 0x04020108, 0x04120108, 0x04021000, 0x04121000, 0x04021100, 0x04121100, 0x04021008, 0x04121008, 0x04021108, 0x04121108, }, { /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ 0x00000000, 0x10000000, 0x00010000, 0x10010000, 0x00000004, 0x10000004, 0x00010004, 0x10010004, 0x20000000, 0x30000000, 0x20010000, 0x30010000, 0x20000004, 0x30000004, 0x20010004, 0x30010004, 0x00100000, 0x10100000, 0x00110000, 0x10110000, 0x00100004, 0x10100004, 0x00110004, 0x10110004, 0x20100000, 0x30100000, 0x20110000, 0x30110000, 0x20100004, 0x30100004, 0x20110004, 0x30110004, 0x00001000, 0x10001000, 0x00011000, 0x10011000, 0x00001004, 0x10001004, 0x00011004, 0x10011004, 0x20001000, 0x30001000, 0x20011000, 0x30011000, 0x20001004, 0x30001004, 0x20011004, 0x30011004, 0x00101000, 0x10101000, 0x00111000, 0x10111000, 0x00101004, 0x10101004, 0x00111004, 0x10111004, 0x20101000, 0x30101000, 0x20111000, 0x30111000, 0x20101004, 0x30101004, 0x20111004, 0x30111004, }, { /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ 0x00000000, 0x08000000, 0x00000008, 0x08000008, 0x00000400, 0x08000400, 0x00000408, 0x08000408, 0x00020000, 0x08020000, 0x00020008, 0x08020008, 0x00020400, 0x08020400, 0x00020408, 0x08020408, 0x00000001, 0x08000001, 0x00000009, 0x08000009, 0x00000401, 0x08000401, 0x00000409, 0x08000409, 0x00020001, 0x08020001, 0x00020009, 0x08020009, 0x00020401, 0x08020401, 0x00020409, 0x08020409, 0x02000000, 0x0A000000, 0x02000008, 0x0A000008, 0x02000400, 0x0A000400, 0x02000408, 0x0A000408, 0x02020000, 0x0A020000, 0x02020008, 0x0A020008, 0x02020400, 0x0A020400, 0x02020408, 0x0A020408, 0x02000001, 0x0A000001, 0x02000009, 0x0A000009, 0x02000401, 0x0A000401, 0x02000409, 0x0A000409, 0x02020001, 0x0A020001, 0x02020009, 0x0A020009, 0x02020401, 0x0A020401, 0x02020409, 0x0A020409, }, { /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ 0x00000000, 0x00000100, 0x00080000, 0x00080100, 0x01000000, 0x01000100, 0x01080000, 0x01080100, 0x00000010, 0x00000110, 0x00080010, 0x00080110, 0x01000010, 0x01000110, 0x01080010, 0x01080110, 0x00200000, 0x00200100, 0x00280000, 0x00280100, 0x01200000, 0x01200100, 0x01280000, 0x01280100, 0x00200010, 0x00200110, 0x00280010, 0x00280110, 0x01200010, 0x01200110, 0x01280010, 0x01280110, 0x00000200, 0x00000300, 0x00080200, 0x00080300, 0x01000200, 0x01000300, 0x01080200, 0x01080300, 0x00000210, 0x00000310, 0x00080210, 0x00080310, 0x01000210, 0x01000310, 0x01080210, 0x01080310, 0x00200200, 0x00200300, 0x00280200, 0x00280300, 0x01200200, 0x01200300, 0x01280200, 0x01280300, 0x00200210, 0x00200310, 0x00280210, 0x00280310, 0x01200210, 0x01200310, 0x01280210, 0x01280310, }, { /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ 0x00000000, 0x04000000, 0x00040000, 0x04040000, 0x00000002, 0x04000002, 0x00040002, 0x04040002, 0x00002000, 0x04002000, 0x00042000, 0x04042000, 0x00002002, 0x04002002, 0x00042002, 0x04042002, 0x00000020, 0x04000020, 0x00040020, 0x04040020, 0x00000022, 0x04000022, 0x00040022, 0x04040022, 0x00002020, 0x04002020, 0x00042020, 0x04042020, 0x00002022, 0x04002022, 0x00042022, 0x04042022, 0x00000800, 0x04000800, 0x00040800, 0x04040800, 0x00000802, 0x04000802, 0x00040802, 0x04040802, 0x00002800, 0x04002800, 0x00042800, 0x04042800, 0x00002802, 0x04002802, 0x00042802, 0x04042802, 0x00000820, 0x04000820, 0x00040820, 0x04040820, 0x00000822, 0x04000822, 0x00040822, 0x04040822, 0x00002820, 0x04002820, 0x00042820, 0x04042820, 0x00002822, 0x04002822, 0x00042822, 0x04042822, }, }; private static final int SPtrans[][] = { { /* nibble 0 */ 0x00820200, 0x00020000, 0x80800000, 0x80820200, 0x00800000, 0x80020200, 0x80020000, 0x80800000, 0x80020200, 0x00820200, 0x00820000, 0x80000200, 0x80800200, 0x00800000, 0x00000000, 0x80020000, 0x00020000, 0x80000000, 0x00800200, 0x00020200, 0x80820200, 0x00820000, 0x80000200, 0x00800200, 0x80000000, 0x00000200, 0x00020200, 0x80820000, 0x00000200, 0x80800200, 0x80820000, 0x00000000, 0x00000000, 0x80820200, 0x00800200, 0x80020000, 0x00820200, 0x00020000, 0x80000200, 0x00800200, 0x80820000, 0x00000200, 0x00020200, 0x80800000, 0x80020200, 0x80000000, 0x80800000, 0x00820000, 0x80820200, 0x00020200, 0x00820000, 0x80800200, 0x00800000, 0x80000200, 0x80020000, 0x00000000, 0x00020000, 0x00800000, 0x80800200, 0x00820200, 0x80000000, 0x80820000, 0x00000200, 0x80020200, }, { /* nibble 1 */ 0x10042004, 0x00000000, 0x00042000, 0x10040000, 0x10000004, 0x00002004, 0x10002000, 0x00042000, 0x00002000, 0x10040004, 0x00000004, 0x10002000, 0x00040004, 0x10042000, 0x10040000, 0x00000004, 0x00040000, 0x10002004, 0x10040004, 0x00002000, 0x00042004, 0x10000000, 0x00000000, 0x00040004, 0x10002004, 0x00042004, 0x10042000, 0x10000004, 0x10000000, 0x00040000, 0x00002004, 0x10042004, 0x00040004, 0x10042000, 0x10002000, 0x00042004, 0x10042004, 0x00040004, 0x10000004, 0x00000000, 0x10000000, 0x00002004, 0x00040000, 0x10040004, 0x00002000, 0x10000000, 0x00042004, 0x10002004, 0x10042000, 0x00002000, 0x00000000, 0x10000004, 0x00000004, 0x10042004, 0x00042000, 0x10040000, 0x10040004, 0x00040000, 0x00002004, 0x10002000, 0x10002004, 0x00000004, 0x10040000, 0x00042000, }, { /* nibble 2 */ 0x41000000, 0x01010040, 0x00000040, 0x41000040, 0x40010000, 0x01000000, 0x41000040, 0x00010040, 0x01000040, 0x00010000, 0x01010000, 0x40000000, 0x41010040, 0x40000040, 0x40000000, 0x41010000, 0x00000000, 0x40010000, 0x01010040, 0x00000040, 0x40000040, 0x41010040, 0x00010000, 0x41000000, 0x41010000, 0x01000040, 0x40010040, 0x01010000, 0x00010040, 0x00000000, 0x01000000, 0x40010040, 0x01010040, 0x00000040, 0x40000000, 0x00010000, 0x40000040, 0x40010000, 0x01010000, 0x41000040, 0x00000000, 0x01010040, 0x00010040, 0x41010000, 0x40010000, 0x01000000, 0x41010040, 0x40000000, 0x40010040, 0x41000000, 0x01000000, 0x41010040, 0x00010000, 0x01000040, 0x41000040, 0x00010040, 0x01000040, 0x00000000, 0x41010000, 0x40000040, 0x41000000, 0x40010040, 0x00000040, 0x01010000, }, { /* nibble 3 */ 0x00100402, 0x04000400, 0x00000002, 0x04100402, 0x00000000, 0x04100000, 0x04000402, 0x00100002, 0x04100400, 0x04000002, 0x04000000, 0x00000402, 0x04000002, 0x00100402, 0x00100000, 0x04000000, 0x04100002, 0x00100400, 0x00000400, 0x00000002, 0x00100400, 0x04000402, 0x04100000, 0x00000400, 0x00000402, 0x00000000, 0x00100002, 0x04100400, 0x04000400, 0x04100002, 0x04100402, 0x00100000, 0x04100002, 0x00000402, 0x00100000, 0x04000002, 0x00100400, 0x04000400, 0x00000002, 0x04100000, 0x04000402, 0x00000000, 0x00000400, 0x00100002, 0x00000000, 0x04100002, 0x04100400, 0x00000400, 0x04000000, 0x04100402, 0x00100402, 0x00100000, 0x04100402, 0x00000002, 0x04000400, 0x00100402, 0x00100002, 0x00100400, 0x04100000, 0x04000402, 0x00000402, 0x04000000, 0x04000002, 0x04100400, }, { /* nibble 4 */ 0x02000000, 0x00004000, 0x00000100, 0x02004108, 0x02004008, 0x02000100, 0x00004108, 0x02004000, 0x00004000, 0x00000008, 0x02000008, 0x00004100, 0x02000108, 0x02004008, 0x02004100, 0x00000000, 0x00004100, 0x02000000, 0x00004008, 0x00000108, 0x02000100, 0x00004108, 0x00000000, 0x02000008, 0x00000008, 0x02000108, 0x02004108, 0x00004008, 0x02004000, 0x00000100, 0x00000108, 0x02004100, 0x02004100, 0x02000108, 0x00004008, 0x02004000, 0x00004000, 0x00000008, 0x02000008, 0x02000100, 0x02000000, 0x00004100, 0x02004108, 0x00000000, 0x00004108, 0x02000000, 0x00000100, 0x00004008, 0x02000108, 0x00000100, 0x00000000, 0x02004108, 0x02004008, 0x02004100, 0x00000108, 0x00004000, 0x00004100, 0x02004008, 0x02000100, 0x00000108, 0x00000008, 0x00004108, 0x02004000, 0x02000008, }, { /* nibble 5 */ 0x20000010, 0x00080010, 0x00000000, 0x20080800, 0x00080010, 0x00000800, 0x20000810, 0x00080000, 0x00000810, 0x20080810, 0x00080800, 0x20000000, 0x20000800, 0x20000010, 0x20080000, 0x00080810, 0x00080000, 0x20000810, 0x20080010, 0x00000000, 0x00000800, 0x00000010, 0x20080800, 0x20080010, 0x20080810, 0x20080000, 0x20000000, 0x00000810, 0x00000010, 0x00080800, 0x00080810, 0x20000800, 0x00000810, 0x20000000, 0x20000800, 0x00080810, 0x20080800, 0x00080010, 0x00000000, 0x20000800, 0x20000000, 0x00000800, 0x20080010, 0x00080000, 0x00080010, 0x20080810, 0x00080800, 0x00000010, 0x20080810, 0x00080800, 0x00080000, 0x20000810, 0x20000010, 0x20080000, 0x00080810, 0x00000000, 0x00000800, 0x20000010, 0x20000810, 0x20080800, 0x20080000, 0x00000810, 0x00000010, 0x20080010, }, { /* nibble 6 */ 0x00001000, 0x00000080, 0x00400080, 0x00400001, 0x00401081, 0x00001001, 0x00001080, 0x00000000, 0x00400000, 0x00400081, 0x00000081, 0x00401000, 0x00000001, 0x00401080, 0x00401000, 0x00000081, 0x00400081, 0x00001000, 0x00001001, 0x00401081, 0x00000000, 0x00400080, 0x00400001, 0x00001080, 0x00401001, 0x00001081, 0x00401080, 0x00000001, 0x00001081, 0x00401001, 0x00000080, 0x00400000, 0x00001081, 0x00401000, 0x00401001, 0x00000081, 0x00001000, 0x00000080, 0x00400000, 0x00401001, 0x00400081, 0x00001081, 0x00001080, 0x00000000, 0x00000080, 0x00400001, 0x00000001, 0x00400080, 0x00000000, 0x00400081, 0x00400080, 0x00001080, 0x00000081, 0x00001000, 0x00401081, 0x00400000, 0x00401080, 0x00000001, 0x00001001, 0x00401081, 0x00400001, 0x00401080, 0x00401000, 0x00001001, }, { /* nibble 7 */ 0x08200020, 0x08208000, 0x00008020, 0x00000000, 0x08008000, 0x00200020, 0x08200000, 0x08208020, 0x00000020, 0x08000000, 0x00208000, 0x00008020, 0x00208020, 0x08008020, 0x08000020, 0x08200000, 0x00008000, 0x00208020, 0x00200020, 0x08008000, 0x08208020, 0x08000020, 0x00000000, 0x00208000, 0x08000000, 0x00200000, 0x08008020, 0x08200020, 0x00200000, 0x00008000, 0x08208000, 0x00000020, 0x00200000, 0x00008000, 0x08000020, 0x08208020, 0x00008020, 0x08000000, 0x00000000, 0x00208000, 0x08200020, 0x08008020, 0x08008000, 0x00200020, 0x08208000, 0x00000020, 0x00200020, 0x08008000, 0x08208020, 0x00200000, 0x08200000, 0x08000020, 0x00208000, 0x00008020, 0x08008020, 0x08200000, 0x00000020, 0x08208000, 0x00208020, 0x00000000, 0x08000000, 0x08200020, 0x00008000, 0x00208020 } }; private static final int cov_2char[] = { 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A }; private static final int byteToUnsigned(byte b) { int value = (int)b; return(value >= 0 ? value : value + 256); } private static int fourBytesToInt(byte b[], int offset) { int value; value = byteToUnsigned(b[offset++]); value |= (byteToUnsigned(b[offset++]) << 8); value |= (byteToUnsigned(b[offset++]) << 16); value |= (byteToUnsigned(b[offset++]) << 24); return(value); } private static final void intToFourBytes(int iValue, byte b[], int offset) { b[offset++] = (byte)((iValue) & 0xff); b[offset++] = (byte)((iValue >>> 8 ) & 0xff); b[offset++] = (byte)((iValue >>> 16) & 0xff); b[offset++] = (byte)((iValue >>> 24) & 0xff); } private static final void PERM_OP(int a, int b, int n, int m, int results[]) { int t; t = ((a >>> n) ^ b) & m; a ^= t << n; b ^= t; results[0] = a; results[1] = b; } private static final int HPERM_OP(int a, int n, int m) { int t; t = ((a << (16 - n)) ^ a) & m; a = a ^ t ^ (t >>> (16 - n)); return(a); } private static int [] des_set_key(byte key[]) { int schedule[] = new int[ITERATIONS * 2]; int c = fourBytesToInt(key, 0); int d = fourBytesToInt(key, 4); int results[] = new int[2]; PERM_OP(d, c, 4, 0x0f0f0f0f, results); d = results[0]; c = results[1]; c = HPERM_OP(c, -2, 0xcccc0000); d = HPERM_OP(d, -2, 0xcccc0000); PERM_OP(d, c, 1, 0x55555555, results); d = results[0]; c = results[1]; PERM_OP(c, d, 8, 0x00ff00ff, results); c = results[0]; d = results[1]; PERM_OP(d, c, 1, 0x55555555, results); d = results[0]; c = results[1]; d = (((d & 0x000000ff) << 16) | (d & 0x0000ff00) | ((d & 0x00ff0000) >>> 16) | ((c & 0xf0000000) >>> 4)); c &= 0x0fffffff; int s, t; int j = 0; for(int i = 0; i < ITERATIONS; i ++) { if(shifts2[i]) { c = (c >>> 2) | (c << 26); d = (d >>> 2) | (d << 26); } else { c = (c >>> 1) | (c << 27); d = (d >>> 1) | (d << 27); } c &= 0x0fffffff; d &= 0x0fffffff; s = skb[0][ (c ) & 0x3f ]| skb[1][((c >>> 6) & 0x03) | ((c >>> 7) & 0x3c)]| skb[2][((c >>> 13) & 0x0f) | ((c >>> 14) & 0x30)]| skb[3][((c >>> 20) & 0x01) | ((c >>> 21) & 0x06) | ((c >>> 22) & 0x38)]; t = skb[4][ (d ) & 0x3f ]| skb[5][((d >>> 7) & 0x03) | ((d >>> 8) & 0x3c)]| skb[6][ (d >>>15) & 0x3f ]| skb[7][((d >>>21) & 0x0f) | ((d >>> 22) & 0x30)]; schedule[j++] = ((t << 16) | (s & 0x0000ffff)) & 0xffffffff; s = ((s >>> 16) | (t & 0xffff0000)); s = (s << 4) | (s >>> 28); schedule[j++] = s & 0xffffffff; } return(schedule); } private static final int D_ENCRYPT ( int L, int R, int S, int E0, int E1, int s[] ) { int t, u, v; v = R ^ (R >>> 16); u = v & E0; v = v & E1; u = (u ^ (u << 16)) ^ R ^ s[S]; t = (v ^ (v << 16)) ^ R ^ s[S + 1]; t = (t >>> 4) | (t << 28); L ^= SPtrans[1][(t ) & 0x3f] | SPtrans[3][(t >>> 8) & 0x3f] | SPtrans[5][(t >>> 16) & 0x3f] | SPtrans[7][(t >>> 24) & 0x3f] | SPtrans[0][(u ) & 0x3f] | SPtrans[2][(u >>> 8) & 0x3f] | SPtrans[4][(u >>> 16) & 0x3f] | SPtrans[6][(u >>> 24) & 0x3f]; return(L); } private static final int [] body(int schedule[], int Eswap0, int Eswap1) { int left = 0; int right = 0; int t = 0; for(int j = 0; j < 25; j ++) { for(int i = 0; i < ITERATIONS * 2; i += 4) { left = D_ENCRYPT(left, right, i, Eswap0, Eswap1, schedule); right = D_ENCRYPT(right, left, i + 2, Eswap0, Eswap1, schedule); } t = left; left = right; right = t; } t = right; right = (left >>> 1) | (left << 31); left = (t >>> 1) | (t << 31); left &= 0xffffffff; right &= 0xffffffff; int results[] = new int[2]; PERM_OP(right, left, 1, 0x55555555, results); right = results[0]; left = results[1]; PERM_OP(left, right, 8, 0x00ff00ff, results); left = results[0]; right = results[1]; PERM_OP(right, left, 2, 0x33333333, results); right = results[0]; left = results[1]; PERM_OP(left, right, 16, 0x0000ffff, results); left = results[0]; right = results[1]; PERM_OP(right, left, 4, 0x0f0f0f0f, results); right = results[0]; left = results[1]; int out[] = new int[2]; out[0] = left; out[1] = right; return(out); } public static final String crypt(String salt, String original) { while(salt.length() < 2) salt += "A"; StringBuffer buffer = new StringBuffer(" "); char charZero = salt.charAt(0); char charOne = salt.charAt(1); buffer.setCharAt(0, charZero); buffer.setCharAt(1, charOne); int Eswap0 = con_salt[(int)charZero]; int Eswap1 = con_salt[(int)charOne] << 4; byte key[] = new byte[8]; for(int i = 0; i < key.length; i ++) key[i] = (byte)0; for(int i = 0; i < key.length && i < original.length(); i ++) { int iChar = (int)original.charAt(i); key[i] = (byte)(iChar << 1); } int schedule[] = des_set_key(key); int out[] = body(schedule, Eswap0, Eswap1); byte b[] = new byte[9]; intToFourBytes(out[0], b, 0); intToFourBytes(out[1], b, 4); b[8] = 0; for(int i = 2, y = 0, u = 0x80; i < 13; i ++) { for(int j = 0, c = 0; j < 6; j ++) { c <<= 1; if(((int)b[y] & u) != 0) c |= 1; u >>>= 1; if(u == 0) { y++; u = 0x80; } buffer.setCharAt(i, (char)cov_2char[c]); } } return(buffer.toString()); } } Rserve/clients/java/Rserve/protocol/REXPFactory.java0000644000176000001440000005546312205226215022224 0ustar ripleyuserspackage org.rosuda.REngine.Rserve.protocol; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004-8 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- import java.util.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.*; /** representation of R-eXpressions in Java @version $Id$ */ public class REXPFactory { /** xpression type: NULL */ public static final int XT_NULL=0; /** xpression type: integer */ public static final int XT_INT=1; /** xpression type: double */ public static final int XT_DOUBLE=2; /** xpression type: String */ public static final int XT_STR=3; /** xpression type: language construct (currently content is same as list) */ public static final int XT_LANG=4; /** xpression type: symbol (content is symbol name: String) */ public static final int XT_SYM=5; /** xpression type: RBool */ public static final int XT_BOOL=6; /** xpression type: S4 object @since Rserve 0.5 */ public static final int XT_S4=7; /** xpression type: generic vector (RList) */ public static final int XT_VECTOR=16; /** xpression type: dotted-pair list (RList) */ public static final int XT_LIST=17; /** xpression type: closure (there is no java class for that type (yet?). currently the body of the closure is stored in the content part of the REXP. Please note that this may change in the future!) */ public static final int XT_CLOS=18; /** xpression type: symbol name @since Rserve 0.5 */ public static final int XT_SYMNAME=19; /** xpression type: dotted-pair list (w/o tags) @since Rserve 0.5 */ public static final int XT_LIST_NOTAG=20; /** xpression type: dotted-pair list (w tags) @since Rserve 0.5 */ public static final int XT_LIST_TAG=21; /** xpression type: language list (w/o tags) @since Rserve 0.5 */ public static final int XT_LANG_NOTAG=22; /** xpression type: language list (w tags) @since Rserve 0.5 */ public static final int XT_LANG_TAG=23; /** xpression type: expression vector */ public static final int XT_VECTOR_EXP=26; /** xpression type: string vector */ public static final int XT_VECTOR_STR=27; /** xpression type: int[] */ public static final int XT_ARRAY_INT=32; /** xpression type: double[] */ public static final int XT_ARRAY_DOUBLE=33; /** xpression type: String[] (currently not used, Vector is used instead) */ public static final int XT_ARRAY_STR=34; /** internal use only! this constant should never appear in a REXP */ public static final int XT_ARRAY_BOOL_UA=35; /** xpression type: RBool[] */ public static final int XT_ARRAY_BOOL=36; /** xpression type: raw (byte[]) @since Rserve 0.4-? */ public static final int XT_RAW=37; /** xpression type: Complex[] @since Rserve 0.5 */ public static final int XT_ARRAY_CPLX=38; /** xpression type: unknown; no assumptions can be made about the content */ public static final int XT_UNKNOWN=48; /** xpression type: RFactor; this XT is internally generated (ergo is does not come from Rsrv.h) to support RFactor class which is built from XT_ARRAY_INT */ public static final int XT_FACTOR=127; /** used for transport only - has attribute */ private static final int XT_HAS_ATTR=128; int type; REXPFactory attr; REXP cont; RList rootList; public REXP getREXP() { return cont; } public REXPList getAttr() { return (attr==null)?null:(REXPList)attr.cont; } public REXPFactory() { } public REXPFactory(REXP r) throws REXPMismatchException { if (r == null) r=new REXPNull(); REXPList a = r._attr(); cont = r; if (a != null) attr = new REXPFactory(a); if (r instanceof REXPNull) { type=XT_NULL; } else if (r instanceof REXPList) { RList l = r.asList(); type = l.isNamed()?XT_LIST_TAG:XT_LIST_NOTAG; if (r instanceof REXPLanguage) type = (type==XT_LIST_TAG)?XT_LANG_TAG:XT_LANG_NOTAG; } else if (r instanceof REXPGenericVector) { type = XT_VECTOR; // FIXME: may have to adjust names attr } else if (r instanceof REXPS4) { type = XT_S4; } else if (r instanceof REXPInteger) { // this includes factor - FIXME: do we need speacial handling? type = XT_ARRAY_INT; } else if (r instanceof REXPDouble) { type = XT_ARRAY_DOUBLE; } else if (r instanceof REXPString) { type = XT_ARRAY_STR; } else if (r instanceof REXPSymbol) { type = XT_SYMNAME; } else if (r instanceof REXPRaw) { type = XT_RAW; } else if (r instanceof REXPLogical) { type = XT_ARRAY_BOOL; } else { // throw new REXPMismatchException(r, "decode"); System.err.println("*** REXPFactory unable to interpret "+r); } } /** parses byte buffer for binary representation of xpressions - read one xpression slot (descends recursively for aggregated xpressions such as lists, vectors etc.) @param buf buffer containing the binary representation @param o offset in the buffer to start at @return position just behind the parsed xpression. Can be use for successive calls to {@link #parseREXP} if more than one expression is stored in the binary array. */ public int parseREXP(byte[] buf, int o) throws REXPMismatchException { int xl = RTalk.getLen(buf,o); boolean hasAtt = ((buf[o]&128)!=0); boolean isLong = ((buf[o]&64)!=0); int xt = (int)(buf[o]&63); //System.out.println("parseREXP: type="+xt+", len="+xl+", hasAtt="+hasAtt+", isLong="+isLong); if (isLong) o+=4; o+=4; int eox=o+xl; type=xt; attr=new REXPFactory(); cont=null; if (hasAtt) o = attr.parseREXP(buf, o); if (xt==XT_NULL) { cont = new REXPNull(getAttr()); return o; } if (xt==XT_DOUBLE) { long lr = RTalk.getLong(buf,o); double[] d = new double[] { Double.longBitsToDouble(lr) }; o+=8; if (o!=eox) { System.err.println("Warning: double SEXP size mismatch\n"); o=eox; } cont = new REXPDouble(d, getAttr()); return o; } if (xt==XT_ARRAY_DOUBLE) { int as=(eox-o)/8,i=0; double[] d=new double[as]; while (o 0) { c = 0; i = o; while (o < eox) { if (buf[o] == 0) { try { if (buf[i] == -1) { /* if the first byte is 0xff (-1 in signed char) then it either needs to be skipped (doubling) or there is an NA value */ if (buf[i + 1] == 0) s[c] = null; /* NA */ else s[c] = new String(buf, i + 1, o - i - 1, RConnection.transferCharset); } else s[c] = new String(buf, i, o - i, RConnection.transferCharset); } catch (java.io.UnsupportedEncodingException ex) { s[c]=""; } c++; i = o + 1; } o++; } } cont = new REXPString(s, getAttr()); return o; } if (xt==XT_VECTOR_STR) { Vector v=new Vector(); while(oPlease note that currently only XT_[ARRAY_]INT, XT_[ARRAY_]DOUBLE and XT_[ARRAY_]STR are supported! All other types will return 4 which is the size of the header. @return length of the REXP including headers (4 or 8 bytes)*/ public int getBinaryLength() throws REXPMismatchException { int l=0; int rxt = type; if (type==XT_LIST || type==XT_LIST_TAG || type==XT_LIST_NOTAG) rxt=(cont.asList()!=null && cont.asList().isNamed())?XT_LIST_TAG:XT_LIST_NOTAG; //System.out.print("len["+xtName(type)+"/"+xtName(rxt)+"] "); if (type==XT_VECTOR_STR) rxt=XT_ARRAY_STR; // VECTOR_STR is broken right now /* if (type==XT_VECTOR && cont.asList()!=null && cont.asList().isNamed()) setAttribute("names",new REXPString(cont.asList().keys())); */ boolean hasAttr = false; REXPList a = getAttr(); RList al = null; if (a!=null) al = a.asList(); if (al != null && al.size()>0) hasAttr=true; if (hasAttr) l+=attr.getBinaryLength(); switch (rxt) { case XT_NULL: case XT_S4: break; case XT_INT: l+=4; break; case XT_DOUBLE: l+=8; break; case XT_RAW: l+=4 + cont.asBytes().length; if ((l&3)>0) l=l-(l&3)+4; break; case XT_STR: case XT_SYMNAME: l+=(cont==null)?1:(cont.asString().length()+1); if ((l&3)>0) l=l-(l&3)+4; break; case XT_ARRAY_INT: l+=cont.asIntegers().length*4; break; case XT_ARRAY_DOUBLE: l+=cont.asDoubles().length*8; break; case XT_ARRAY_CPLX: l+=cont.asDoubles().length*8; break; case XT_ARRAY_BOOL: l += cont.asBytes().length + 4; if ((l & 3) > 0) l = l - (l & 3) + 4; break; case XT_LIST_TAG: case XT_LIST_NOTAG: case XT_LANG_TAG: case XT_LANG_NOTAG: case XT_LIST: case XT_VECTOR: { final RList lst = cont.asList(); int i=0; while (i0) l=l-(l&3)+4; // System.out.println("TAG length: "+(l-pl)); } i++; } if ((l&3)>0) l=l-(l&3)+4; break; } case XT_ARRAY_STR: { String sa[] = cont.asStrings(); int i=0; while (i < sa.length) { if (sa[i] != null) { try { byte b[] = sa[i].getBytes(RConnection.transferCharset); if (b.length > 0) { if (b[0] == -1) l++; l += b.length; } b = null; } catch (java.io.UnsupportedEncodingException uex) { // FIXME: we should so something ... so far we hope noone's gonna mess with the encoding } } else l++; // NA = -1 l++; i++; } if ((l&3)>0) l=l-(l&3)+4; break; } } // switch if (l>0xfffff0) l+=4; // large data need 4 more bytes // System.out.println("len:"+(l+4)+" "+xtName(rxt)+"/"+xtName(type)+" "+cont); return l+4; // add the header } /** Stores the REXP in its binary (ready-to-send) representation including header into a buffer and returns the index of the byte behind the REXP.

Please note that currently only XT_[ARRAY_]INT, XT_[ARRAY_]DOUBLE and XT_[ARRAY_]STR are supported! All other types will be stored as SEXP of the length 0 without any contents. @param buf buffer to store the REXP binary into @param off offset of the first byte where to store the REXP @return the offset of the first byte behind the stored REXP */ public int getBinaryRepresentation(byte[] buf, int off) throws REXPMismatchException { int myl=getBinaryLength(); boolean isLarge=(myl>0xfffff0); boolean hasAttr = false; final REXPList a = getAttr(); RList al = null; if (a != null) al = a.asList(); if (al != null && al.size()>0) hasAttr=true; int rxt=type, ooff=off; if (type==XT_VECTOR_STR) rxt=XT_ARRAY_STR; // VECTOR_STR is broken right now if (type==XT_LIST || type==XT_LIST_TAG || type==XT_LIST_NOTAG) rxt=(cont.asList()!=null && cont.asList().isNamed())?XT_LIST_TAG:XT_LIST_NOTAG; // System.out.println("@"+off+": "+xtName(rxt)+"/"+xtName(type)+" "+cont+" ("+myl+"/"+buf.length+") att="+hasAttr); RTalk.setHdr(rxt|(hasAttr?XT_HAS_ATTR:0),myl-(isLarge?8:4),buf,off); off+=(isLarge?8:4); if (hasAttr) off=attr.getBinaryRepresentation(buf, off); switch (rxt) { case XT_S4: case XT_NULL: break; case XT_INT: RTalk.setInt(cont.asInteger(),buf,off); break; case XT_DOUBLE: RTalk.setLong(Double.doubleToRawLongBits(cont.asDouble()),buf,off); break; case XT_ARRAY_INT: { int ia[]=cont.asIntegers(); int i=0, io=off; while(i 0) { for(int i =0; i < ba.length; i++) buf[io++] = (byte) ( (ba[i] == REXPLogical.NA) ? 2 : ((ba[i] == REXPLogical.FALSE) ? 0 : 1) ); while ((io & 3) != 0) buf[io++] = 3; } break; } case XT_ARRAY_DOUBLE: { double da[]=cont.asDoubles(); int i=0, io=off; while(i 0) { if (b[0] == -1) /* if the first entry happens to be -1 then we need to double it so it doesn't get confused with NAs */ buf[io++] = -1; System.arraycopy(b, 0, buf, io, b.length); io += b.length; } b = null; } catch (java.io.UnsupportedEncodingException uex) { // FIXME: we should so something ... so far we hope noone's gonna mess with the encoding } } else buf[io++] = -1; /* NAs are stored as 0xff (-1 in signed bytes) */ buf[io++] = 0; i++; } i = io - off; while ((i & 3) != 0) { buf[io++] = 1; i++; } // padding if necessary.. break; } case XT_LIST_TAG: case XT_LIST_NOTAG: case XT_LANG_TAG: case XT_LANG_NOTAG: case XT_LIST: case XT_VECTOR: case XT_VECTOR_EXP: { int io = off; final RList lst = cont.asList(); if (lst != null) { int i=0; while (i @"+off+", len "+b.length+" (cont "+buf.length+") \""+s+"\""); System.arraycopy(b,0,buf,io,b.length); io+=b.length; b=null; } catch (java.io.UnsupportedEncodingException uex) { // FIXME: we should so something ... so far we hope noone's gonna mess with the encoding } buf[io++]=0; while ((io&3)!=0) buf[io++]=0; // padding if necessary.. return io; } /** returns human-readable name of the xpression type as string. Arrays are denoted by a trailing asterisk (*). @param xt xpression type @return name of the xpression type */ public static String xtName(int xt) { if (xt==XT_NULL) return "NULL"; if (xt==XT_INT) return "INT"; if (xt==XT_STR) return "STRING"; if (xt==XT_DOUBLE) return "REAL"; if (xt==XT_BOOL) return "BOOL"; if (xt==XT_ARRAY_INT) return "INT*"; if (xt==XT_ARRAY_STR) return "STRING*"; if (xt==XT_ARRAY_DOUBLE) return "REAL*"; if (xt==XT_ARRAY_BOOL) return "BOOL*"; if (xt==XT_ARRAY_CPLX) return "COMPLEX*"; if (xt==XT_SYM) return "SYMBOL"; if (xt==XT_SYMNAME) return "SYMNAME"; if (xt==XT_LANG) return "LANG"; if (xt==XT_LIST) return "LIST"; if (xt==XT_LIST_TAG) return "LIST+T"; if (xt==XT_LIST_NOTAG) return "LIST/T"; if (xt==XT_LANG_TAG) return "LANG+T"; if (xt==XT_LANG_NOTAG) return "LANG/T"; if (xt==XT_CLOS) return "CLOS"; if (xt==XT_RAW) return "RAW"; if (xt==XT_S4) return "S4"; if (xt==XT_VECTOR) return "VECTOR"; if (xt==XT_VECTOR_STR) return "STRING[]"; if (xt==XT_VECTOR_EXP) return "EXPR[]"; if (xt==XT_FACTOR) return "FACTOR"; if (xt==XT_UNKNOWN) return "UNKNOWN"; return ""; } } Rserve/clients/java/Rserve/RSession.java0000644000176000001440000000230712205226215020007 0ustar ripleyuserspackage org.rosuda.REngine.Rserve; import org.rosuda.REngine.Rserve.protocol.RPacket; import org.rosuda.REngine.Rserve.protocol.RTalk; public class RSession implements java.io.Serializable { // serial version UID should only change if method signatures change // significantly enough that previous versions cannot be used with // current versions private static final long serialVersionUID = -7048099825974875604l; String host; int port; byte[] key; transient RPacket attachPacket=null; // response on session attach int rsrvVersion; protected RSession() { // default no-args constructor for serialization } RSession(RConnection c, RPacket p) throws RserveException { this.host=c.host; this.rsrvVersion=c.rsrvVersion; byte[] ct = p.getCont(); if (ct==null || ct.length!=32+3*4) throw new RserveException(c, "Invalid response to session detach request."); this.port = RTalk.getInt(ct, 4); this.key=new byte[32]; System.arraycopy(ct, 12, this.key, 0, 32); } /** attach/resume this session */ public RConnection attach() throws RserveException { RConnection c = new RConnection(this); attachPacket = c.rt.request(-1); return c; } } Rserve/clients/java/Rserve/RFileOutputStream.java0000644000176000001440000001025212205226215021636 0ustar ripleyusers// JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2003 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- // // RFileOutputStream.java // // Created by Simon Urbanek on Wed Oct 22 2003. // package org.rosuda.REngine.Rserve; import java.io.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.protocol.*; /** RFileOutputStream is an {@link OutputStream} to transfer files from the client to Rserve server. It is used very much like a {@link FileOutputStream}. Currently mark and seek is not supported. The current implementation is also "one-shot" only, that means the file can be written only once. @version $Id$ */ public class RFileOutputStream extends OutputStream { /** RTalk class to use for communication with the Rserve */ RTalk rt; /** set to true when {@link #close} was called. Any subsequent read requests on closed stream result in an {@link IOException} or error result */ boolean closed; /** tries to create a file on the R server, using specified {@link RTalk} object and filename. Be aware that the filename has to be specified in host format (which is usually unix). In general you should not use directories since Rserve provides an own directory for every connection. Future Rserve servers may even strip all directory navigation characters for security purposes. Therefore only filenames without path specification are considered valid, the behavior in respect to absolute paths in filenames is undefined. @param rti RTalk object for communication with Rserve @param fb filename of the file to create (existing file will be overwritten) */ RFileOutputStream(RTalk rti, String fn) throws IOException { rt=rti; RPacket rp=rt.request(RTalk.CMD_createFile,fn); if (rp==null || !rp.isOk()) throw new IOException((rp==null)?"Connection to Rserve failed":("Request return code: "+rp.getStat())); closed=false; } /** writes one byte to the file. This function should be avoided, since {@link RFileOutputStream} provides no buffering. This means that each call to this function leads to a complete packet exchange between the server and the client. Use {@link #write(byte[])} instead whenever possible. In fact this function calls write(b,0,1). @param b byte to write */ public void write(int b) throws IOException { byte[] ba=new byte[1]; write(ba,0,1); } /** writes the content of b into the file. This methods is equivalent to calling write(b,0,b.length). @param b content to write */ public void write(byte b[]) throws IOException { write(b,0,b.length); } /** Writes specified number of bytes to the remote file. @param b buffer containing the bytes to write @param off offset where to start @param len number of bytes to write */ public void write(byte[] b, int off, int len) throws IOException { if (closed) throw new IOException("File is not open"); if (len<0) len=0; boolean isLarge=(len>0xfffff0); byte[] hdr=RTalk.newHdr(RTalk.DT_BYTESTREAM,len); RPacket rp=rt.request(RTalk.CMD_writeFile,hdr,b,off,len); if (rp==null || !rp.isOk()) throw new IOException((rp==null)?"Connection to Rserve failed":("Request return code: "+rp.getStat())); } /** close stream - is not related to the actual RConnection, calling close does not close the RConnection. */ public void close() throws IOException { RPacket rp=rt.request(RTalk.CMD_closeFile,(byte[])null); if (rp==null || !rp.isOk()) throw new IOException((rp==null)?"Connection to Rserve failed":("Request return code: "+rp.getStat())); closed=true; } /** currently (Rserve 0.3) there is no way to force flush on the remote side, hence this function is noop. Future versions of Rserve may support this feature though. At any rate, it is safe to call it. */ public void flush() { } } Rserve/clients/java/Rserve/RserveException.java0000644000176000001440000000532012205226215021365 0ustar ripleyusers// JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- // // RserveException.java // // Created by Simon Urbanek on Mon Aug 18 2003. // // $Id$ // package org.rosuda.REngine.Rserve; import org.rosuda.REngine.Rserve.protocol.RPacket; import org.rosuda.REngine.Rserve.protocol.RTalk; import org.rosuda.REngine.REngineException; public class RserveException extends REngineException { protected String err; protected int reqReturnCode; public String getRequestErrorDescription() { return getRequestErrorDescription(reqReturnCode); } public String getRequestErrorDescription(int code) { switch(code) { case 0: return "no error"; case 2: return "R parser: input incomplete"; case 3: return "R parser: syntax error"; case RTalk.ERR_auth_failed: return "authorization failed"; case RTalk.ERR_conn_broken: return "connection broken"; case RTalk.ERR_inv_cmd: return "invalid command"; case RTalk.ERR_inv_par: return "invalid parameter"; case RTalk.ERR_IOerror: return "I/O error on the server"; case RTalk.ERR_not_open: return "connection is not open"; case RTalk.ERR_access_denied: return "access denied (local to the server)"; case RTalk.ERR_unsupported_cmd: return "unsupported command"; case RTalk.ERR_unknown_cmd: return "unknown command"; case RTalk.ERR_data_overflow: return "data overflow, incoming data too big"; case RTalk.ERR_object_too_big: return "evaluation successful, but returned object is too big to transport"; case RTalk.ERR_out_of_mem: return "FATAL: Rserve ran out of memory, closing connection"; case RTalk.ERR_session_busy: return "session is busy"; case RTalk.ERR_detach_failed: return "session detach failed"; case RTalk.ERR_ctrl_closed: return "control pipe to master process is closed/broken"; } return "error code: "+code; } public String getMessage() { return super.getMessage()+((reqReturnCode!=-1)?", request status: "+getRequestErrorDescription():""); } public RserveException(RConnection c, String msg) { this(c,msg,-1); } public RserveException(RConnection c, String msg, int requestReturnCode) { super(c, msg); reqReturnCode=requestReturnCode; if (c!=null) c.lastError=getMessage(); } public RserveException(RConnection c, String msg, RPacket p) { this(c, msg, (p==null)?-1:p.getStat()); } public int getRequestReturnCode() { return reqReturnCode; } } Rserve/clients/java/Rserve/test/0000755000176000001440000000000012205226215016354 5ustar ripleyusersRserve/clients/java/Rserve/test/Makefile0000644000176000001440000000213113442516164020022 0ustar ripleyusersJAVA=java JAVAC=javac JFLAGS+=-encoding utf8 -source 1.4 -target 1.4 all: test PlotDemo.class StartRserve.class ../Rserve.jar: ../../REngine.jar $(MAKE) -C .. Rserve.jar ../../REngine.jar: $(MAKE) -C ../.. REngine.jar test: test.class ../Rserve.jar ../../REngine.jar $(JAVA) -cp ../Rserve.jar:../../REngine.jar:. test test.class: test.java ../Rserve.jar ../../REngine.jar $(JAVAC) $(JFLAGS) -d . -cp ../Rserve.jar:../../REngine.jar:. test.java PlotDemo.class: PlotDemo.java ../Rserve.jar ../../REngine.jar $(JAVAC) $(JFLAGS) -d . -cp ../Rserve.jar:../../REngine.jar:. $< PlotDemo: PlotDemo.class ../Rserve.jar ../../REngine.jar $(JAVA) -cp ../Rserve.jar:../../REngine.jar:. $@ jt: jt.class ../Rserve.jar ../../REngine.jar $(JAVA) -cp ../Rserve.jar:../../REngine.jar:. $@ jt.class: jt.java ../Rserve.jar ../../REngine.jar $(JAVAC) $(JFLAGS) -d . -cp ../Rserve.jar:../../REngine.jar:. jt.java StartRserve.class: StartRserve.java ../Rserve.jar ../../REngine.jar $(JAVAC) $(JFLAGS) -d . -cp ../Rserve.jar:../../REngine.jar:. StartRserve.java clean: rm -rf org *~ *.class .PHONY: test all clean Rserve/clients/java/Rserve/test/test.java0000644000176000001440000002767412205226215020216 0ustar ripleyusersimport org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.*; class TestException extends Exception { public TestException(String msg) { super(msg); } } public class test { public static void main(String[] args) { try { RConnection c = new RConnection(); // REngine is the backend-agnostic API -- using eng instead of c makes sure that we don't use Rserve extensions inadvertently REngine eng = (REngine) c; System.out.println(">>" + c.eval("R.version$version.string").asString() + "<<"); { System.out.println("* Test string and list retrieval"); RList l = c.eval("{d=data.frame(\"huhu\",c(11:20)); lapply(d,as.character)}").asList(); int cols = l.size(); int rows = l.at(0).length(); String[][] s = new String[cols][]; for (int i=0; i= 0) { String s = line.substring(i + 11).trim(); int j = s.indexOf("REG_SZ"); if (j >= 0) s = s.substring(j + 6).trim(); installPath = s; System.out.println("R InstallPath = "+s); } } else System.out.println("Rserve>" + line); } } catch (IOException e) { e.printStackTrace(); } } } /** simple class that start Rserve locally if it's not running already - see mainly checkLocalRserve method. It spits out quite some debugging outout of the console, so feel free to modify it for your application if desired.

Important: All applications should shutdown every Rserve that they started! Never leave Rserve running if you started it after your application quits since it may pose a security risk. Inform the user if you started an Rserve instance. */ public class StartRserve { /** shortcut to launchRserve(cmd, "--no-save --slave", "--no-save --slave", false) */ public static boolean launchRserve(String cmd) { return launchRserve(cmd, "--no-save --slave","--no-save --slave",false); } /** attempt to start Rserve. Note: parameters are not quoted, so avoid using any quotes in arguments @param cmd command necessary to start R @param rargs arguments are are to be passed to R @param rsrvargs arguments to be passed to Rserve @return true if Rserve is running or was successfully started, false otherwise. */ public static boolean launchRserve(String cmd, String rargs, String rsrvargs, boolean debug) { try { Process p; boolean isWindows = false; String osname = System.getProperty("os.name"); if (osname != null && osname.length() >= 7 && osname.substring(0,7).equals("Windows")) { isWindows = true; /* Windows startup */ p = Runtime.getRuntime().exec("\""+cmd+"\" -e \"library(Rserve);Rserve("+(debug?"TRUE":"FALSE")+",args='"+rsrvargs+"')\" "+rargs); } else /* unix startup */ p = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", "echo 'library(Rserve);Rserve("+(debug?"TRUE":"FALSE")+",args=\""+rsrvargs+"\")'|"+cmd+" "+rargs }); System.out.println("waiting for Rserve to start ... ("+p+")"); // we need to fetch the output - some platforms will die if you don't ... StreamHog errorHog = new StreamHog(p.getErrorStream(), false); StreamHog outputHog = new StreamHog(p.getInputStream(), false); if (!isWindows) /* on Windows the process will never return, so we cannot wait */ p.waitFor(); System.out.println("call terminated, let us try to connect ..."); } catch (Exception x) { System.out.println("failed to start Rserve process with "+x.getMessage()); return false; } int attempts = 5; /* try up to 5 times before giving up. We can be conservative here, because at this point the process execution itself was successful and the start up is usually asynchronous */ while (attempts > 0) { try { RConnection c = new RConnection(); System.out.println("Rserve is running."); c.close(); return true; } catch (Exception e2) { System.out.println("Try failed with: "+e2.getMessage()); } /* a safety sleep just in case the start up is delayed or asynchronous */ try { Thread.sleep(500); } catch (InterruptedException ix) { }; attempts--; } return false; } /** checks whether Rserve is running and if that's not the case it attempts to start it using the defaults for the platform where it is run on. This method is meant to be set-and-forget and cover most default setups. For special setups you may get more control over R with <launchRserve instead. */ public static boolean checkLocalRserve() { if (isRserveRunning()) return true; String osname = System.getProperty("os.name"); if (osname != null && osname.length() >= 7 && osname.substring(0,7).equals("Windows")) { System.out.println("Windows: query registry to find where R is installed ..."); String installPath = null; try { Process rp = Runtime.getRuntime().exec("reg query HKLM\\Software\\R-core\\R"); StreamHog regHog = new StreamHog(rp.getInputStream(), true); rp.waitFor(); regHog.join(); installPath = regHog.getInstallPath(); } catch (Exception rge) { System.out.println("ERROR: unable to run REG to find the location of R: "+rge); return false; } if (installPath == null) { System.out.println("ERROR: canot find path to R. Make sure reg is available and R was installed with registry settings."); return false; } return launchRserve(installPath+"\\bin\\R.exe"); } return (launchRserve("R") || /* try some common unix locations of R */ ((new File("/Library/Frameworks/R.framework/Resources/bin/R")).exists() && launchRserve("/Library/Frameworks/R.framework/Resources/bin/R")) || ((new File("/usr/local/lib/R/bin/R")).exists() && launchRserve("/usr/local/lib/R/bin/R")) || ((new File("/usr/lib/R/bin/R")).exists() && launchRserve("/usr/lib/R/bin/R")) || ((new File("/usr/local/bin/R")).exists() && launchRserve("/usr/local/bin/R")) || ((new File("/sw/bin/R")).exists() && launchRserve("/sw/bin/R")) || ((new File("/usr/common/bin/R")).exists() && launchRserve("/usr/common/bin/R")) || ((new File("/opt/bin/R")).exists() && launchRserve("/opt/bin/R")) ); } /** check whether Rserve is currently running (on local machine and default port). @return true if local Rserve instance is running, false otherwise */ public static boolean isRserveRunning() { try { RConnection c = new RConnection(); System.out.println("Rserve is running."); c.close(); return true; } catch (Exception e) { System.out.println("First connect try failed with: "+e.getMessage()); } return false; } /** just a demo main method which starts Rserve and shuts it down again */ public static void main(String[] args) { System.out.println("result="+checkLocalRserve()); try { RConnection c=new RConnection(); c.shutdown(); } catch (Exception x) {}; } } Rserve/clients/java/Rserve/test/jt.java0000644000176000001440000000205312205226215017634 0ustar ripleyusersimport java.io.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.*; public class jt { public static void main(String[] args) { try { RConnection c = new RConnection((args.length>0)?args[0]:"127.0.0.1"); BufferedReader ir=new BufferedReader(new InputStreamReader(System.in)); String s=null; System.out.print("> "); while ((s=ir.readLine()).length() > 0) { if (s.equals("shutdown")) { System.out.println("Sending shutdown request"); c.shutdown(); System.out.println("Shutdown successful. Quitting console."); return; } else { REXP rx = c.parseAndEval(s); System.out.println("result(debug): "+rx.toDebugString()); } System.out.print("> "); } } catch (RserveException rse) { System.out.println(rse); /* } catch (REXPMismatchException mme) { System.out.println(mme); mme.printStackTrace(); */ } catch (Exception e) { e.printStackTrace(); } } } Rserve/clients/java/Rserve/test/PlotDemo.java0000644000176000001440000000757012205226215020753 0ustar ripleyusers// // PlotDemo demo - REngine and graphics // // $Id$ // import java.io.*; import java.util.*; import java.awt.*; import java.awt.event.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.*; /** A demonstration of the use of Rserver and graphics devices to create graphics in R, pull them into Java and display them. It is a really simple demo. */ public class PlotDemo extends Canvas { public static void main(String args[]) { try { String device = "jpeg"; // device we'll call (this would work with pretty much any bitmap device) // connect to Rserve (if the user specified a server at the command line, use it, otherwise connect locally) RConnection c = new RConnection((args.length>0)?args[0]:"127.0.0.1"); // if Cairo is installed, we can get much nicer graphics, so try to load it if (c.parseAndEval("suppressWarnings(require('Cairo',quietly=TRUE))").asInteger()>0) device="CairoJPEG"; // great, we can use Cairo device else System.out.println("(consider installing Cairo package for better bitmap output)"); // we are careful here - not all R binaries support jpeg // so we rather capture any failures REXP xp = c.parseAndEval("try("+device+"('test.jpg',quality=90))"); if (xp.inherits("try-error")) { // if the result is of the class try-error then there was a problem System.err.println("Can't open "+device+" graphics device:\n"+xp.asString()); // this is analogous to 'warnings', but for us it's sufficient to get just the 1st warning REXP w = c.eval("if (exists('last.warning') && length(last.warning)>0) names(last.warning)[1] else 0"); if (w.isString()) System.err.println(w.asString()); return; } // ok, so the device should be fine - let's plot - replace this by any plotting code you desire ... c.parseAndEval("data(iris); attach(iris); plot(Sepal.Length, Petal.Length, col=unclass(Species)); dev.off()"); // There is no I/O API in REngine because it's actually more efficient to use R for this // we limit the file size to 1MB which should be sufficient and we delete the file as well xp = c.parseAndEval("r=readBin('test.jpg','raw',1024*1024); unlink('test.jpg'); r"); // now this is pretty boring AWT stuff - create an image from the data and display it ... Image img = Toolkit.getDefaultToolkit().createImage(xp.asBytes()); Frame f = new Frame("Test image"); f.add(new PlotDemo(img)); f.addWindowListener(new WindowAdapter() { // just so we can close the window public void windowClosing(WindowEvent e) { System.exit(0); } }); f.pack(); f.setVisible(true); // close RConnection, we're done c.close(); } catch (RserveException rse) { // RserveException (transport layer - e.g. Rserve is not running) System.out.println(rse); } catch (REXPMismatchException mme) { // REXP mismatch exception (we got something we didn't think we get) System.out.println(mme); mme.printStackTrace(); } catch(Exception e) { // something else System.out.println("Something went wrong, but it's not the Rserve: " +e.getMessage()); e.printStackTrace(); } } Image img; public PlotDemo(Image img) { this.img=img; MediaTracker mediaTracker = new MediaTracker(this); mediaTracker.addImage(img, 0); try { mediaTracker.waitForID(0); } catch (InterruptedException ie) { System.err.println(ie); System.exit(1); } setSize(img.getWidth(null), img.getHeight(null)); } public void paint(Graphics g) { g.drawImage(img, 0, 0, null); } } Rserve/clients/java/Rserve/RFileInputStream.java0000644000176000001440000000711512205226215021441 0ustar ripleyuserspackage org.rosuda.REngine.Rserve; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- import java.io.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.protocol.*; /** RFileInputStream is an {@link InputStream} to transfer files from Rserve server to the client. It is used very much like a {@link FileInputStream}. Currently mark and seek is not supported. The current implementation is also "one-shot" only, that means the file can be read only once. @version $Id$ */ public class RFileInputStream extends InputStream { /** RTalk class to use for communication with the Rserve */ RTalk rt; /** set to true when {@link #close} was called. Any subsequent read requests on closed stream result in an {@link IOException} or error result */ boolean closed; /** set to true once EOF is reached - or more specifically the first time remore fread returns OK and 0 bytes */ boolean eof; /** tries to open file on the R server, using specified {@link RTalk} object and filename. Be aware that the filename has to be specified in host format (which is usually unix). In general you should not use directories since Rserve provides an own directory for every connection. Future Rserve servers may even strip all directory navigation characters for security purposes. Therefore only filenames without path specification are considered valid, the behavior in respect to absolute paths in filenames is undefined. */ RFileInputStream(RTalk rti, String fn) throws IOException { rt=rti; RPacket rp=rt.request(RTalk.CMD_openFile,fn); if (rp==null || !rp.isOk()) throw new IOException((rp==null)?"Connection to Rserve failed":("Request return code: "+rp.getStat())); closed=false; eof=false; } /** reads one byte from the file. This function should be avoided, since {@link RFileInputStream} provides no buffering. This means that each call to this function leads to a complete packet exchange between the server and the client. Use {@link #read(byte[],int,int)} instead whenever possible. In fact this function calls #read(b,0,1). @return -1 on any failure, or the acquired byte (0..255) on success */ public int read() throws IOException { byte[] b=new byte[1]; if (read(b,0,1)<1) return -1; return b[0]; } /** Reads specified number of bytes (or less) from the remote file. @param b buffer to store the read bytes @param off offset where to strat filling the buffer @param len maximal number of bytes to read @return number of bytes read or -1 if EOF reached */ public int read(byte[] b, int off, int len) throws IOException { if (closed) throw new IOException("File is not open"); if (eof) return -1; RPacket rp=rt.request(RTalk.CMD_readFile,len); if (rp==null || !rp.isOk()) throw new IOException((rp==null)?"Connection to Rserve failed":("Request return code: "+rp.getStat())); byte[] rd=rp.getCont(); if (rd==null) { eof=true; return -1; }; int i=0; while(iRserve */ package org.rosuda.REngine.Rserve ; Rserve/clients/java/REngineInputInterface.java0000644000176000001440000000157312205226215021170 0ustar ripleyuserspackage org.rosuda.REngine; /** interface defining delegate methods used by {@link REngine} to forward input callbacks from R. */ public interface REngineInputInterface { /** called when R enters the read stage of the event loop. *

Important: implementations should never use a direct return! That will cause a tigh-spinning event loop. Implementation must wait for input asynchronously (e.g., declare synchonized RReadConsole and use wait()) and return only when a complete line is available for processing. * @param eng calling engine * @param prompt prompt to display in the console * @param addToHistory flag indicating whether the input is transient (false) or to be recorded in the command history (true). * @return string to be processed as console input */ public String RReadConsole(REngine eng, String prompt, int addToHistory); } Rserve/clients/java/REngineException.java0000644000176000001440000000164412205226215020205 0ustar ripleyusers// REngine - generic Java/R API // // Copyright (C) 2006 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- // // RSrvException.java // // Created by Simon Urbanek on Wed Jun 21 2006. // // $Id$ // package org.rosuda.REngine; /** REngineException is a generic exception that can be thrown by methods invoked on an R engine. */ public class REngineException extends Exception { /** engine associated with this exception */ protected REngine engine; /** creates an R engine exception @param engine engine associated with this exception @param msg message describing the cause */ public REngineException(REngine engine, String msg) { super(msg); this.engine = engine; } /** returns the engine associated with this exception @return engine associated with this exception */ public REngine getEngine() { return engine; } } Rserve/clients/java/REXPS4.java0000644000176000001440000000027412205226215015762 0ustar ripleyuserspackage org.rosuda.REngine; /** S4 REXP is a completely vanilla REXP */ public class REXPS4 extends REXP { public REXPS4() { super(); } public REXPS4(REXPList attr) { super(attr); } } Rserve/clients/java/REXPMismatchException.java0000644000176000001440000000360612205226215021122 0ustar ripleyusers// REngine - generic Java/R API // // Copyright (C) 2007,2008 Simon Urbanek // --- for licensing information see LICENSE file in the distribution --- // // REXPMismatch.java // // Created by Simon Urbanek on 2007/05/03 // // $Id: REngineException.java 2555 2006-06-21 20:36:42Z urbaneks $ // package org.rosuda.REngine; /** This exception is thrown whenever the operation requested is not supported by the given R object type, e.g. using asStrings on an S4 object. Most {@link REXP} methods throw this exception. Previous R/Java interfaces were silently returning null in those cases, but using exceptions helps to write more robust code. */ public class REXPMismatchException extends Exception { REXP sender; String access; /** primary constructor. The exception message will be formed as "attempt to access <REXP-class> as <access-string>" * @param sender R object that triggered this exception (cannot be null!) * @param access assumed type of the access that was requested. It should be a simple name of the assumed type (e.g. "vector"). The type name can be based on R semantics beyond basic types reflected by REXP classes. In cases where certain assertions were not satisfied, the string should be of the form "type (assertion)" (e.g. "data frame (must have dim>0)"). */ public REXPMismatchException(REXP sender, String access) { super("attempt to access "+sender.getClass().getName()+" as "+access); this.sender = sender; this.access = access; } /** retrieve the exception sender/origin * @return REXP object that triggered the exception */ public REXP getSender() { return sender; } /** get the assumed access type that was violated by the sender. * @return string describing the access type. See {@link #REXPMismatchException} for details. */ public String getAccess() { return access; } } Rserve/clients/java/REngineUIInterface.java0000644000176000001440000000146512205226215020406 0ustar ripleyuserspackage org.rosuda.REngine; /** interface defining delegate methods used by {@link REngine} to forward user interface callbacks from R. */ public interface REngineUIInterface { /** called when the busy state of R changes - usual response is to change the shape of the cursor * @param eng calling engine * @param state busy state of R (0 = not busy) */ public void RBusyState (REngine eng, int state); /** called when R wants the user to choose a file. * @param eng calling engine * @param newFile if true then the user can specify a non-existing file to be created, otherwise an existing file must be selected. * @return full path and name of the selected file or null if the selection was cancelled. */ public String RChooseFile (REngine eng, boolean newFile); } Rserve/clients/java/REXPUnknown.java0000644000176000001440000000175312205226215017136 0ustar ripleyuserspackage org.rosuda.REngine; /** REXPUnknown is a stand-in for an object that cannot be represented in the REngine hierarchy. Usually this class can be encountered when new types are introduced in R or if a given engine doesn't support all data types. Usually REXPUnknown can only be retrieved from the engine but never assigned. */ public class REXPUnknown extends REXP { /** type of the unterlying obejct */ int type; /** creates a new unknown object of the given type * @param type internal R type code of this object */ public REXPUnknown(int type) { super(); this.type=type; } /** creates a new unknown object of the given type * @param type internal R type code of this object * @param attr attributes */ public REXPUnknown(int type, REXPList attr) { super(attr); this.type=type; } /** returns the internal R type of this unknown obejct * @return type code */ public int getType() { return type; } public String toString() { return super.toString()+"["+type+"]"; } } Rserve/clients/java/package-info.java0000644000176000001440000000011012205226215017306 0ustar ripleyusers/** * High level java interface to R */ package org.rosuda.REngine ; Rserve/clients/cxx/0000755000176000001440000000000012205226217014012 5ustar ripleyusersRserve/clients/cxx/rsdown.cc0000644000176000001440000000437712205226215015646 0ustar ripleyusers/* * Small Rserve shutdown program * Copyright (C) 2004-8 Simon Urbanek, All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: demo1.cc 203 2007-05-10 18:12:06Z urbanek $ */ #define MAIN // we are the main program, we need to define this #define SOCK_ERRORS // we will use verbose socket errors #include "sisocks.h" #include "Rconnection.h" int main(int ac, char **av) { initsocks(); // this is needed for Win32 - it does nothing on unix Rconnection *rc = 0; int port = -1, help = 0; const char *sock_name = 0; const char *host_name = 0; const char *pwd = 0; int i = 1; while (i < ac) { if (av[i][0] == '-') { switch (av[i][1]) { case 'h': help = 1; break; case 'p': if (++i < ac) port = atoi(av[i]); break; case 'P': if (++i < ac) pwd = av[i]; else pwd = getpass("password: "); break; case 's': if (++i < ac) sock_name = av[i]; break; } } else if (!host_name) host_name = av[i]; i++; } if (help) { printf("\n Usage: %s [] [-p ] [-s ] [-P ] [-h] \n\n", av[0]); return 0; } if (host_name) { if (port > 1) rc = new Rconnection(host_name, port); else rc = new Rconnection(host_name); } else if (sock_name) { rc = new Rconnection(sock_name, -1); } else { rc = new Rconnection(); } i = rc->connect(); if (i) { char buf[1024]; sockerrorchecks(buf, 1024, -1); fprintf(stderr, "ERROR: unable to connect (result=%d, socket:%s).\n", i, buf); } else rc->shutdown(pwd); delete rc; return 0; } Rserve/clients/cxx/rcmd.cc0000644000176000001440000000761612205226215015256 0ustar ripleyusers/* * Small demo to illustrate the use of the C++ interface to Rserve * Copyright (C) 2004 Simon Urbanek, All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Leser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id$ */ #define MAIN // we are the main program, we need to define this #define SOCK_ERRORS // we will use verbose socket errors #include "sisocks.h" #include "Rconnection.h" char buf[1024]; int main(int ac, char **av) { initsocks(); // this is needed for Win32 - it does nothing on unix Rconnection *rc = 0; int port = -1, help = 0, do_cd = 1; const char *sock_name = 0; const char *host_name = 0; const char *pwd = 0; const char *user = 0; const char *wd = 0; int i = 1; while (i < ac) { if (av[i][0] == '-') { switch (av[i][1]) { case 'h': help = 1; break; case 'H': if (++i < ac) host_name = av[i]; break; case 'u': if (++i < ac) user = av[i]; break; case 'p': if (++i < ac) port = atoi(av[i]); break; case 'P': if (++i < ac) pwd = av[i]; else pwd = getpass("password: "); break; case 's': if (++i < ac) sock_name = av[i]; break; case 'w': if (++i < ac) wd = av[i]; break; case 'n': do_cd = 0; break; case 'c': i++; } } i++; } if (wd) do_cd = 1; if (help) { printf("\n Usage: %s [-H ] [-c ] [-w

] [-n] [-p ] [-s ] [-u ] [-P ] [-h] [ [...]]\n\n", av[0]); return 0; } if (host_name) { if (port > 1) rc = new Rconnection(host_name, port); else rc = new Rconnection(host_name); } else if (sock_name) { rc = new Rconnection(sock_name, -1); } else { rc = new Rconnection(); } buf[1023]=0; i = rc->connect(); if (i) { sockerrorchecks(buf, 1023, -1); fprintf(stderr, "unable to connect (result=%d, socket:%s).\n", i, buf); return i; } if (user) { if (!pwd) pwd = ""; i = rc->login(user, pwd); if (i) { fprintf(stderr, "login failed (result=%d)\n", i); return i; } } if (do_cd) { char *es, *d; const char *c; if (!wd) wd = strdup(getwd(buf)); d = es = (char*) malloc(strlen(wd) * 2 + 14); c = wd; strcpy(d, "setwd(\""); d += 7; while (*c) { if (*c == '\"' || *c == '\\' || *c == '\'') (d++)[0] = '\\'; if (*c == '\n' || *c == '\r') (d++)[0] = ' '; else (d++)[0] = (c++)[0]; } strcpy(d, "\")"); rc->voidEval(es); free(es); } i = 1; // source all files specified at the command line and print the output while (i < ac) { if (av[i][0] == '-') { switch(av[i][1]) { /* skip options that have extra argument */ case 'c': if (++i < ac) { snprintf(buf, 1023, "try(paste(capture.output(%s),collapse='\\n'))", av[i]); Rstring *str = (Rstring*) rc->eval(buf); puts(str->string()); delete str; } break; case 'p': case 'P': case 's': case 'H': case 'u': case 'w': i++; } } else { snprintf(buf, 1023, "try(paste(capture.output(source(\"%s\")),collapse='\\n'))", av[i]); Rstring *str = (Rstring*) rc->eval(buf); puts(str->string()); delete str; } i++; } // dispose of the connection object - this implicitly closes the connection delete rc; return 0; } Rserve/clients/cxx/COPYING0000644000176000001440000006350412205226215015053 0ustar ripleyusers GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! Rserve/clients/cxx/configure.ac0000644000176000001440000000555412205226215016307 0ustar ripleyusers# Process this file with autoconf to produce a configure script. AC_INIT([Rserve-cxx-client],[0.1],[Simon.Urbanek@r-project.org]) AC_CONFIG_SRCDIR([Rconnection.cc]) AC_CONFIG_HEADER([config.h]) AC_PROG_CC AC_PROG_CXX AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([string.h memory.h sys/time.h unistd.h]) AC_CHECK_HEADERS([sys/stat.h sys/types.h sys/socket.h sys/un.h netinet/in.h netinet/tcp.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_BIGENDIAN(AC_DEFINE(BS_BIG_ENDIAN, 1, [Defined if the platform is big-endian]), AC_DEFINE(BS_LITTLE_ENDIAN, 1, [Defined if the platform is little-endian]), [ AC_MSG_RESULT(endianness unknown - will rely solely on compiler macros) AC_MSG_CHECKING([whether compiler sets endianness macros]) AC_COMPILE_IFELSE([ #if defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN_ || defined __BIG_ENDIAN__ || defined _BIG_ENDIAN_ #define BS_OK 1 #else cannot determine compiler's endianness #endif ],[AC_MSG_RESULT(yes)],[ AC_MSG_RESULT(no) AC_MSG_ERROR([Cannot determine endianness neither from the compiler nor using a test. Try adding -D_BIG_ENDIAN_ or -D_LITTLE_ENDIAN_ to PKG_CPPFLAGS. ])]) ]) AC_HEADER_TIME # Checks for library functions. AC_FUNC_FORK AC_TYPE_SIGNAL AC_CHECK_FUNCS([memset mkdir rmdir select socket]) # Check whether we can use crypt (and if we do if it's in the crypt library) AC_SEARCH_LIBS(crypt, crypt, [AC_DEFINE(HAS_CRYPT, 1, [If defined Rserve supports unix crypt password encryption.])]) AC_CHECK_HEADERS([crypt.h]) # socket related stuff - indroduced first due to Solaris # socklen_t - note that we don't try to find an equivalent! # we'll use BSD-style int in case this one isn't defined. # that should be fine for all major platforms. AC_CHECK_TYPE(socklen_t,, AC_DEFINE(socklen_t, int, [Define to `int' if neither nor define.]), [ #include #include ]) # connect may need -lsocket and/or -lnsl (e.g. on Solaris) AC_CHECK_FUNCS(connect) if test x"$ac_cv_func_connect" = x"no"; then case "$LIBS" in *-lnsl*) ;; *) AC_CHECK_LIB(nsl_s, printf) ;; esac case "$LIBS" in *-lnsl*) ;; *) AC_CHECK_LIB(nsl, printf) ;; esac case "$LIBS" in *-lsocket*) ;; *) AC_CHECK_LIB(socket, connect) ;; esac case "$LIBS" in *-linet*) ;; *) AC_CHECK_LIB(inet, connect) ;; esac dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value dnl has been cached. if test x"$ac_cv_lib_socket_connect" = x"yes" || test x"$ac_cv_lib_inet_connect" = x"yes"; then # ac_cv_func_connect=yes # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run AC_DEFINE(HAVE_CONNECT, 1, [ ]) fi fi # on some platforms libR expects dl code in the binary AC_CHECK_LIB(dl, dlopen) AC_CONFIG_FILES([Makefile]) AC_OUTPUT Rserve/clients/cxx/Rsrv.h0000644000176000001440000004522212205226216015123 0ustar ripleyusers/* * Rsrv.h : constants and macros for Rserve client/server architecture * Copyright (C) 2002-13 Simon Urbanek * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; version 2.1 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Note: This header file is licensed under LGPL to allow other * programs to use it under LGPL. Rserve itself is licensed under GPL. * * $Id$ */ /* external defines: MAIN - should be defined in just one file that will contain the fn definitions and variables */ #ifndef __RSRV_H__ #define __RSRV_H__ #ifndef NO_CONFIG_H #include "config.h" #endif #define RSRV_VER 0x010703 /* Rserve v1.7-3 */ #define default_Rsrv_port 6311 /* Rserve communication is done over any reliable connection-oriented protocol (usually TCP/IP or local sockets). After the connection is established, the server sends 32 bytes of ID-string defining the capabilities of the server. Each attribute of the ID-string is 4 bytes long and is meant to be user-readable (i.e. don't use special characters), and it's a good idea to make "\r\n\r\n" the last attribute the ID string must be of the form: [0] "Rsrv" - R-server ID signature [4] "0100" - version of the R server [8] "QAP1" - protocol used for communication (here Quad Attributes Packets v1) [12] any additional attributes follow. \r\n and '-' are ignored. optional attributes (in any order; it is legitimate to put dummy attributes, like "----" or " " between attributes): "R151" - version of R (here 1.5.1) "ARpt" - authorization required (here "pt"=plain text, "uc"=unix crypt, "m5"=MD5) connection will be closed if the first packet is not CMD_login. if more AR.. methods are specified, then client is free to use the one he supports (usually the most secure) "K***" - key if encoded authentification is challenged (*** is the key) for unix crypt the first two letters of the key are the salt required by the server */ /* QAP1 transport protocol header structure all int and double entries throughout the transfer are in Intel-endianess format: int=0x12345678 -> char[4]=(0x78,0x56,x34,0x12) functions/macros for converting from native to protocol format are available below Please note also that all values muse be quad-aligned, i.e. the length must be divisible by 4. This is automatically assured for int/double etc., but care must be taken when using strings and byte streams. */ struct phdr { /* always 16 bytes */ int cmd; /* command */ int len; /* length of the packet minus header (ergo -16) */ int dof; /* data offset behind header (ergo usually 0) */ int res; /* high 32-bit of the packet length (since 0103 and supported on 64-bit platforms only) aka "lenhi", but the name was not changed to maintain compatibility */ }; /* each entry in the data section (aka parameter list) is preceded by 4 bytes: 1 byte : parameter type 3 bytes: length parameter list may be terminated by 0/0/0/0 but doesn't have to since "len" field specifies the packet length sufficiently (hint: best method for parsing is to allocate len+4 bytes, set the last 4 bytes to 0 and trverse list of parameters until (int)0 occurs since 0102: if the 7-th bit (0x40) in parameter type is set then the length is encoded in 7 bytes enlarging the header by 4 bytes. */ /* macros for handling the first int - split/combine (24-bit version only!) */ #define PAR_TYPE(X) ((X) & 255) #define PAR_LEN(X) (((unsigned int)(X)) >> 8) #define PAR_LENGTH PAR_LEN #define SET_PAR(TY,LEN) ((((unsigned int) (LEN) & 0xffffff) << 8) | ((TY) & 255)) #define CMD_STAT(X) (((X) >> 24)&127) /* returns the stat code of the response */ #define SET_STAT(X,s) ((X) | (((s) & 127) << 24)) /* sets the stat code */ #define CMD_RESP 0x10000 /* all responses have this flag set */ #define RESP_OK (CMD_RESP|0x0001) /* command succeeded; returned parameters depend on the command issued */ #define RESP_ERR (CMD_RESP|0x0002) /* command failed, check stats code attached string may describe the error */ #define CMD_OOB 0x20000 /* out-of-band data - i.e. unsolicited messages */ #define OOB_SEND (CMD_OOB | 0x1000) /* OOB send - unsolicited SEXP sent from the R instance to the client. 12 LSB are reserved for application-specific code */ #define OOB_MSG (CMD_OOB | 0x2000) /* OOB message - unsolicited message sent from the R instance to the client requiring a response. 12 LSB are reserved for application-specific code */ #define IS_OOB_SEND(X) (((X) & 0x0ffff000) == OOB_SEND) #define IS_OOB_MSG(X) (((X) & 0x0ffff000) == OOB_MSG) #define OOB_USR_CODE(X) ((X) & 0xfff) /* flag for create_server: Use QAP object-cap mode */ #define SRV_QAP_OC 0x40 /* mask of all flags that are relevant to QAP (so they can be passed through) */ #define SRV_QAP_FLAGS (SRV_QAP_OC) /* stat codes; 0-0x3f are reserved for program specific codes - e.g. for R connection they correspond to the stat of Parse command. the following codes are returned by the Rserv itself codes <0 denote Rerror as provided by R_tryEval */ #define ERR_auth_failed 0x41 /* auth.failed or auth.requested but no login came. in case of authentification failure due to name/pwd mismatch, server may send CMD_accessDenied instead */ #define ERR_conn_broken 0x42 /* connection closed or broken packet killed it */ #define ERR_inv_cmd 0x43 /* unsupported/invalid command */ #define ERR_inv_par 0x44 /* some parameters are invalid */ #define ERR_Rerror 0x45 /* R-error occured, usually followed by connection shutdown */ #define ERR_IOerror 0x46 /* I/O error */ #define ERR_notOpen 0x47 /* attempt to perform fileRead/Write on closed file */ #define ERR_accessDenied 0x48 /* this answer is also valid on CMD_login; otherwise it's sent if the server deosn;t allow the user to issue the specified command. (e.g. some server admins may block file I/O operations for some users) */ #define ERR_unsupportedCmd 0x49 /* unsupported command */ #define ERR_unknownCmd 0x4a /* unknown command - the difference between unsupported and unknown is that unsupported commands are known to the server but for some reasons (e.g. platform dependent) it's not supported. unknown commands are simply not recognized by the server at all. */ /* The following ERR_.. exist since 1.23/0.1-6 */ #define ERR_data_overflow 0x4b /* incoming packet is too big. currently there is a limit as of the size of an incoming packet. */ #define ERR_object_too_big 0x4c /* the requested object is too big to be transported in that way. If received after CMD_eval then the evaluation itself was successful. optional parameter is the size of the object */ /* since 1.29/0.1-9 */ #define ERR_out_of_mem 0x4d /* out of memory. the connection is usually closed after this error was sent */ /* since 0.6-0 */ #define ERR_ctrl_closed 0x4e /* control pipe to the master process is closed or broken */ /* since 0.4-0 */ #define ERR_session_busy 0x50 /* session is still busy */ #define ERR_detach_failed 0x51 /* unable to detach seesion (cannot determine peer IP or problems creating a listening socket for resume) */ /* since 1.7 */ #define ERR_disabled 0x61 /* feature is disabled */ #define ERR_unavailable 0x62 /* feature is not present in this build */ #define ERR_cryptError 0x63 /* crypto-system error */ #define ERR_securityClose 0x64 /* server-initiated close due to security violation (too many attempts, excessive timeout etc.) */ /* availiable commands */ #define CMD_login 0x001 /* "name\npwd" : - */ #define CMD_voidEval 0x002 /* string : - */ #define CMD_eval 0x003 /* string | encoded SEXP : encoded SEXP */ #define CMD_shutdown 0x004 /* [admin-pwd] : - */ /* security/encryption - all since 1.7-0 */ #define CMD_switch 0x005 /* string (protocol) : - */ #define CMD_keyReq 0x006 /* string (request) : bytestream (key) */ #define CMD_secLogin 0x007 /* bytestream (encrypted auth) : - */ #define CMD_OCcall 0x00f /* SEXP : SEXP -- it is the only command supported in object-capability mode and it requires that the SEXP is a language construct with OC reference in the first position */ #define CMD_OCinit 0x434f7352 /* SEXP -- 'RsOC' - command sent from the server in OC mode with the packet of initial capabilities. */ /* file I/O routines. server may answe */ #define CMD_openFile 0x010 /* fn : - */ #define CMD_createFile 0x011 /* fn : - */ #define CMD_closeFile 0x012 /* - : - */ #define CMD_readFile 0x013 /* [int size] : data... ; if size not present, server is free to choose any value - usually it uses the size of its static buffer */ #define CMD_writeFile 0x014 /* data : - */ #define CMD_removeFile 0x015 /* fn : - */ /* object manipulation */ #define CMD_setSEXP 0x020 /* string(name), REXP : - */ #define CMD_assignSEXP 0x021 /* string(name), REXP : - ; same as setSEXP except that the name is parsed */ /* session management (since 0.4-0) */ #define CMD_detachSession 0x030 /* : session key */ #define CMD_detachedVoidEval 0x031 /* string : session key; doesn't */ #define CMD_attachSession 0x032 /* session key : - */ /* control commands (since 0.6-0) - passed on to the master process */ /* Note: currently all control commands are asychronous, i.e. RESP_OK indicates that the command was enqueued in the master pipe, but there is no guarantee that it will be processed. Moreover non-forked connections (e.g. the default debug setup) don't process any control commands until the current client connection is closed so the connection issuing the control command will never see its result. */ #define CMD_ctrl 0x40 /* -- not a command - just a constant -- */ #define CMD_ctrlEval 0x42 /* string : - */ #define CMD_ctrlSource 0x45 /* string : - */ #define CMD_ctrlShutdown 0x44 /* - : - */ /* 'internal' commands (since 0.1-9) */ #define CMD_setBufferSize 0x081 /* [int sendBufSize] this commad allow clients to request bigger buffer sizes if large data is to be transported from Rserve to the client. (incoming buffer is resized automatically) */ #define CMD_setEncoding 0x082 /* string (one of "native","latin1","utf8") : -; since 0.5-3 */ /* special commands - the payload of packages with this mask does not contain defined parameters */ #define CMD_SPECIAL_MASK 0xf0 #define CMD_serEval 0xf5 /* serialized eval - the packets are raw serialized data without data header */ #define CMD_serAssign 0xf6 /* serialized assign - serialized list with [[1]]=name, [[2]]=value */ #define CMD_serEEval 0xf7 /* serialized expression eval - like serEval with one additional evaluation round */ /* data types for the transport protocol (QAP1) do NOT confuse with XT_.. values. */ #define DT_INT 1 /* int */ #define DT_CHAR 2 /* char */ #define DT_DOUBLE 3 /* double */ #define DT_STRING 4 /* 0 terminted string */ #define DT_BYTESTREAM 5 /* stream of bytes (unlike DT_STRING may contain 0) */ #define DT_SEXP 10 /* encoded SEXP */ #define DT_ARRAY 11 /* array of objects (i.e. first 4 bytes specify how many subsequent objects are part of the array; 0 is legitimate) */ #define DT_CUSTOM 32 /* custom types not defined in the protocol but used by applications */ #define DT_LARGE 64 /* new in 0102: if this flag is set then the length of the object is coded as 56-bit integer enlarging the header by 4 bytes */ /* XpressionTypes REXP - R expressions are packed in the same way as command parameters transport format of the encoded Xpressions: [0] int type/len (1 byte type, 3 bytes len - same as SET_PAR) [4] REXP attr (if bit 8 in type is set) [4/8] data .. */ #define XT_NULL 0 /* P data: [0] */ #define XT_INT 1 /* - data: [4]int */ #define XT_DOUBLE 2 /* - data: [8]double */ #define XT_STR 3 /* P data: [n]char null-term. strg. */ #define XT_LANG 4 /* - data: same as XT_LIST */ #define XT_SYM 5 /* - data: [n]char symbol name */ #define XT_BOOL 6 /* - data: [1]byte boolean (1=TRUE, 0=FALSE, 2=NA) */ #define XT_S4 7 /* P data: [0] */ #define XT_VECTOR 16 /* P data: [?]REXP,REXP,.. */ #define XT_LIST 17 /* - X head, X vals, X tag (since 0.1-5) */ #define XT_CLOS 18 /* P X formals, X body (closure; since 0.1-5) */ #define XT_SYMNAME 19 /* s same as XT_STR (since 0.5) */ #define XT_LIST_NOTAG 20 /* s same as XT_VECTOR (since 0.5) */ #define XT_LIST_TAG 21 /* P X tag, X val, Y tag, Y val, ... (since 0.5) */ #define XT_LANG_NOTAG 22 /* s same as XT_LIST_NOTAG (since 0.5) */ #define XT_LANG_TAG 23 /* s same as XT_LIST_TAG (since 0.5) */ #define XT_VECTOR_EXP 26 /* s same as XT_VECTOR (since 0.5) */ #define XT_VECTOR_STR 27 /* - same as XT_VECTOR (since 0.5 but unused, use XT_ARRAY_STR instead) */ #define XT_ARRAY_INT 32 /* P data: [n*4]int,int,.. */ #define XT_ARRAY_DOUBLE 33 /* P data: [n*8]double,double,.. */ #define XT_ARRAY_STR 34 /* P data: string,string,.. (string=byte,byte,...,0) padded with '\01' */ #define XT_ARRAY_BOOL_UA 35 /* - data: [n]byte,byte,.. (unaligned! NOT supported anymore) */ #define XT_ARRAY_BOOL 36 /* P data: int(n),byte,byte,... */ #define XT_RAW 37 /* P data: int(n),byte,byte,... */ #define XT_ARRAY_CPLX 38 /* P data: [n*16]double,double,... (Re,Im,Re,Im,...) */ #define XT_UNKNOWN 48 /* P data: [4]int - SEXP type (as from TYPEOF(x)) */ /* | +--- interesting flags for client implementations: P = primary type s = secondary type - its decoding is identical to a primary type and thus the client doesn't need to decode it separately. - = deprecated/removed. if a client doesn't need to support old Rserve versions, those can be safely skipped. Total primary: 4 trivial types (NULL, STR, S4, UNKNOWN) + 6 array types + 3 recursive types */ #define XT_LARGE 64 /* new in 0102: if this flag is set then the length of the object is coded as 56-bit integer enlarging the header by 4 bytes */ #define XT_HAS_ATTR 128 /* flag; if set, the following REXP is the attribute */ /* the use of attributes and vectors results in recursive storage of REXPs */ #define BOOL_TRUE 1 #define BOOL_FALSE 0 #define BOOL_NA 2 #define GET_XT(X) ((X)&63) #define GET_DT(X) ((X)&63) #define HAS_ATTR(X) (((X)&XT_HAS_ATTR)>0) #define IS_LARGE(X) (((X)&XT_LARGE)>0) #if defined sun && ! defined ALIGN_DOUBLES #define ALIGN_DOUBLES #endif /* this is the type used to calculate pointer distances */ /* note: we may want to use size_t or something more compatible */ typedef unsigned long rlen_t; #ifdef ULONG_MAX #define rlen_max ULONG_MAX #else #ifdef __LP64__ #define rlen_max 0xffffffffffffffffL #else #define rlen_max 0xffffffffL #endif /* __LP64__ */ #endif /* ULONG_MAX */ /* functions/macros to convert native endianess of int/double for transport currently ony PPC style and Intel style are supported */ /* Since 0.4-5 we no longer use configure-time endianness tests to allow cross-compilation. Either BS_xx_ENDIAN constant is defined by configure and thus should be relied upon only if the compiler contants don't work */ #if defined __BIG_ENDIAN__ || defined _BIG_ENDIAN_ #define SWAPEND 1 #elif defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN_ || defined BS_LITTLE_ENDIAN /* #undef SWAPEND */ #elif defined BS_BIG_ENDIAN #define SWAPEND 1 #elif __ia64__ || __i386__ || __x86_64__ /* take a guess based on the architecture (Intel-like) */ #define __LITTLE_ENDIAN__ 1 #elif __ppc__ || __ppc64__ /* any ppc */ #define __BIG_ENDIAN__ 1 #define SWAPEND 1 #elif ! defined Win32 /* Windows is little-endian is most cases, anywhere else we're stuck */ #error "Cannot determine endianness. Make sure config.h is included or __{BIG|LITTLE}_ENDIAN__ is defined ." #endif /* FIXME: all the mess below needs more efficient implementation - the current one is so messy to work around alignment problems on some platforms like Sun and HP 9000 */ #ifdef SWAPEND /* swap endianness - for PPC and co. */ #ifdef MAIN unsigned int itop(unsigned int i) { char b[4]; b[0]=((char*)&i)[3]; b[3]=((char*)&i)[0]; b[1]=((char*)&i)[2]; b[2]=((char*)&i)[1]; return *((unsigned int*)b); } double dtop(double i) { char b[8]; b[0]=((char*)&i)[7]; b[1]=((char*)&i)[6]; b[2]=((char*)&i)[5]; b[3]=((char*)&i)[4]; b[7]=((char*)&i)[0]; b[6]=((char*)&i)[1]; b[5]=((char*)&i)[2]; b[4]=((char*)&i)[3]; return *((double*)b); } void fixdcpy(void *t,void *s) { int i=0; while (i<8) { ((char*)t)[7-i]=((char*)s)[i]; i++; } } #else extern unsigned int itop(unsigned int i); extern double dtop(double i); extern void fixdcpy(void *t,void *s); #endif #define ptoi(X) itop(X) /* itop*itop=id */ #define ptod(X) dtop(X) #else #define itop(X) (X) #define ptoi(X) (X) #define dtop(X) (X) #define ptod(X) (X) #define fixdcpy(T,S) ((double*)(T))[0]=((double*)(S))[0]; #define NATIVE_COPY 1 #endif #ifndef HAVE_CONFIG_H /* this tiny function can be used to make sure that the endianess is correct (it is not included if the package was configured with autoconf since then it should be fine anyway) */ #ifdef MAIN int isByteSexOk() { int i; i=itop(0x12345678); return (*((char*)&i)==0x78); } #else extern int isByteSexOk(); #endif #else #define isByteSexOk 1 #endif /* STANDALONE_RSERVE takes precedence over RSERVE_PKG */ #if defined STANDALONE_RSERVE && defined RSERVE_PKG #undef RSERVE_PKG #endif #endif /*--- The following makes the indenting behavior of emacs compatible with Xcode's 4/4 setting ---*/ /* Local Variables: */ /* indent-tabs-mode: t */ /* tab-width: 4 */ /* c-basic-offset: 4 */ /* End: */ Rserve/clients/cxx/config.h.in0000644000176000001440000001016012205226217016033 0ustar ripleyusers/* config.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* Defined if the platform is big-endian */ #undef BS_BIG_ENDIAN /* Defined if the platform is little-endian */ #undef BS_LITTLE_ENDIAN /* If defined Rserve supports unix crypt password encryption. */ #undef HAS_CRYPT /* */ #undef HAVE_CONNECT /* Define to 1 if you have the header file. */ #undef HAVE_CRYPT_H /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `dl' library (-ldl). */ #undef HAVE_LIBDL /* Define to 1 if you have the `inet' library (-linet). */ #undef HAVE_LIBINET /* Define to 1 if you have the `nsl' library (-lnsl). */ #undef HAVE_LIBNSL /* Define to 1 if you have the `nsl_s' library (-lnsl_s). */ #undef HAVE_LIBNSL_S /* Define to 1 if you have the `socket' library (-lsocket). */ #undef HAVE_LIBSOCKET /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the `mkdir' function. */ #undef HAVE_MKDIR /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_TCP_H /* Define to 1 if you have the `rmdir' function. */ #undef HAVE_RMDIR /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT /* Define to 1 if you have the `socket' function. */ #undef HAVE_SOCKET /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_UN_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vfork' function. */ #undef HAVE_VFORK /* Define to 1 if you have the header file. */ #undef HAVE_VFORK_H /* Define to 1 if `fork' works. */ #undef HAVE_WORKING_FORK /* Define to 1 if `vfork' works. */ #undef HAVE_WORKING_VFORK /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `int' if does not define. */ #undef pid_t /* Define to `int' if neither nor define. */ #undef socklen_t /* Define as `fork' if `vfork' does not work. */ #undef vfork Rserve/clients/cxx/sisocks.h0000644000176000001440000001700612205226216015644 0ustar ripleyusers/* system independent sockets (basically for unix and Win) * Copyright (C) 2000,1 Simon Urbanek * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; version 2.1 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * conditional defines: MAIN should be defined in just one file that will contain the fn definitions and variables USE_SNPRINTF emulate snprintf on Win platforms (you will lose the security which is provided under unix of course) SOCK_ERRORS include error code handling and checking functions */ #ifndef __SISOCKS_H__ #define __SISOCKS_H__ #if defined __GNUC__ && !defined unix && !defined Win32 /* MacOS X hack (gcc on any platform should behave as unix - except for Win32, where we need to keep using winsock) */ #define unix #endif #if defined STANDALONE_RSERVE && defined RSERVE_PKG #undef RSERVE_PKG #endif #if defined SOCK_ERRORS || defined USE_SNPRINTF #include #endif #include #ifdef unix #include #include #include #include #include #include #include #define sockerrno errno #define SOCKET int #define INVALID_SOCKET (-1) #define closesocket(A) close(A) #else #define windows #include #include #include #include #define inet_aton(A,B) (0, B.s_addr=inet_addr(A)) #define sockerrno WSAGetLastError() #ifndef WIN64 #define ECONNREFUSED WSAECONNREFUSED #define EADDRINUSE WSAEADDRINUSE #define ENOTSOCK WSAENOTSOCK #define EISCONN WSAEISCONN #define ETIMEDOUT WSAETIMEDOUT #define ENETUNREACH WSAENETUNREACH #define EINPROGRESS WSAEINPROGRESS #define EALREADY WSAEALREADY #define EAFNOSUPPORT WSAEAFNOSUPPORT #define EBADF WSAEBADF #define EINVAL WSAEINVAL #define EOPNOTSUPP WSAEOPNOTSUPP #define EFAULT WSAEFAULT #define EWOULDBLOCK WSAEWOULDBLOCK #define EACCES WSAEACCES #else #define ECONNREFUSED WSAECONNREFUSED #define EADDRINUSE WSAEADDRINUSE #define ENOTSOCK WSAENOTSOCK #define EISCONN WSAEISCONN #define ETIMEDOUT WSAETIMEDOUT #define ENETUNREACH WSAENETUNREACH #define EINPROGRESS WSAEINPROGRESS #define EALREADY WSAEALREADY #define EOPNOTSUPP WSAEOPNOTSUPP #define EWOULDBLOCK WSAEWOULDBLOCK #endif #ifdef USE_SNPRINTF #ifdef MAIN int snprintf(char *buf, int len, char *fmt, ...) { va_list argptr; int cnt; va_start(argptr, fmt); cnt = vsprintf(buf, fmt, argptr); va_end(argptr); return(cnt); } #else extern int snprintf(char *buf, int len, char *fmt, ...); #endif #endif #endif #define SA struct sockaddr #define SAIN struct sockaddr_in #ifdef windows #ifdef MAIN int initsocks(void) { WSADATA dt; /* initialize WinSock 1.1 */ return (WSAStartup(0x0101,&dt))?-1:0; } #else extern int initsocks(void); #endif #define donesocks() WSACleanup() #else /* no stupid stuff necessary for unix */ #define initsocks() #define donesocks() #endif #ifdef SOCK_ERRORS #ifdef MAIN int suppmode=0; int socklasterr; FILE *sockerrlog=0; /* copy error description to buf or set *buf=0 if none */ int sockerrorchecks(char *buf, int blen, int res) { *buf=0; if (res==-1) { switch(sockerrno) { case EBADF: strncpy(buf,"bad descriptor",blen); break; case EINVAL: strncpy(buf,"already in use",blen); break; case EACCES: strncpy(buf,"access denied",blen); break; case ENOTSOCK: strncpy(buf,"descriptor is not a socket",blen); break; case EOPNOTSUPP: strncpy(buf,"operation not supported",blen); break; case EFAULT: strncpy(buf,"fault",blen); break; case EWOULDBLOCK: strncpy(buf,"operation would block",blen); break; case EISCONN: strncpy(buf,"is already connected",blen); break; case ECONNREFUSED: strncpy(buf,"connection refused",blen); break; case ETIMEDOUT: strncpy(buf,"operation timed out",blen); break; case ENETUNREACH: strncpy(buf,"network is unreachable",blen); break; case EADDRINUSE: strncpy(buf,"address already in use",blen); break; case EINPROGRESS: strncpy(buf,"in progress",blen); break; case EALREADY: strncpy(buf,"previous connect request not completed yet",blen); break; #ifdef unix default: snprintf(buf,blen,"unknown socket error %d",sockerrno); #else default: sprintf(buf,"unknown socket error %d",sockerrno); #endif } } return res; } #ifdef RSERVE_PKG /* use error instead of exit */ #include int sockerrorcheck(char *sn, int rtb, int res) { if ((signed int)res == -1) { char sock_err_buf[72]; sockerrorchecks(sock_err_buf, sizeof(sock_err_buf), res); if (rtb) Rf_error("%s socket error #%d (%s)", sn, (int) sockerrno, sock_err_buf); else Rf_warning("%s socket error #%d (%s)", sn, (int) sockerrno, sock_err_buf); } return res; } #else /* check socket error and add to log file if necessary */ int sockerrorcheck(char *sn, int rtb, int res) { if (!sockerrlog) sockerrlog=stderr; if ((signed int)res==-1) { if (socklasterr==sockerrno) { suppmode++; } else { if (suppmode>0) { fprintf(sockerrlog,"##> REP: (last error has been repeated %d times.)\n",suppmode); suppmode=0; } fprintf(sockerrlog,"##> SOCK_ERROR: %s error #%d",sn,sockerrno); switch(sockerrno) { case EBADF: fprintf(sockerrlog,"(bad descriptor)"); break; case EINVAL: fprintf(sockerrlog,"(already in use)"); break; case EACCES: fprintf(sockerrlog,"(access denied)"); break; case ENOTSOCK: fprintf(sockerrlog,"(descriptor is not a socket)"); break; case EOPNOTSUPP: fprintf(sockerrlog,"(operation not supported)"); break; case EFAULT: fprintf(sockerrlog,"(fault)"); break; case EWOULDBLOCK: fprintf(sockerrlog,"(operation would block)"); break; case EISCONN: fprintf(sockerrlog,"(is already connected)"); break; case ECONNREFUSED: fprintf(sockerrlog,"(connection refused)"); break; case ETIMEDOUT: fprintf(sockerrlog,"(operation timed out)"); break; case ENETUNREACH: fprintf(sockerrlog,"(network is unreachable)"); break; case EADDRINUSE: fprintf(sockerrlog,"(address already in use)"); break; case EINPROGRESS: fprintf(sockerrlog,"(in progress)"); break; case EALREADY: fprintf(sockerrlog,"(previous connect request not completed yet)"); break; default: fprintf(sockerrlog,"(?)"); } fprintf(sockerrlog,"\n"); fflush(sockerrlog); socklasterr=sockerrno; } if (rtb) exit(1); } return res; } #endif #else extern int suppmode; extern int socklasterr; extern FILE *sockerrlog; int sockerrorchecks(char *buf, int blen, int res); int sockerrorcheck(char *sn, int rtb, int res); #endif #define FCF(X,F) sockerrorcheck(X,1,F) #define CF(X,F) sockerrorcheck(X,0,F) #endif #ifdef MAIN struct sockaddr *build_sin(struct sockaddr_in *sa,char *ip,int port) { memset(sa,0,sizeof(struct sockaddr_in)); sa->sin_family=AF_INET; sa->sin_port=htons(port); sa->sin_addr.s_addr=(ip)?inet_addr(ip):htonl(INADDR_ANY); return (struct sockaddr*)sa; } #else struct sockaddr *build_sin(struct sockaddr_in *sa,char *ip,int port); #endif #endif /* __SISOCKS_H__ */ Rserve/clients/cxx/Makefile.in0000644000176000001440000000044612205226215016061 0ustar ripleyusers# Makefile for C++ Rserve clients. # # $Id$ SRC = $(wildcard *.cc) OBJ = $(SRC:%.cc=%.o) DST = demo1 rcons rsdown LIBS+=@LIBS@ CPPFLAGS+=-DHAVE_CONFIG_H all: $(DST) $(OBJ) %: Rconnection.o %.o $(CXX) $^ -o $@ $(LIBS) debug: $(MAKE) CXXFLAGS=-g all clean: rm -rf *~ *.o \#* .\#* $(DST) Rserve/clients/cxx/Makefile.win0000755000176000001440000000063412205226215016252 0ustar ripleyusers# Makefile for C++ Rserve clients - Win32 version # # $Id$ SRC = $(wildcard *.cc) OBJ = $(SRC:%.cc=%.o) DST = demo1 rcons CXXFLAGS+=-I../include -I../include/Win32 -I.. -I. -DWin32 LIBS+=-lwsock32 linkRL= all: $(DST) demo1: Rconnection.o demo1.o $(CXX) $^ -o $@ $(LIBS) rcons: Rconnection.o rcons.o $(CXX) $^ -o $@ $(LIBS) $(linkRL) debug: CXXFLAGS=-g $(MAKE) all clean: rm -rf *~ *.o \#* .\#* $(DST) Rserve/clients/cxx/demo1.cc0000644000176000001440000001010212205226215015316 0ustar ripleyusers/* * Small demo to illustrate the use of the C++ interface to Rserve * Copyright (C) 2004 Simon Urbanek, All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Leser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id$ */ #include using std::cout; #define MAIN // we are the main program, we need to define this #define SOCK_ERRORS // we will use verbose socket errors #include "sisocks.h" #include "Rconnection.h" // this is just a very silly example to show how the C++ API works ... int main(int argc, char **argv) { initsocks(); // this is needed for Win32 - it does nothing on unix Rconnection *rc = new Rconnection(); int i=rc->connect(); if (i) { char msg[128]; sockerrorchecks(msg, 128, -1); printf("unable to connect (result=%d, socket:%s).\n", i, msg); return i; } double d[6] = { 1.5, 2.4, 5.6, -1.2, 0.6, 1.7 }; // assign the above contents to the variable "a" in R Rdouble *rd = new Rdouble(d, 6); rc->assign("a", rd); delete rd; // create a 2 x 3 matrix named "b" and calculate b * t(b) matrix product Rdouble *x = (Rdouble*) rc->eval("b<-matrix(a,2); b%*%t(b)"); if (x) { // if everything was fine, we have the result cout << x << "\n"; // just for fun - let's get the matrix dimensionality Rinteger *dim = (Rinteger*) x->attribute("dim"); if (dim) cout << dim->intAt(0) << " by " << dim->intAt(1) << " matrix\n"; // and print the contents of the matrix (unformatted) double *d = x->doubleArray(); int i=0, ct = x->length(); while (i < ct) { cout << d[i++] << " "; } cout << "\n"; // finally dispose of the object delete x; } // integer constant assignment test int ia[6] = { 1, 4, 6, 3, 5 , 2 }; Rinteger *ri = new Rinteger(ia, 6); rc->assign("i", ri); delete ri; // let's get the whole iris data Rvector *iris = (Rvector*) rc->eval("data(iris); iris"); if (!iris) { cout << "oops! couldn't get iris data\n"; delete rc; return 0; } // now let's just get the sepal width - this a cheap operation, no talking to Rserve, because we have all the data already Rdouble *sw = (Rdouble*) iris->byName("Sepal.Width"); double *swd = sw->doubleArray(); // and print it ... { int i=0, ct=sw->length(); while (i using std::cout; #define MAIN // we are the main program, we need to define this #define SOCK_ERRORS // we will use verbose socket errors #include "Rconnection.h" #ifdef READLINE #include #include #endif #ifdef READLINE char *c=0; #else char c[1024]; #endif int main(int argc, char **argv) { initsocks(); // this is needed for Win32 - it does noting on unix Rconnection *rc = new Rconnection(); int i=rc->connect(); if (i) { char msg[128]; sockerrorchecks(msg, 128, -1); printf("unable to connect (result=%d, socket:%s).\n", i, msg); return i; } printf("connected. Type \"q\" to quit.\n"); do { #ifdef READLINE c=readline("Rcli> "); if (c && *c) add_history(c); #else printf("Rcli> "); c[1023]=0; fgets(c,1023,stdin); char *rq=c; while(*rq && rq-c<1023) { if (*rq=='\n') *rq=0; rq++; } #endif if (!strcmp(c,"q") || !strcmp(c,"quit") || !strcmp(c,"exit")) { cout << "ok, you got enough, right? leaving.\n"; break; } int res=0; if (!strcmp(c,"shutdown")) { // this is a demo of low-level commands being send via "request" Rmessage *msg=new Rmessage(); cout << "performing shutdown.\n"; res=rc->request(msg,CMD_shutdown); delete(msg); } else if (*c) { // this is a regular "eval" demo Rexp *xp=rc->eval(c, &res); if (xp) { cout << "type=" << xp->type << ", len=" << xp->len << ", result:" << *xp << "\n"; if (xp->attr) cout << "attributes: " << *xp->attr << "\n"; delete(xp); } else cout << "eval failed with result " << res << "\n"; } if (res) { cout << "request failed with error code " << res << "\n"; break; } } while (1); delete(rc); return 0; } Rserve/clients/cxx/Rconnection.h0000644000176000001440000003220512205226215016444 0ustar ripleyusers/* * C++ Interface to Rserve * Copyright (C) 2004-8 Simon Urbanek, All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Leser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Although this code is licensed under LGPL v2.1, we strongly encourage * everyone modifying this software to contribute back any improvements and * bugfixes to the project for the benefit all other users. Thank you. * * $Id$ */ /* external defines: SWAPEND - needs to be defined for platforms with inverse endianess related to Intel MAIN - should be defined in just one file that will contain the fn definitions and variables (this is inherited from Rsrv.h and sisocks.h) */ #ifndef __RCONNECTION_H__ #define __RCONNECTION_H__ #if defined __GNUC__ && !defined unix && !defined Win32 && !defined WIN32 #define unix #endif #include #include #include "sisocks.h" #include "Rsrv.h" typedef unsigned int Rsize_t; //=== Rconnection error codes #define CERR_connect_failed -1 #define CERR_handshake_failed -2 #define CERR_invalid_id -3 #define CERR_protocol_not_supp -4 #define CERR_not_connected -5 #define CERR_peer_closed -7 #define CERR_malformed_packet -8 #define CERR_send_error -9 #define CERR_out_of_mem -10 #define CERR_not_supported -11 #define CERR_io_error -12 // this one is custom - authentication method required by // the server is not supported in this client #define CERR_auth_unsupported -20 #define A_required 0x001 #define A_crypt 0x002 #define A_plain 0x004 //===================================== Rmessage ---- QAP1 storage class Rmessage { public: struct phdr head; char *data; Rsize_t len; int complete; // the following is avaliable only for parsed messages (max 16 pars) int pars; unsigned int *par[16]; Rmessage(); Rmessage(int cmd); // 0 data Rmessage(int cmd, const char *txt); // DT_STRING data Rmessage(int cmd, int i); // DT_INT data (1 entry) Rmessage(int cmd, const void *buf, int len, int raw_data=0); // raw data or DT_BYTESTREAM virtual ~Rmessage(); int command() { return complete?head.cmd:-1; } Rsize_t length() { return complete?head.len:-1; } int is_complete() { return complete; } int read(int s); void parse(); int send(int s); }; //===================================== Rexp --- basis for all SEXPs class Rexp { public: Rmessage *msg; unsigned int *pos; Rsize_t len; Rexp *attr; int type; /* memory manegement for data/len: - content is in a message and this Rexp is the master of that message: master=0; msg=; - content is in a message, but this Rexp is not the master master=; msg=0 - content is all self-allocated with no message associated master=this; msg=0 */ char *data, *next; protected: // the next two are only cached if requested, no direct access allowed int attribs; const char **attrnames; Rexp *master; // if this is set then this Rexp allocated the memory for us, so we are not supposed to free anything; if this is set to "this" then the content is self-allocated, including any data int rcount; // reference count - only for a master - it counts how many children still exist public: Rexp(Rmessage *msg); Rexp(unsigned int *pos, Rmessage *msg=0); Rexp(int type, const char *data=0, int len=0, Rexp *attr=0); virtual ~Rexp(); void set_master(Rexp *m); char *parse(unsigned int *pos); virtual Rsize_t storageSize() { return len+((len>0x7fffff)?8:4); } virtual void store(char *buf); Rexp *attribute(const char *name); const char **attributeNames(); virtual Rsize_t length() { return len; } friend std::ostream& operator<< (std::ostream& os, const Rexp& exp) { return ((Rexp&)exp).os_print(os); } friend std::ostream& operator<< (std::ostream& os, const Rexp* exp) { return ((Rexp*)exp)->os_print(os); } virtual std::ostream& os_print(std::ostream& os) { return os << "Rexp[type=" << type << ",len=" << len <<"]"; } }; //===================================== Rint --- XT_INT/XT_ARRAY_INT class Rinteger : public Rexp { public: Rinteger(Rmessage *msg) : Rexp(msg) { fix_content(); } Rinteger(unsigned int *ipos, Rmessage *imsg) : Rexp(ipos, imsg) { fix_content(); } Rinteger(int *array, int count) : Rexp(XT_ARRAY_INT, (char*)array, count*sizeof(int)) { fix_content(); } int *intArray() { return (int*) data; } int intAt(int pos) { return (pos>=0 && (unsigned)pos=0 && (unsigned)pos= nel) ? 0 : cont[i]; } char *string() { return stringAt(0); } virtual Rsize_t length() { return nel; } unsigned int count() { return nel; } int indexOfString(const char *str); virtual std::ostream& os_print (std::ostream& os) { return os << "char*[" << nel <<"]\"" << string() <<"\".."; } private: void decode() { char *c = (char*) data; unsigned int i = 0; nel = 0; while (i < len) { if (!c[i]) nel++; i++; } if (nel) { i = 0; cont = (char**) malloc(sizeof(char*)*nel); while (i < nel) { cont[i] = strdup(c); while (*c) c++; c++; i++; } } else cont = 0; } }; //===================================== Rstring --- XT_STR class Rstring : public Rexp { public: Rstring(Rmessage *msg) : Rexp(msg) {} Rstring(unsigned int *ipos, Rmessage *imsg) : Rexp(ipos, imsg) {} Rstring(const char *str) : Rexp(XT_STR, str, strlen(str)+1) {} char *string() { return (char*) data; } virtual std::ostream& os_print (std::ostream& os) { return os << "\"" << string() <<"\""; } }; //===================================== Rlist --- XT_LIST (CONS lists) class Rlist : public Rexp { public: Rexp *head, *tag; Rlist *tail; Rlist(Rmessage *msg) : Rexp(msg) { head=tag=0; tail=0; fix_content(); } Rlist(unsigned int *ipos, Rmessage *imsg) : Rexp(ipos, imsg) { head=tag=0; tail=0; fix_content(); } /* this is a sort of special constructor that allows to create a Rlist based solely on its content. This is necessary since 0.5 because each LISTSXP is no longer represented by its own encoded SEXP but they are packed in one content list instead */ Rlist(int type, Rexp *head, Rexp *tag, char *next, Rmessage *imsg) : Rexp(type, 0, 0, 0) { this->head = head; this->tag = tag; tail = 0; this->next = next; this->msg = imsg; master = 0; } virtual ~Rlist(); Rexp *entryByTagName(const char *tagName) { if (tag && (tag->type==XT_SYM || tag->type==XT_SYMNAME) && !strcmp(((Rsymbol*)tag)->symbolName(),tagName)) return head; if (tail) return tail->entryByTagName(tagName); return 0; } virtual std::ostream& os_print (std::ostream& os) { os << "Rlist[tag="; if (tag) os << *tag; else os << ""; os << ",head="; if (head) os << *head; else os << ""; if (tail) os << ",tail=" << *tail; return os << "]"; } private: void fix_content(); }; //===================================== Rvector --- XT_VECTOR (general lists) class Rvector : public Rexp { protected: Rexp **cont; int count; // cached char **strs; public: Rvector(Rmessage *msg) : Rexp(msg) { cont=0; count=0; strs=0; fix_content(); } Rvector(unsigned int *ipos, Rmessage *imsg) : Rexp(ipos, imsg) { cont=0; count=0; strs=0; fix_content(); } virtual ~Rvector(); char **strings(); int indexOf(Rexp *exp); int indexOfString(const char *str); virtual Rsize_t length() { return (Rsize_t) count; } char *stringAt(int i) { if (i < 0 || i >= count || !cont[i] || cont[i]->type != XT_STR) return 0; return ((Rstring*)cont[i])->string(); } Rexp *elementAt(int i) { return (i < 0 || i >= count || !cont[i]) ? 0 : cont[i]; } Rexp* byName(const char *name); virtual std::ostream& os_print (std::ostream& os) { os << "Rvector[count=" << count << ":"; int i=0; while (i. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: Simon.Urbanek@r-project.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='Rserve-cxx-client' PACKAGE_TARNAME='rserve-cxx-client' PACKAGE_VERSION='0.1' PACKAGE_STRING='Rserve-cxx-client 0.1' PACKAGE_BUGREPORT='Simon.Urbanek@r-project.org' PACKAGE_URL='' ac_unique_file="Rconnection.cc" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='LTLIBOBJS LIBOBJS EGREP GREP CPP ac_ct_CXX CXXFLAGS CXX OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CXX CXXFLAGS CCC CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures Rserve-cxx-client 0.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/rserve-cxx-client] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of Rserve-cxx-client 0.1:";; esac cat <<\_ACEOF Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXX C++ compiler command CXXFLAGS C++ compiler flags CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF Rserve-cxx-client configure 0.1 generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval "test \"\${$3+set}\"" = set; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------------------ ## ## Report this to Simon.Urbanek@r-project.org ## ## ------------------------------------------ ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_mongrel # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_compile # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_type # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by Rserve-cxx-client $as_me 0.1, which was generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5 ; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5 ; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5 ; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5 ; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if test "${ac_cv_objext+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if test "${ac_cv_prog_cxx_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if test "${ac_cv_path_GREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if test "${ac_cv_path_EGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5 $as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; } if test "${ac_cv_header_sys_wait_h+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif int main () { int s; wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_sys_wait_h=yes else ac_cv_header_sys_wait_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5 $as_echo "$ac_cv_header_sys_wait_h" >&6; } if test $ac_cv_header_sys_wait_h = yes; then $as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in string.h memory.h sys/time.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in sys/stat.h sys/types.h sys/socket.h sys/un.h netinet/in.h netinet/tcp.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if test "${ac_cv_c_const+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if test "${ac_cv_c_bigendian+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define BS_BIG_ENDIAN 1" >>confdefs.h ;; #( no) $as_echo "#define BS_LITTLE_ENDIAN 1" >>confdefs.h ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: endianness unknown - will rely solely on compiler macros" >&5 $as_echo "endianness unknown - will rely solely on compiler macros" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler sets endianness macros" >&5 $as_echo_n "checking whether compiler sets endianness macros... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN_ || defined __BIG_ENDIAN__ || defined _BIG_ENDIAN_ #define BS_OK 1 #else cannot determine compiler's endianness #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "Cannot determine endianness neither from the compiler nor using a test. Try adding -D_BIG_ENDIAN_ or -D_LITTLE_ENDIAN_ to PKG_CPPFLAGS. " "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if test "${ac_cv_header_time+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi # Checks for library functions. ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" if test "x$ac_cv_type_pid_t" = x""yes; then : else cat >>confdefs.h <<_ACEOF #define pid_t int _ACEOF fi for ac_header in vfork.h do : ac_fn_c_check_header_mongrel "$LINENO" "vfork.h" "ac_cv_header_vfork_h" "$ac_includes_default" if test "x$ac_cv_header_vfork_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_VFORK_H 1 _ACEOF fi done for ac_func in fork vfork do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done if test "x$ac_cv_func_fork" = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working fork" >&5 $as_echo_n "checking for working fork... " >&6; } if test "${ac_cv_func_fork_works+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_fork_works=cross else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* By Ruediger Kuhlmann. */ return fork () < 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_fork_works=yes else ac_cv_func_fork_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_fork_works" >&5 $as_echo "$ac_cv_func_fork_works" >&6; } else ac_cv_func_fork_works=$ac_cv_func_fork fi if test "x$ac_cv_func_fork_works" = xcross; then case $host in *-*-amigaos* | *-*-msdosdjgpp*) # Override, as these systems have only a dummy fork() stub ac_cv_func_fork_works=no ;; *) ac_cv_func_fork_works=yes ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5 $as_echo "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;} fi ac_cv_func_vfork_works=$ac_cv_func_vfork if test "x$ac_cv_func_vfork" = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working vfork" >&5 $as_echo_n "checking for working vfork... " >&6; } if test "${ac_cv_func_vfork_works+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_vfork_works=cross else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Thanks to Paul Eggert for this test. */ $ac_includes_default #include #ifdef HAVE_VFORK_H # include #endif /* On some sparc systems, changes by the child to local and incoming argument registers are propagated back to the parent. The compiler is told about this with #include , but some compilers (e.g. gcc -O) don't grok . Test for this by using a static variable whose address is put into a register that is clobbered by the vfork. */ static void #ifdef __cplusplus sparc_address_test (int arg) # else sparc_address_test (arg) int arg; #endif { static pid_t child; if (!child) { child = vfork (); if (child < 0) { perror ("vfork"); _exit(2); } if (!child) { arg = getpid(); write(-1, "", 0); _exit (arg); } } } int main () { pid_t parent = getpid (); pid_t child; sparc_address_test (0); child = vfork (); if (child == 0) { /* Here is another test for sparc vfork register problems. This test uses lots of local variables, at least as many local variables as main has allocated so far including compiler temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should reuse the register of parent for one of the local variables, since it will think that parent can't possibly be used any more in this routine. Assigning to the local variable will thus munge parent in the parent process. */ pid_t p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(), p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid(); /* Convince the compiler that p..p7 are live; otherwise, it might use the same hardware register for all 8 local variables. */ if (p != p1 || p != p2 || p != p3 || p != p4 || p != p5 || p != p6 || p != p7) _exit(1); /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent from child file descriptors. If the child closes a descriptor before it execs or exits, this munges the parent's descriptor as well. Test for this by closing stdout in the child. */ _exit(close(fileno(stdout)) != 0); } else { int status; struct stat st; while (wait(&status) != child) ; return ( /* Was there some problem with vforking? */ child < 0 /* Did the child fail? (This shouldn't happen.) */ || status /* Did the vfork/compiler bug occur? */ || parent != getpid() /* Did the file descriptor bug occur? */ || fstat(fileno(stdout), &st) != 0 ); } } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_vfork_works=yes else ac_cv_func_vfork_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_vfork_works" >&5 $as_echo "$ac_cv_func_vfork_works" >&6; } fi; if test "x$ac_cv_func_fork_works" = xcross; then ac_cv_func_vfork_works=$ac_cv_func_vfork { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5 $as_echo "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;} fi if test "x$ac_cv_func_vfork_works" = xyes; then $as_echo "#define HAVE_WORKING_VFORK 1" >>confdefs.h else $as_echo "#define vfork fork" >>confdefs.h fi if test "x$ac_cv_func_fork_works" = xyes; then $as_echo "#define HAVE_WORKING_FORK 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 $as_echo_n "checking return type of signal handlers... " >&6; } if test "${ac_cv_type_signal+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { return *(signal (0, 0)) (0) == 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_type_signal=int else ac_cv_type_signal=void fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 $as_echo "$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF for ac_func in memset mkdir rmdir select socket do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done # Check whether we can use crypt (and if we do if it's in the crypt library) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing crypt" >&5 $as_echo_n "checking for library containing crypt... " >&6; } if test "${ac_cv_search_crypt+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char crypt (); int main () { return crypt (); ; return 0; } _ACEOF for ac_lib in '' crypt; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_crypt=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if test "${ac_cv_search_crypt+set}" = set; then : break fi done if test "${ac_cv_search_crypt+set}" = set; then : else ac_cv_search_crypt=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_crypt" >&5 $as_echo "$ac_cv_search_crypt" >&6; } ac_res=$ac_cv_search_crypt if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define HAS_CRYPT 1" >>confdefs.h fi for ac_header in crypt.h do : ac_fn_c_check_header_mongrel "$LINENO" "crypt.h" "ac_cv_header_crypt_h" "$ac_includes_default" if test "x$ac_cv_header_crypt_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_CRYPT_H 1 _ACEOF fi done # socket related stuff - indroduced first due to Solaris # socklen_t - note that we don't try to find an equivalent! # we'll use BSD-style int in case this one isn't defined. # that should be fine for all major platforms. ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" " #include #include " if test "x$ac_cv_type_socklen_t" = x""yes; then : else $as_echo "#define socklen_t int" >>confdefs.h fi # connect may need -lsocket and/or -lnsl (e.g. on Solaris) for ac_func in connect do : ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect" if test "x$ac_cv_func_connect" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_CONNECT 1 _ACEOF fi done if test x"$ac_cv_func_connect" = x"no"; then case "$LIBS" in *-lnsl*) ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf in -lnsl_s" >&5 $as_echo_n "checking for printf in -lnsl_s... " >&6; } if test "${ac_cv_lib_nsl_s_printf+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl_s $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char printf (); int main () { return printf (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nsl_s_printf=yes else ac_cv_lib_nsl_s_printf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_s_printf" >&5 $as_echo "$ac_cv_lib_nsl_s_printf" >&6; } if test "x$ac_cv_lib_nsl_s_printf" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBNSL_S 1 _ACEOF LIBS="-lnsl_s $LIBS" fi ;; esac case "$LIBS" in *-lnsl*) ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf in -lnsl" >&5 $as_echo_n "checking for printf in -lnsl... " >&6; } if test "${ac_cv_lib_nsl_printf+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char printf (); int main () { return printf (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nsl_printf=yes else ac_cv_lib_nsl_printf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_printf" >&5 $as_echo "$ac_cv_lib_nsl_printf" >&6; } if test "x$ac_cv_lib_nsl_printf" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBNSL 1 _ACEOF LIBS="-lnsl $LIBS" fi ;; esac case "$LIBS" in *-lsocket*) ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5 $as_echo_n "checking for connect in -lsocket... " >&6; } if test "${ac_cv_lib_socket_connect+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char connect (); int main () { return connect (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_connect=yes else ac_cv_lib_socket_connect=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5 $as_echo "$ac_cv_lib_socket_connect" >&6; } if test "x$ac_cv_lib_socket_connect" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSOCKET 1 _ACEOF LIBS="-lsocket $LIBS" fi ;; esac case "$LIBS" in *-linet*) ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -linet" >&5 $as_echo_n "checking for connect in -linet... " >&6; } if test "${ac_cv_lib_inet_connect+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-linet $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char connect (); int main () { return connect (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_inet_connect=yes else ac_cv_lib_inet_connect=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_inet_connect" >&5 $as_echo "$ac_cv_lib_inet_connect" >&6; } if test "x$ac_cv_lib_inet_connect" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBINET 1 _ACEOF LIBS="-linet $LIBS" fi ;; esac if test x"$ac_cv_lib_socket_connect" = x"yes" || test x"$ac_cv_lib_inet_connect" = x"yes"; then # ac_cv_func_connect=yes # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run $as_echo "#define HAVE_CONNECT 1" >>confdefs.h fi fi # on some platforms libR expects dl code in the binary { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if test "${ac_cv_lib_dl_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDL 1 _ACEOF LIBS="-ldl $LIBS" fi ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : ${CONFIG_STATUS=./config.status} ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by Rserve-cxx-client $as_me 0.1, which was generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ Rserve-cxx-client config.status 0.1 configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_t=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_t"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$tmp/stdin" case $ac_file in -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi Rserve/clients/cxx/ReadMe.txt0000644000176000001440000000536412205226215015716 0ustar ripleyusersThis directory contains a sample C++ client for Rserve You can compile this client without R. Just run "configure" in the Rserve directory, a corresponding Makefile will be automatically generated. Win32: There is no configure for Windows, but there is a special Makefile.win to build it - use "make -f Makefile.win" - it requires MinGW (or compatible) and GNU make. This C++ interface is experimental and does not come in form of a library, it is left to the user to build one or just use it in static form. Rconnection.h and Rconnection.cc is all that's needed. This directory also contains two little examples: * demo1.cc This (rather silly) example demonstrates the basic use of the API, such as assigning contents, evaluating expressions and fetching various parts of the data. * rcons.cc A very simple console to Rserve. It uses the os_print method to print the results and its attributes. It is helpful if you want to understand how R and Rserve stores various expressions. * rcmd.cc This program "sources" all files specified on the command line into a Rserve session and prints its output. It is something like a 'fast' version of R CMD BATCH. It's very simple, so look at the code if you want a more sophisticated behavior. The entire C++ interface handles only the most basic types such as lists, vectors, doubles, integers and strings. Look at the sources to see how to implement other types if necessary (although there isn't too much missing, maybe logical vectors ...). A word about the memory allocation of the objects here: in most cases the memory is allocated by the Rmessage object that receives the evaluated expression for R. All further Rexp objects are just pointers inside that message. For convenience there is one "main" Rexp, which knows about the message and automaically deallocates it upon its own destruction. This means that from user's point of view there is always only *one* object which can be deleted, namely the one returned by 'eval'. The user should *never* delete any object obtained indirectly from another Rexp. Complex Rexps, such as Rvector always return direct pointers to their content. This applies also to pointer to other types obtained from Rexp such as doubleArray of Rdouble. You should always copy this content if you plan to make modifications. This approach was taken to provide very fast access to all objects returned from Rserve. Usually noting needs to be copied - this is imporant, because the objects could be quite large. Please feel free to contribute to this project. I don't use this C++ interface myself, therefore it is left to the users to extend it further. All low-level handling is implemented, therefore it is much easier to add high-level functionality. see also: http://www.rosuda.org/Rserve/ Simon Urbanek, Sept 2004 Rserve/clients/cxx/Rconnection.cc0000644000176000001440000006247412205226215016615 0ustar ripleyusers/* * C++ Interface to Rserve * Copyright (C) 2004-8 Simon Urbanek, All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Leser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Although this code is licensed under LGPL v2.1, we strongly encourage * everyone modifying this software to contribute back any improvements and * bugfixes to the project for the benefit all other users. Thank you. * * $Id$ */ /* external defines: SWAPEND - needs to be defined for platforms with inverse endianess related to Intel see also SOCK_ERROR, MAIN and other defines in sisocks.h */ /* locally generated status error and return codes: -1 - operation failed (e.g. connect failed) -2 - handhake failed -3 - invalid ID string -4 - protocol not supported -5 - not connected -6 - - unused - -7 - remote connection close -8 - malformed packet -9 - send error -10 - out of memory -11 - operation is unsupported (e.g. unix login while crypt is not linked) -12 - eval didn't return a SEXP (possibly the server is too old/buggy or crashed) */ #include "Rconnection.h" #include #include "sisocks.h" #ifdef unix #include #include #else #define AF_LOCAL -1 #endif #if defined HAVE_NETINET_TCP_H && defined HAVE_NETINET_IN_H #define CAN_TCP_NODELAY #include #include #endif #ifdef Win32 #define CAN_TCP_NODELAY #endif #include "Rsrv.h" #ifndef AF_LOCAL #define AF_LOCAL AF_UNIX #endif // NOTE: 0103 compatibility has not been established! use at your own risk! static const char *myID = "Rsrv0103QAP1"; /* this client supports up to protocol version 0103 */ #define IS_LIST_TYPE_(TYPE) ((TYPE) == XT_LIST || (TYPE) == XT_LIST_NOTAG || (TYPE) == XT_LIST_TAG) #define IS_SYMBOL_TYPE_(TYPE) ((TYPE) == XT_SYM || (TYPE) == XT_SYMNAME) static Rexp *new_parsed_Rexp(unsigned int *d, Rmessage *msg) { int type=ptoi(*d)&0x3f; #ifdef DEBUG_CXX printf("new_parsed_Rexp(%p, %p) type=%d\n", d, msg, type); #endif if (type==XT_ARRAY_INT || type==XT_INT) return new Rinteger(d,msg); if (type==XT_ARRAY_DOUBLE || type==XT_DOUBLE) return new Rdouble(d,msg); if (IS_LIST_TYPE_(type)) return new Rlist(d,msg); if (type==XT_VECTOR) return new Rvector(d,msg); if (type==XT_STR) return new Rstring(d,msg); if (type==XT_SYM || type==XT_SYMNAME) return new Rsymbol(d,msg); if (type==XT_ARRAY_STR) return new Rstrings(d,msg); return new Rexp(d,msg); } static Rexp *new_parsed_Rexp_from_Msg(Rmessage *msg) { int hl=1; unsigned int *hp=msg->par[0]; Rsize_t plen=hp[0]>>8; if ((hp[0]&DT_LARGE)>0) { hl++; plen|=((Rsize_t)hp[1])<<24; } return new_parsed_Rexp(hp+hl,msg); } Rmessage::Rmessage() { complete=0; data=0; len=0; } Rmessage::Rmessage(int cmd) { memset(&head,0,sizeof(head)); head.cmd = cmd; data=0; len=0; complete=1; } Rmessage::Rmessage(int cmd, const char *txt) { memset(&head,0,sizeof(head)); int tl=strlen(txt)+1; if ((tl&3)>0) tl=(tl+4)&0xffffc; // allign the text len=tl+4; // message length is tl + 4 (short format only) head.cmd=cmd; head.len=len; data=(char*)malloc(tl+16); memset(data,0,tl+16); *((int*)data)=itop(SET_PAR(DT_STRING,tl)); strcpy(data+4,txt); complete=1; } Rmessage::Rmessage(int cmd, const void *buf, int dlen, int raw_data) { memset(&head,0,sizeof(head)); len=(raw_data)?dlen:(dlen+4); head.cmd=cmd; head.len=len; data=(char*)malloc(len); memcpy(data, (raw_data)?buf:((char*)buf+4), dlen); if (!raw_data) *((int*)data)=itop(SET_PAR(DT_BYTESTREAM,dlen)); complete=1; } Rmessage::Rmessage(int cmd, int i) { memset(&head,0,sizeof(head)); len=8; // DT_INT+len (4) + payload-1xINT (4) head.cmd=cmd; head.len=len; data=(char*)malloc(8); *((int*)data)=itop(SET_PAR(DT_INT,4)); ((int*)data)[1]=itop(i); complete=1; } Rmessage::~Rmessage() { if(data) free(data); complete=0; } int Rmessage::read(int s) { complete=0; int n=recv(s,(char*)&head,sizeof(head),0); if (n!=sizeof(head)) { closesocket(s); s=-1; return (n==0)?-7:-8; } Rsize_t i=len=head.len=ptoi(head.len); head.cmd=ptoi(head.cmd); head.dof=ptoi(head.dof); head.res=ptoi(head.res); if (head.dof>0) { // skip past DOF if present char sb[256]; int k=head.dof; while (k>0) { n=recv(s,(char*)sb,(k>256)?256:k,0); if (n<1) { closesocket(s); s=-1; return -8; // malformed packet } k-=n; } } if (i>0) { data=(char*) malloc(i); if (!data) { closesocket(s); s=-1; return -10; // out of memory } char *dp=data; while(i>0 && (n=recv(s,(char*)dp,i,0))>0) { dp+=n; i-=n; } if (i>0) { closesocket(s); s=-1; return -8; } } parse(); complete=1; return 0; } void Rmessage::parse() { pars=0; if (len<4) return; char *c=data, *eop=c+len; while (c>8; if ((p1&DT_LARGE)>0) { hs+=4; unsigned int p2=ptoi(pp[1]); len|=((Rsize_t)p2)<<24; } #ifdef DEBUG_CXX printf(" par %d: %d length %d\n", pars, p1&0x3f, len); #endif par[pars++]=(unsigned int*)c; c+=hs; c+=len; if (pars>15) break; // max 16 pars } } int Rmessage::send(int s) { int failed=0; head.cmd=itop(head.cmd); head.len=itop(head.len); head.dof=itop(head.dof); head.res=itop(head.res); if (::send(s,(char*)&head,sizeof(head),0)!=sizeof(head)) failed=-1; if (!failed && len>0 && (Rsize_t)::send(s,data,len,0)!=len) failed=-1; head.cmd=ptoi(head.cmd); head.len=ptoi(head.len); head.dof=ptoi(head.dof); head.res=ptoi(head.res); return failed; } Rexp::Rexp(Rmessage *msg) { #ifdef DEBUG_CXX printf("new Rexp@%x\n", this); #endif master=0; rcount=0; attr=0; attribs=0; this->msg=msg; int hl=1; unsigned int *hp=msg->par[0]; Rsize_t plen=hp[0]>>8; if ((hp[0]&DT_LARGE)>0) { hl++; plen|=((Rsize_t)hp[1])<<24; } next=parse(hp+hl); } Rexp::Rexp(unsigned int *pos, Rmessage *msg) { #ifdef DEBUG_CXX printf("new Rexp@%x\n", this); #endif attr=0; master=0; this->msg=msg; rcount=0; attribs=0; next=parse(pos); } Rexp::Rexp(int type, const char *data, int len, Rexp *attr) { this->attr=attr; master=this; rcount=0; attribs=0; this->type=type; this->msg=0; if (len>0) { #ifdef DEBUG_CXX fprintf(stderr, "Rexp::Rexp %p: allocating %d bytes\n", this, len); #endif this->data=(char*) malloc(len); memcpy(this->data, data, len); this->len=len; } else this->len=0; next=(char*)data+this->len; } Rexp::~Rexp() { #ifdef DEBUG_CXX printf("releasing Rexp@%p\n", this); #endif if (attr) delete(attr); attr=0; if (master) { if (master==this) { free(data); len=0; } else master->rcount--; master=0; } if (msg) { if (rcount>0) fprintf(stderr, "WARNING! Rexp master %lx delete requested, but %d object(s) are using our memory - refusing to free, leaking...\n", (long)this, rcount); else delete(msg); } msg=0; } void Rexp::set_master(Rexp *m) { if (master) master->rcount--; master=m; if (m) m->rcount++; } char *Rexp::parse(unsigned int *pos) { // plen is not used this->pos=pos; int hl=1; unsigned int p1=ptoi(pos[0]); len=p1>>8; if ((p1&XT_LARGE)>0) { hl++; len|=((Rsize_t)(ptoi(pos[1])))<<24; } data=(char*)(pos+hl); if (p1&XT_HAS_ATTR) { attr=new_parsed_Rexp((unsigned int*)data, 0); len-=attr->next-data; data=attr->next; if (master || msg) attr->set_master(master?master:this); } type=p1&0x3f; #ifdef DEBUG_CXX printf("Rexp(type=%d, len=%d, attr=%p)\n", type, len, attr); #endif return data+len; } void Rexp::store(char *buf) { int hl=4; unsigned int *i = (unsigned int*)buf; i[0]=SET_PAR(type, len); i[0]=itop(i[0]); if (len>0x7fffff) { buf[0]|=XT_LARGE; i[1]=itop(len>>24); hl+=4; } memcpy(buf+hl, data, len); } Rexp *Rexp::attribute(const char *name) { return (attr && IS_LIST_TYPE_(attr->type)) ? ((Rlist*)attr)->entryByTagName(name) : 0; } const char **Rexp::attributeNames() { if (!attr || !IS_LIST_TYPE_(attr->type)) return 0; if (attribs == 0) { // let us cache attribute names Rlist *l = (Rlist*) attr; while (l && (IS_LIST_TYPE_(l->type))) { if (l->tag && IS_SYMBOL_TYPE_(l->tag->type)) attribs++; l = l->tail; } attrnames = (const char**) malloc(sizeof(char*)*(attribs+1)); l = (Rlist*) attr; while (l && IS_LIST_TYPE_(l->type)) { if (l->tag && IS_SYMBOL_TYPE_(l->tag->type)) attrnames[attribs++] = ((Rsymbol*)l->tag)->symbolName(); l = l->tail; } attrnames[attribs] = 0; } return attrnames; } void Rinteger::fix_content() { if (len<0 || !data) return; #ifdef SWAPEND int *i = (int*) data; int *j = (int*) (data+len); while (inext; if (ptrnext; if (ptrtype!=XT_LIST) { // if tail is not a list, then something is wrong - just delete it delete(tail); tail=0; } } } } } else if (type == XT_LIST_NOTAG) { /* new style list w/o tags */ Rlist *lt = this; int n = 0; while (ptr < eod) { Rexp *h = new_parsed_Rexp((unsigned int*) ptr, 0); if (!h) break; if (n) lt = lt->tail = new Rlist(type, h, 0, h->next, msg); else lt->head = h; n++; ptr = h->next; } } else if (type == XT_LIST_TAG) { /* new style list with tags */ Rlist *lt = this; int n = 0; while (ptr < eod) { Rexp *h = new_parsed_Rexp((unsigned int*) ptr, 0); #ifdef DEBUG_CXX printf(" LIST_TAG: n=%d, ptr=%p, h=%p\n", n, ptr, h); #endif if (!h) break; ptr = h->next; Rexp *t = new_parsed_Rexp((unsigned int*) ptr, 0); #ifdef DEBUG_CXX printf(" tag=%p (ptr=%p)\n", t, ptr); #endif if (!t) break; if (n) lt = lt->tail = new Rlist(type, h, t, t->next, msg); else { lt->head = h; lt->tag = t; } ptr = t->next; n++; } next = ptr; } #ifdef DEBUG_CXX printf(" end of list %p, ptr=%p\n", this, ptr); #endif } Rvector::~Rvector() { int i=0; while(itype==XT_STR) sc++; i++; } if (sc==0) return 0; strs=(char**)malloc(sizeof(char*)*(sc+1)); i=0; sc=0; while (itype==XT_STR) strs[sc++]=((Rstring*)cont[i])->string(); i++; } strs[sc]=0; return strs; } int Rvector::indexOf(Rexp *exp) { int i=0; while (itype==XT_STR && !strcmp(((Rstring*)cont[i])->string(),str)) return i; i++; } return -1; } int Rstrings::indexOfString(const char *str) { unsigned int i = 0; while (i < nel) { if (cont[i] && !strcmp(cont[i], str)) return i; i++; } return -1; } Rexp* Rvector::byName(const char *name) { /* here we are not using IS_LIST_TYPE_() because XT_LIST_NOTAG is guaranteed to not match */ if (count < 1 || !attr || (attr->type!=XT_LIST && attr->type != XT_LIST_TAG)) return 0; Rexp *e = ((Rlist*) attr)->head; if (((Rlist*) attr)->tag) e = ((Rlist*) attr)->entryByTagName("names"); if (!e || (e->type!=XT_VECTOR && e->type!=XT_ARRAY_STR && e->type!=XT_STR)) return 0; if (e->type == XT_VECTOR) { int pos = ((Rvector*)e)->indexOfString(name); if (pos>-1 && postype == XT_ARRAY_STR) { int pos = ((Rstrings*)e)->indexOfString(name); if (pos>-1 && posstring(),name)) return cont[0]; } return 0; } void Rvector::fix_content() { char *ptr = data; char *eod = data+len; capacity=16; cont=(Rexp**) malloc(sizeof(Rexp*)*capacity); while (ptrnext; else break; count++; } } Rconnection::Rconnection(const char *host, int port) { if (!host) host = "127.0.0.1"; this->host = strdup(host); this->port = port; family = (port==-1) ? AF_LOCAL : AF_INET; s = -1; auth = 0; salt[0] = '.'; salt[1] = '.'; session_key = 0; } Rconnection::Rconnection(Rsession *session) { const char *sHost = session->host(); if (!sHost) sHost="127.0.0.1"; this->host = strdup(sHost); this->port = session->port(); family = AF_INET; s = -1; auth = 0; salt[0]='.'; salt[1]='.'; session_key = (char*) malloc(32); memcpy(session_key, session->key(), 32); } Rconnection::~Rconnection() { if (host) free(host); host = 0; if (s != -1) closesocket(s); s = -1; } int Rconnection::connect() { #ifdef unix struct sockaddr_un sau; #endif SAIN sai; char IDstring[33]; if (family==AF_INET) { memset(&sai,0,sizeof(sai)); build_sin(&sai,host,port); } else { #ifdef unix memset(&sau,0,sizeof(sau)); sau.sun_family=AF_LOCAL; strcpy(sau.sun_path,host); // FIXME: possible overflow! #else return -11; // unsupported #endif } IDstring[32]=0; int i; s=socket(family,SOCK_STREAM,0); if (family==AF_INET) { #ifdef CAN_TCP_NODELAY int opt=1; setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (const char*) &opt, sizeof(opt)); #endif i=::connect(s,(SA*)&sai,sizeof(sai)); } #ifdef unix else i=::connect(s,(SA*)&sau,sizeof(sau)); #endif if (i==-1) { closesocket(s); s=-1; return -1; // connect failed } if (session_key) { // resume a session int n = send(s, session_key, 32, 0); if (n != 32) { closesocket(s); s = -1; return -2; // handshake failed (session key send error) } Rmessage *msg = new Rmessage(); int q = msg->read(s); delete msg; return q; } int n=recv(s,IDstring,32,0); if (n!=32) { closesocket(s); s=-1; return -2; // handshake failed (no IDstring) } if (strncmp(IDstring,myID,4)) { closesocket(s); s=-1; return -3; // invalid IDstring } if (strncmp(IDstring+8,myID+8,4) || strncmp(IDstring+4,myID+4,4)>0) { closesocket(s); s=-1; return -4; // protocol not supported } { int i=12; while (i<32) { if (!strncmp(IDstring+i, "ARuc", 4)) auth|=A_required|A_crypt; if (!strncmp(IDstring+i, "ARpt", 4)) auth|=A_required|A_plain; if (IDstring[i]=='K') { salt[0]=IDstring[i+1]; salt[1]=IDstring[i+2]; } i+=4; } } return 0; } int Rconnection::disconnect() { if (s>-1) { closesocket(s); s=-1; } return 0; } /**--- low-level functions --*/ int Rconnection::request(Rmessage *msg, int cmd, int len, void *par) { struct phdr ph; if (s==-1) return -5; // not connected memset(&ph,0,sizeof(ph)); ph.len=itop(len); ph.cmd=itop(cmd); if (send(s,(char*)&ph,sizeof(ph),0)!=sizeof(ph)) { closesocket(s); s=-1; return -9; } if (len>0 && send(s,(char*)par,len,0)!=len) { closesocket(s); s=-1; return -9; } return msg->read(s); } int Rconnection::request(Rmessage *targetMsg, Rmessage *contents) { if (s==-1) return -5; // not connected if (contents->send(s)) { closesocket(s); s=-1; return -9; // send error } return targetMsg->read(s); } /** --- high-level functions -- */ int Rconnection::shutdown(const char *key) { Rmessage *msg = new Rmessage(); Rmessage *cm = key?new Rmessage(CMD_shutdown, key):new Rmessage(CMD_shutdown); int res = request(msg, cm); delete cm; delete msg; return res; } int Rconnection::assign(const char *symbol, Rexp *exp) { Rmessage *msg=new Rmessage(); Rmessage *cm=new Rmessage(CMD_setSEXP); int tl=strlen(symbol)+1; if (tl&3) tl=(tl+4)&0xfffc; Rsize_t xl=exp->storageSize(); Rsize_t hl=4+tl+4; if (xl>0x7fffff) hl+=4; cm->data=(char*) malloc(hl+xl); cm->head.len=cm->len=hl+xl; ((unsigned int*)cm->data)[0]=SET_PAR(DT_STRING, tl); ((unsigned int*)cm->data)[0]=itop(((unsigned int*)cm->data)[0]); strcpy(cm->data+4, symbol); ((unsigned int*)(cm->data+4+tl))[0]=SET_PAR((Rsize_t) ((xl>0x7fffff)?(DT_SEXP|DT_LARGE):DT_SEXP), (Rsize_t) xl); ((unsigned int*)(cm->data+4+tl))[0]=itop(((unsigned int*)(cm->data+4+tl))[0]); if (xl>0x7fffff) ((unsigned int*)(cm->data+4+tl))[1]=itop(xl>>24); exp->store(cm->data+hl); int res=request(msg,cm); delete (cm); if (res) { delete(msg); return res; } if (!res) res = CMD_STAT(msg->command()); delete(msg); return res; } int Rconnection::voidEval(const char *cmd) { int status=0; eval(cmd, &status, 1); return status; } Rexp *Rconnection::eval(const char *cmd, int *status, int opt) { /* opt = 1 -> void eval */ Rmessage *msg=new Rmessage(); Rmessage *cmdMessage=new Rmessage((opt&1)?CMD_voidEval:CMD_eval, cmd); int res=request(msg,cmdMessage); delete (cmdMessage); if (opt&1 && !res) { if (status) *status=0; // we should put response code here delete(msg); return 0; } if ((opt & 1) == 0 && !res && (msg->pars!=1 || (ptoi(msg->par[0][0])&0x3f)!=DT_SEXP)) { delete(msg); if (status) *status=-12; // returned object is not SEXP return 0; } if (res) { delete(msg); if (status) *status=res; return 0; } if (status) *status=0; return new_parsed_Rexp_from_Msg(msg); } /** detached eval (aka detached void eval) initiates eval and detaches the session. * @param cmd command to evaluate. If NULL equivalent to simple detach() * @param status optional status to be reported (zero on success) * @return object describintg he session. * Note that the caller is responsible for freeing the object if not needed. */ Rsession *Rconnection::detachedEval(const char *cmd, int *status) { Rmessage *msg = new Rmessage(); Rmessage *cmdMessage = cmd ? new Rmessage(CMD_detachedVoidEval, cmd) : new Rmessage(CMD_detachSession); int res = request(msg, cmdMessage); delete cmdMessage; if (res) { if (status) *status = res; delete msg; return 0; } if (msg->pars != 2 || PAR_TYPE(ptoi(msg->par[0][0])) != DT_INT || PAR_LEN(ptoi(msg->par[0][0])) != sizeof(int) || PAR_TYPE(ptoi(msg->par[1][0])) != DT_BYTESTREAM || PAR_LEN(ptoi(msg->par[1][0])) != 32) { // invalid contents if (status) *status = -12; delete msg; return 0; } Rsession *session = new Rsession(host, ptoi(msg->par[0][1]), (const char*) (msg->par[1] + 1)); delete msg; if (status) *status=0; return session; } Rsession *Rconnection::detach(int *status) { return detachedEval(0, status); } int Rconnection::openFile(const char *fn) { Rmessage *msg=new Rmessage(); Rmessage *cmdMessage=new Rmessage(CMD_openFile, fn); int res=request(msg,cmdMessage); delete (cmdMessage); if (!res) res=CMD_STAT(msg->command()); delete (msg); return res; } int Rconnection::createFile(const char *fn) { Rmessage *msg=new Rmessage(); Rmessage *cmdMessage=new Rmessage(CMD_createFile, fn); int res=request(msg,cmdMessage); delete (cmdMessage); if (!res) res=CMD_STAT(msg->command()); delete (msg); return res; } int Rconnection::readFile(char *buf, unsigned int len) { Rmessage *msg=new Rmessage(); Rmessage *cmdMessage=new Rmessage(CMD_readFile, len); int res=request(msg,cmdMessage); delete(cmdMessage); if (!res) { // FIXME: Rserve up to 0.4-0 actually sends buggy response - it ommits DT_BYTESTREAM header! if (msg->len > len) { // we're in trouble here - techincally we should not get this delete(msg); return CERR_malformed_packet; } if (msg->len > 0) memcpy(buf, msg->data, msg->len); int rl = msg->len; delete(msg); return rl; } delete(msg); return CERR_io_error; } int Rconnection::writeFile(const char *buf, unsigned int len) { Rmessage *msg=new Rmessage(); Rmessage *cmdMessage=new Rmessage(CMD_writeFile, buf, len); int res=request(msg,cmdMessage); delete(cmdMessage); if (!res && msg->command()==RESP_OK) { delete(msg); return 0; } delete(msg); // FIXME: this is not really true ... return (res==0)?CERR_io_error:res; } int Rconnection::closeFile() { Rmessage *msg=new Rmessage(); Rmessage *cmdMessage=new Rmessage(CMD_closeFile); int res=request(msg,cmdMessage); delete(cmdMessage); if (!res && msg->command()==RESP_OK) { delete(msg); return 0; } delete(msg); // FIXME: this is not really true ... return (res==0)?CERR_io_error:res; } int Rconnection::removeFile(const char *fn) { Rmessage *msg=new Rmessage(); Rmessage *cmdMessage=new Rmessage(CMD_removeFile, fn); int res=request(msg,cmdMessage); delete (cmdMessage); if (!res) res=CMD_STAT(msg->command()); delete (msg); return res; } int Rconnection::login(const char *user, const char *pwd) { char *authbuf, *c; if (!(auth&A_required)) return 0; authbuf=(char*) malloc(strlen(user)+strlen(pwd)+22); strcpy(authbuf, user); c=authbuf+strlen(user); *c='\n'; c++; strcpy(c,pwd); #ifdef unix if (auth&A_crypt) strcpy(c,crypt(pwd,salt)); #else if (!(auth&A_plain)) { free(authbuf); return CERR_auth_unsupported; } #endif Rmessage *msg=new Rmessage(); Rmessage *cmdMessage=new Rmessage(CMD_login, authbuf); int res=request(msg,cmdMessage); delete (cmdMessage); if (!res) res=CMD_STAT(msg->command()); delete (msg); free(authbuf); return res; } #ifdef CMD_ctrl /* server control methods */ int serverEval(const char *cmd); int serverSource(const char *fn); int serverShutdown(); int Rconnection::serverEval(const char *cmd) { Rmessage *msg = new Rmessage(); /* result message */ Rmessage *cmdMessage = new Rmessage(CMD_ctrlEval, cmd); /* request message */ int res = request(msg, cmdMessage); delete (cmdMessage); if (!res) res = CMD_STAT(msg->command()); delete (msg); return res; } int Rconnection::serverSource(const char *fn) { Rmessage *msg = new Rmessage(); /* result message */ Rmessage *cmdMessage = new Rmessage(CMD_ctrlSource, fn); /* request message */ int res = request(msg, cmdMessage); delete (cmdMessage); if (!res) res = CMD_STAT(msg->command()); delete (msg); return res; } int Rconnection::serverShutdown() { Rmessage *msg = new Rmessage(); /* result message */ Rmessage *cmdMessage = new Rmessage(CMD_ctrlShutdown); /* request message */ int res = request(msg, cmdMessage); delete (cmdMessage); if (!res) res = CMD_STAT(msg->command()); delete (msg); return res; } #endif Rserve/clients/README.txt0000644000176000001440000000110012205226215014674 0ustar ripleyusersThis directory contains various Rserve clients: cxx - minimal C++ client java - Java client based on the REngine API. This is the actively developed Java client as it is more flexible and consistent than the older JRclient. It supports multiple back-ends such as Rserve or JRI. php - minimal PHP client and example code that can be used to run FastRWeb via PHP instead of CGI NOTE: a more complete PHP client written by Clement Turbelin based on this minimal version is available from http://code.google.com/p/rserve-php Rserve/clients/php/0000755000176000001440000000000012205226215013775 5ustar ripleyusersRserve/clients/php/simple.php0000644000176000001440000002675412205226215016015 0ustar ripleyusers>= 8; $r .= chr($i & 255); $i >>=8; $r .= chr($i & 255); $i >>=8; $r .= chr($i & 255); return $r; } function mkint24($i) { $r = chr($i & 255); $i >>= 8; $r .= chr($i & 255); $i >>=8; $r .= chr($i & 255); return $r; } function flt64($buf, $o=0) { $ss = substr($buf, $o, 8); if ($machine_is_bigendian) for ($k = 0; $k < 7; $k++) $ss[7 - $k] = $buf[$o + $k]; $r = unpack("d", substr($buf, $o, 8)); return $r[1]; } function mkp_str($cmd, $string) { $n = strlen($string) + 1; $string .= chr(0); while (($n & 3) != 0) { $string .= chr(1); $n++; } return mkint32($cmd) . mkint32($n + 4) . mkint32(0) . mkint32(0) . chr(4) . mkint24($n) . $string; } function get_rsp($socket) { $n = socket_recv($socket, $buf, 16, 0); if ($n != 16) return FALSE; $len = int32($buf, 4); $ltg = $len; while ($ltg > 0) { $n = socket_recv($socket, $b2, $ltg, 0); if ($n > 0) { $buf .= $b2; unset($b2); $ltg -= $n; } else break; } return $buf; } // parse SEXP results -- limited implementation for now (large packets and some data types are not supported) function parse_SEXP($buf, &$offset, &$attr = NULL) { $r = $buf; $i = $offset; // some simple parsing - just skip attributes and assume short responses $ra = int8($r, $i); $rl = int24($r, $i + 1); $i += 4; $offset = $eoa = $i + $rl; // echo "[data type ".($ra & 63).", length ".$rl." with payload from ".$i." to ".$eoa."]
\n"; if (($ra & 64) == 64) { echo "sorry, long packets are not supported (yet)."; return FALSE; } if ($ra > 127) { $ra &= 127; $al = int24($r, $i + 1); $attr = parse_SEXP($buf, $i); $i += $al + 4; } if ($ra == 0) return NULL; if ($ra == 16) { // generic vector $a = array(); while ($i < $eoa) $a[] = parse_SEXP($buf, /* & */ $i); // if the 'names' attribute is set, convert the plain array into a map if (isset($attr['names'])) { $names = $attr['names']; $na = array(); $n = count($a); for ($k = 0; $k < $n; $k++) $na[$names[$k]] = $a[$k]; return $na; } return $a; } if ($ra == 19) { // symbol $oi = $i; while ($i < $eoa && ord($r[$i]) != 0) $i++; return substr($buf, $oi, $i - $oi); } if ($ra == 20 || $ra == 22) { // pairlist w/o tags $a = array(); while ($i < $eoa) $a[] = parse_SEXP($buf, /* & */ $i); return $a; } if ($ra == 21 || $ra == 23) { // pairlist with tags $a = array(); while ($i < $eoa) { $val = parse_SEXP($buf, /* & */ $i); $tag = parse_SEXP($buf, /* & */ $i); $a[$tag] = $val; } return $a; } if ($ra == 32) { // integer array $a = array(); while ($i < $eoa) { $a[] = int32($r, $i); $i += 4; } if (count($a) == 1) return $a[0]; return $a; } if ($ra == 33) { // double array $a = array(); while ($i < $eoa) { $a[] = flt64($r, $i); $i += 8; } if (count($a) == 1) return $a[0]; return $a; } if ($ra == 34) { // string array $a = array(); $oi = $i; while ($i < $eoa) { if (ord($r[$i]) == 0) { $a[] = substr($r, $oi, $i - $oi); $oi = $i + 1; } $i++; } if (count($a) == 1) return $a[0]; return $a; } if ($ra == 36) { // boolean vector $n = int32($r, $i); $i += 4; $k = 0; $a = array(); while ($k < $n) { $v = int8($r, $i++); $a[$k++] = ($v == 1) ? TRUE : (($v == 0) ? FALSE : NULL); } if ($n == 1) return $a[0]; return $a; } if ($ra == 37) { // raw vector $len = int32($r, $i); $i += 4; return substr($r, $i, $len); } if ($ra == 48) { // unimplemented type in Rserve $uit = int32($r, $i); // echo "Note: result contains type #$uit unsupported by Rserve.
"; return NULL; } echo "Warning: type ".$ra." is currently not implemented in the PHP client."; return FALSE; } //------------ Rserve API functions // if port is 0 then host is interpreted as unix socket, otherwise host is the host to connect to (default is local) and port is the TCP port number (6311 is the default) function Rserve_connect($host="127.0.0.1", $port=6311) { if ($port == 0) $ok = (($socket = socket_create(AF_UNIX, SOCK_STREAM, 0)) and (socket_connect($socket, $host))); else $ok = (($socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) and (socket_connect($socket, $host, $port))); if ($ok) { $n = socket_recv($socket, $buf, 32, 0); if ($n < 32 || strncmp($buf, "Rsrv", 4) != 0) { echo "Invalid response from server."; return FALSE; } $rv = substr($buf, 4, 4); if (strcmp($rv, "0103") != 0) { echo "Unsupported protocol version."; return FALSE; } } else { echo "Unable to connect
".socket_strerror(socket_last_error())."
"; return FALSE; } return $socket; } function Rserve_eval($socket, $command, $attr = NULL) { $pkt = mkp_str(3, $command); socket_send($socket, $pkt, strlen($pkt), 0); $r = get_rsp($socket); $res = int32($r); $sc = ($res >> 24) & 127; $rr = $res & 255; if ($rr != 1) { echo "eval failed with error code " . $sc; return FALSE; } if (int8($r, 16) != 10) { echo "invalid response (expecting SEXP)"; return FALSE; } $i = 20; return parse_SEXP($r, $i, /* & */ $attr); } function Rserve_assign_raw($socket, $name, $what) { // CMD_setSEXP $bl = strlen($what); if ($bl > 16777088) trigger_error("Body in Rserve_assign_raw is too big ($bl bytes), only small QAP packets are currently supported."); $n = strlen($name) + 1; $name .= chr(0); while (($n & 3) != 0) { $name .= chr(1); $n++; } // [CMD_setSEXP][DT_STRING(name)][DT_SEXP([XT_RAW, (i32) len, what])] = payload + 4 + 4 + 8 $pkt = mkint32(0x20) /* CMD_setSXP */ . mkint32($n + $bl + 16) . mkint32(0) . mkint32(0) . chr(4) . mkint24($n) . $name . chr(10) /* SEXP */ . mkint24($bl + 8). chr(37) /* XT_RAW */ . mkint24($bl + 4) . mkint32($bl) . $what; socket_send($socket, $pkt, strlen($pkt), 0); $r = get_rsp($socket); $res = int32($r); $sc = ($res >> 24) & 127; $rr = $res & 255; if ($rr != 1) { echo "eval failed with error code " . $sc; return FALSE; } return TRUE; } function Rserve_close($socket) { return socket_close($socket); } //========== FastRWeb - compatible requests - sample use of the client to behave like Rcgi in FastRWeb $root = "/var/FastRWeb"; // set to the root of your FastRWeb installation - must be absolute function process_FastRWeb($host, $port) { global $root; // $req = array_merge($_GET, $_POST); $path = $_SERVER['PATH_INFO']; if (!isset($path)) { echo "No path specified."; return FALSE; } $path = str_replace("..", "_", $path); // sanitize paths // We cannot check for the presence of the script, because FastRWeb now // supports PATH_INFO *after* the script name. // If you don't care but want fast error, uncomment the followign two lines. // $script = "$root/web.R$path.R"; // if (!file_exists($script)) { echo "Script [$script] $path.R does not exist."; return FALSE; } $raddr = $_SERVER['REMOTE_ADDR']; $method = $_SERVER['REQUEST_METHOD']; $ct = $_SERVER['CONTENT_TYPE']; $cl = $_SERVER['CONTENT_LENGTH'] + 0; // escape as needed $uri = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $_SERVER['REQUEST_URI'])); // NOTE: the C client URI-encodes control characters and quotes -- maybe a good idea? $cook = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $_SERVER['HTTP_COOKIE'])); $qs = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $_SERVER['QUERY_STRING'])); $path = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $path)); $s = Rserve_connect($host, $port); $bodyval = "NULL"; if ($ct == "" && $cl == 0) $cl = -1; else { $body = file_get_contents("php://input"); Rserve_assign_raw($s, "body", $body); $bodyval = ".GlobalEnv\$body"; } $r = Rserve_eval($s, "{ library(FastRWeb); request<-list(uri=\"$uri\", method=\"$method\", c.type=\"$ct\", c.length=$cl, body=$bodyval, client.ip=\"$raddr\", query.string=\"$qs\", raw.cookies=\"$cook\"); FastRWeb:::.run(request,\"$root\",\"$path\") }"); Rserve_close($s); if (!is_array($r)) { // this ususally means that an erro rocurred since the returned value is jsut a string ob_end_flush(); echo $r; exit(0); } if (isset($r[2])) header("Content-type: $r[2]"); if (($r[0] == "file") or ($r[0] == "tmpfile")) { error_log("INFO: $r[0]: '$r[1]'"); $contents = file_get_contents($root."/tmp/".$r[1]); ob_end_clean(); echo $contents; if ($r[0] == "tmpfile") unlink($r[0]); exit(0); } if ($r[0] == "html") { ob_end_clean(); echo (is_array($r[1]) ? implode("\n", $r[1]) : $r[1]); exit(0); } print_r($r); ob_end_flush(); exit(0); } //--- the following lines serve as FastRWeb handler (see FastRWeb package and IASC paper) // NOTE: this implementation is for FastRWeb 1.1 and higher! // If you changed the socket setting or use remote server change the parameters (host, port) below process_FastRWeb("$root/socket", 0); // default FastRWeb setting ob_end_flush(); /*========== user code -- example and test -- comment out the above and uncomment this for testing $s = Rserve_connect(); if ($s == FALSE) { echo "Connect FAILED"; } else { print_r (Rserve_eval($s, "list(str=R.version.string,foo=1:10,bar=1:5/2,logic=c(TRUE,FALSE,NA))")); echo "

"; print_r (Rserve_eval($s, "{x=rnorm(10); y=x+rnorm(10)/2; lm(y~x)}")); Rserve_close($s); } ob_end_flush(); */ ?> Rserve/version0000755000176000001440000000024712205226215013163 0ustar ripleyusers#!/bin/sh VER=`sed -n 's/.*Rserve v\([0-9.\-]*\).*/\1/p' src/Rsrv.h|head -n 1` if test "x$1" = "x-f"; then echo "Rserve_${VER}.tar.gz" else echo "${VER}" fi Rserve/NEWS0000644000176000001440000010347512205226215012256 0ustar ripleyusers NEWS/Changelog for Rserve --------------------------- 1.7-3 2013-08-21 o the handling of server configuration modes has been inconsistent for some combinations (mostly affected were combinations involving WebSockets upgrade and OC mode on HTTP/WS servers). Also the websockets.qap.oc configuration option has been misspelled. o HTTPS->WSS upgrade is now supported o mkdist -i installs the built package, use -c for check o Windows compatibility has been restored thanks to David Champagne from Revolution Analytics 1.7-2 2013-08-12 o when uid/gid is changed, create a new tempdir() and set its permissions as well as the wokring directory's owner to match. o bugfix: if the first command is not any of the eval family the Rserve may respond with an additional, spurious error response o deamonized server would record incorrect pid when pid.file is used (i#5). The pid is now removed on clean sutdown. o added support for keep.alive configuration option - it is global to all servers and if enabled the client sockets are instructed to keep the connection alive by periodic messages. 1.7-1 2013-07-02 o remove a spurious character that prevented compilation on Suns o add OPENSSL_INCLUDES precious variable that can be used to point to non-standard location of OpenSSL headers o check the usability of OpenSSL headers before enabling TLS support o added the choice of GPLv2 or GPLv2 with OpenSSL linking exception 1.7-0 *** ---- HEADLINE NEWS ---- *** new protocols: HTTP, HTTPS, WebSockets and TLS/QAP *** added protocol switching (from QAP to TLS/QAP) via CMD_switch *** The R client was moved to RSclient package *** New in-session server support with run.Rserve() *** Out-of-band messages via self.oobSend() *** user-based uid/gid switch, MD5/SHA1 stored passwords *** preliminary IPv6 support; RSA secure authentication *** .Rserve.done global env hook for optiopnal cleanup *** auth.function setting to allow custom authentication *** Object-capability mode for hardened, secure services *** ---- END - see below for details ---- o This is the first release in the new 1.x Rserve series. Many of the Rserve internals have been re-written or cleaned up. The original protocol remains the same (so all clients that worked with Rserve 0.6 will continue to work), but the suite of available protocols has been extended (see below). o added support for multiple protocols in Rserve: ** QAP ** this is the original Rserve protocol used in Rserve 0.x series. It works over TCP/IP and unix sockets. It is enabled by default and can be disabled using "qap disable" configuration directive. ** HTTP ** this is very similar to the built-in R http server except that on unix it forks on connection so it allows parallel separate, persistent connections. It requires a worker function .http.request to be defined in the session which will handle incoming requests. This allows the use of facilities like FastRWeb without an external webserver. This protocol is disabled by default and can be enabled by setting "http.port" configuration directive to the desired port to listen to. (Also see TLS support below for https server). The http.raw.body configuration option (default is false which results in the same behavior as Rhttpd) can be used to force passing body in raw form to the handler (useful for the FastRWeb handler which does its own parsing). ** WebSockets ** this protocol is used by HTML5 web browsers for direct access to R with a persistent connection. This allows implementation of websites that have a dedicated R session (and could be used as an R console). There are two subprotocols supported by Rserve: -- WebSocket(*, "QAP") -- this is a tunnel for the original QAP protocol through WebSockets. It requires a browser capable of binary WebSockets protocol (version 01 or higher). It allows very efficient data transfer, typically by loading ArrayBuffers directly into GPU or CPU. It is disabled by default and can be enabled using "websockets.qap enable" configuration directive. (If no subprotocol is specified, QAP is assumed) -- WebSocket(*, "text") -- this is a very simplistic protocol using plain text frames to send input to R and output from R directly as text. It acts essentially as an R console. This protocol works with any WebSockets implementation including version hybi-00 and hixie-75/76 It is disabled by default and can be enabled using "websockets.text enable" configuration directive. NOTE: The textual WebSockets protocol does NOT provide any authentication mechanism, so use with extreme care as you are essentially giving any user with a web browser access to R and thus to the shell. In addition to enabling each or both subprotocols, the port on which the WebSockets server should listen must be specified in the configuration using "websockets.port" directive, for example "websockets.port 8080". Alternatively, the HTTP server can be enabled to allow connection upgrade to WebSockets on the same port with "http.upgrade.websockets enable" NOTE: remember that the default in Rserve is to disallow remote connections, so you may need to use "remote enable" in order to use WebSockets or HTTP in practice, since the point is to serve remote machines. Typically, if both QAP and either HTTP or WebSockets are used, it is recommended to use QAP on a local unix socket for better access control. o Rserve now supports SSL/TLS connections on QAP, HTTP and WS protocols. The TLS key/CA entries are common for all protocols. The relevant new configuration directives are: tls.key tls.cert tls.ca SSL/TLS can be used in several ways: with separate port for TLS connections or by switching protocol form a regular QAP connection using CMD_switch with "TLS" as argument. The latter can be enabled using switch.qap.tls enable Enabled switching is advertized by Rserve with the presence of a "TLS" entry in the ID string. Keys and other TLS entries must be initialized in order for TLS to be enabled. Dedicated TLS servers can be enabled by specifying the port for the corresponding protocol: qap.tls.port - for Rserve/QAP http.tls.port - for HTTPS websockets.tls.port - for WebSockets (there are synonyms "https.port" for "http.tls.port" and "tls.port" for "qap.tls.port", however, the *.tls.port versions are preferred for clarity) The use of TLS protocols is encouraged where sensitive data is transmitted or when requiring secure authentication. For QAP protocol, using TCL/QAP with SHA1 passwords (also new, see below) is the currently recommended way where authorization is required. The only drawback is increased CPU utilization during transfers casued by the encryption and the fact that TLS-enabled clients must be used. See also RSA secure authentication (CMD_keyReq + CMD_secLogin) for a different method if only the authentication step is to be encrypted. When enabling TLS tls.key and tls.cert are mandatory, tls.ca is optional to establish CA chain of trust (whether this is needed depends on the client and the certificate). To generate a key and self-signed certificate, you can use something like openssl genrsa -out server.key 2048 openssl req -new -key server.key -out server.csr openssl x509 -req -days 365 -in server.csr \ -signkey server.key -out server.crt NOTE: TLS services are started **in addition** to any other servers, i.e., if you want to enable TLS/QAP only, you have to set tls.qap.port but also add "qap disable" to disable the plain Rserve access. o QAP servers (classic Rserve QAP, QAP/TLS and WebSocket/QAP) support object-capability (OC) mode in which all Rserve commands are disabled except for CMD_OCcall. All messages including the initial handshake are always QAP and the initial message defines capabilities (here opaque references to closures) that can be called. This mode can be enabled using qap.oc enable ## for Rserve QAP and QAP/TLS websockets.qap.oc enable ## for WebSockets/QAP In this mode the configuration *must* define a function oc.init (typically using eval or source configuration directives) which has to supply OC references that can be used in calls. If the evaluation of oc.init() fails, the connection is closed immediately. The use of invalid OC references or any other commands other than CMD_OCcall results in immediate connection termination. This allows creation of hardened, secure services that can disallow arbitrary code execution. NOTE: this mode is inherenty incompatible with all classic Rserve clients. The first four bytes of the initial packet are "RsOC" instead of "Rsrv" o Rserve can now be started from within an existing R session using run.Rserve() command. This allows the user to prepare a session "by hand", run Rserve from within that session and go back to the session (by shutting down the server or sending an interrupt). This allows the use of Rserve even without the presence of libR. o Rserve now supports out-of-band (OOB) messages. Those can be sent using the self.oobSend() [one-way] and self.oobMessage() [roundtrip] functions from within code that is evaluated in Rserve child instances. OOB messages are not used by Rserve itself but offer asynchronous notification to clients that support it (one typical use are WS-QAP1 tunnels to web browsers that allow status updates as R code is evaluated). o Rserve accepts additional command line arguments: --RS-source (same as "source " in cfg file) --RS-enable-remote (same as "remote enable" in cfg file) --RS-enable-control (same as "control enable" in cfg file) o The Rserve package no longer includes the R client. It has been moved to a separate package "RSclient" so that it can be used on machines separate from the server. o There was a bug in QAP storage estimation affecting pairlists, possibly resulting in buffer overflows. This should be fixed and an error message will be printed when such overflows are detected in the future (which hopefully won't happen). o Bugfix: command line parsing would skip over some arguments o Passwords file can contain MD5 or SHA1 hash of a password instead of the plaintext password for non-crypt authentication. In that case the hash must be lowercase hex representation with preceding $ sign, so for example user "foo" with password "bar" would have an entry foo $62cdb7020ff920e5aa642c3d4066950dd1f01f4d You can use echo -n 'password' | openssl sha1 to obtain the SHA1 hash of a password (openssl md5 for MD5 hash - MD5 is probably more common but less secure than SHA1). This feature makes sure that passwords are not stored in plain text and thus are safe from local attacks. o Rserve now has the ability to change uid/gid according to the user that has been authenticated. The following settings concern this feature (unix-only): auto.uid {enable|disable} [disable] auto.gid {enable}disable} [disable] default.uid [none] default.gid [none] The auto.uid/gid directives enable setuid/setgid based on user's uid/gid. In case no uid/gid is specified with the username, the default.uid/gid settings will be used. If there is no uid/gid in the username and no defaults are specified, the user's authentication will fail. User's uid/gid can be specified in the passwords file by appending /uid,gid to the username. If gid is not specified, uid will be used for both uid and gid. So for example user "foo" (from the above MD5 example) with uid=501 would have an entry on the passwords file: foo/501 $37b51d194a7513e45b56f6524f2d51f2 For this to work, Rserve must be started as root. However, with auto.uid enabled it is safe to do so since Rserve will prevent any R access until authenticated. You should, however, use a client capable of secure RSA authentication or use secure connection such as QAP/TLS as to not send password in cleartext over the wire. o Rserve can now be run in a mode where each connection has a different uid and/or gid such that separate client instances are isolated. This allows more restricted setup in cases where instances may not be trusted and need to be sandboxed. The following configuration directives are associated with this functionality: random.uid {enable|disable} [disable] random.gui {enable|disable} [disable] random.uid.range {..} [32768..65540] If random.uid is enabled and random.gid disable then only the uid of the process is changed. If both are enabled then the gid is set to match the value of the uid. random.gid cannot be enabled without random.uid. To support sandboxing, the permissions on the working directory can be specified using workdir.mode o If any kind of client-process uid switching is enabled in the configuration, the permissions on the working directory will match the uid of the process. Also the working directories are now named by the process ID to facilitate cleanup. o Rserve now supports secure authentication even outside of SSL/TLS. There are two new commands that can be used by the client: CMD_keyReq - requests an authentication key from the server that will be used to perform a secure login. The kind of the requested key is specified as a parameter. Currently, only "rsa-authkey" is supported which returns server authentication key (authkey) and a RSA public key which must be used to encode the authkey and the authentication information (see below). The RSA key can be compared on the client side to ensure the authenticity of the server. CMD_secLogin - secure login. It consists of an encrypted data stream that will authenticate the user. In the case of the "rsa-authkey" method, the stream consists of the authkey and the login + password, all of which must be encrypted using server's RSA key. The RSA key on the server (Rserve) side is specified using rsa.key configuration file directive. The file is expected to be in PEM format. You can generate such file, e.g., with: openssl genrsa -out server.key 4096 where 4096 is the key size in bits. A public key can be extracted from the private key using openssl rsa -pubout -in server.key -out server_pub.key The clients can pre-share the public key by other means to compare it to the key received from the server as to verify its authenticity. This will prevent them from sending the authentication information to rogue servers. NOTE: if the rsa.key directive is missing, Rserve will generate a key on the fly when asked for RSA authentication - although this allows encrypted transmission and thus is safe from sniffing, it is not safe from man-in-the-middle attacks where a rogue server intercepts the request and sends its own public key. Therefore the use of the rsa.key directive is highly recommended. The RSA authentication enables the client to a) check the authenticity of the server (by comparing the RSA public key) and b) send authentication information encrypted. This method is highly recommended in cases where a full TLS/SSL encryption of the entire connection would be too expensive (i.e. in cases where the data is large and the security of the transported data is not crucial). o Rserve has a preliminary IPv6 support. Rserve must be installed with --enable-ipv6 configure flag to enable it in the Rserve build. In order to start all servers on IPv6 add ipv6 enable to the configuration file. The option is global, i.e. once enabled it applies to all servers that support it. Note that not all features work with IPv6 yet - detaching sessions (they will use IPv4 for re-attach) and remote client filtering only work with IPv4 at this point. o Rserve now binds only to the loopback interface in "remote disable" mode. This is safer and prevents remote DoS attacks. Previously, Rserve would bind on all interfaces and check the peer IP address. If desired, you can replicate the old behavior by adding remote enable allow 127.0.0.1 to the configuration (if you don't know the difference then you don't need this -- if you actually need this, then you probably want to add more "allow" entries for the machine's other interfaces as well). o If a function .Rserve.done() is defined in the global environment, it will be run after a clean connection shutdown. This allows custom code to be run when a client connection is closed. o If a function .Rserve.served() is defined in the global environment of the server, it will be run after a client connection has been served. For forked servers this is just after the fork(), for co-operative servers this is after the client conenction has been closed. It is guaranteed that no other client is served before the call so it can be used to manage resources that are unsafe to share with forked processes (e.g. sockets etc.). o The server and client process can be tagged with extra information in argv[0] so it is possible to distinguish the server and children. This behavior can be enabled using tag.argv enable Note, however, that this not always possible and it will have impact on programs that use argv[0] such as killall. o Added configuration option pid.file and command-line option --RS-pidfile which instructs Rserve to write its process id (pid) into that file at startup. o Added configuration directives http.user, https.user and websockets.user which take a username and perform setuid/setgid/initgroups immediately after forking. This minimizes the amount of code that is run with elevated privileges in cases where user switching is desired. o Added configuration directive daemon disable which can be used to prevent Rserve from daemonizing. It has effect only in builds of Rserve that support daemonization. Note that -DNODAEMON build flag disables daemonization entirely and can be used in any Rserve version. o All commands based on eval now also accept DT_SEXP in addition to DT_STRING. In such case the parse step is skipped and the expression is evaluated directly. The intended use of this functionality is to evaluate language constructs and thus allow calls with both reference and inlined arguments. o QAP decoding is slightly more efficient and avoids protection cascades. QAP_decode() has now only one argument and it is guaranteed to not increase the protection stack when returning (which implies that it is the responsibility of the caller to protect the result if needed). o Both QAP encoding and decoding now use native copy operations on little-endian machines which can increase the speed considerably when the compiler cannot do this optimization on its own (most commoly used compilers don't). o Assigning logical NAs now uses the proper NA_LOGICAL value that is also recognized by R. (PR#276) o Forked child processes will now close all server sockets so that any server can be restarted without closing existing children. o Signal handling has been streamlined: the server process captures HUP, TERM and INT which will lead to clean shutdown. Child processes restore signal handlers back to R so that regular R signal handling rules apply. Note that interrupt during eval will result in RESP_ERR with code 127 even if try() is used. --- In order to support new ideas a major re-organization of Rserve --- --- has been started - almost 10 years after the first release. --- --- It is time to look ahead again with a new major version. The --- --- protocol will remain compatible so 1.x series can be used to --- --- replace the previous 0.x series --- 0.6-8 2012-02-20 o added RSserverEval() and RSserverSource() control commands in the R client as well as ctrl parameter to RSshutdown(). o added new facility that allows R scripts running in Rserve to issue control commands if allowed. This feature must be enabled in the Rserve configuration file using r-control enable This will make self.ctrlEval() and self.ctrlSource() functions available to code that is running within the Rserve instance. It is also possible to use this feature without explicitly loading the Rserve package via .Call("Rserve_ctrlEval", paste(text, collapse='\n')) .Call("Rserve_ctrlSource", as.character(file)) although this may change in the future. 0.6-7 2012-01-17 o fix processing of login information **IMPORTANT**: this fixes a serious security hole in the remote login mechanism! If you rely on authentication, please make sure you update your Rserve immediately! (Thanks to Daniel Faber for reporting) o add a namespace to make R 2.14+ happy o work around broken readBin() in R 2.14.0 that errors on unsigned integers (affects R client only) 0.6-6 2011-12-10 o fix a bug that can cause heap corruption due to incorrect addressing in padding of symbols. Unless extremely long symbol names are used it is unlikely to have a real effect in practice, but in theory it could be used to zero targetted parts of the heap. Thanks to Ralph Heinkel for reporting. o fix Rserve() call on Windows with quote=FALSE and more than one argument. o clarify that sisocks.h is under LGPL 2.1 as well as the other headers used by clients. o add support for plain S4 objects (S4SEXP) in assignments (Note: derived S4 objects - those using other native SEXP type as a base - cannot be supported properly, becasue there is no way to distinguish them from S3 objects!) o Unsupported types in CMD_assign will no longer crash R. The resulting object is always NULL and an error is printed on the R side. 0.6-5 2011-06-21 o use new install.libs.R custom installation script in R 2.13.1 to install binaries o install clients by default on Windows as well o multi-arch binaries are no longer installed with the arch suffix in the package root. The canonical place is libs$(R_ARCH) instead. For now Rserve.exe/Rserve_d.exe are still installed in the root but they will be also removed in the future as they are not multi-arch safe. 0.6-4 2011-05-19 o make all buffers capable of using 64-bit sizes. This means that clients can use more that 4Gb of data on 64-bit platforms when communicating with Rserve, provided the buffer limits are either disabled or configured to be high enough. Note that this does not change the limitations in R with respect to vector lengths so you still can only use up to 2^31-1 elements. o bug fix: contrary to the documentation scalar logicals were sent in the old XT_BOOL format instead of XT_ARRAY_BOOL o work around several issues introduced in R 2.13.0 for Windows Rserve() now also allows arguments to be passed to system() for more fine-grained control of the environment, mostly to work around bugs and incompatible changes to system() on Windows in R 2.13.0 (commonly used options are invisible=FALSE to get back to a more reasonable pre-2.13.0 behavior and wait=TRUE if using R 2.13.0 that has broken wait=FALSE support). o In Rserve() startup wrapper, args are now quoted automatically if quote=TRUE is set. For backward compatilility args are not quoted by default if they consist of just one string. 0.6-3 2011-01-17 o bug fix: the child process could get stuck in the server loop after some abnormal return from the child connection code Thanks to David Richardson for reporting. o set R_ARCH automatically on Windows if a multi-arch R is detected (such as CRAN binaries since R 2.12.0) o add R_ARCH support in Rserve() on Windows to locate the proper binary o bug fix: C++ client did not handle new-style lists (introduced in Rserve 0.5) properly. Thanks to Carl Martin Grewe for reporting. 0.6-2 2010-09-02 o add support for NAs in character vectors by using a special "\xff" string. Any string beginning with '\xff' is prepended by additional '\xff' to remove ambiuguity and clients should remove leading '\xff' accordingly. (Note that UTF-8 encoded strings never contain '\xff' so in most uses it never occurs). The Java client has been updated accordingly and represents NA strings with null. o add a new config file option "interactive" that allows to run Rserve in interactive or non-interactive mode across platforms. Previously Windows ran in non-interactive mode and unix in interactive mode. Non-interactive mode is useful if you want to prevent R from soliciting user input, but it requires error option to be set if you don't want to quit R on all errors (i.e., something like options(error=function() NULL) will do) Note: on unix the interactivity flag can only be set *after* R initialization (due to limitation in R) so you still may have to pass flags like --no-save in order to appease R. o more Windows fixes - Rserve uses R's own initialization in recent R versions. This also fixes issues with Win64 and more recent toolchains. Note that both Widnows and unix now behave consistently with respect to interactive mode - the default is now interactive for both platforms but can be changed in the config file. 0.6-1 2010-05-24 o add a safety margin to the send buffer to avoid crashes when size estimates are off (e.g., due to re-coding) o added a very primitive PHP client o Win64 fixes by Brian Ripley o added new configuration options: su {now|server|client} - switches user either immediately as the config file is loaded ("now", default and always the behavior of Rserve before 0.6-1), when the server is ready ("server") or when a client is spawned ("client"). The latter is useful to restrict clients from sending signals to the server process. uid, gid config options are interpreted accordingly to the su value. cachepwd - {no|yes|indefinitely} - allows Rserve to cache the password file. "no" = read it at each authorization (default and behavior before 0.6-1), "yes" = read it when a client is spawned before su, "indefinitely" = read it just after the config file (most efficient but changes are only active after re-start). "yes" has only effect in unix and can be used to restrict permissions on the password file such that client code has no access to it (do does "indefinitely" but can be used anywhere). 0.6-0 2009-10-27 o added support for control commands CMD_ctrlEval, CMD_ctrlSource and CMD_ctrlShutdown. Those commands provide control over the server process. The side-efect of eval and source are then available to all future connections. Control commands are only available if they are enabled, e.g., with the config file entry "control enable". In addition if authorization is required or the passwords file is set only designated users will have control access (see next point). Note that enabling control commands will make Rserve use at least one file descriptor per active child process, so you may want to adjust the maximum number of file descriptor in your system if you expect hundreds of concurrent clients. o The passwords file format has been enhanced to give finer-granularity control over the user authorization. Only users with "@" prefix can issue control commands. The prefix is not part of the user name for authentication purposes. In addition, if the password file contains an entry starting with "*" it will be interpreted as blank authorization, i.e. any username/pwd will authenticate. This may be useful in conjunction with control prefix, e.g., the following file would give blank authorization to all users but only the user "joe" will be able to use control commands: @joe foobar * o Windows build cleanup (thanks to Brian Ripley) o fixed decoding of XT_RAW (it advanced too far), this affected the use of XT_RAW as non-last element only (thanks to Saptarshi Guha for reporting) o don't advertize ARuc if not supported (this bug only affected systems without crypt support with plaintext enabled and required authorization) o add assign support for logical vectors 0.5-3 2009-01-25 o fix SET_VECTOR_ELT/SET_STRING_ELT mismatches o set object flag when decoding objects that have a "class" attribute (fixes issues with S3 objects that were passed from the client to the server). o set S4 bit for pure S4 objects (S4SEXP). No other S4 objects are supported because there is no way to tell that an assembled object is really an S4 object o added string encoding support (where R supports it) The string encoding can be set in the configuration file (directive "encoding"), on the command line with --RS-encoding or within a session by the client command CMD_setEncoding. This means that strings are converted to the given encoding before being sent to the client and also all strings from the client are assumed to come from the given encoding. (Previously the strings were always passed as-is with no conversion). The currently supported encodings are "native" (same as the server session locale), "utf8" and "latin1". The server default is currently "native" for compatibility with previous versions (but may change to "utf8" in the future, so explicit use of encoding in the config file is advised). If a server is used mainly by Java clients, it is advisable to set the server encoding to "utf8" since that it the only encoding supported by Java clients. For efficieny it is still advisable to run Rserve in the same locale as the majority of clients to minimize the necessary conversions. With diverse clients UTF-8 is the most versatile encoding for the server to run in while it can still serve latin1 clients as well. 0.5-2 2008-10-17 o fix a bug in CMD_readFile and CMD_setBufferSize that resulted in invalid buffer sizes (one of the ways to trigger the bug was to attempt to read a small number of bytes with readFile). Thanks to H. Rehauer for reporting. o ignore attributes if they are not in a LISTSXP - there seem to be other uses of the ATTRIB entry in conjunction with character hashes in recent R versions. (BR #76) o adapt C++ client to changes in 0.5 (at least to the point where the demo1 code works) o add support for XT_VECTOR_EXP in assignments o improve protection for vectors o report "remote" setting in --RS-settings o updates in the REngine Java client, added documentation 0.5-1 2008-07-22 o fix build issue with R 2.7.x on Windows o mergefat now works properly and uses cp if there is no lipo (this fixes multi-arch issues on Mac OS X and makes sure that Rserve/Rserve.dbg are installed even on non-Mac systems) 0.5-0 2008-07-21 o added CMD_serEval and CMD_serAssign which are highly efficient when talking to R clients as they don't need any intermediate buffer. The corresponding R client functions RSeval and RSassign have been re-written to use this new API. o deprecate scalar types in the protocol o add more efficient storage for dotted-pair lists and symbol names o add support for complex numbers o new Java client: REngine it is more flexible than JRclient and it can be used with other Java/R engines such as JRI. Also it has a much more clean API and better exeption handling. - allow NaNs to be passed in raw form to R, i.e. double NAs can be created using Double.longBitsToDouble(0x7ff00000000007a2L) (nice methods for this should follow) o C++ client was moved to src/client/cxx JRclient: o change the representation of lists to generic named vectors (class RList) o change the ways attributes are accessed 0.4-7 2007-01-14 o relax DLL versions checking on Windows o added more sophisticated implementation of RSassign in R client to support larger data. Nevertheless, due to limitations in R, objects must be serializable to less than 8MB to be assignable via RSassign. o added more robust error handling in the R client o fixed compilation on systems with custom include dir (such as Debian) o JRclient is now part of the Rserve package. See clients.txt for details. It is not compiled by default (but installed when --with-client is specified), because we cannot assume the existence of a Java compiler. 0.4-6 2006-11-30 o fixed bug in RSeval when handling large objects o minor fix in RSassign o add an endianness hack for Windows in case config.h is not included properly 0.4-5 2006-11-29 o added --with-server option (by default enabled). When disabled, the server itself is not built. When enabled, R must provide R shared library, i.e. it must have been compiled with --enable-R-shlib. o added --with-client option (by default disabled). When enabled, the C/C++ client is built and installed in the package. It will be copied in the "client" directory of the package and contains all files necessary for building a client application. This option has no effect on the R client which is always built and installed. o Windows version of Rserve now builds and installs both debug (Rserve_d.exe) and regular (Rserve.exe) version of Rserve. In addition, the Rserve function can now be used to launch Rserve even on Windows. o endianness detection now prefers information from the compiler macros thus allowing cross-compilation. Use -D_BIG_ENDIAN_ or -D_LITTLE_ENDIAN_ to override it if necessary. o allows universal build on Mac OS X o adapt to R_ParseVector interface change in R-devel 0.4-4 2006-11-15 o first release on CRAN o added support for RAW type (both in and out) o added rudimentary client support (thanks to David Reiss for his contributions) and documentation Previous major releases: 0.4 2005-08-31 * added support for sessions 0.3 2003-10-07 * new format for boolean arrays last version: 0.3-18 (2005-08-28) 0.2 2003-08-21 * support for large objects 0.1 2002-07-06 * first release Rserve/R/0000755000176000001440000000000012205226215011746 5ustar ripleyusersRserve/R/conn.R0000644000176000001440000000630412205226215013031 0ustar ripleyusersRserve <- function(debug=FALSE, port, args=NULL, quote=(length(args) > 1), wait, ...) { args <- as.character(args) if (!isTRUE(quote) && length(args) > 1) args <- paste(args, collapse=' ') if (.Platform$OS.type == "windows") { arch <- .Platform$r_arch if (is.null(arch) || !nzchar(arch)) arch <- "" ffn <- if (debug) "Rserve_d.exe" else "Rserve.exe" fn <- shortPathName(if (nzchar(arch)) system.file("libs", arch, ffn, package="Rserve") else system.file(package="Rserve", ffn)) if (!nchar(fn) || !file.exists(fn)) stop("Cannot find ", ffn) else { if (!missing(port)) args <- c( args, "--RS-port", as.integer(port) ) if (nzchar(arch)) arch <- paste("\\", arch, sep='') pad <- gsub("/", "\\", shortPathName(paste(R.home(),"\\bin",arch,";",sep='')), fixed=TRUE) if (charmatch(pad, Sys.getenv("PATH"), nomatch=0) == 0) Sys.setenv(PATH=paste(pad, Sys.getenv("PATH"), sep='')) fn <- if (isTRUE(quote)) paste(shQuote(c(fn, args), "cmd"), collapse=' ') else paste(shQuote(fn, "cmd"), paste(args, collapse=' ')) cat("Starting Rserve...\n", fn, "\n") if (missing(wait)) wait <- FALSE return(invisible(system(fn, wait=wait, ...))) } } name <- if (!debug) "Rserve" else "Rserve.dbg" fn <- system.file(package="Rserve", "libs", .Platform$r_arch, name) if (!nchar(fn)) fn <- name if (!missing(port)) args <- c( args, "--RS-port", as.integer(port) ) if (length(args)) fn <- paste(fn, paste(if (isTRUE(quote)) shQuote(args, "sh") else args, collapse=' ')) cmd <- paste(file.path(R.home(),"bin","R"), "CMD", fn) if (!missing(port)) cat("Starting Rserve on port", port, ":\n",cmd,"\n\n") else cat("Starting Rserve:\n",cmd,"\n\n") if (debug) cat("Note: debug version of Rserve doesn't daemonize so your R session will be blocked until you shut down Rserve.\n") if (missing(wait)) wait <- TRUE invisible(system(cmd, wait=wait, ...)) } run.Rserve <- function(..., config.file="/etc/Rserve.conf") .Call(run_Rserve, as.character(config.file), sapply(list(...), as.character)) self.ctrlEval <- function(expr) { if (!is.loaded("Rserve_ctrlEval")) stop("This command can only be run inside Rserve with r-control enabled") if (is.language(expr)) expr <- deparse(expr) if (!is.character(expr)) stop("expr must me a character vector, name, call or an expression") call <- getNativeSymbolInfo("Rserve_ctrlEval") invisible(.Call(call, paste(expr, collapse='\n'))) } self.ctrlSource <- function(file) { if (!is.loaded("Rserve_ctrlSource")) stop("This command can only be run inside Rserve with r-control enabled") if (!is.character(file) || length(file) != 1) stop("`file' must be a string") call <- getNativeSymbolInfo("Rserve_ctrlSource") invisible(.Call(call, file)) } self.oobSend <- function(what, code = 0L) { if (!is.loaded("Rserve_oobSend")) stop("This command can only be run inside Rserve with oob enabled") call <- getNativeSymbolInfo("Rserve_oobSend") invisible(.Call(call, what, code)) } self.oobMessage <- function(what, code = 0L) { if (!is.loaded("Rserve_oobMsg")) stop("This command can only be run inside Rserve with oob enabled") call <- getNativeSymbolInfo("Rserve_oobMsg") invisible(.Call(call, what, code)) } Rserve/MD50000644000176000001440000003100713455133430012062 0ustar ripleyusers6d36d25b2f5f1d68f21e34e6c9b207be *DESCRIPTION 52b8686c329855db3de97bc9fe302a62 *INDEX 51ab443d0a22e0e9e4f693c12f07f8e9 *LICENSE c66359bb3166f6d7884539df312aea9e *NAMESPACE de890dd1555a67a1b4c9b10b240e3364 *NEWS 717819ef4178d789c6fcf33fbbd7d34e *R/conn.R 7f625ea437de1b3a87e89147c748ae5a *aclocal.m4 1285c2452b360dcb43dae2fae24c1dc8 *cleanup 55ff86fb75adec42e8cb85e096da5661 *clients.txt 2d6d65e154495e0623b04894c4d956a8 *clients/README.txt fbc093901857fcd118f065f900982c24 *clients/cxx/COPYING e0d11aa8d62727526e8d3037a456aded *clients/cxx/Makefile.in 4b639fc216ef057350a5a03939b76753 *clients/cxx/Makefile.win 45385251b966f0de7475a839dc7964b5 *clients/cxx/Rconnection.cc ec86601fc371e0b63771f9d622669ce1 *clients/cxx/Rconnection.h edff7c7d2bee83e149e109900d099d84 *clients/cxx/ReadMe.txt 277b19f0a010cf2603bff3817a2e5482 *clients/cxx/Rsrv.h 1ab1a282ff3fa459017d1df997364f05 *clients/cxx/config.h.in 96d35f88f36e1edf0f0ec536f5bda4fb *clients/cxx/configure 0803720c1ee8ac258df3c8fad0214e43 *clients/cxx/configure.ac 993a295d84a30c1d73f70e3f62130c0f *clients/cxx/demo1.cc 8b96ec5504b8e8e1da6721b46a4a32d2 *clients/cxx/rcmd.cc a0b407b59f56cd555ceb51ca2015ea87 *clients/cxx/rcons.cc 8baea46b2f4700829a587bde50c84526 *clients/cxx/rsdown.cc ada2eb6892a791449d79878822e55c01 *clients/cxx/sisocks.h ad9c6e9aebbc77e550ea297f19fceb5d *clients/java/JRI/JRIEngine.java b7fd604595471ef1828106e6e0be2d15 *clients/java/JRI/Makefile 9714690518f4d6dbfe3f89fefb0e8a91 *clients/java/JRI/package-info.java ecd8c8639668ad35fa74730ad499f010 *clients/java/JRI/test/Makefile cf61905afba88cc39be79c5dabcf4d07 *clients/java/JRI/test/RTest.java 067d3e0bb9ba9932948fecad436036e6 *clients/java/LICENSE a2baa880f0a850d7546df1dce1b941de *clients/java/Makefile 3927ba79c7a801f36075f1b809d06196 *clients/java/MutableREXP.java 68e35b7867588de61eb9ecb2f7748bc3 *clients/java/REXP.java a8de3e1fab786f0d9762b5b2b0f63bed *clients/java/REXPDouble.java 3683350b5fe442d759a1176a96ea7790 *clients/java/REXPEnvironment.java 024e5f5858a25b9c88e437bde83b0a08 *clients/java/REXPExpressionVector.java 754b193f82b377f2e20437a8deaeb60a *clients/java/REXPFactor.java b2e1002544b9c27c97002c2b8b55be0c *clients/java/REXPGenericVector.java 8def14772888086b046354a84b5ef042 *clients/java/REXPInteger.java edee0fd33051c198b82956231f0f5a68 *clients/java/REXPJavaReference.java 42f721124ae0cd5ef5edfb115a412cb6 *clients/java/REXPLanguage.java c6c00f3859d2ef66e7b16bd784beebc1 *clients/java/REXPList.java e9d0ea19f11eaac2e15980e9b7cf6e9a *clients/java/REXPLogical.java c951b85ed10dd9f326d595af605c2aef *clients/java/REXPMismatchException.java 28d4839ce78289590aae84bc6d141339 *clients/java/REXPNull.java beab9bdcfe5d6a09e8bb0258d086a684 *clients/java/REXPRaw.java 22db9a286a51a60cee7aa99037748e88 *clients/java/REXPReference.java e03aebe85120fe43490135da423dcd24 *clients/java/REXPS4.java 12f0c290a307d36c419d85cb5e9f8a32 *clients/java/REXPString.java 16494ce82d7ac67394151cad5cee3844 *clients/java/REXPSymbol.java f28e65acd497901e47295b156775a469 *clients/java/REXPUnknown.java 2ad6c462e1fa0498d7ed43d89ba9ca4d *clients/java/REXPVector.java 4a2893e415791cf97e161e94f9a626d1 *clients/java/REXPWrapper.java 22ee01dbc4f722020f650cde873a8d48 *clients/java/REngine.java ba7130aa5f03935284e484d82f05b2f2 *clients/java/REngineCallbacks.java 80f05407ddfa287167fcf5ef9cd84390 *clients/java/REngineConsoleHistoryInterface.java c71f9739a92170a9cc623291d1fcd524 *clients/java/REngineEvalException.java b362d69d0db6262c80f0407991926107 *clients/java/REngineException.java fe69b8b51e8c7ae6a9cdfc5c80f5a2f0 *clients/java/REngineInputInterface.java 22b51c4f124c06d1f6d6c9431e6b86ea *clients/java/REngineOutputInterface.java baaafc80d15203c724de9f9e439fb157 *clients/java/REngineStdOutput.java 78312e95629e7556d324acfd11ddd547 *clients/java/REngineUIInterface.java b05e012fb558a1f17213e7f4912c4027 *clients/java/RFactor.java 9e0e7022027bd5efb0a5556340364e36 *clients/java/RList.java f45e3b7b0ae9cb051ad8654fc919ef85 *clients/java/Rserve/Makefile d991adc0ee460626426f0f05166e7bf7 *clients/java/Rserve/RConnection.java 1d3f3cac377aaa8428cc6f03782dfd9d *clients/java/Rserve/RFileInputStream.java d48ea3cff02124d49b40cdacc461307f *clients/java/Rserve/RFileOutputStream.java 8217731c41f582992313a4946401074f *clients/java/Rserve/RSession.java 862b7665896988fc9039ebf3ba0d2837 *clients/java/Rserve/Rserve.jar e8cbed2c7167b2eccab2ebfcc800aa64 *clients/java/Rserve/RserveException.java 78bf28c04d3b9de9ef4ef95a0c7918c1 *clients/java/Rserve/package-info.java 68e1a1474896cc52b31f07652ca74225 *clients/java/Rserve/protocol/REXPFactory.java 1e506d528dde55b267dea0bb79551fbd *clients/java/Rserve/protocol/RPacket.java 3287687eb08c3356b633f4672779c01a *clients/java/Rserve/protocol/RTalk.java ed28b70af013379d2a96d0d7dca1a7d6 *clients/java/Rserve/protocol/jcrypt.java 9a072fc90592c80991ea2020d0d2b7e5 *clients/java/Rserve/test/Makefile 2592ee47962bec10a6c90519c67dd4aa *clients/java/Rserve/test/PlotDemo.java a593b733b11ca43a7955c59ebb589e37 *clients/java/Rserve/test/StartRserve.java d4ff8f3834f9ca9b742f05c4936a3baa *clients/java/Rserve/test/jt.java eb679aec02bcc436f027e46b27722ffa *clients/java/Rserve/test/test.java fd1948ffcc8aa12424c33d08869eeb72 *clients/java/package-info.java 8533aa43245961e8d15d0602432d20f6 *clients/php/simple.php b9f6f52e01d37812a00972eae1c23994 *configure 37f8c234778c8219f006367a7881c986 *configure.ac 243e9a3eede74518a6bc030bfec66beb *configure.win ab9a9969d8e1be834972ec514fdb9c1b *inst/java/REngine.jar 85a1dc8b89ddc2a603184b9d8b8fa35d *inst/java/Rserve.jar b2c9af5ad6e9685f0e2bf4a495e18e12 *man/Rserv.Rd ffcadeb5fc4e139fa5da05eac3c3d905 *man/run.Rserve.Rd e76ccbbe06bdf6737fe05d45c953dc53 *man/self.Rd b52eaae46f8d1b4bc77b62a9a9368c90 *src/Makevars.in 090d4ac765eb970eadfc5787be2f39ab *src/Makevars.win fa8a1c083d32e1771ade42528af860bf *src/RSserver.c d4da9b05f710d31f0e22fc07de913827 *src/RSserver.h effcc56b0df8693d53081d79a9b2651a *src/Rserv.c 277b19f0a010cf2603bff3817a2e5482 *src/Rsrv.h b4bafa877c47764dad4c9e3777904f9d *src/base64.c 2d6d65e154495e0623b04894c4d956a8 *src/client/README.txt fbc093901857fcd118f065f900982c24 *src/client/cxx/COPYING e0d11aa8d62727526e8d3037a456aded *src/client/cxx/Makefile.in 4b639fc216ef057350a5a03939b76753 *src/client/cxx/Makefile.win 45385251b966f0de7475a839dc7964b5 *src/client/cxx/Rconnection.cc ec86601fc371e0b63771f9d622669ce1 *src/client/cxx/Rconnection.h edff7c7d2bee83e149e109900d099d84 *src/client/cxx/ReadMe.txt 277b19f0a010cf2603bff3817a2e5482 *src/client/cxx/Rsrv.h 1ab1a282ff3fa459017d1df997364f05 *src/client/cxx/config.h.in 96d35f88f36e1edf0f0ec536f5bda4fb *src/client/cxx/configure 0803720c1ee8ac258df3c8fad0214e43 *src/client/cxx/configure.ac 993a295d84a30c1d73f70e3f62130c0f *src/client/cxx/demo1.cc 8b96ec5504b8e8e1da6721b46a4a32d2 *src/client/cxx/rcmd.cc a0b407b59f56cd555ceb51ca2015ea87 *src/client/cxx/rcons.cc 8baea46b2f4700829a587bde50c84526 *src/client/cxx/rsdown.cc ada2eb6892a791449d79878822e55c01 *src/client/cxx/sisocks.h ad9c6e9aebbc77e550ea297f19fceb5d *src/client/java/JRI/JRIEngine.java b7fd604595471ef1828106e6e0be2d15 *src/client/java/JRI/Makefile 9714690518f4d6dbfe3f89fefb0e8a91 *src/client/java/JRI/package-info.java ecd8c8639668ad35fa74730ad499f010 *src/client/java/JRI/test/Makefile cf61905afba88cc39be79c5dabcf4d07 *src/client/java/JRI/test/RTest.java 067d3e0bb9ba9932948fecad436036e6 *src/client/java/LICENSE a2baa880f0a850d7546df1dce1b941de *src/client/java/Makefile 3927ba79c7a801f36075f1b809d06196 *src/client/java/MutableREXP.java 68e35b7867588de61eb9ecb2f7748bc3 *src/client/java/REXP.java a8de3e1fab786f0d9762b5b2b0f63bed *src/client/java/REXPDouble.java 3683350b5fe442d759a1176a96ea7790 *src/client/java/REXPEnvironment.java 024e5f5858a25b9c88e437bde83b0a08 *src/client/java/REXPExpressionVector.java 754b193f82b377f2e20437a8deaeb60a *src/client/java/REXPFactor.java b2e1002544b9c27c97002c2b8b55be0c *src/client/java/REXPGenericVector.java 8def14772888086b046354a84b5ef042 *src/client/java/REXPInteger.java edee0fd33051c198b82956231f0f5a68 *src/client/java/REXPJavaReference.java 42f721124ae0cd5ef5edfb115a412cb6 *src/client/java/REXPLanguage.java c6c00f3859d2ef66e7b16bd784beebc1 *src/client/java/REXPList.java e9d0ea19f11eaac2e15980e9b7cf6e9a *src/client/java/REXPLogical.java c951b85ed10dd9f326d595af605c2aef *src/client/java/REXPMismatchException.java 28d4839ce78289590aae84bc6d141339 *src/client/java/REXPNull.java beab9bdcfe5d6a09e8bb0258d086a684 *src/client/java/REXPRaw.java 22db9a286a51a60cee7aa99037748e88 *src/client/java/REXPReference.java e03aebe85120fe43490135da423dcd24 *src/client/java/REXPS4.java 12f0c290a307d36c419d85cb5e9f8a32 *src/client/java/REXPString.java 16494ce82d7ac67394151cad5cee3844 *src/client/java/REXPSymbol.java f28e65acd497901e47295b156775a469 *src/client/java/REXPUnknown.java 2ad6c462e1fa0498d7ed43d89ba9ca4d *src/client/java/REXPVector.java 4a2893e415791cf97e161e94f9a626d1 *src/client/java/REXPWrapper.java 22ee01dbc4f722020f650cde873a8d48 *src/client/java/REngine.java ba7130aa5f03935284e484d82f05b2f2 *src/client/java/REngineCallbacks.java 80f05407ddfa287167fcf5ef9cd84390 *src/client/java/REngineConsoleHistoryInterface.java c71f9739a92170a9cc623291d1fcd524 *src/client/java/REngineEvalException.java b362d69d0db6262c80f0407991926107 *src/client/java/REngineException.java fe69b8b51e8c7ae6a9cdfc5c80f5a2f0 *src/client/java/REngineInputInterface.java 22b51c4f124c06d1f6d6c9431e6b86ea *src/client/java/REngineOutputInterface.java baaafc80d15203c724de9f9e439fb157 *src/client/java/REngineStdOutput.java 78312e95629e7556d324acfd11ddd547 *src/client/java/REngineUIInterface.java b05e012fb558a1f17213e7f4912c4027 *src/client/java/RFactor.java 9e0e7022027bd5efb0a5556340364e36 *src/client/java/RList.java f45e3b7b0ae9cb051ad8654fc919ef85 *src/client/java/Rserve/Makefile d991adc0ee460626426f0f05166e7bf7 *src/client/java/Rserve/RConnection.java 1d3f3cac377aaa8428cc6f03782dfd9d *src/client/java/Rserve/RFileInputStream.java d48ea3cff02124d49b40cdacc461307f *src/client/java/Rserve/RFileOutputStream.java 8217731c41f582992313a4946401074f *src/client/java/Rserve/RSession.java 862b7665896988fc9039ebf3ba0d2837 *src/client/java/Rserve/Rserve.jar e8cbed2c7167b2eccab2ebfcc800aa64 *src/client/java/Rserve/RserveException.java 78bf28c04d3b9de9ef4ef95a0c7918c1 *src/client/java/Rserve/package-info.java 68e1a1474896cc52b31f07652ca74225 *src/client/java/Rserve/protocol/REXPFactory.java 1e506d528dde55b267dea0bb79551fbd *src/client/java/Rserve/protocol/RPacket.java 3287687eb08c3356b633f4672779c01a *src/client/java/Rserve/protocol/RTalk.java ed28b70af013379d2a96d0d7dca1a7d6 *src/client/java/Rserve/protocol/jcrypt.java 9a072fc90592c80991ea2020d0d2b7e5 *src/client/java/Rserve/test/Makefile 2592ee47962bec10a6c90519c67dd4aa *src/client/java/Rserve/test/PlotDemo.java a593b733b11ca43a7955c59ebb589e37 *src/client/java/Rserve/test/StartRserve.java d4ff8f3834f9ca9b742f05c4936a3baa *src/client/java/Rserve/test/jt.java eb679aec02bcc436f027e46b27722ffa *src/client/java/Rserve/test/test.java fd1948ffcc8aa12424c33d08869eeb72 *src/client/java/package-info.java 8533aa43245961e8d15d0602432d20f6 *src/client/php/simple.php 3ac4c8a0a047db07dfe9ac9da1f7bdae *src/config.h.in 87b87bb8446ca19457afbc8dbfcc2370 *src/http.c eea5617dbcc9fb006cec57cbaaf75451 *src/http.h 07f4e02182a19800f5f9a6c0b2140c7e *src/include/Parse.h 90f990b9a30211202d6ed2095ffbe4e2 *src/include/Win32/Startup.h a03ebc57c45822c6aaf865f2120a775a *src/include/Win32/config.h 06b89bc548e3388a756a1b9bbdaf3683 *src/include/Win32/psignal.h a1f31afcfe229fffeda88e3104734009 *src/include/sbthread.h ada2eb6892a791449d79878822e55c01 *src/include/sisocks.h e36d63fcff9d59adda22fdee9ccc29b3 *src/install.libs.R d8276113b955960f3bf277d2be01a61a *src/md5.c e24b5d8a466d17335ea4ec4904c9beec *src/md5.h 252501b1958da38383088bc595e2f0ee *src/mergefat 2569154c8902ad1511113b472662b5c5 *src/oc.c 985e1c6b5c4e38b3520a3cc18d257e21 *src/oc.h 776937666580d8effe519b1d61ea902e *src/other/RSpool.c ed50225ffc871ea75203c241e3f7b32f *src/qap_decode.c ee2f74fbf8cd5b0a0bbededbe780ade4 *src/qap_decode.h 8fe9685eadcab6a6299ef4d1e8a4ebe5 *src/qap_encode.c 01782f7ec33b0bb4e14d1da0b8b1595f *src/qap_encode.h bfab19f88159bd4d44ace4cf59fcd363 *src/rsdebug.h e21336c443664f6c40fa3a04ed4a6e92 *src/rserr.h 7215816267af6d856ac12091358fa114 *src/rsio.c 795ae55df1085b8ba9a0f40138446c22 *src/rsio.h edc34c4297f7fe9c513ebd8acfa30d14 *src/session.c 904fbcb3ba2658527e65903bbe22ac2e *src/session.h af56434a66f449b3acaa179ce6d52d37 *src/sha1.c 6be2d1704b37fb778ca61bca437bb6af *src/sha1.h 8e1606d9e2714dabb12555e970a3c6f6 *src/standalone.c 2430da17df078a07ff46223a130babee *src/tls.c 030f5f8bf8c8a75b09135027e72243ed *src/tls.h 111eae6e7813486d384c4c5eb942045c *src/websockets.c 68c0813df8afaf04ef638b87c076572b *src/websockets.h 6c79ce859ea4d9b7fc011e29b612f0e9 *src/winembed.c d18a2e38f8ae660db1adef030a658253 *version Rserve/DESCRIPTION0000644000176000001440000000170213455133430013257 0ustar ripleyusersPackage: Rserve Version: 1.7-3.1 Title: Binary R server Author: Simon Urbanek Maintainer: Simon Urbanek Depends: R (>= 1.5.0) Suggests: RSclient SystemRequirements: libR, GNU make Description: Rserve acts as a socket server (TCP/IP or local sockets) which allows binary requests to be sent to R. Every connection has a separate workspace and working directory. Client-side implementations are available for popular languages such as C/C++ and Java, allowing any application to use facilities of R without the need of linking to R code. Rserve supports remote connection, user authentication and file transfer. A simple R client is included in this package as well. License: GPL-2 | file LICENSE URL: http://www.rforge.net/Rserve/ NeedsCompilation: yes Repository: CRAN Date/Publication: 2019-04-15 16:53:44 UTC Packaged: 2019-03-14 18:24:52 UTC; ripley Rserve/configure0000755000176000001440000051635713442516164013506 0ustar ripleyusers#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for Rserve 1.7. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: Simon.Urbanek@r-project.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='Rserve' PACKAGE_TARNAME='rserve' PACKAGE_VERSION='1.7' PACKAGE_STRING='Rserve 1.7' PACKAGE_BUGREPORT='Simon.Urbanek@r-project.org' PACKAGE_URL='' ac_unique_file="src/Rserv.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='LTLIBOBJS LIBOBJS EGREP GREP CPP OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC PKG_LIBS PKG_CPPFLAGS OPENSSL_INCLUDES RLD RINC R_HOME WITH_CLIENT_FALSE WITH_CLIENT_TRUE WITH_SERVER_FALSE WITH_SERVER_TRUE target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking with_server with_client enable_ipv6 ' ac_precious_vars='build_alias host_alias target_alias OPENSSL_INCLUDES PKG_CPPFLAGS PKG_LIBS CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures Rserve 1.7 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/rserve] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of Rserve 1.7:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-ipv6 enable the use of IPv6 protocol. [no] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-server compile Rserve server (default is [yes]). Given that this is the main functionality of Rserve, the only reason to disable the server is to configure R or C++ client separately. --with-client compile additional C/C++ Rserve client (default is [no]). The client can be always compiled manually regardless of this setting. Some influential environment variables: OPENSSL_INCLUDES optional path to the include directory for OpenSSL headers PKG_CPPFLAGS additional pre-processor flags PKG_LIBS additional linker library flags CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF Rserve configure 1.7 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------------------ ## ## Report this to Simon.Urbanek@r-project.org ## ## ------------------------------------------ ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by Rserve $as_me 1.7, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers src/config.h" # find R home and set CC/CFLAGS : ${R_HOME=`R RHOME`} if test -z "${R_HOME}"; then echo "could not determine R_HOME" exit 1 fi # Check whether --with-server was given. if test "${with_server+set}" = set; then : withval=$with_server; with_server=$withval else with_server=yes fi # Check whether --with-client was given. if test "${with_client+set}" = set; then : withval=$with_client; with_client=$withval else with_client=no fi # Check whether --enable-ipv6 was given. if test "${enable_ipv6+set}" = set; then : enableval=$enable_ipv6; want_ipv6="${enableval}" else want_ipv6=no fi RLD=`${R_HOME}/bin/R CMD config --ldflags 2>/dev/null` has_R_shlib=no if test -n "$RLD"; then has_R_shlib=yes fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to compile the server" >&5 $as_echo_n "checking whether to compile the server... " >&6; } if test "${with_server}" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } if test "${has_R_shlib}" = no; then as_fn_error $? "R was configured without --enable-R-shlib or --enable-R-static-lib *** Rserve requires R (shared or static) library. *** *** Please install R library or compile R with either --enable-R-shlib *** *** or --enable-R-static-lib support *** Alternatively use --without-server if you wish to build only Rserve client. " "$LINENO" 5 fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to compile the client" >&5 $as_echo_n "checking whether to compile the client... " >&6; } if test "${with_client}" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x${with_server}" = xyes; then WITH_SERVER_TRUE= WITH_SERVER_FALSE='#' else WITH_SERVER_TRUE='#' WITH_SERVER_FALSE= fi if test "x${with_client}" = xyes; then WITH_CLIENT_TRUE= WITH_CLIENT_FALSE='#' else WITH_CLIENT_TRUE='#' WITH_CLIENT_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC=`${R_HOME}/bin/R CMD config CC`; CXX=`${R_HOME}/bin/R CMD config CXX`; CPPFLAGS="${CPPFLAGS} ${PKG_CPPFLAGS}" CFLAGS=`${R_HOME}/bin/R CMD config CFLAGS` CXXFLAGS=`${R_HOME}/bin/R CMD config CXXFLAGS` RINC=`${R_HOME}/bin/R CMD config --cppflags` LIBS="${LIBS} ${PKG_LIBS}" if test "x${OPENSSL_INCLUDES}" != x; then CPPFLAGS="${CPPFLAGS} -I${OPENSSL_INCLUDES}" fi # Checks for programs. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Checks for libraries. # Checks for header files. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5 $as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; } if ${ac_cv_header_sys_wait_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif int main () { int s; wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_sys_wait_h=yes else ac_cv_header_sys_wait_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5 $as_echo "$ac_cv_header_sys_wait_h" >&6; } if test $ac_cv_header_sys_wait_h = yes; then $as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in string.h memory.h sys/time.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in sys/stat.h sys/types.h sys/socket.h sys/un.h netinet/in.h netinet/tcp.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __cplusplus /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this sort of thing. */ char tx; char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; } bx; struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define BS_BIG_ENDIAN 1" >>confdefs.h ;; #( no) $as_echo "#define BS_LITTLE_ENDIAN 1" >>confdefs.h ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: endianness unknown - will rely solely on compiler macros" >&5 $as_echo "endianness unknown - will rely solely on compiler macros" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler sets endianness macros" >&5 $as_echo_n "checking whether compiler sets endianness macros... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN_ || defined __BIG_ENDIAN__ || defined _BIG_ENDIAN_ #define BS_OK 1 #else cannot determine compiler's endianness #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "Cannot determine endianness neither from the compiler nor using a test. Try adding -D_BIG_ENDIAN_ or -D_LITTLE_ENDIAN_ to PKG_CPPFLAGS. " "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi # Checks for library functions. ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" if test "x$ac_cv_type_pid_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define pid_t int _ACEOF fi for ac_header in vfork.h do : ac_fn_c_check_header_mongrel "$LINENO" "vfork.h" "ac_cv_header_vfork_h" "$ac_includes_default" if test "x$ac_cv_header_vfork_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_VFORK_H 1 _ACEOF fi done for ac_func in fork vfork do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done if test "x$ac_cv_func_fork" = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working fork" >&5 $as_echo_n "checking for working fork... " >&6; } if ${ac_cv_func_fork_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_fork_works=cross else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* By Ruediger Kuhlmann. */ return fork () < 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_fork_works=yes else ac_cv_func_fork_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_fork_works" >&5 $as_echo "$ac_cv_func_fork_works" >&6; } else ac_cv_func_fork_works=$ac_cv_func_fork fi if test "x$ac_cv_func_fork_works" = xcross; then case $host in *-*-amigaos* | *-*-msdosdjgpp*) # Override, as these systems have only a dummy fork() stub ac_cv_func_fork_works=no ;; *) ac_cv_func_fork_works=yes ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5 $as_echo "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;} fi ac_cv_func_vfork_works=$ac_cv_func_vfork if test "x$ac_cv_func_vfork" = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working vfork" >&5 $as_echo_n "checking for working vfork... " >&6; } if ${ac_cv_func_vfork_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_vfork_works=cross else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Thanks to Paul Eggert for this test. */ $ac_includes_default #include #ifdef HAVE_VFORK_H # include #endif /* On some sparc systems, changes by the child to local and incoming argument registers are propagated back to the parent. The compiler is told about this with #include , but some compilers (e.g. gcc -O) don't grok . Test for this by using a static variable whose address is put into a register that is clobbered by the vfork. */ static void #ifdef __cplusplus sparc_address_test (int arg) # else sparc_address_test (arg) int arg; #endif { static pid_t child; if (!child) { child = vfork (); if (child < 0) { perror ("vfork"); _exit(2); } if (!child) { arg = getpid(); write(-1, "", 0); _exit (arg); } } } int main () { pid_t parent = getpid (); pid_t child; sparc_address_test (0); child = vfork (); if (child == 0) { /* Here is another test for sparc vfork register problems. This test uses lots of local variables, at least as many local variables as main has allocated so far including compiler temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should reuse the register of parent for one of the local variables, since it will think that parent can't possibly be used any more in this routine. Assigning to the local variable will thus munge parent in the parent process. */ pid_t p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(), p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid(); /* Convince the compiler that p..p7 are live; otherwise, it might use the same hardware register for all 8 local variables. */ if (p != p1 || p != p2 || p != p3 || p != p4 || p != p5 || p != p6 || p != p7) _exit(1); /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent from child file descriptors. If the child closes a descriptor before it execs or exits, this munges the parent's descriptor as well. Test for this by closing stdout in the child. */ _exit(close(fileno(stdout)) != 0); } else { int status; struct stat st; while (wait(&status) != child) ; return ( /* Was there some problem with vforking? */ child < 0 /* Did the child fail? (This shouldn't happen.) */ || status /* Did the vfork/compiler bug occur? */ || parent != getpid() /* Did the file descriptor bug occur? */ || fstat(fileno(stdout), &st) != 0 ); } } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_vfork_works=yes else ac_cv_func_vfork_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_vfork_works" >&5 $as_echo "$ac_cv_func_vfork_works" >&6; } fi; if test "x$ac_cv_func_fork_works" = xcross; then ac_cv_func_vfork_works=$ac_cv_func_vfork { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5 $as_echo "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;} fi if test "x$ac_cv_func_vfork_works" = xyes; then $as_echo "#define HAVE_WORKING_VFORK 1" >>confdefs.h else $as_echo "#define vfork fork" >>confdefs.h fi if test "x$ac_cv_func_fork_works" = xyes; then $as_echo "#define HAVE_WORKING_FORK 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 $as_echo_n "checking return type of signal handlers... " >&6; } if ${ac_cv_type_signal+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { return *(signal (0, 0)) (0) == 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_type_signal=int else ac_cv_type_signal=void fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 $as_echo "$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF for ac_func in memset mkdir rmdir select socket srandomdev do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done # Check whether we can use crypt (and if we do if it's in the crypt library) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing crypt" >&5 $as_echo_n "checking for library containing crypt... " >&6; } if ${ac_cv_search_crypt+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char crypt (); int main () { return crypt (); ; return 0; } _ACEOF for ac_lib in '' crypt; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_crypt=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_crypt+:} false; then : break fi done if ${ac_cv_search_crypt+:} false; then : else ac_cv_search_crypt=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_crypt" >&5 $as_echo "$ac_cv_search_crypt" >&6; } ac_res=$ac_cv_search_crypt if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define HAS_CRYPT 1" >>confdefs.h fi for ac_header in crypt.h do : ac_fn_c_check_header_mongrel "$LINENO" "crypt.h" "ac_cv_header_crypt_h" "$ac_includes_default" if test "x$ac_cv_header_crypt_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_CRYPT_H 1 _ACEOF fi done # socket related stuff - indroduced first due to Solaris # socklen_t - note that we don't try to find an equivalent! # we'll use BSD-style int in case this one isn't defined. # that should be fine for all major platforms. ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" " #include #include " if test "x$ac_cv_type_socklen_t" = xyes; then : else $as_echo "#define socklen_t int" >>confdefs.h fi # connect may need -lsocket and/or -lnsl (e.g. on Solaris) for ac_func in connect do : ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect" if test "x$ac_cv_func_connect" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_CONNECT 1 _ACEOF fi done if test x"$ac_cv_func_connect" = x"no"; then case "$LIBS" in *-lnsl*) ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf in -lnsl_s" >&5 $as_echo_n "checking for printf in -lnsl_s... " >&6; } if ${ac_cv_lib_nsl_s_printf+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl_s $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char printf (); int main () { return printf (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nsl_s_printf=yes else ac_cv_lib_nsl_s_printf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_s_printf" >&5 $as_echo "$ac_cv_lib_nsl_s_printf" >&6; } if test "x$ac_cv_lib_nsl_s_printf" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBNSL_S 1 _ACEOF LIBS="-lnsl_s $LIBS" fi ;; esac case "$LIBS" in *-lnsl*) ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf in -lnsl" >&5 $as_echo_n "checking for printf in -lnsl... " >&6; } if ${ac_cv_lib_nsl_printf+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char printf (); int main () { return printf (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nsl_printf=yes else ac_cv_lib_nsl_printf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_printf" >&5 $as_echo "$ac_cv_lib_nsl_printf" >&6; } if test "x$ac_cv_lib_nsl_printf" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBNSL 1 _ACEOF LIBS="-lnsl $LIBS" fi ;; esac case "$LIBS" in *-lsocket*) ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5 $as_echo_n "checking for connect in -lsocket... " >&6; } if ${ac_cv_lib_socket_connect+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char connect (); int main () { return connect (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_connect=yes else ac_cv_lib_socket_connect=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5 $as_echo "$ac_cv_lib_socket_connect" >&6; } if test "x$ac_cv_lib_socket_connect" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSOCKET 1 _ACEOF LIBS="-lsocket $LIBS" fi ;; esac case "$LIBS" in *-linet*) ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -linet" >&5 $as_echo_n "checking for connect in -linet... " >&6; } if ${ac_cv_lib_inet_connect+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-linet $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char connect (); int main () { return connect (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_inet_connect=yes else ac_cv_lib_inet_connect=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_inet_connect" >&5 $as_echo "$ac_cv_lib_inet_connect" >&6; } if test "x$ac_cv_lib_inet_connect" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBINET 1 _ACEOF LIBS="-linet $LIBS" fi ;; esac if test x"$ac_cv_lib_socket_connect" = x"yes" || test x"$ac_cv_lib_inet_connect" = x"yes"; then # ac_cv_func_connect=yes # don't! it would cause AC_CHECK_FUNC to succeed next time configure is run $as_echo "#define HAVE_CONNECT 1" >>confdefs.h fi fi # IPv6 have_ipv6=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable IPv6" >&5 $as_echo_n "checking whether to enable IPv6... " >&6; } if test "$want_ipv6" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working IPv6 sockets" >&5 $as_echo_n "checking for working IPv6 sockets... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main(void) { struct sockaddr_in6 sin; int i = socket(PF_INET6, SOCK_STREAM, 0); sin.sin6_family = AF_INET6; sin.sin6_addr = in6addr_any; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } have_ipv6=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "$have_ipv6" = yes; then $as_echo "#define HAVE_IPV6 1" >>confdefs.h fi # on some platforms libR expects dl code in the binary { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDL 1 _ACEOF LIBS="-ldl $LIBS" fi # check RSA/crypto ac_fn_c_check_header_mongrel "$LINENO" "openssl/rsa.h" "ac_cv_header_openssl_rsa_h" "$ac_includes_default" if test "x$ac_cv_header_openssl_rsa_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing RSA_generate_key" >&5 $as_echo_n "checking for library containing RSA_generate_key... " >&6; } if ${ac_cv_search_RSA_generate_key+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char RSA_generate_key (); int main () { return RSA_generate_key (); ; return 0; } _ACEOF for ac_lib in '' crypto ssl openssl; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_RSA_generate_key=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_RSA_generate_key+:} false; then : break fi done if ${ac_cv_search_RSA_generate_key+:} false; then : else ac_cv_search_RSA_generate_key=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_RSA_generate_key" >&5 $as_echo "$ac_cv_search_RSA_generate_key" >&6; } ac_res=$ac_cv_search_RSA_generate_key if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define HAVE_RSA 1" >>confdefs.h fi fi # check SSL support ac_fn_c_check_header_mongrel "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default" if test "x$ac_cv_header_openssl_ssl_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing SSL_CTX_load_verify_locations" >&5 $as_echo_n "checking for library containing SSL_CTX_load_verify_locations... " >&6; } if ${ac_cv_search_SSL_CTX_load_verify_locations+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char SSL_CTX_load_verify_locations (); int main () { return SSL_CTX_load_verify_locations (); ; return 0; } _ACEOF for ac_lib in '' ssl openssl; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_SSL_CTX_load_verify_locations=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_SSL_CTX_load_verify_locations+:} false; then : break fi done if ${ac_cv_search_SSL_CTX_load_verify_locations+:} false; then : else ac_cv_search_SSL_CTX_load_verify_locations=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_SSL_CTX_load_verify_locations" >&5 $as_echo "$ac_cv_search_SSL_CTX_load_verify_locations" >&6; } ac_res=$ac_cv_search_SSL_CTX_load_verify_locations if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define HAVE_TLS 1" >>confdefs.h fi fi ac_config_files="$ac_config_files src/Makevars" ac_config_files="$ac_config_files src/client/cxx/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -z "${WITH_SERVER_TRUE}" && test -z "${WITH_SERVER_FALSE}"; then as_fn_error $? "conditional \"WITH_SERVER\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${WITH_CLIENT_TRUE}" && test -z "${WITH_CLIENT_FALSE}"; then as_fn_error $? "conditional \"WITH_CLIENT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by Rserve $as_me 1.7, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ Rserve config.status 1.7 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;; "src/Makevars") CONFIG_FILES="$CONFIG_FILES src/Makevars" ;; "src/client/cxx/Makefile") CONFIG_FILES="$CONFIG_FILES src/client/cxx/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi Rserve/man/0000755000176000001440000000000012205226215012320 5ustar ripleyusersRserve/man/Rserv.Rd0000644000176000001440000000524312205226215013714 0ustar ripleyusers\name{Rserve} \title{Server providing R functionality to applications via TCP/IP or local unix sockets} \alias{Rserve} \usage{ # R CMD Rserve [] Rserve(debug = FALSE, port, args = NULL, quote=(length(args) > 1), wait, ...) } \description{ Starts Rserve in daemon mode (unix only). Any additional parameters not related to Rserve will be passed straight to the underlying R. For configuration, usage and command line parameters please consult the online documentation at http://www.rforge.net/Rserve. Use \code{R CMD Rserve --help} for a brief help. The \code{Rserve} function is provided for convenience only. On Windows the \code{Rserve()} function sets up the \code{PATH} to include the current R.DLL so that Rserve can be run. } \arguments{ \item{debug}{determines whether regular Rserve or debug version of Rserve (\code{Rserve.dbg}) should be started.} \item{port}{port used by Rserve to listen for connections. If not specified, it will be taken from the configuration file (if present) or default to 6311} \item{args}{further arguments passed to Rserve (as a string that will be passed to the \code{system} command - see \code{quote} below).} \item{quote}{logical, if \code{TRUE} then arguments are quoted, otherwise they are just joined with spaces} \item{wait}{wait argument for the \code{\link{system}} call. It defaults to \code{FALSE} on Windows and \code{TRUE} elsewhere.} \item{\dots}{other arguments to be passes to \code{\link{system}}.} } \details{ Rserve is not just a package, but an application. It is provided as a R package for convenience only. For details see http://www.rforge.net/Rserve } \note{ \code{R CMD Rserve} will only work on unix when installed from \emph{sources} and with sufficient permissions to have write-rights in \code{$R_HOME/bin}. Binary installations have no way to write in \code{$R_HOME/bin} and thus \code{Rserve()} function described above is the only reliable way to start \code{Rserve} in that case. Java developers may want to see the \code{StartRserve} class in \code{java/Rserve/test} examples for easy way to start \code{Rserve} from Java. Rserve can be compiled with TLS/SSL support based on OpenSSL. Therefore the following statements may be true if Rserve binaries are shipped together with OpenSSL: This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/). This product includes cryptographic software written by Eric Young (eay@cryptsoft.com). This product includes software written by Tim Hudson (tjh@cryptsoft.com). They are not true otherwise. } \seealso{\code{\link{run.Rserve}}} \author{Simon Urbanek} \keyword{interface} Rserve/man/run.Rserve.Rd0000644000176000001440000000273212205226215014664 0ustar ripleyusers\name{run.Rserve} \alias{run.Rserve} \title{ Start Rserve within the current R process. } \description{ \code{run.Rserve} makes the current R process into an Rserve instance. Rserve takes over until it is shut down or receives a user interrupt signal. The main difference between \code{\link{Rserve}} and \code{run.Rserve} is that \code{Rserve} starts a new process, whereas \code{run.Rserve} turns the current R session into Rserve. This is only possible if there are no UI elements or other parts that could interfere with the prepation of \code{Rserve}. } \usage{ run.Rserve(..., config.file = "/etc/Rserve.conf") } %- maybe also 'usage' for other objects documented here. \arguments{ \item{\dots}{ all named arguments are treated as entries that would be otherwise present in the configuration file. So argument \code{foo="bar"} has the same meaning as \code{foo bar} in the configuration file. The only exception is that logical values can be used instead of \code{enable}/\code{disable}. Some settings such as \code{uid} are not relevant and thus ignored. } \item{config.file}{ path of the configuration file to load in the Rserve. It will be loaded before the above settings and is optional, i.e. if the file is not present or readable it will be ignored. } } %\details{ %} \value{ Returns \code{TRUE} after the Rserve was shut down. } %\references{ %} \author{Simon Urbanek} \seealso{ \code{\link{Rserve}} } \keyword{interface} Rserve/man/self.Rd0000644000176000001440000000454012205226215013543 0ustar ripleyusers\name{self} \title{Functions usable for R code run inside Rserve} \alias{self.ctrlEval} \alias{self.ctrlSource} \alias{self.oobSend} \alias{self.oobMessage} \usage{ self.ctrlEval(expr) self.ctrlSource(file) self.oobSend(what, code = 0L) self.oobMessage(what, code = 0L) } \description{ The following functions can only be used inside Rserve, they cannot be used in stand-alone R. They interact with special features of Rserve. All commands below will succeed only if Rserve has been started with \code{r-control enable} configuration setting for security reasons. \code{self.ctrlEval} issues a control command to the Rserve parent instance that evaluates the given expression in the server. The expression is only queued for evaluation which will happen asynchronously in the server (see \code{RSserverEval} in \code{RSclient} package for details). Note that the current session is unaffected by the command. \code{self.ctrlSource} issues a control command to the Rserve parent instance to source the given file in the server, see \code{RSserverSource} in the \code{RSclient} package for details. \code{self.oobSend} sends a out-of-band (OOB) message with the encoded content of \code{what} to the client connected to this session. The OOB facility must be enabled in the Rserve configuration (using \code{oob enable}) and the client must support OOB messages for this to be meaningful. This facility is not used by Rserve itself, it is offered to specialized applications (e.g. \code{Cairo} supports asynchronous notification of web clients using WebSockets-QAP1 tunnel to dynamically update graphics on the web during evaluation). \code{self.oobMessage} is like \code{self.oobSend} except that it waits for a response and returns the response. } \arguments{ \item{expr}{R expression to evaluate remotely} \item{file}{path to a file that will be sourced into the main instance} \item{what}{object to include as the payload fo the message} \item{code}{user-defined message code that will be ORed with the \code{OOB_SEND}/\code{OOB_MSG} message code} } \value{ \code{oobMessage} returns data contained in the response message. All other functions return \code{TRUE} (invisibly). } \examples{ \dontrun{ self.ctrlEval("a <- rnorm(10)") self.oobSend(list("url","http://foo/bar")) } } \author{Simon Urbanek} \keyword{interface} Rserve/configure.win0000755000176000001440000000063012205226215014247 0ustar ripleyusers#!/bin/sh echo '--- Rserve for Windows ---' echo '' echo '** MAKE SURE YOU READ THE RSERVE RELEASE NOTES FOR WINDOWS !! **' echo '** Rserve for Windows is different in several aspects **' echo '** from the unix version, see **' echo '** http://rforge.net/Rserve/rserve-win.html **' echo '' mkdir inst 2>/dev/null cp -R src/client inst/ 2>/dev/null Rserve/cleanup0000755000176000001440000000017113442516164013132 0ustar ripleyusers#!/bin/sh #rm -f config.log config.status *~ #cd src; make clean ; cd .. find . -name \*~ -or -name .#\* | xargs rm -f Rserve/LICENSE0000644000176000001440000004072612205226215012563 0ustar ripleyusers [Summary: GPL-2 with OpenSSL linking exception] Rserve Copyright (C) 2002-2013 Simon Urbanek This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. In addition, as a special exception, the copyright holders give permission to link the code of portions of this program with the OpenSSL project's "OpenSSL" library (or with modified versions of it that use the same license as the "OpenSSL" library - see http://www.openssl.org/), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than OpenSSL. If you modify file(s) with this exception, you may extend this exception to your version of the file(s), but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. If you delete this exception statement from all source files in the program, then also delete it here. Full text of GPL-2 follows: GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Rserve/INDEX0000644000176000001440000000015412205226215012337 0ustar ripleyusersRserve Server providing R functionality to applications via TCP/IP Rserve/clients.txt0000644000176000001440000000325212205226215013751 0ustar ripleyusersRserve is a binary R server that listens to clients and processes their requests. The Rserve package primarity builds the server which can be the started using R CMD Rserve or via the Rserve() function in R. Clients programs that connect to a running Rserve and submit requests for computation. The Rserve protocol is open source, so anyone is free to write a client, but Rserve package comes with three clients: - Java client in src/client/java - C++ client in src/client - simple R client part of the Rserve R package Java client ============= The most sophisticated client is the Java client which allows any Java application to use R facilities without linking directly to R. It supports the full range of Rserve functionality and is located in src/client/java It can be compiled into a JAR file by typing "make" in the src/client/java directory. The resulting file JRcleint.jar is all that is needed. JavaDoc documentation can be generated using "make doc". C++ client ============ The C++ client is located in the src/client directory and will be compiled if --with-client is specified upon installation. Alternatively it can be compiled manually by typing "make" in src/client after configure script was run. See ReadMe.txt in src/client for details. R client ========== The Rserve package also includes a simple R client, i.e. it allows you to connect to Rserve from R itself. It is very simple and limited, because Rserve was not primarily meant for R-to-R communication (there are better ways to do that), but it is useful for quick interactive connection to an Rserve farm. See ?RSconnect in R after loading the Rserve package. --- Simon Urbanek, 2006-11-30