...
|
...
|
@@ -3009,6 +3009,7 @@ re_socketinit(re_t *re,char *filename)
|
3009
|
3009
|
if(select(oldfd+1,NULL,&writeset,NULL,&tv)>0) {
|
3010
|
3010
|
comms->socketfilename[0]='\0';
|
3011
|
3011
|
fprintf(stderr,"WARNING: There is a process using the communication socket for the file\n");
|
|
3012
|
+#warning TODO: if the unix domain socket is in use, connect to it and warn that I''m also able to service that filename, so (1) it forwards the petitions, and (2) be waware of when the other process quits to retake control of the unix domain socket
|
3012
|
3013
|
return(-1);
|
3013
|
3014
|
}
|
3014
|
3015
|
close(oldfd),oldfd=-1;
|
...
|
...
|
@@ -3214,12 +3215,33 @@ int
|
3214
|
3215
|
re_socketin(re_t *re, int nclient, char *line)
|
3215
|
3216
|
{
|
3216
|
3217
|
/* note that the '\n' delimiter has been already removed */
|
3217
|
|
-#warning TODO
|
3218
|
|
-#warning Test with "socat - UNIX-CONNECT:/tmp/.re_${USER}/filename.ext"
|
|
3218
|
+ /* Commands can be sent from the command line using socat as in: */
|
|
3219
|
+ /* "socat - UNIX-CONNECT:/tmp/.re_${USER}/filename.ext" */
|
|
3220
|
+ char *ptr;
|
3219
|
3221
|
#if 1
|
3220
|
|
-
|
3221
|
3222
|
fprintf(stderr,"Received from client \"%s\" (%i).\n",line,nclient);
|
3222
|
3223
|
#endif
|
|
3224
|
+ if(memcmp(line,"goto ",5)==0) {
|
|
3225
|
+ int oldline;
|
|
3226
|
+ ptr=line+5;
|
|
3227
|
+ /* change line */
|
|
3228
|
+ re->command=COMMAND_GOTOLINE;
|
|
3229
|
+ strncpy(re->commandbuf,ptr,sizeof(re->commandbuf));
|
|
3230
|
+ re->commandbuf[sizeof(re->commandbuf)-1]='\0';
|
|
3231
|
+ oldline=re->curline;
|
|
3232
|
+ re_processcommand(re);
|
|
3233
|
+ if(oldline!=re->curline) {
|
|
3234
|
+ /* position the cursor near the top of the window */
|
|
3235
|
+ re->originline=re->curline-3;
|
|
3236
|
+ re->originline=(re->originline<0)?0:re->originline;
|
|
3237
|
+ }
|
|
3238
|
+ /* send end-of-results */
|
|
3239
|
+ re_socketout(re, nclient, "\n");
|
|
3240
|
+ } else {
|
|
3241
|
+#if 1
|
|
3242
|
+fprintf(stderr,"Ignoring unknown command from client \"%s\" (%i).\n",line,nclient);
|
|
3243
|
+#endif
|
|
3244
|
+ }
|
3223
|
3245
|
return(0);
|
3224
|
3246
|
}
|
3225
|
3247
|
|