...
|
...
|
@@ -198,6 +198,7 @@ typedef struct commclient_t {
|
198
|
198
|
typedef struct comms_t {
|
199
|
199
|
int serverfd;
|
200
|
200
|
char id[MAXFILENAMESIZE];
|
|
201
|
+ char selectedid[MAXFILENAMESIZE];
|
201
|
202
|
char socketfilename[SOCKETFILENAMESIZE];
|
202
|
203
|
int sizeclients;
|
203
|
204
|
int usedclients;
|
...
|
...
|
@@ -3278,15 +3279,17 @@ fprintf(stderr,"Received from client \"%s\" (%i).\n",line,nclient);
|
3278
|
3279
|
#if 0
|
3279
|
3280
|
fprintf(stderr,"Changing line because of command from client \"%s\" (%i).\n",line,nclient);
|
3280
|
3281
|
#endif
|
3281
|
|
- re->command=COMMAND_GOTOLINE;
|
3282
|
|
- strncpy(re->commandbuf,ptr,sizeof(re->commandbuf));
|
3283
|
|
- re->commandbuf[sizeof(re->commandbuf)-1]='\0';
|
3284
|
|
- oldline=re->curline;
|
3285
|
|
- re_processcommand(re);
|
3286
|
|
- if(oldline!=re->curline) {
|
3287
|
|
- /* position the cursor near the top of the window */
|
3288
|
|
- re->originline=re->curline-3;
|
3289
|
|
- re->originline=(re->originline<0)?0:re->originline;
|
|
3282
|
+ if(re->comms.selectedid[0]=='\0' || strcmp(re->comms.id,re->comms.selectedid)==0) {
|
|
3283
|
+ re->command=COMMAND_GOTOLINE;
|
|
3284
|
+ strncpy(re->commandbuf,ptr,sizeof(re->commandbuf));
|
|
3285
|
+ re->commandbuf[sizeof(re->commandbuf)-1]='\0';
|
|
3286
|
+ oldline=re->curline;
|
|
3287
|
+ re_processcommand(re);
|
|
3288
|
+ if(oldline!=re->curline) {
|
|
3289
|
+ /* position the cursor near the top of the window */
|
|
3290
|
+ re->originline=re->curline-3;
|
|
3291
|
+ re->originline=(re->originline<0)?0:re->originline;
|
|
3292
|
+ }
|
3290
|
3293
|
}
|
3291
|
3294
|
/* send end-of-results */
|
3292
|
3295
|
re_socketout(re, nclient, "\n");
|
...
|
...
|
@@ -3298,12 +3301,14 @@ fprintf(stderr,"Changing line because of command from client \"%s\" (%i).\n",lin
|
3298
|
3301
|
#endif
|
3299
|
3302
|
if(re->comms.clients[i]==NULL || re->comms.clients[i]->fd==-1 || re->comms.clients[i]->remoteid[0]=='\0')
|
3300
|
3303
|
continue;
|
3301
|
|
- avail=re->comms.clients[i]->sizebufout-re->comms.clients[i]->usedbufout;
|
3302
|
|
- if((strlen(line)+1)>avail) {
|
3303
|
|
- fprintf(stderr,"Couldn't forward command to client because the output buffer is full (avail:%li, req:%li)\n",(long)avail,(long)(strlen(line)+1));
|
3304
|
|
- continue;
|
|
3304
|
+ if(re->comms.selectedid[0]=='\0' || strcmp(re->comms.clients[i]->remoteid,re->comms.selectedid)==0) {
|
|
3305
|
+ avail=re->comms.clients[i]->sizebufout-re->comms.clients[i]->usedbufout;
|
|
3306
|
+ if((strlen(line)+1)>avail) {
|
|
3307
|
+ fprintf(stderr,"Couldn't forward command to client because the output buffer is full (avail:%li, req:%li)\n",(long)avail,(long)(strlen(line)+1));
|
|
3308
|
+ continue;
|
|
3309
|
+ }
|
|
3310
|
+ re_socketout(re, i, "%s\n",line);
|
3305
|
3311
|
}
|
3306
|
|
- re_socketout(re, i, "%s\n",line);
|
3307
|
3312
|
}
|
3308
|
3313
|
} else if(memcmp(line,"id ",3)==0) {
|
3309
|
3314
|
ptr=line+3;
|
...
|
...
|
@@ -3328,6 +3333,24 @@ fprintf(stderr,"Listing ids because of command from client \"%s\" (%i).\n",line,
|
3328
|
3333
|
}
|
3329
|
3334
|
/* send end-of-results */
|
3330
|
3335
|
re_socketout(re, nclient, "\n");
|
|
3336
|
+ } else if(strcmp(line,"select")==0) {
|
|
3337
|
+ /* reset select id */
|
|
3338
|
+#if 0
|
|
3339
|
+fprintf(stderr,"Resetting selected id because of command from client \"%s\" (%i).\n",line,nclient);
|
|
3340
|
+#endif
|
|
3341
|
+ re->comms.selectedid[0]='\0';
|
|
3342
|
+ /* send end-of-results */
|
|
3343
|
+ re_socketout(re, nclient, "\n");
|
|
3344
|
+ } else if(memcmp(line,"select ",7)==0) {
|
|
3345
|
+ ptr=line+7;
|
|
3346
|
+ /* select id */
|
|
3347
|
+#if 0
|
|
3348
|
+fprintf(stderr,"Changing selected id because of command from client \"%s\" (%i).\n",line,nclient);
|
|
3349
|
+#endif
|
|
3350
|
+ strncpy(re->comms.selectedid,ptr,sizeof(re->comms.selectedid));
|
|
3351
|
+ re->comms.selectedid[sizeof(re->comms.selectedid)-1]='\0';
|
|
3352
|
+ /* send end-of-results */
|
|
3353
|
+ re_socketout(re, nclient, "\n");
|
3331
|
3354
|
} else if(line[0]=='\0' ) {
|
3332
|
3355
|
; /* ignore the end-of-message (should only receive them on forwarding clients) */
|
3333
|
3356
|
} else {
|