我写了以下递归输入验证器,它适用于我.有没有更好的方法来访问每个dom元素并检查它是否是输入字段并验证它?
function formValidator(parent)
{
//base case no children
if( parent.children().length == 0)
return
//recurse through each childs' child
parent.children().each(function(){
formValidator($(this));
/**
* Work : check if this node is an input node
*/
if($(this).is("input"))
{
var type = $(this).attr('type');
if(type =="text")
//do work bro
}
});//end for each
}
Run Code Online (Sandbox Code Playgroud) 我在Linux内核模块内调用系统调用时遇到一些困难.系统调用已经过测试,并且可以从标准的c用户空间程序中正常工作,但我似乎无法获得内核模块来编译和运行它们.
在我的用户程序中,我包含以下代码,系统调用有效:
#include <linux/unistd.h>
#define __NR_sys_mycall 343
extern long int _syscall(long int_sysno,...)__THROW;
//and then a simple call is done as such
long value = syscall(__NR_sys_mycall);
printf("The value is %ld\n",value);
Run Code Online (Sandbox Code Playgroud)
但是当我在我的Linux内核模块中尝试相同的事情时,我得到了一堆错误,或者说错误:隐式声明函数'syscall'(如果我不包括_syscall定义)或一长串关于语法的错误if我...所以我的假设是我需要内核空间版本来调用系统调用.我是对还是错?
//My LKM code
#include <linux/module.h>
#include <linux/unistd.h>
#define __NR_sys_mycall 343
static int start_init(void)
{
long value = syscall(__NR_sys_mycall);
printk("The value is %ld\n",value);
return 0;
}
static void finish_exit(void)
{
printk("Done!\n");
}
module_init(start_init);
module_exit(finish_exit);
Run Code Online (Sandbox Code Playgroud) 我有一个 Makefile,我已将其复制并在我用 C for Linux 编写的许多小程序中使用。遗憾的是,我不了解它如何工作的每个细节,我通常只是注释掉输出文件的名称并插入我想要的名称,它就可以成功编译我的程序。我想使用这些说明:
使用命令行编译器的用户通常会使用“/I%SQLAPIDIR%\include”或“-I${SQLAPIDIR}/include”等选项。头文件位于 SQLAPI++ 发行版的 include 子目录中
这样我的 Makefile 就会在编译时添加库。我检查了这个网站并找到了以下链接,但它们没有帮助:
我尝试包含该目录......
OBJS = testql.o
CC = g++
DEBUG = -g
SQLAPI=/home/developer/Desktop/ARC_DEVELOPER/user123/testsql/SQLAPI
CFLAGS = -I${SQLAPI}/include -Wall -c $(DEBUG)
LFLAGS = -Wall $(DEBUG)
testql: $(OBJS)
$(CC) $(LFLAGS) $(OBJS) -o testql
clean:
rm -f testql *.o *~ core
Run Code Online (Sandbox Code Playgroud)
当我运行下面的代码时,出现错误:
[developer@localhost testql]$ make
g++ -c -o testql.o testql.cpp
testql.cpp:2:44: fatal error: SQLAPI.h: No such file or directory
#include <SQLAPI.h> // main …Run Code Online (Sandbox Code Playgroud) c ×1
c++ ×1
gcc ×1
html ×1
javascript ×1
jquery ×1
linux ×1
linux-kernel ×1
makefile ×1
recursion ×1
system-calls ×1