Skip to content

Instantly share code, notes, and snippets.

@drex44
Created March 7, 2016 07:35
Show Gist options
  • Save drex44/253eaf6733be2dd527d5 to your computer and use it in GitHub Desktop.
Save drex44/253eaf6733be2dd527d5 to your computer and use it in GitHub Desktop.
Error while executing exec loader.sce
addinter(libbuild_lib_path + filesep() + 'libbuild_lib' + getdynlibext(), 'libbuild_lib', list_functions);
Link failed for dynamic library '/home/dhanraj/gsoc/scilab/scilab/scilab/modules/sha256//libbuild_lib.so'.
An error occurred: /home/dhanraj/gsoc/scilab/scilab/scilab/modules/sha256//libbuild_lib.so: undefined symbol: sha256
Link failed for dynamic library '/home/dhanraj/gsoc/scilab/scilab/scilab/modules/sha256//libbuild_lib.so'.
An error occurred: /home/dhanraj/gsoc/scilab/scilab/scilab/modules/sha256//libbuild_lib.so: undefined symbol: sha256
at line 15 of executed file /home/dhanraj/gsoc/scilab/scilab/scilab/modules/sha256/loader.sce
addinter: The shared archive was not loaded: (null)
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "openssl/sha.h"
#include "api_scilab.h"
#include "Scierror.h"
#include "sha256.h"
char* getSHA256(char *fname, void* pvApiCtx)
{
SciErr sciErr;
////////// Variables declaration //////////
int *piAddressVarOne = NULL;
char *string = NULL;
char *hash = NULL;
int iRet = 0;
CheckInputArgument(pvApiCtx, 1, 1) ;
CheckOutputArgument(pvApiCtx, 1, 1) ;
sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
if (sciErr.iErr)
{
printError(&sciErr, 0);
return 0;
}
if ( !isStringType(pvApiCtx, &piAddressVarOne))
{
Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"),fname , 1);
return 0;
}
//printf("Enter String :");
//scanf("%s",&string);
/*sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne,&m1,&n1,&lenStVarOne,&pStVarOne);
if(sciErr.iErr)
{
printError(&sciErr, 0);
return 0;
}
*/
if(isScalar(pvApiCtx, piAddressVarOne))
{
iRet = getAllocatedSingleString(pvApiCtx, piAddressVarOne, &string);
if(iRet)
{
freeAllocatedSingleString(string);
return iRet;
}
hash = sha256(&string);
iRet = createSingleString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, hash);
if(iRet)
{
freeAllocatedSingleString(hash);
return iRet;
}
}
/* alloc string */
//pStVarOne = (char*)MALLOC(sizeof(char)*(lenStVarOne + 1));
/* get string One */
/*
sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne,&m1,&n1,&lenStVarOne,&pStVarOne);
if(sciErr.iErr)
{
printError(&sciErr, 0);
return 0;
}
*/
AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
ReturnArguments(pvApiCtx);
return 0;
}
files=["getSHA256.c"];
// TODO: WTF ?
WITHOUT_AUTO_PUTLHSVAR = %t;
ilib_build('build_lib',['sha256','getSHA256'],files,[]);
exec loader.sce
/* ==================================================================== */
/* SHA256 Function */
/* This file is released under the 3-clause BSD license. See COPYING-BSD. */
/* ==================================================================== */
#include "string.h"
#include "stdlib.h"
#include "openssl/sha.h"
#include "api_scilab.h"
/* ==================================================================== */
char* sha256(char *string) {
unsigned char digest[SHA256_DIGEST_LENGTH];
//const char* string ="gsoc";
//printf("Enter String :");
//scanf("%s",&string);
SHA256_CTX ctx;
SHA256_Init(&ctx);
SHA256_Update(&ctx, string, strlen(string));
SHA256_Final(digest, &ctx);
static char mdString[SHA256_DIGEST_LENGTH*2+1];
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++)
sprintf(&mdString[i*2], "%02x", (unsigned int)digest[i]);
return (char *)mdString;
}
/* ==================================================================== */
/* ==================================================================== */
/* This file is released under the 3-clause BSD license. See COPYING-BSD. */
/* ==================================================================== */
/**
* multiplybypi function
* @param[in] string a character pointer
* @return SHA256 hash value of input string
*/
char* sha256(char *String);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment