我试图解析HTML代码,以提取其中的所有链接.为了避免不可用的链接,我删除以开头<!--和结尾的注释代码.-->问题出现了:在HTML代码中我可能会找到一些JavaScript代码,例如:
<html>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
if (document.images) {
var pic2 = new Image(); // for the inactive image
pic2.src = "pic2.jpg";
var title2 = new Image();
title2.src = "title2.jpg";
}
...
-->
Run Code Online (Sandbox Code Playgroud)
奇怪的是,js代码已被注释但它仍然有效.因此,如果我删除该代码,结果将不会如预期的那样.我应该怎么做以确定我何时面对未使用的注释代码以及该注释代码何时起作用?
我有一个最小的,完整的,可验证的例子,我想做什么.
基本上我想实现一个集成了一些CUDA代码的OpenSSL RSA引擎.CUDA部分应该进行模幂运算,但在这个例子中并不重要,所以我只使用了BN_mod_exp(参见engine.c文件,modexp函数)以简化代码.我提供的代码是我项目的简化版本,使用这些命令可以很容易地构建/编译它:
gcc -fPIC -I/usr/local/cuda/include -c engine.c
nvcc --compiler-options '-fPIC' -c my_cuda.cu -lcrypto
g++ -L/usr/local/cuda/lib64 -shared -o gpu.so engine.o my_cuda.o -lcuda -lcudart
openssl engine -t -c `pwd`/gpu.so
Run Code Online (Sandbox Code Playgroud)
...最后一个命令的输出表明RSA引擎可用
/*engine.c*/
#include <openssl/opensslconf.h>
#include <stdio.h>
#include <string.h>
#include <openssl/crypto.h>
#include <openssl/buffer.h>
#include <openssl/engine.h>
#include <openssl/rsa.h>
#include <openssl/bn.h>
#include <openssl/err.h>
#include "my_cuda.h"
/* Constants used when creating the ENGINE */
static const char *engine_e_rsax_id = "rsa_gpu";
static const char *engine_e_rsax_name = "RSAX engine support";
static int modexp(BIGNUM *r, …Run Code Online (Sandbox Code Playgroud)