- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 BSD 平台 (OSX) 上开发的应用程序中使用了出色的 UNIX“comm”命令行实用程序。当我部署到我的 Linux 生产服务器时,我遗憾地发现,Ubuntu Linux 的“comm”实用程序没有使用 -i 标志来指示行比较时不区分大小写。显然 POSIX 标准不需要 -i 选项。
所以……我进退两难了。我真的需要在 BSD 上运行良好的 -i 选项。到目前为止,我一直在尝试在 Linux 机器上编译 BSD comm.c 源代码,但我得到了:
me@host:~$ gcc comm.c
comm.c: In function ‘getline’:
comm.c:195: warning: assignment makes pointer from integer without a cast
comm.c: In function ‘wcsicoll’:
comm.c:264: warning: assignment makes pointer from integer without a cast
comm.c:270: warning: assignment makes pointer from integer without a cast
/tmp/ccrvPbfz.o: In function `getline':
comm.c:(.text+0x421): undefined reference to `reallocf'
/tmp/ccrvPbfz.o: In function `wcsicoll':
comm.c:(.text+0x691): undefined reference to `reallocf'
comm.c:(.text+0x6ef): undefined reference to `reallocf'
collect2: ld returned 1 exit status
对于如何在 Linux 上获得支持“comm -i”的 comm 版本,有人有任何建议吗?
谢谢!
最佳答案
您可以在 comm.c
中添加以下内容:
void *reallocf(void *ptr, size_t size)
{
void *ret = realloc(ptr, size);
if (ret == NULL) {
free(ptr);
}
return ret;
}
你应该可以编译它了。确保 comm.c
有#include <stdlib.h>
在其中(它可能已经这样做了)。
编译失败的原因是 BSD comm.c
使用 reallocf()
这不是标准的 C 函数。但是很容易写。
关于UNIX 'comm' 实用程序允许在 BSD 中不区分大小写,但在 Linux 中不允许(通过 -i 标志)。我如何在 Linux 中获取它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2153371/
几个线程可以在同一个套接字描述符(即accept(sock_fd))上同时操作而无需担心吗? 我最感兴趣的平台是POSIX/Linux。 最佳答案 是的,它们是“可重入的”-内核在处理套接字结构时会锁
具有 '__P' 的 socket.h BSP header 为 int bind __P((int, const struct sockaddr *, socklen_t)) 你能告诉我这里的“__
我有一个服务器: ./server portNumber 我有一个客户: ./client serverIpAddress 我在客户端只有服务器IP地址。我想连接到服务器套接字。但是每次 Server
我在网上找到的所有教程和示例总是指定一个端口号,如 7000 或 4950 等。如果这些端口在一台计算机上打开,但在另一台计算机上打开怎么办?似乎那种情况使这样做成为一个坏主意。有没有办法说“查找并使
我的代码是: int main(int argc, char *argv[]) { int sockfd, new_fd; /* listen on sock_fd, new connect
我知道 Hardened Linux from Scratch project 这是一个为您提供分步说明的项目,用于完全从源代码构建您自己的定制和强化的 Linux 系统。我想知道 BSD 中的等价物
我一直在用 C 编写一些套接字代码。我需要修改数据包 header 并控制它们的发送方式,所以我采用了原始套接字方法。但是,我写的代码无法在 BSD 系统(Mac OS X/Darwin、FreeBS
我想测试BSP API实现的正确性和完整性。 测试集必须针对ARM sam7x进行交叉编译。 最佳答案 我不知道您是否会感兴趣,但是这里有指向纽约BSD session 2008的演讲的两个链接:De
如标题所述,BSD插槽的双工是什么? -并且在同一个 socket 上。 最佳答案 如果阅读socket(2)手册页,您将看到SOCK_STREAM类型的套接字是全双工的。与Windows相同,请参见
当我尝试将数据从我的 tcp 服务器发送到我的 tcp 客户端时,我不断收到“错误的文件描述符”错误。这在套接字方面意味着什么?我在这方面已经有一段时间了,我看不出我的代码有什么问题。它与我两天前使用
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 6年前关闭。 Improve thi
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 关闭 7 年前。 Improve
我在尝试将 BSD 客户端套接字连接到服务器时遇到一些问题。套接字的创建和连接是通过JNI 实现的。实际的连接是通过java代码建立的。 JNI部分: #include #include #inc
我想使用 BSD API 创建一个伪终端。我的理解是,Unix 98 API 将自动使用 posix_openpt() 查找空闲端口,但使用 BSD API 我需要检查/查找要连接的空闲端口。这是正确
我正在尝试熟悉网络 BSD API。我了解提交给 BSD API 的多字节数据(如地址和端口)必须采用网络字节顺序,并且我们应该使用 htons() 和 htonl() 等转换函数来执行此操作。这段代
我有这个命令字符串,它在 OS X 10.6.8 (Snow Leopard) 中运行良好(它告诉我它的 grep 是 grep (GNU grep) 2.5.1)... $ grep -hi 'TE
我遇到了一个有趣的问题。我的系统是华硕笔记本电脑上的 Arch Linux(最新)。现在,真正奇怪的问题是: finger 不会随 Arch 自动安装。我试图使用 pacman 来安装它,但它不在存储
因此,我尝试使用 strcmp 将缓冲区与字符串进行比较。我希望服务器在客户端说"man" 时以特殊方式响应,否则只需回复 got it。我看不出我做错了什么,但即使我从客户端输入 man,我的输
我想参与数据包转发(不是路由)。例如,系统是主机与其网关之间的第 2 层网桥。我想检查第 7 层的字符串或任何“foo”并根据结果转发/丢弃/延迟数据包。我遇到的问题是拦截数据包。 目前我读到的内容:
我想在 BSD 网络堆栈中添加一些我自己的 printf 语句。但是在添加它们之后,我看不到机器控制台上出现的消息。我试图在 netisr ( sys/net/netisr.c ) 中添加一些。甚至找
我是一名优秀的程序员,十分优秀!