
C/C++
虾虾林
这个作者很懒,什么都没留下…
展开
-
ps+grep判断进程是否存在
如果知道进程号的话,直接去判断/proc/下查找对应进程号文件是否存在即可(见5),但是当进程号不知道,只知道进程名称的时候,可以用这个方法。有时候,我们在线上查日志定位问题的时候,经常会使用cat xxxx.log |grep yyyy命令,如果grep的时候,想排除某些字段,那么可以如下操作:cat test.log | grep "login"|grep -v "deviceTyp...原创 2020-01-04 10:37:58 · 2625 阅读 · 0 评论 -
jpeg二进制数据转base64后在前端显示
需求:前端从后端获取图片。背景:后端数据均保存在硬盘里,从硬盘取出后的Jpeg图片,二进制数据传输给前端显示图片直接二进制传输,中间层需要兼容,想着直接转base64字符串,js刚好可以直接显示图片Bse64是一种以64个可打印字符对二进制数据进行编码的编码算法。base64在对数据进行编码时以三个8位字符型数据为一组,取这三个字符型数据的ASCII码,然后以6位为一组组成4个新...原创 2019-11-01 09:56:02 · 2006 阅读 · 0 评论 -
epoll建立服务器
服务端static int failover_read_from_tcp(int fd, char * buf, int size){ int offset = 0; int bytes; int wanted = size; while (wanted > 0) { bytes = read(fd, buf+offset, wanted); if (bytes &...原创 2018-11-22 16:27:27 · 168 阅读 · 0 评论 -
【QT】QListWidget 删除或者隐藏行
1、删除行QListWidgetItem *item1,*item2,*item3;item1 = ui->listWidget->takeItem(0);ui->listWidget->removeItemWidget(item1);delete item1; item2 = ui->listWidget->takeItem(0...原创 2018-11-29 10:57:35 · 12867 阅读 · 0 评论 -
linux下时间函数
void get_local_time(long sec, char *plocaltime, int len){ struct tm t1 = {0}; localtime_r(&sec, &t1); snprintf(plocaltime, len, "%04d-%02d-%02d %02d:%02d:%02d", t1.tm_year+1900, t1.tm...原创 2018-12-07 09:52:17 · 198 阅读 · 0 评论 -
【Linux】快速保存pid号到文件&查询进程是否存在
快速保存pid号到文件#define MS_GUI_PID "/tmp/gui"int ms_system(const char* cmd){ if (!cmd) return -1; int res = 0; int status = 0; pid_t pid = vfork(); struct rusage info; memset(&info, ...原创 2018-12-27 09:13:34 · 1336 阅读 · 0 评论 -
模块化代码(封装 __attribute__ constructor&destructor )
constructor / destructor意思是: 构造器和析构器;constructor修饰的函数会在main函数之前执行,destructor修饰的函数会在程序exit前调用.示例如下:int main(int argc, char * argv[]) { @autoreleasepool { NSLog(@"main"); retur...原创 2019-02-28 20:14:30 · 339 阅读 · 0 评论 -
gdb调试
参考http://beej.us/guide/bggdb/#compilinghttps://blog.youkuaiyun.com/liigo/article/details/582231/http://blog.jobbole.com/107759/gdb 最直观的作用就是能快速的定位到段错误的位置,前提是编译的时候有加上 -g,如果遇到开源的代码,那。。只能反汇编慢慢找了...原创 2019-02-28 21:13:03 · 843 阅读 · 0 评论 -
__attribute__ 总结
attribute是GNU C特色之一,在iOS用的比较广泛.系统中有许多地方使用到. attribute可以设置函数属性(Function Attribute )、变量属性(Variable Attrib转载 2019-02-26 14:51:24 · 475 阅读 · 0 评论 -
socket 子进程bind端口占用问题
发现一个socket参数可以在子进程运行的时候可以不继承父进程(FORK)的句柄,父进程退出、子进程未退出的情况下,可以在下次父进程重新运行时,再次bind的时候不会失败。/* close server socket on exec so cgi's can't write to it*/if (fcntl(server_s, F_SETFD, 1) == -1){ msprin...原创 2019-06-05 11:34:57 · 1243 阅读 · 0 评论 -
ppp-2.4.5移植(交叉编译)
移植无非就三个步骤1、./configure2、make3、make install正常情况下在步骤1可以指定编译器,CC=xxxx之类,或者直接指定host名称,一般--host=xxxxx指定后,对应的编译器就不用指定了,会默认xxxx-gcc,裁剪也会默认用xxxx-strip,但是!!!ppp不支持选项‘--host=’选项,只支持‘--prefix=’,所以步骤1无法指定...原创 2019-09-25 18:01:57 · 2653 阅读 · 1 评论 -
【QT】ui设计界面 创建信号与槽 原理
https://blog.youkuaiyun.com/u013378306/article/details/52431826转载 2018-11-08 13:32:40 · 1754 阅读 · 0 评论 -
【Nginx】海思3536&3798移植Nginx
https://download.youkuaiyun.com/download/y7u8t6/10761125原创 2018-11-02 18:11:38 · 711 阅读 · 0 评论 -
【QT】触发信号时获取控件对象
snapshotBox = new CustomCheckBox [sys_info.max_cameras];for (int i(0); i < sys_info.max_cameras && i < MAX_CAMERA; i++){ (this->snapshotBox+i)->setText(QString("%1").arg(i +...原创 2018-11-02 16:47:44 · 1344 阅读 · 0 评论 -
Linux 获取IPv6网关
基于hisi3536实现的,ubuntu下只要找到对应的配置文件(ipv6_route)即可#include <stdio.h>#include <unistd.h>#include <pthread.h>#include <stdlib.h>#include <string.h>#include <sys/prct...原创 2018-10-09 10:32:21 · 5901 阅读 · 0 评论 -
IPv6 Scope:Link连接问题
Linux中设置的IPv6地址有两种类型,一种是Scope:Global,另一种为Scope:Link。后者是有MAC地址通过一定的格式转换出来的全球唯一的本地链路地址。~ # ifconfigeth0 Link encap:Ethernet HWaddr 1C:C3:16:63:B1:72 inet addr:192.168.9.51 Bcast...原创 2018-10-09 10:31:55 · 18990 阅读 · 0 评论 -
线程
#include <stdlib.h>#include <stdio.h>#include <pthread.h> //thread#include <unistd.h> //syscall#include <sys/syscall.h>#include <sys/prctl.h> //prctl...原创 2018-10-09 10:31:15 · 129 阅读 · 0 评论 -
snmp移植
1.源码安装包 http://www.net-snmp.org/download.html或者https://download.youkuaiyun.com/download/y7u8t6/10707891 2.交叉编译root@IT-PC-135:/home/user1/hong/smdd/arm_for_snmp/net-snmp-5.7.2.1#./configure --...原创 2018-10-09 10:30:45 · 576 阅读 · 0 评论 -
hisi 配置静态IP地址
静态IP地址配置文件路径 /etc/network/interfacesinterfaces格式#设置单个ipv4地址The loopback interfaceauto loiface lo inet loopback auto eth0iface eth0 inet staticaddress 192.168.9.51netmask 255.255.252....原创 2018-10-09 10:47:52 · 1368 阅读 · 0 评论 -
ubuntu下IPv6查询相关命令
查询默认网关 /sbin/ip -6 route show dev eth0/bin/ip -6 route show dev eth0/bin/ip route show dev eth0/sbin/ip route show dev eth0ip -6 addr show eth0 添加网关route -A inet6 add default gw 2001:f...原创 2018-10-09 10:55:17 · 2898 阅读 · 0 评论 -
c语言判断格式是否IPv6
int net_is_validipv6(const char *hostname){ struct sockaddr_in6 addr; if (!hostname) return -1; if (strchr(hostname, '.')) return -1;//暂时排除::ffff:204.152.189.116 if (inet_pton(AF_INET6, hostna...原创 2018-10-25 08:49:16 · 2988 阅读 · 1 评论 -
【QT】新弹窗默认无焦点
1.新窗口界面focusPolicy设置为StrongFocus2.重写showEvent函数void ResetPasswordDialog::showEvent(QShowEvent *e){ if(this->focusWidget()){ this->focusWidget()->clearFocus(); } ui-&...原创 2018-10-26 15:01:58 · 5375 阅读 · 0 评论 -
system function
1.systemint xx_system(const char* cmd){ if (!cmd) return -1; int res = 0; int status = 0; pid_t pid = vfork(); struct rusage info; memset(&info, 0, sizeof(struct rusage)); if (pid...原创 2018-10-30 09:43:25 · 563 阅读 · 0 评论 -
线程2
#define TASK_OK 0#define TASK_ERROR -1int ms_task_set_name(const char* name);#define TASK_HANDLE pthread_tint ms_task_create(TASK_HANDLE *handle, void *(*func)(void *), void *arg);//detachedint ...原创 2018-10-30 13:38:29 · 186 阅读 · 0 评论 -
repost
完整linux学习笔记 https://mubu.com/doc/explore/17005linux目录结构详细介绍http://blog.51cto.com/yangrong/1288072linux系统目录详解 http://blog.51cto.com/ctohf/907442亿图9.2完美破解版 https://www.cnblogs.com/byronliu029/p/9...原创 2018-10-30 16:51:21 · 508 阅读 · 0 评论 -
【shell】海思3536 多网卡绑定聚合——bond技术
0.原理说明目前网卡绑定mode共有七种(0~6)bond0、bond1、bond2、bond3、bond4、bond5、bond6常用的有三种:mode=0:平衡负载模式,有自动备援,但需要”Switch”支援及设定。mode=1:自动备援模式,其中一条线若断线,其他线路将会自动备援。mode=6:平衡负载模式,有自动备援,不必”Switch”支援及设定。海斯3536 启...原创 2018-11-01 15:40:29 · 1813 阅读 · 0 评论 -
海思3536&3798 DHCPv6移植
1.源码地址https://download.youkuaiyun.com/download/y7u8t6/10758248 2.交叉编译一、libnl 1.11.解压libnl-1.1.tar.gz 到指定目录下 ../libnl_pro2.修改libnl_pro内的文件 **** .../libnl_pro/lib/route/link/vlan.c **** #i...原创 2018-11-01 15:58:52 · 1546 阅读 · 0 评论 -
linux下获取本机IPv6地址、前缀、网关
获取本机IPv6信息命令:cat /proc/net/if_inet6root@IT-PC-135:/home/user1/# cat /proc/net/if_inet6 fe80000000000000922b34fffe4e70f4 02 40 20 80 eth020010f80075400000000000000000050 02 40 00 80 eth00...原创 2018-10-09 10:27:05 · 29133 阅读 · 1 评论