[plt-scheme] mzc mzscheme c-lambda c-declare (lib "cffi.ss" "compiler" ) troubleshoting

From: pbx tsx (pbx06 at hotmail.com)
Date: Sun Apr 4 17:12:34 EDT 2004

hello

i am a student who is trying to code a distributed password cracker
(client & server that co-ordinate the task of exaustive key space searching)
for the annual projet contest of the university of Nice in FRANCE.

I encourted some problems when interfacing my scheme code with "the c code 
of the UNIX crypt function".


$>cat pass.scm
(module crypt mzscheme
  (require (lib "cffi.ss" "compiler" ))
  (c-declare "#include <stdio.h>")
  (c-declare "#include <time.h>")
  (c-declare "#include <unistd.h>")
  ;// char *crypt(const char *key, const char *salt) ;   //CRYPT(3)
  (define crypt-me (c-lambda (char-string char-string) char-string "crypt"))
)



$mzc pass.scm
MzScheme compiler (mzc) version 206p1, Copyright (c) 2004 PLT Scheme, Inc.
"pass.scm":
[output to "./pass.so"]



$cat test.scm
(load-extension "pass.so")
(begin
  (display (crypt "sa" "secret"))
  (newline)
)

$mzscheme -r test.scm
load-extension: couldn't open "/home/pbx06/coding/pass.so" 
(/home/pbx06/coding/pass.so: undefined symbol: crypt)



i am sure i made a mistake somewhere.
i will thankfull if someone can help me to figure out what went wrong.

the following c code is OK ans is what i meant to do in scheme:
>cat pass.c
#define _XOPEN_SOURCE
#include <unistd.h>
int  main (int argc, char **argv)
{
  char *password;
  /* argv[2] is my password. argv[1] is salt. */
  password = crypt(argv[2],argv[1]);
  /*print the result*/
  puts(password);
  return 0;
}

$gcc pass.c -o pass -l crypt
$./pass sa secret
saHW9GdxihkGQ

_________________________________________________________________
MSN Search, le moteur de recherche qui pense comme vous !  
http://search.msn.fr



Posted on the users mailing list.