mirror of
https://github.com/eddyem/eddys_snippets.git
synced 2026-03-22 09:40:55 +03:00
add anonymous UNIX-sockets
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.15.1, 2022-01-24T14:33:13. -->
|
||||
<!-- Written by QtCreator 6.0.0, 2022-02-03T13:42:08. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
@@ -115,6 +115,7 @@
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Default</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericBuildConfiguration</value>
|
||||
|
||||
@@ -77,10 +77,19 @@ static int CANsend(int sock, char *cmd){
|
||||
|
||||
int start_socket(char *path, CANcmd mesg, int par){
|
||||
FNAME();
|
||||
if(!path) return 1;
|
||||
int sock = -1;
|
||||
struct sockaddr_un saddr = {0};
|
||||
saddr.sun_family = AF_UNIX;
|
||||
strncpy(saddr.sun_path, path, 106); // if sun_path[0] == 0 we don't create a file
|
||||
if(*path == 0){ // if sun_path[0] == 0 then don't create a file
|
||||
DBG("convert name");
|
||||
saddr.sun_path[0] = 0;
|
||||
strncpy(saddr.sun_path+1, path+1, 105);
|
||||
}else if(strncmp("\\0", path, 2) == 0){
|
||||
DBG("convert name");
|
||||
saddr.sun_path[0] = 0;
|
||||
strncpy(saddr.sun_path+1, path+2, 105);
|
||||
}else strncpy(saddr.sun_path, path, 106);
|
||||
if((sock = socket(AF_UNIX, SOCK_SEQPACKET, 0)) < 0){ // or SOCK_STREAM?
|
||||
LOGERR("socket()");
|
||||
ERR("socket()");
|
||||
|
||||
Reference in New Issue
Block a user