/* * * client part of the communication between card client and register server * * by MagicalFred Dec, 98 * */ defcom CsendBitmapCli = sendBitmapCli I S ;; defcom CendBitmap = endBitmap ;; defcom CaskFavorite = askInfoFavorite S S S ;; defcom CaskBitmap = askBitmap S I I ;; var numfavorite = 0 ;; var askedbmp = 0 ;; /* return proc from the send of the bmp signature */ /* if 0 it means the server ask the new bitmap, if 1, it means bitmaps are ok */ fun __bitmapOk(i)=if i == 0 then let _FILEOpen _channel _checkpack bitmapS -> F in ( _FILESeek F 0 0 ; let _FILESize F -> siz in let _FILERead F 1000 -> s in _on channelA CsendBitmapCli [ 0 s ] ; _FILEClose F ; 0 ) else ( let hd listFAV -> f in _on _channel CaskFavorite [ f.authorFAV f.sitenameFAV f.emailFAV ] ; set numfavorite = 0 ) ;; /* return proc : the server ask the next part of the bitmap */ fun __askBitmapCli (len)= let _FILEOpen _channel _checkpack bitmapS -> F in ( if len >= _FILESize F then ( _on _channel CendBitmap [] ) else ( _FILESeek F len 0 ; let _FILERead F 1000 -> s in _on channelA CsendBitmapCli [ len s ] ) ; _FILEClose F ) ;; fun __askFavorite ()= let hd listFAV -> f in _on _channel CaskFavorite [ f.authorFAV f.sitenameFAV f.emailFAV ] ; set numfavorite = 0 ;; fun __infoFavorite (id,message,ip,last,bitmap,signature)= let nth_list listFAV numfavorite -> f in ( set f.messageFAV = message ; set f.ipFAV = ip ; set f.lastFAV = last ; set f.idnumFAV = id ; set f.bitmapFAV = bitmap ; set f.signatureFAV = signature ; if signature != nil then let _getlongname _getpack _checkpack bitmap bitmap "#" -> signature2 in if !strcmp signature signature2 then 0 else /* ask the bitmap to the directory */ ( _on _channel CaskBitmap [ bitmap id 0 ] ; set askedbmp = askedbmp + 1 ) else 0 ) ; set numfavorite = numfavorite + 1 ; let nth_list listFAV numfavorite -> f in if f != nil then (_on _channel CaskFavorite [ f.authorFAV f.sitenameFAV f.emailFAV ] ; 0) else if askedbmp == 0 then _closechannel else 0 ;; fun __endBitmap(name,id)= set askedbmp = askedbmp - 1 ; if askedbmp == 0 then _closechannel else 0 ;; fun __sendBitmap(name,id,s,pos)= _appendpack s _getmodifypack name ; _on _channel CaskBitmap [ name id pos ] ;; fun __wrongPass()= WrongPassword ; _closechannel ; 0 ;;