2006-01-30 21:43:32 +03:00
|
|
|
/*
|
|
|
|
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
|
|
* See LICENSE file for license details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/Xproto.h>
|
2006-04-25 19:29:54 +04:00
|
|
|
#include <X11/Xlib.h>
|
2006-01-30 21:43:32 +03:00
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
2006-01-31 15:25:23 +03:00
|
|
|
#include "wm.h"
|
2006-01-30 21:43:32 +03:00
|
|
|
|
2006-02-10 00:48:01 +03:00
|
|
|
static char E9pversion[] = "9P version not supported";
|
|
|
|
static char Enoperm[] = "permission denied";
|
|
|
|
static char Enofile[] = "file not found";
|
2006-05-17 12:36:56 +04:00
|
|
|
static char Efidinuse[] = "fid in use";
|
2006-02-10 00:48:01 +03:00
|
|
|
static char Enomode[] = "mode not supported";
|
|
|
|
static char Enofunc[] = "function not supported";
|
|
|
|
static char Enocommand[] = "command not supported";
|
2006-03-11 03:07:19 +03:00
|
|
|
static char Ebadvalue[] = "bad value";
|
2006-02-10 00:48:01 +03:00
|
|
|
|
2006-04-06 09:55:33 +04:00
|
|
|
enum { WMII_IOUNIT = 2048 };
|
2006-02-10 11:13:35 +03:00
|
|
|
|
2006-01-30 21:43:32 +03:00
|
|
|
/*
|
|
|
|
* filesystem specification
|
2006-05-01 21:39:26 +04:00
|
|
|
* / FsDroot
|
|
|
|
* /def/ FsDdef
|
|
|
|
* /def/border FsFborder 0..n
|
|
|
|
* /def/font FsFfont xlib font name
|
2006-04-13 12:06:07 +04:00
|
|
|
* /def/selcolors FsFselcolors selected colors
|
|
|
|
* /def/normcolors FsFnormcolors normal colors
|
2006-05-01 21:39:26 +04:00
|
|
|
* /def/rules FsFrules rules
|
|
|
|
* /def/keys FsFkeys keys
|
|
|
|
* /def/grabmod FsFgrabmod grab modifier
|
|
|
|
* /def/colmode FsFmode column mode
|
|
|
|
* /def/colwidth FsFcolw column width
|
|
|
|
* /tags FsFtags
|
|
|
|
* /bar/ FsDbars
|
2006-04-13 12:06:07 +04:00
|
|
|
* /bar/lab/ FsDbar
|
2006-05-01 21:39:26 +04:00
|
|
|
* /bar/lab/data FsFdata <arbitrary data which gets displayed>
|
|
|
|
* /bar/lab/colors FsFcolors <#RRGGBB> <#RRGGBB> <#RRGGBB>
|
|
|
|
* /client/ FsDclients
|
|
|
|
* /client/1/ FsDGclient see /view/X/X/X/ namespace below
|
|
|
|
* /event FsFevent
|
|
|
|
* /ctl FsFctl command interface (root)
|
|
|
|
* /view/ FsDview
|
|
|
|
* /view/ FsDview
|
|
|
|
* /view/ctl FsFctl command interface (tag)
|
|
|
|
* /view/name FsFname current view name
|
2006-04-13 12:06:07 +04:00
|
|
|
* /view/sel/ FsDarea
|
2006-05-01 21:39:26 +04:00
|
|
|
* /view/1/ FsDarea
|
|
|
|
* /view/1/ctl FsFctl command interface (area)
|
|
|
|
* /view/1/mode FsFmode column mode
|
2006-04-13 12:06:07 +04:00
|
|
|
* /view/1/sel/ FsDclient
|
2006-05-01 21:39:26 +04:00
|
|
|
* /view/1/1/class FsFclass Class:instance of client
|
|
|
|
* /view/1/1/index FsFindex index of client in /client
|
|
|
|
* /view/1/1/name FsFname name of client
|
|
|
|
* /view/1/1/tags FsFtags tag of client
|
|
|
|
* /view/1/geom FsFgeom geometry of client
|
|
|
|
* /view/1/ctl FsFctl command interface (client)
|
2006-01-30 21:43:32 +03:00
|
|
|
*/
|
|
|
|
|
2006-02-06 17:20:25 +03:00
|
|
|
Qid root_qid;
|
2006-02-02 00:24:07 +03:00
|
|
|
const char *err;
|
2006-01-30 21:43:32 +03:00
|
|
|
|
|
|
|
/* IXP stuff */
|
|
|
|
|
2006-03-23 18:07:18 +03:00
|
|
|
/*
|
2006-02-10 17:59:30 +03:00
|
|
|
* Qid->path is calculated related to the index of the associated structure.
|
2006-04-13 18:52:33 +04:00
|
|
|
* i1 is associated to tag, key, global client, or bar
|
2006-02-10 17:59:30 +03:00
|
|
|
* i2 is associated to area
|
|
|
|
* i3 is associated to client
|
2006-03-23 11:54:20 +03:00
|
|
|
* ie /view/sel/ctl is i1id = sel tag id, i2id = sel area id , i3id = 0 (no id)
|
2006-02-10 17:59:30 +03:00
|
|
|
*/
|
2006-02-02 16:50:04 +03:00
|
|
|
unsigned long long
|
2006-05-01 21:39:26 +04:00
|
|
|
pack_qpath(unsigned char type, unsigned short i1id, unsigned short i2id, unsigned short i3id)
|
2006-01-30 21:43:32 +03:00
|
|
|
{
|
2006-03-23 18:07:18 +03:00
|
|
|
return ((unsigned long long) type << 48) | ((unsigned long long) i1id << 32)
|
2006-02-10 17:59:30 +03:00
|
|
|
| ((unsigned long long) i2id << 16) | (unsigned long long) i3id;
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned char
|
2006-05-01 21:39:26 +04:00
|
|
|
unpack_type(unsigned long long path)
|
2006-01-30 21:43:32 +03:00
|
|
|
{
|
2006-03-23 18:07:18 +03:00
|
|
|
return (path >> 48) & 0xff;
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
|
|
|
|
2006-01-31 15:25:23 +03:00
|
|
|
static unsigned short
|
2006-05-01 21:39:26 +04:00
|
|
|
unpack_i1id(unsigned long long path)
|
2006-01-31 15:25:23 +03:00
|
|
|
{
|
2006-03-23 18:07:18 +03:00
|
|
|
return (path >> 32) & 0xffff;
|
2006-01-31 15:25:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned short
|
2006-05-01 21:39:26 +04:00
|
|
|
unpack_i2id(unsigned long long path)
|
2006-01-31 01:48:41 +03:00
|
|
|
{
|
2006-03-23 18:07:18 +03:00
|
|
|
return (path >> 16) & 0xffff;
|
2006-01-31 01:48:41 +03:00
|
|
|
}
|
|
|
|
|
2006-01-30 21:43:32 +03:00
|
|
|
static unsigned short
|
2006-05-01 21:39:26 +04:00
|
|
|
unpack_i3id(unsigned long long path)
|
2006-01-30 21:43:32 +03:00
|
|
|
{
|
2006-03-23 18:07:18 +03:00
|
|
|
return path & 0xffff;
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
|
|
|
|
2006-05-01 21:39:26 +04:00
|
|
|
static unsigned char
|
|
|
|
dir_of_qid(Qid wqid[IXP_MAX_WELEM], unsigned short qsel)
|
|
|
|
{
|
|
|
|
return qsel ? unpack_type(wqid[qsel - 1].path) : FsDroot;
|
|
|
|
}
|
|
|
|
|
2006-02-10 17:59:30 +03:00
|
|
|
static void
|
2006-05-01 21:39:26 +04:00
|
|
|
unpack_qpath(Qid wqid[IXP_MAX_WELEM], unsigned short qsel,
|
|
|
|
unsigned char *type, int *i1, int *i2, int *i3)
|
2006-02-10 17:59:30 +03:00
|
|
|
{
|
2006-05-01 21:39:26 +04:00
|
|
|
unsigned short i1id = unpack_i1id(wqid[qsel].path);
|
|
|
|
unsigned short i2id = unpack_i2id(wqid[qsel].path);
|
|
|
|
unsigned short i3id = unpack_i3id(wqid[qsel].path);
|
|
|
|
*type = unpack_type(wqid[qsel].path);
|
2006-02-10 17:59:30 +03:00
|
|
|
|
|
|
|
if(i1id) {
|
2006-05-01 21:39:26 +04:00
|
|
|
unsigned char dir_type = dir_of_qid(wqid, qsel);
|
|
|
|
if((dir_type == FsDGclient) || (dir_type == FsDclients))
|
2006-04-12 12:44:07 +04:00
|
|
|
*i1 = idx_of_client_id(i1id);
|
2006-03-07 19:22:36 +03:00
|
|
|
else {
|
|
|
|
switch(*type) {
|
2006-05-01 21:39:26 +04:00
|
|
|
case FsFdata:
|
|
|
|
case FsFcolors:
|
|
|
|
case FsDbar: *i1 = idx_of_bar_id(i1id); break;
|
|
|
|
default: *i1 = idx_of_view_id(i1id); break;
|
2006-03-07 19:22:36 +03:00
|
|
|
}
|
2006-02-10 17:59:30 +03:00
|
|
|
}
|
2006-03-05 18:48:14 +03:00
|
|
|
if(i2id && (*i1 != -1)) {
|
2006-04-12 12:44:07 +04:00
|
|
|
*i2 = idx_of_area_id(view.data[*i1], i2id);
|
2006-03-05 18:48:14 +03:00
|
|
|
if(i3id && (*i2 != -1))
|
2006-04-12 12:44:07 +04:00
|
|
|
*i3 = idx_of_frame_id(view.data[*i1]->area.data[*i2], i3id);
|
2006-03-05 18:48:14 +03:00
|
|
|
}
|
2006-02-10 17:59:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-30 21:43:32 +03:00
|
|
|
static char *
|
2006-05-01 21:39:26 +04:00
|
|
|
name_of_qid(Qid wqid[IXP_MAX_WELEM], unsigned short qsel)
|
2006-01-30 21:43:32 +03:00
|
|
|
{
|
2006-05-01 21:39:26 +04:00
|
|
|
unsigned char dir_type, type;
|
2006-03-05 18:48:14 +03:00
|
|
|
int i1 = -1, i2 = -1, i3 = -1;
|
2006-03-08 19:45:16 +03:00
|
|
|
static char buf[256];
|
2006-01-30 21:43:32 +03:00
|
|
|
|
2006-05-01 21:39:26 +04:00
|
|
|
unpack_qpath(wqid, qsel, &type, &i1, &i2, &i3);
|
|
|
|
dir_type = dir_of_qid(wqid, qsel);
|
2006-02-03 20:11:22 +03:00
|
|
|
|
2006-02-10 17:59:30 +03:00
|
|
|
switch(type) {
|
2006-03-23 18:07:18 +03:00
|
|
|
case FsDroot: return "/"; break;
|
|
|
|
case FsDdef: return "def"; break;
|
2006-04-12 16:14:34 +04:00
|
|
|
case FsDclients: return "client"; break;
|
|
|
|
case FsDbars: return "bar"; break;
|
2006-03-23 18:07:18 +03:00
|
|
|
case FsDview:
|
2006-05-01 21:39:26 +04:00
|
|
|
if(dir_type != FsDroot)
|
2006-04-12 16:14:34 +04:00
|
|
|
return nil;
|
|
|
|
if(i1 == sel)
|
2006-04-13 12:06:07 +04:00
|
|
|
return "view";
|
2006-04-12 16:14:34 +04:00
|
|
|
return view.data[i1]->name;
|
2006-03-23 18:07:18 +03:00
|
|
|
break;
|
2006-04-12 16:14:34 +04:00
|
|
|
case FsDbar:
|
2006-03-23 18:07:18 +03:00
|
|
|
if(i1 == -1)
|
2006-03-15 15:18:05 +03:00
|
|
|
return nil;
|
2006-04-13 18:52:33 +04:00
|
|
|
return bar.data[i1]->name;
|
2006-03-23 18:07:18 +03:00
|
|
|
break;
|
|
|
|
case FsDarea:
|
|
|
|
if(i1 == -1 || i2 == -1)
|
|
|
|
return nil;
|
2006-04-03 00:53:56 +04:00
|
|
|
if(view.data[i1]->sel == i2)
|
2006-03-23 18:07:18 +03:00
|
|
|
return "sel";
|
|
|
|
snprintf(buf, sizeof(buf), "%u", i2);
|
|
|
|
return buf;
|
|
|
|
break;
|
|
|
|
case FsDGclient:
|
|
|
|
if(i1 == -1)
|
|
|
|
return nil;
|
|
|
|
snprintf(buf, sizeof(buf), "%u", i1);
|
|
|
|
return buf;
|
|
|
|
break;
|
|
|
|
case FsDclient:
|
|
|
|
if(i1 == -1 || i2 == -1 || i3 == -1)
|
|
|
|
return nil;
|
2006-04-03 00:53:56 +04:00
|
|
|
if(view.data[i1]->area.data[i2]->sel == i3)
|
2006-03-23 18:07:18 +03:00
|
|
|
return "sel";
|
|
|
|
snprintf(buf, sizeof(buf), "%u", i3);
|
|
|
|
return buf;
|
|
|
|
break;
|
|
|
|
case FsFselcolors: return "selcolors"; break;
|
|
|
|
case FsFnormcolors: return "normcolors"; break;
|
|
|
|
case FsFfont: return "font"; break;
|
2006-04-14 14:45:53 +04:00
|
|
|
case FsFcolw: return "colwidth"; break;
|
2006-04-12 13:08:31 +04:00
|
|
|
case FsFgrabmod: return "grabmod"; break;
|
2006-03-23 18:07:18 +03:00
|
|
|
case FsFrules: return "rules"; break;
|
|
|
|
case FsFkeys: return "keys"; break;
|
|
|
|
case FsFcolors: return "colors"; break;
|
|
|
|
case FsFdata:
|
|
|
|
if(i1 == -1)
|
|
|
|
return nil;
|
|
|
|
return "data";
|
|
|
|
break;
|
|
|
|
case FsFctl: return "ctl"; break;
|
|
|
|
case FsFborder: return "border"; break;
|
|
|
|
case FsFgeom:
|
2006-05-01 21:39:26 +04:00
|
|
|
if((dir_type == FsDclient) && (i1 == -1 || i2 == -1 || i3 == -1))
|
2006-03-23 18:07:18 +03:00
|
|
|
return nil;
|
|
|
|
else if(i1 == -1)
|
|
|
|
return nil;
|
|
|
|
return "geom";
|
|
|
|
break;
|
2006-04-13 19:41:58 +04:00
|
|
|
case FsFtags:
|
2006-05-01 21:39:26 +04:00
|
|
|
if((dir_type == FsDclient) && (i1 == -1 || i2 == -1 || i3 == -1))
|
2006-04-13 19:41:58 +04:00
|
|
|
return nil;
|
2006-05-01 21:39:26 +04:00
|
|
|
else if((dir_type == FsDGclient) && (i1 == -1))
|
2006-04-13 19:41:58 +04:00
|
|
|
return nil;
|
|
|
|
return "tags";
|
|
|
|
break;
|
2006-03-23 18:07:18 +03:00
|
|
|
case FsFclass:
|
2006-04-26 10:59:55 +04:00
|
|
|
case FsFindex:
|
2006-03-23 18:07:18 +03:00
|
|
|
case FsFname:
|
2006-05-01 21:39:26 +04:00
|
|
|
if((dir_type == FsDclient) && (i1 == -1 || i2 == -1 || i3 == -1))
|
2006-03-23 18:07:18 +03:00
|
|
|
return nil;
|
|
|
|
else if(i1 == -1)
|
|
|
|
return nil;
|
2006-04-26 10:59:55 +04:00
|
|
|
switch(type) {
|
|
|
|
case FsFname:
|
2006-03-23 18:07:18 +03:00
|
|
|
return "name";
|
2006-04-26 10:59:55 +04:00
|
|
|
break;
|
|
|
|
case FsFclass:
|
2006-04-13 19:41:58 +04:00
|
|
|
return "class";
|
2006-04-26 10:59:55 +04:00
|
|
|
break;
|
|
|
|
case FsFindex:
|
|
|
|
return "index";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-03-23 18:07:18 +03:00
|
|
|
break;
|
|
|
|
case FsFmode:
|
2006-05-01 21:39:26 +04:00
|
|
|
if((dir_type == FsDarea) && (i1 == -1 || i2 == -1))
|
2006-04-14 14:03:44 +04:00
|
|
|
return nil;
|
2006-05-01 21:39:26 +04:00
|
|
|
if(dir_type == FsDdef)
|
2006-04-14 14:03:44 +04:00
|
|
|
return "colmode";
|
|
|
|
else
|
|
|
|
return "mode";
|
2006-03-23 18:07:18 +03:00
|
|
|
break;
|
|
|
|
case FsFevent: return "event"; break;
|
|
|
|
default: return nil; break;
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
2006-04-26 10:59:55 +04:00
|
|
|
return nil;
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
|
|
|
|
2006-03-08 19:45:16 +03:00
|
|
|
static unsigned char
|
2006-05-01 21:39:26 +04:00
|
|
|
type_of_name(Qid wqid[IXP_MAX_WELEM], unsigned short qsel, char *name)
|
2006-01-30 21:43:32 +03:00
|
|
|
{
|
2006-05-01 21:39:26 +04:00
|
|
|
unsigned char dir_type;
|
|
|
|
int i1 = -1, i2 = -1, i3 = -1;
|
2006-03-23 18:07:18 +03:00
|
|
|
unsigned int i;
|
2006-05-01 21:39:26 +04:00
|
|
|
|
|
|
|
unpack_qpath(wqid, qsel, &dir_type, &i1, &i2, &i3);
|
|
|
|
|
2006-05-17 12:36:56 +04:00
|
|
|
if(!name || !name[0] || !strncmp(name, "/", 2))
|
2006-03-05 16:16:48 +03:00
|
|
|
return FsDroot;
|
2006-03-11 03:07:19 +03:00
|
|
|
if(!strncmp(name, "tags", 5))
|
|
|
|
return FsFtags;
|
2006-04-12 16:14:34 +04:00
|
|
|
if(!strncmp(name, "client", 7))
|
2006-03-07 19:22:36 +03:00
|
|
|
return FsDclients;
|
2006-04-12 16:14:34 +04:00
|
|
|
if(!strncmp(name, "view", 5))
|
2006-04-13 12:06:07 +04:00
|
|
|
return FsDview;
|
2006-02-24 12:38:48 +03:00
|
|
|
if(!strncmp(name, "bar", 4))
|
2006-04-12 16:14:34 +04:00
|
|
|
return FsDbars;
|
2006-02-09 21:40:12 +03:00
|
|
|
if(!strncmp(name, "def", 4))
|
2006-03-05 16:16:48 +03:00
|
|
|
return FsDdef;
|
2006-01-30 21:43:32 +03:00
|
|
|
if(!strncmp(name, "ctl", 4))
|
2006-03-05 16:16:48 +03:00
|
|
|
return FsFctl;
|
2006-01-30 21:43:32 +03:00
|
|
|
if(!strncmp(name, "event", 6))
|
2006-03-05 16:16:48 +03:00
|
|
|
return FsFevent;
|
2006-04-26 10:59:55 +04:00
|
|
|
if(!strncmp(name, "class", 6))
|
2006-03-10 13:59:26 +03:00
|
|
|
return FsFclass;
|
2006-04-26 10:59:55 +04:00
|
|
|
if(!strncmp(name, "index", 6))
|
|
|
|
return FsFindex;
|
2006-01-31 11:27:54 +03:00
|
|
|
if(!strncmp(name, "name", 5))
|
2006-03-05 16:16:48 +03:00
|
|
|
return FsFname;
|
2006-01-31 11:27:54 +03:00
|
|
|
if(!strncmp(name, "border", 7))
|
2006-03-05 16:16:48 +03:00
|
|
|
return FsFborder;
|
2006-03-05 18:48:14 +03:00
|
|
|
if(!strncmp(name, "geom", 5))
|
2006-03-05 16:16:48 +03:00
|
|
|
return FsFgeom;
|
2006-02-10 20:32:35 +03:00
|
|
|
if(!strncmp(name, "colors", 7))
|
2006-03-05 16:16:48 +03:00
|
|
|
return FsFcolors;
|
2006-02-10 20:32:35 +03:00
|
|
|
if(!strncmp(name, "selcolors", 10))
|
2006-03-05 16:16:48 +03:00
|
|
|
return FsFselcolors;
|
2006-02-10 20:32:35 +03:00
|
|
|
if(!strncmp(name, "normcolors", 11))
|
2006-03-05 16:16:48 +03:00
|
|
|
return FsFnormcolors;
|
2006-03-10 16:55:44 +03:00
|
|
|
if(!strncmp(name, "font", 5))
|
|
|
|
return FsFfont;
|
2006-04-14 14:45:53 +04:00
|
|
|
if(!strncmp(name, "colwidth", 9))
|
|
|
|
return FsFcolw;
|
2006-04-12 13:08:31 +04:00
|
|
|
if(!strncmp(name, "grabmod", 8))
|
|
|
|
return FsFgrabmod;
|
2006-03-10 18:21:20 +03:00
|
|
|
if(!strncmp(name, "keys", 5))
|
|
|
|
return FsFkeys;
|
2006-03-10 16:39:46 +03:00
|
|
|
if(!strncmp(name, "rules", 6))
|
|
|
|
return FsFrules;
|
2006-02-10 00:48:01 +03:00
|
|
|
if(!strncmp(name, "data", 5))
|
2006-03-05 16:16:48 +03:00
|
|
|
return FsFdata;
|
2006-04-14 14:03:44 +04:00
|
|
|
if(!strncmp(name, "mode", 5) || !strncmp(name, "colmode", 8))
|
2006-03-05 16:16:48 +03:00
|
|
|
return FsFmode;
|
2006-04-12 16:14:34 +04:00
|
|
|
if((dir_type == FsDbars) && bar_of_name(name))
|
|
|
|
return FsDbar;
|
2006-04-13 12:06:07 +04:00
|
|
|
if((dir_type == FsDroot) && view_of_name(name))
|
2006-04-12 16:14:34 +04:00
|
|
|
return FsDview;
|
2006-02-02 15:20:07 +03:00
|
|
|
if(!strncmp(name, "sel", 4))
|
2006-01-31 19:52:14 +03:00
|
|
|
goto dyndir;
|
2006-03-23 18:07:18 +03:00
|
|
|
i = (unsigned short) cext_strtonum(name, 0, 0xffff, &err);
|
|
|
|
if(err)
|
2006-04-29 20:51:45 +04:00
|
|
|
return FsLast;
|
2006-01-31 19:52:14 +03:00
|
|
|
dyndir:
|
2006-02-10 17:59:30 +03:00
|
|
|
switch(dir_type) {
|
2006-04-12 16:14:34 +04:00
|
|
|
case FsDbars: return FsDbar; break;
|
2006-03-23 11:54:20 +03:00
|
|
|
case FsDview: return FsDarea; break;
|
2006-03-07 19:22:36 +03:00
|
|
|
case FsDclients: return FsDGclient; break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsDarea: return FsDclient; break;
|
2006-01-31 11:27:54 +03:00
|
|
|
}
|
2006-04-29 20:51:45 +04:00
|
|
|
return FsLast;
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
|
|
|
|
2006-05-01 21:39:26 +04:00
|
|
|
static Qid *
|
|
|
|
qid_of_name(Qid wqid[IXP_MAX_WELEM], unsigned short qsel, char *name)
|
2006-01-30 21:43:32 +03:00
|
|
|
{
|
2006-05-01 21:39:26 +04:00
|
|
|
int i1 = -1, i2 = -1, i3 = -1, i;
|
|
|
|
unsigned char dir_type, type;
|
|
|
|
static Qid new;
|
2006-01-30 21:43:32 +03:00
|
|
|
|
2006-05-01 21:39:26 +04:00
|
|
|
unpack_qpath(wqid, qsel, &dir_type, &i1, &i2, &i3);
|
|
|
|
type = type_of_name(wqid, qsel, name);
|
2006-02-10 17:59:30 +03:00
|
|
|
|
2006-01-30 21:43:32 +03:00
|
|
|
switch(type) {
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsDroot:
|
2006-05-01 21:39:26 +04:00
|
|
|
new = root_qid;
|
2006-01-30 21:43:32 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsDdef:
|
2006-03-07 19:22:36 +03:00
|
|
|
case FsDclients:
|
2006-04-12 16:14:34 +04:00
|
|
|
case FsDbars:
|
2006-03-07 19:53:16 +03:00
|
|
|
if(dir_type != FsDroot)
|
2006-05-01 21:39:26 +04:00
|
|
|
return nil;
|
|
|
|
new.type = IXP_QTDIR;
|
|
|
|
new.path = pack_qpath(type, 0, 0, 0);
|
2006-02-10 00:48:01 +03:00
|
|
|
break;
|
2006-03-23 11:54:20 +03:00
|
|
|
case FsDview:
|
2006-04-13 12:06:07 +04:00
|
|
|
if(dir_type != FsDroot || !view.size)
|
2006-05-01 21:39:26 +04:00
|
|
|
return nil;
|
|
|
|
new.type = IXP_QTDIR;
|
|
|
|
if(!strncmp(name, "view", 5))
|
|
|
|
new.path = pack_qpath(FsDview, view.data[sel]->id, 0, 0);
|
2006-04-12 16:14:34 +04:00
|
|
|
else {
|
|
|
|
View *v;
|
2006-05-01 21:39:26 +04:00
|
|
|
if(!(v = view_of_name(name)))
|
|
|
|
return nil;
|
|
|
|
new.path = pack_qpath(FsDview, v->id, 0, 0);
|
2006-04-12 16:14:34 +04:00
|
|
|
}
|
2006-03-05 22:00:18 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsDarea:
|
2006-05-01 21:39:26 +04:00
|
|
|
if(i1 == -1 || dir_type != FsDview)
|
|
|
|
return nil;
|
2006-02-10 17:59:30 +03:00
|
|
|
{
|
2006-05-01 21:39:26 +04:00
|
|
|
View *p = view.data[i1];
|
|
|
|
new.type = IXP_QTDIR;
|
|
|
|
if(!strncmp(name, "sel", 4)) {
|
|
|
|
new.path = pack_qpath(FsDarea, p->id, p->area.data[p->sel]->id, 0);
|
2006-02-16 13:53:10 +03:00
|
|
|
}
|
2006-02-10 17:59:30 +03:00
|
|
|
else {
|
2006-05-01 21:39:26 +04:00
|
|
|
i = cext_strtonum(name, 0, 0xffff, &err);
|
2006-04-03 00:53:56 +04:00
|
|
|
if(err || (i >= p->area.size))
|
2006-05-01 21:39:26 +04:00
|
|
|
return nil;
|
|
|
|
new.path = pack_qpath(FsDarea, p->id, p->area.data[i]->id, 0);
|
2006-02-06 11:20:23 +03:00
|
|
|
}
|
2006-01-31 19:52:14 +03:00
|
|
|
}
|
2006-01-31 15:25:23 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsDclient:
|
2006-05-01 21:39:26 +04:00
|
|
|
if(i1 == -1 || i2 == -1 || dir_type != FsDarea)
|
|
|
|
return nil;
|
2006-02-10 17:59:30 +03:00
|
|
|
{
|
2006-05-01 21:39:26 +04:00
|
|
|
View *p = view.data[i1];
|
|
|
|
Area *a = p->area.data[i2];
|
|
|
|
new.type = IXP_QTDIR;
|
|
|
|
if(!strncmp(name, "sel", 4)) {
|
2006-04-03 00:53:56 +04:00
|
|
|
if(!a->frame.size)
|
2006-05-01 21:39:26 +04:00
|
|
|
return nil;
|
|
|
|
new.path = pack_qpath(FsDclient, p->id, a->id, a->frame.data[a->sel]->id);
|
2006-02-10 17:59:30 +03:00
|
|
|
}
|
|
|
|
else {
|
2006-05-01 21:39:26 +04:00
|
|
|
i = cext_strtonum(name, 0, 0xffff, &err);
|
2006-04-03 00:53:56 +04:00
|
|
|
if(err || (i >= a->frame.size))
|
2006-05-01 21:39:26 +04:00
|
|
|
return nil;
|
|
|
|
new.path = pack_qpath(FsDclient, p->id, a->id, a->frame.data[i]->id);
|
2006-02-10 17:59:30 +03:00
|
|
|
}
|
2006-01-31 19:52:14 +03:00
|
|
|
}
|
2006-01-31 15:25:23 +03:00
|
|
|
break;
|
2006-03-07 19:22:36 +03:00
|
|
|
case FsDGclient:
|
2006-03-07 19:53:16 +03:00
|
|
|
if(dir_type != FsDclients)
|
2006-05-01 21:39:26 +04:00
|
|
|
return nil;
|
|
|
|
i = cext_strtonum(name, 0, 0xffff, &err);
|
2006-04-03 00:53:56 +04:00
|
|
|
if(err || (i >= client.size))
|
2006-05-01 21:39:26 +04:00
|
|
|
return nil;
|
|
|
|
new.path = pack_qpath(FsDGclient, client.data[i]->id, 0, 0);
|
2006-03-07 19:22:36 +03:00
|
|
|
break;
|
2006-04-12 16:14:34 +04:00
|
|
|
case FsDbar:
|
|
|
|
if(dir_type != FsDbars)
|
2006-05-01 21:39:26 +04:00
|
|
|
return nil;
|
2006-03-09 04:15:43 +03:00
|
|
|
{
|
2006-04-12 12:44:07 +04:00
|
|
|
Bar *l;
|
2006-05-01 21:39:26 +04:00
|
|
|
if(!(l = bar_of_name(name)))
|
|
|
|
return nil;
|
|
|
|
new.type = IXP_QTDIR;
|
|
|
|
new.path = pack_qpath(FsDbar, l->id, 0, 0);
|
2006-03-09 04:15:43 +03:00
|
|
|
}
|
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFdata:
|
|
|
|
case FsFcolors:
|
2006-05-01 21:39:26 +04:00
|
|
|
if((i1 == -1) || (dir_type != FsDbar))
|
|
|
|
return nil;
|
2006-03-22 21:57:18 +03:00
|
|
|
goto Mkfile;
|
2006-03-05 18:48:14 +03:00
|
|
|
break;
|
|
|
|
case FsFmode:
|
2006-05-01 21:39:26 +04:00
|
|
|
if((dir_type == FsDarea) && (i1 == -1 || i2 == -1))
|
|
|
|
return nil;
|
2006-03-22 21:57:18 +03:00
|
|
|
goto Mkfile;
|
2006-03-05 18:48:14 +03:00
|
|
|
break;
|
|
|
|
case FsFgeom:
|
|
|
|
case FsFname:
|
2006-04-26 10:59:55 +04:00
|
|
|
case FsFindex:
|
2006-03-10 13:59:26 +03:00
|
|
|
case FsFclass:
|
2006-03-21 20:14:50 +03:00
|
|
|
if(dir_type == FsDroot)
|
2006-05-01 21:39:26 +04:00
|
|
|
return nil;
|
2006-03-05 21:20:27 +03:00
|
|
|
case FsFtags:
|
2006-05-01 21:39:26 +04:00
|
|
|
if((dir_type != FsDroot) && (dir_type != FsDview)
|
|
|
|
&& (dir_type != FsDGclient) && (dir_type != FsDclient))
|
|
|
|
return nil;
|
|
|
|
if((dir_type == FsDclient) && ((i1 == -1 || i2 == -1 || i3 == -1)))
|
|
|
|
return nil;
|
|
|
|
else if((dir_type == FsDGclient) && (i1 == -1))
|
|
|
|
return nil;
|
2006-03-22 21:57:18 +03:00
|
|
|
goto Mkfile;
|
|
|
|
break;
|
2006-03-10 16:55:44 +03:00
|
|
|
case FsFborder:
|
2006-04-12 13:08:31 +04:00
|
|
|
case FsFgrabmod:
|
2006-03-10 16:55:44 +03:00
|
|
|
case FsFfont:
|
2006-04-14 14:45:53 +04:00
|
|
|
case FsFcolw:
|
2006-03-10 16:55:44 +03:00
|
|
|
case FsFrules:
|
|
|
|
case FsFselcolors:
|
|
|
|
case FsFnormcolors:
|
2006-03-10 18:21:20 +03:00
|
|
|
case FsFkeys:
|
2006-03-23 18:07:18 +03:00
|
|
|
if(dir_type != FsDdef)
|
2006-05-01 21:39:26 +04:00
|
|
|
return nil;
|
2006-03-22 21:54:27 +03:00
|
|
|
case FsFctl:
|
|
|
|
case FsFevent:
|
2006-03-22 21:57:18 +03:00
|
|
|
Mkfile:
|
2006-05-01 21:39:26 +04:00
|
|
|
new.type = IXP_QTFILE;
|
|
|
|
new.path = pack_qpath(type, unpack_i1id(wqid[qsel].path), unpack_i2id(wqid[qsel].path),
|
|
|
|
unpack_i3id(wqid[qsel].path));
|
2006-01-30 21:43:32 +03:00
|
|
|
break;
|
2006-03-22 21:54:27 +03:00
|
|
|
default:
|
2006-05-01 21:39:26 +04:00
|
|
|
return nil;
|
2006-03-22 21:54:27 +03:00
|
|
|
break;
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
2006-05-01 21:39:26 +04:00
|
|
|
return &new;
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int
|
2006-05-01 21:39:26 +04:00
|
|
|
pack_stat(Stat *stat, Qid wqid[IXP_MAX_WELEM], unsigned short qsel,
|
|
|
|
char *name, unsigned long long length, unsigned int mode)
|
2006-01-30 21:43:32 +03:00
|
|
|
{
|
2006-05-01 21:39:26 +04:00
|
|
|
Qid *qid;
|
2006-03-23 18:07:18 +03:00
|
|
|
stat->mode = mode;
|
|
|
|
stat->atime = stat->mtime = time(0);
|
|
|
|
cext_strlcpy(stat->uid, getenv("USER"), sizeof(stat->uid));
|
|
|
|
cext_strlcpy(stat->gid, getenv("USER"), sizeof(stat->gid));
|
|
|
|
cext_strlcpy(stat->muid, getenv("USER"), sizeof(stat->muid));
|
2006-01-30 21:43:32 +03:00
|
|
|
|
2006-03-23 18:07:18 +03:00
|
|
|
cext_strlcpy(stat->name, name, sizeof(stat->name));
|
|
|
|
stat->length = length;
|
2006-05-01 21:39:26 +04:00
|
|
|
if((qid = qid_of_name(wqid, qsel ? qsel - 1 : 0, name)))
|
|
|
|
stat->qid = *qid;
|
|
|
|
|
2006-01-30 21:43:32 +03:00
|
|
|
return ixp_sizeof_stat(stat);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int
|
2006-05-01 21:39:26 +04:00
|
|
|
stat_of_name(Stat *stat, char *name, Qid wqid[IXP_MAX_WELEM], unsigned short qsel)
|
2006-01-30 21:43:32 +03:00
|
|
|
{
|
2006-03-08 19:45:16 +03:00
|
|
|
unsigned char dir_type, type;
|
2006-05-01 21:39:26 +04:00
|
|
|
int i1 = 0, i2 = 0, i3 = 0;
|
2006-03-08 19:45:16 +03:00
|
|
|
char buf[256];
|
2006-03-05 03:55:45 +03:00
|
|
|
Frame *f;
|
2006-01-30 21:43:32 +03:00
|
|
|
|
2006-05-01 21:39:26 +04:00
|
|
|
unpack_qpath(wqid, qsel, &dir_type, &i1, &i2, &i3);
|
|
|
|
if((i1 == -1) || (i2 == -1) || (i3 == -1))
|
2006-04-29 20:51:45 +04:00
|
|
|
return 0;
|
2006-05-01 21:39:26 +04:00
|
|
|
type = type_of_name(wqid, qsel, name);
|
2006-02-03 22:02:37 +03:00
|
|
|
|
2006-03-23 18:07:18 +03:00
|
|
|
switch (type) {
|
|
|
|
case FsDclient:
|
|
|
|
case FsDGclient:
|
|
|
|
case FsDarea:
|
|
|
|
case FsDview:
|
|
|
|
case FsDdef:
|
2006-03-07 19:22:36 +03:00
|
|
|
case FsDclients:
|
2006-04-12 16:14:34 +04:00
|
|
|
case FsDbar:
|
2006-03-23 18:07:18 +03:00
|
|
|
case FsDroot:
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name, 0, IXP_DMDIR | IXP_DMREAD | IXP_DMEXEC);
|
2006-03-23 18:07:18 +03:00
|
|
|
break;
|
2006-04-12 16:14:34 +04:00
|
|
|
case FsDbars:
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name, 0, IXP_DMDIR | IXP_DMREAD | IXP_DMWRITE | IXP_DMEXEC);
|
2006-03-23 18:07:18 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFctl:
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name, 0, IXP_DMWRITE);
|
2006-03-07 19:22:36 +03:00
|
|
|
break;
|
2006-03-23 18:07:18 +03:00
|
|
|
case FsFevent:
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name, 0, IXP_DMREAD | IXP_DMWRITE);
|
2006-01-30 21:43:32 +03:00
|
|
|
break;
|
2006-03-23 18:07:18 +03:00
|
|
|
case FsFborder:
|
2006-02-24 12:38:48 +03:00
|
|
|
snprintf(buf, sizeof(buf), "%d", def.border);
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name, strlen(buf), IXP_DMREAD | IXP_DMWRITE);
|
2006-03-23 18:07:18 +03:00
|
|
|
break;
|
|
|
|
case FsFgeom:
|
2006-03-07 19:22:36 +03:00
|
|
|
if(dir_type == FsDclient) {
|
2006-05-01 21:39:26 +04:00
|
|
|
f = view.data[i1]->area.data[i2]->frame.data[i3];
|
2006-03-07 19:22:36 +03:00
|
|
|
snprintf(buf, sizeof(buf), "%d %d %d %d", f->rect.x, f->rect.y,
|
|
|
|
f->rect.width, f->rect.height);
|
|
|
|
}
|
|
|
|
else {
|
2006-05-01 21:39:26 +04:00
|
|
|
Client *c = client.data[i1];
|
2006-03-07 19:22:36 +03:00
|
|
|
snprintf(buf, sizeof(buf), "%d %d %d %d", c->rect.x, c->rect.y,
|
|
|
|
c->rect.width, c->rect.height);
|
|
|
|
}
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name, strlen(buf), IXP_DMREAD | IXP_DMWRITE);
|
2006-03-23 18:07:18 +03:00
|
|
|
break;
|
|
|
|
case FsFclass:
|
2006-03-10 13:59:26 +03:00
|
|
|
if(dir_type == FsDclient) {
|
2006-05-01 21:39:26 +04:00
|
|
|
f = view.data[i1]->area.data[i2]->frame.data[i3];
|
|
|
|
return pack_stat(stat, wqid, qsel, name, strlen(f->client->classinst), IXP_DMREAD);
|
2006-03-10 13:59:26 +03:00
|
|
|
}
|
2006-03-23 18:07:18 +03:00
|
|
|
else
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name, strlen(client.data[i1]->classinst), IXP_DMREAD);
|
2006-03-23 18:07:18 +03:00
|
|
|
break;
|
2006-04-26 10:59:55 +04:00
|
|
|
case FsFindex:
|
|
|
|
if(dir_type == FsDclient) {
|
2006-05-01 21:39:26 +04:00
|
|
|
f = view.data[i1]->area.data[i2]->frame.data[i3];
|
2006-04-26 10:59:55 +04:00
|
|
|
snprintf(buf, sizeof(buf), "%d", idx_of_client_id(f->client->id));
|
|
|
|
}
|
|
|
|
else
|
2006-05-01 21:39:26 +04:00
|
|
|
snprintf(buf, sizeof(buf), "%d", i1);
|
|
|
|
return pack_stat(stat, wqid, qsel, name, strlen(buf), IXP_DMREAD);
|
2006-04-26 10:59:55 +04:00
|
|
|
break;
|
2006-03-23 18:07:18 +03:00
|
|
|
case FsFname:
|
2006-03-07 19:22:36 +03:00
|
|
|
if(dir_type == FsDclient) {
|
2006-05-01 21:39:26 +04:00
|
|
|
f = view.data[i1]->area.data[i2]->frame.data[i3];
|
|
|
|
return pack_stat(stat, wqid, qsel, name, strlen(f->client->name), IXP_DMREAD);
|
2006-03-07 19:22:36 +03:00
|
|
|
}
|
2006-04-11 19:21:38 +04:00
|
|
|
else if(dir_type == FsDview)
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name,
|
|
|
|
view.size ? strlen(view.data[i1]->name) : 0, IXP_DMREAD);
|
2006-03-23 18:07:18 +03:00
|
|
|
else
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name, strlen(client.data[i1]->name), IXP_DMREAD);
|
2006-03-23 18:07:18 +03:00
|
|
|
break;
|
|
|
|
case FsFtags:
|
2006-04-13 19:41:58 +04:00
|
|
|
switch(dir_type) {
|
|
|
|
case FsDclient:
|
2006-05-01 21:39:26 +04:00
|
|
|
f = view.data[i1]->area.data[i2]->frame.data[i3];
|
|
|
|
return pack_stat(stat, wqid, qsel, name, strlen(f->client->tags), IXP_DMREAD | IXP_DMWRITE);
|
2006-04-13 19:41:58 +04:00
|
|
|
break;
|
|
|
|
case FsDGclient:
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel,
|
|
|
|
name, strlen(client.data[i1]->tags), IXP_DMREAD | IXP_DMWRITE);
|
2006-04-13 19:41:58 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
unsigned int i, len = 0;
|
|
|
|
for(i = 0; i < view.size; i++)
|
|
|
|
len += strlen(view.data[i]->name) + 1;
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name, len, IXP_DMREAD);
|
2006-04-13 19:41:58 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2006-03-06 18:35:07 +03:00
|
|
|
break;
|
2006-03-23 18:07:18 +03:00
|
|
|
case FsFdata:
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name,
|
|
|
|
(i1 == bar.size) ? 0 : strlen(bar.data[i1]->data), IXP_DMREAD | IXP_DMWRITE);
|
2006-03-23 18:07:18 +03:00
|
|
|
break;
|
|
|
|
case FsFmode:
|
2006-04-14 14:03:44 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
if(dir_type == FsDarea)
|
2006-05-01 21:39:26 +04:00
|
|
|
i = view.data[i1]->area.data[i2]->mode;
|
2006-04-14 14:03:44 +04:00
|
|
|
else
|
|
|
|
i = def.colmode;
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name,
|
|
|
|
strlen(str_of_column_mode(i)), IXP_DMREAD | IXP_DMWRITE);
|
2006-04-14 14:03:44 +04:00
|
|
|
}
|
2006-03-23 18:07:18 +03:00
|
|
|
break;
|
|
|
|
case FsFcolors:
|
|
|
|
case FsFselcolors:
|
|
|
|
case FsFnormcolors:
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name, 23, IXP_DMREAD | IXP_DMWRITE);
|
2006-03-10 16:55:44 +03:00
|
|
|
break;
|
2006-03-23 18:07:18 +03:00
|
|
|
case FsFkeys:
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name, def.keys ? strlen(def.keys) : 0, IXP_DMREAD | IXP_DMWRITE);
|
2006-03-10 18:21:20 +03:00
|
|
|
break;
|
2006-03-23 18:07:18 +03:00
|
|
|
case FsFrules:
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name, def.rules ? strlen(def.rules) : 0, IXP_DMREAD | IXP_DMWRITE);
|
2006-03-10 16:39:46 +03:00
|
|
|
break;
|
2006-04-14 14:45:53 +04:00
|
|
|
case FsFcolw:
|
|
|
|
snprintf(buf, sizeof(buf), "%d", def.colw);
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name, strlen(buf), IXP_DMREAD | IXP_DMWRITE);
|
2006-03-23 18:07:18 +03:00
|
|
|
case FsFfont:
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name, strlen(def.font), IXP_DMREAD | IXP_DMWRITE);
|
2006-04-12 13:08:31 +04:00
|
|
|
case FsFgrabmod:
|
2006-05-01 21:39:26 +04:00
|
|
|
return pack_stat(stat, wqid, qsel, name, strlen(def.grabmod), IXP_DMREAD | IXP_DMWRITE);
|
2006-02-10 00:48:01 +03:00
|
|
|
break;
|
2006-03-23 18:07:18 +03:00
|
|
|
}
|
2006-01-30 21:43:32 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-08 19:45:16 +03:00
|
|
|
static char *
|
|
|
|
xversion(IXPConn *c, Fcall *fcall)
|
|
|
|
{
|
2006-03-23 18:07:18 +03:00
|
|
|
if(strncmp(fcall->version, IXP_VERSION, strlen(IXP_VERSION)))
|
|
|
|
return E9pversion;
|
|
|
|
else if(fcall->maxmsg > IXP_MAX_MSG)
|
|
|
|
fcall->maxmsg = IXP_MAX_MSG;
|
|
|
|
fcall->id = RVERSION;
|
2006-03-08 19:45:16 +03:00
|
|
|
ixp_server_respond_fcall(c, fcall);
|
2006-03-23 18:07:18 +03:00
|
|
|
return nil;
|
2006-03-08 19:45:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
xattach(IXPConn *c, Fcall *fcall)
|
|
|
|
{
|
2006-03-23 18:07:18 +03:00
|
|
|
IXPMap *new = cext_emallocz(sizeof(IXPMap));
|
2006-05-17 12:36:56 +04:00
|
|
|
cext_vattach(ixp_vector_of_maps(&c->map), new);
|
2006-05-01 21:39:26 +04:00
|
|
|
new->wqid[0] = root_qid;
|
|
|
|
new->nwqid = 1;
|
2006-03-23 18:07:18 +03:00
|
|
|
new->fid = fcall->fid;
|
|
|
|
fcall->id = RATTACH;
|
2006-05-17 12:36:56 +04:00
|
|
|
fcall->qid = new->wqid[new->sel];
|
2006-03-08 19:45:16 +03:00
|
|
|
ixp_server_respond_fcall(c, fcall);
|
2006-03-23 18:07:18 +03:00
|
|
|
return nil;
|
2006-03-08 19:45:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
xwalk(IXPConn *c, Fcall *fcall)
|
|
|
|
{
|
2006-03-23 18:07:18 +03:00
|
|
|
IXPMap *m;
|
2006-05-17 12:36:56 +04:00
|
|
|
unsigned int qsel, nwqid;
|
|
|
|
Qid wqid[IXP_MAX_WELEM], *qid;
|
2006-03-08 19:45:16 +03:00
|
|
|
|
2006-03-23 18:07:18 +03:00
|
|
|
if(!(m = ixp_server_fid2map(c, fcall->fid)))
|
|
|
|
return Enofile;
|
|
|
|
if(fcall->fid != fcall->newfid && (ixp_server_fid2map(c, fcall->newfid)))
|
2006-05-17 12:36:56 +04:00
|
|
|
return Efidinuse;
|
2006-05-01 21:39:26 +04:00
|
|
|
|
2006-05-17 12:36:56 +04:00
|
|
|
for(qsel = 0; qsel < m->nwqid; qsel++)
|
|
|
|
wqid[qsel] = m->wqid[qsel];
|
|
|
|
if(qsel)
|
|
|
|
qsel--;
|
2006-05-01 21:39:26 +04:00
|
|
|
for(nwqid = 0; nwqid < fcall->nwname; nwqid++) {
|
2006-05-17 12:36:56 +04:00
|
|
|
if(qsel >= IXP_MAX_WELEM)
|
2006-05-01 21:39:26 +04:00
|
|
|
break;
|
2006-05-17 12:36:56 +04:00
|
|
|
if(!strncmp(fcall->wname[nwqid], "..", 3)) {
|
|
|
|
if(qsel)
|
|
|
|
qsel--;
|
|
|
|
qid = &wqid[qsel];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
qid = qid_of_name(wqid, qsel, fcall->wname[nwqid]);
|
|
|
|
if(!qid)
|
|
|
|
break;
|
|
|
|
qsel++;
|
|
|
|
}
|
|
|
|
fcall->wqid[nwqid] = wqid[qsel] = *qid;
|
2006-03-23 18:07:18 +03:00
|
|
|
}
|
2006-05-17 12:36:56 +04:00
|
|
|
|
2006-05-01 21:39:26 +04:00
|
|
|
if(fcall->nwname && !nwqid)
|
|
|
|
return Enofile;
|
2006-05-17 12:36:56 +04:00
|
|
|
|
2006-03-23 18:07:18 +03:00
|
|
|
/* a fid will only be valid, if the walk was complete */
|
|
|
|
if(nwqid == fcall->nwname) {
|
2006-05-17 12:36:56 +04:00
|
|
|
unsigned int i;
|
2006-03-23 18:07:18 +03:00
|
|
|
if(fcall->fid != fcall->newfid) {
|
2006-03-08 19:45:16 +03:00
|
|
|
m = cext_emallocz(sizeof(IXPMap));
|
2006-04-13 17:35:10 +04:00
|
|
|
cext_vattach(ixp_vector_of_maps(&c->map), m);
|
2006-03-23 18:07:18 +03:00
|
|
|
}
|
2006-05-17 12:36:56 +04:00
|
|
|
for(i = 0; i <= qsel; i++)
|
2006-05-01 21:39:26 +04:00
|
|
|
m->wqid[i] = wqid[i];
|
2006-05-17 12:36:56 +04:00
|
|
|
m->nwqid = qsel + 1;
|
|
|
|
m->sel = qsel;
|
2006-03-23 18:07:18 +03:00
|
|
|
m->fid = fcall->newfid;
|
|
|
|
}
|
|
|
|
fcall->id = RWALK;
|
|
|
|
fcall->nwqid = nwqid;
|
2006-03-08 19:45:16 +03:00
|
|
|
ixp_server_respond_fcall(c, fcall);
|
2006-03-23 18:07:18 +03:00
|
|
|
return nil;
|
2006-03-08 19:45:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
xcreate(IXPConn *c, Fcall *fcall)
|
|
|
|
{
|
2006-03-23 18:07:18 +03:00
|
|
|
IXPMap *m = ixp_server_fid2map(c, fcall->fid);
|
2006-05-01 21:39:26 +04:00
|
|
|
Qid *qid;
|
2006-03-08 19:45:16 +03:00
|
|
|
unsigned char type;
|
|
|
|
|
2006-03-23 18:07:18 +03:00
|
|
|
if(!(fcall->mode | IXP_OWRITE))
|
|
|
|
return Enomode;
|
|
|
|
if(!m)
|
|
|
|
return Enofile;
|
2006-03-08 19:45:16 +03:00
|
|
|
if(!strncmp(fcall->name, ".", 2) || !strncmp(fcall->name, "..", 3))
|
|
|
|
return "illegal file name";
|
2006-05-01 21:39:26 +04:00
|
|
|
type = unpack_type(m->wqid[m->sel].path);
|
2006-03-08 19:45:16 +03:00
|
|
|
switch(type) {
|
2006-04-12 16:14:34 +04:00
|
|
|
case FsDbars:
|
2006-04-12 12:44:07 +04:00
|
|
|
create_bar(fcall->name, False);
|
2006-03-09 04:15:43 +03:00
|
|
|
break;
|
2006-03-08 19:45:16 +03:00
|
|
|
default:
|
2006-03-22 16:32:46 +03:00
|
|
|
return Enofile;
|
2006-03-08 19:45:16 +03:00
|
|
|
break;
|
|
|
|
}
|
2006-05-01 21:39:26 +04:00
|
|
|
if(!(qid = qid_of_name(m->wqid, m->sel, fcall->name)))
|
|
|
|
return Enofile;
|
|
|
|
m->wqid[m->nwqid++] = fcall->qid = *qid;
|
|
|
|
m->sel++;
|
2006-03-08 19:45:16 +03:00
|
|
|
fcall->id = RCREATE;
|
|
|
|
fcall->iounit = WMII_IOUNIT;
|
|
|
|
ixp_server_respond_fcall(c, fcall);
|
2006-03-23 18:07:18 +03:00
|
|
|
return nil;
|
2006-03-08 19:45:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
xopen(IXPConn *c, Fcall *fcall)
|
|
|
|
{
|
2006-03-23 18:07:18 +03:00
|
|
|
IXPMap *m = ixp_server_fid2map(c, fcall->fid);
|
2006-03-08 19:45:16 +03:00
|
|
|
|
2006-03-23 18:07:18 +03:00
|
|
|
if(!m)
|
|
|
|
return Enofile;
|
|
|
|
if(!(fcall->mode | IXP_OREAD) && !(fcall->mode | IXP_OWRITE))
|
|
|
|
return Enomode;
|
|
|
|
fcall->id = ROPEN;
|
2006-05-01 21:39:26 +04:00
|
|
|
fcall->qid = m->wqid[m->sel];
|
2006-03-23 18:07:18 +03:00
|
|
|
fcall->iounit = WMII_IOUNIT;
|
2006-03-08 19:45:16 +03:00
|
|
|
ixp_server_respond_fcall(c, fcall);
|
2006-05-01 21:39:26 +04:00
|
|
|
|
2006-03-23 18:07:18 +03:00
|
|
|
return nil;
|
2006-03-08 19:45:16 +03:00
|
|
|
}
|
|
|
|
|
2006-02-10 00:48:01 +03:00
|
|
|
static char *
|
|
|
|
xremove(IXPConn *c, Fcall *fcall)
|
|
|
|
{
|
2006-03-23 18:07:18 +03:00
|
|
|
IXPMap *m = ixp_server_fid2map(c, fcall->fid);
|
2006-02-10 17:59:30 +03:00
|
|
|
unsigned char type;
|
|
|
|
int i1 = 0, i2 = 0, i3 = 0;
|
2006-02-10 00:48:01 +03:00
|
|
|
|
2006-03-23 18:07:18 +03:00
|
|
|
if(!m)
|
|
|
|
return Enofile;
|
2006-05-01 21:39:26 +04:00
|
|
|
unpack_qpath(m->wqid, m->sel, &type, &i1, &i2, &i3);
|
2006-02-10 17:59:30 +03:00
|
|
|
if((i1 == -1) || (i2 == -1) || (i3 == -1))
|
2006-02-10 00:48:01 +03:00
|
|
|
return Enofile;
|
2006-04-12 16:14:34 +04:00
|
|
|
if(type != FsDbar)
|
2006-03-09 04:15:43 +03:00
|
|
|
return Enoperm;
|
|
|
|
/* clunk */
|
2006-04-13 17:35:10 +04:00
|
|
|
cext_vdetach(ixp_vector_of_maps(&c->map), m);
|
2006-03-09 04:15:43 +03:00
|
|
|
free(m);
|
2006-02-10 17:59:30 +03:00
|
|
|
switch(type) {
|
2006-04-12 16:14:34 +04:00
|
|
|
case FsDbar:
|
2006-02-10 17:59:30 +03:00
|
|
|
{
|
2006-05-02 02:00:16 +04:00
|
|
|
Bar *b = bar.data[i1];
|
|
|
|
if(b->intern)
|
2006-03-24 15:36:35 +03:00
|
|
|
return Enoperm;
|
2006-04-13 18:52:33 +04:00
|
|
|
/* now detach the bar */
|
2006-05-02 02:00:16 +04:00
|
|
|
destroy_bar(b);
|
2006-02-10 17:59:30 +03:00
|
|
|
draw_bar();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2006-02-10 00:48:01 +03:00
|
|
|
}
|
2006-03-23 18:07:18 +03:00
|
|
|
fcall->id = RREMOVE;
|
2006-02-10 17:59:30 +03:00
|
|
|
ixp_server_respond_fcall(c, fcall);
|
|
|
|
return nil;
|
2006-02-10 00:48:01 +03:00
|
|
|
}
|
|
|
|
|
2006-02-03 20:11:22 +03:00
|
|
|
static char *
|
|
|
|
xread(IXPConn *c, Fcall *fcall)
|
2006-01-30 21:43:32 +03:00
|
|
|
{
|
|
|
|
Stat stat;
|
2006-03-23 18:07:18 +03:00
|
|
|
IXPMap *m = ixp_server_fid2map(c, fcall->fid);
|
2006-05-01 21:39:26 +04:00
|
|
|
int i1 = 0, i2 = 0, i3 = 0;
|
2006-01-31 21:57:14 +03:00
|
|
|
unsigned int i, len;
|
2006-05-01 21:39:26 +04:00
|
|
|
unsigned char dir_type, type, *p = fcall->data;
|
2006-03-08 19:45:16 +03:00
|
|
|
char buf[256];
|
2006-03-05 03:55:45 +03:00
|
|
|
Frame *f;
|
2006-01-30 21:43:32 +03:00
|
|
|
|
2006-03-23 18:07:18 +03:00
|
|
|
if(!m)
|
|
|
|
return Enofile;
|
2006-05-01 21:39:26 +04:00
|
|
|
unpack_qpath(m->wqid, m->sel, &type, &i1, &i2, &i3);
|
2006-02-10 17:59:30 +03:00
|
|
|
if((i1 == -1) || (i2 == -1) || (i3 == -1))
|
2006-02-03 20:11:22 +03:00
|
|
|
return Enofile;
|
2006-05-01 21:39:26 +04:00
|
|
|
dir_type = dir_of_qid(m->wqid, m->sel);
|
2006-02-03 20:11:22 +03:00
|
|
|
|
|
|
|
fcall->count = 0;
|
|
|
|
if(fcall->offset) {
|
2006-02-10 17:59:30 +03:00
|
|
|
switch (type) {
|
2006-04-13 12:06:07 +04:00
|
|
|
case FsDroot:
|
|
|
|
/* jump to offset */
|
2006-05-01 21:39:26 +04:00
|
|
|
len = stat_of_name(&stat, "ctl", m->wqid, m->sel);
|
|
|
|
len += stat_of_name(&stat, "event", m->wqid, m->sel);
|
|
|
|
len += stat_of_name(&stat, "def", m->wqid, m->sel);
|
|
|
|
len += stat_of_name(&stat, "bar", m->wqid, m->sel);
|
2006-04-13 12:06:07 +04:00
|
|
|
if(client.size)
|
2006-05-01 21:39:26 +04:00
|
|
|
len += stat_of_name(&stat, "client", m->wqid, m->sel);
|
2006-04-13 19:41:58 +04:00
|
|
|
if(view.size) {
|
2006-05-01 21:39:26 +04:00
|
|
|
len += stat_of_name(&stat, "tags", m->wqid, m->sel);
|
|
|
|
len += stat_of_name(&stat, "view", m->wqid, m->sel);
|
2006-04-13 19:41:58 +04:00
|
|
|
}
|
2006-04-13 12:06:07 +04:00
|
|
|
for(i = 0; i < view.size; i++) {
|
2006-05-01 21:39:26 +04:00
|
|
|
len += stat_of_name(&stat, view.data[i]->name, m->wqid, m->sel);
|
2006-04-13 12:06:07 +04:00
|
|
|
if(len <= fcall->offset)
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* offset found, proceeding */
|
|
|
|
for(; i < view.size; i++) {
|
2006-05-01 21:39:26 +04:00
|
|
|
len = stat_of_name(&stat, view.data[i]->name, m->wqid, m->sel);
|
2006-04-13 12:06:07 +04:00
|
|
|
if(fcall->count + len > fcall->iounit)
|
|
|
|
break;
|
|
|
|
fcall->count += len;
|
2006-05-01 21:39:26 +04:00
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-04-13 12:06:07 +04:00
|
|
|
}
|
|
|
|
break;
|
2006-03-07 19:22:36 +03:00
|
|
|
case FsDclients:
|
|
|
|
/* jump to offset */
|
|
|
|
len = 0;
|
2006-04-03 00:53:56 +04:00
|
|
|
for(i = 0; i < client.size; i++) {
|
2006-03-07 19:22:36 +03:00
|
|
|
snprintf(buf, sizeof(buf), "%u", i);
|
2006-05-01 21:39:26 +04:00
|
|
|
len += stat_of_name(&stat, buf, m->wqid, m->sel);
|
2006-03-07 19:22:36 +03:00
|
|
|
if(len <= fcall->offset)
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* offset found, proceeding */
|
2006-04-03 00:53:56 +04:00
|
|
|
for(; i < client.size; i++) {
|
2006-03-07 19:22:36 +03:00
|
|
|
snprintf(buf, sizeof(buf), "%u", i);
|
2006-05-01 21:39:26 +04:00
|
|
|
len = stat_of_name(&stat, buf, m->wqid, m->sel);
|
2006-03-07 19:22:36 +03:00
|
|
|
if(fcall->count + len > fcall->iounit)
|
|
|
|
break;
|
|
|
|
fcall->count += len;
|
2006-05-01 21:39:26 +04:00
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-03-07 19:22:36 +03:00
|
|
|
}
|
|
|
|
break;
|
2006-04-12 16:14:34 +04:00
|
|
|
case FsDbars:
|
2006-02-10 00:48:01 +03:00
|
|
|
/* jump to offset */
|
2006-03-24 15:36:35 +03:00
|
|
|
len = 0;
|
2006-04-13 18:52:33 +04:00
|
|
|
for(i = 0; i < bar.size; i++) {
|
2006-05-01 21:39:26 +04:00
|
|
|
len += stat_of_name(&stat, bar.data[i]->name, m->wqid, m->sel);
|
2006-02-10 00:48:01 +03:00
|
|
|
if(len <= fcall->offset)
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* offset found, proceeding */
|
2006-04-13 18:52:33 +04:00
|
|
|
for(; i < bar.size; i++) {
|
2006-05-01 21:39:26 +04:00
|
|
|
len = stat_of_name(&stat, bar.data[i]->name, m->wqid, m->sel);
|
2006-02-10 00:48:01 +03:00
|
|
|
if(fcall->count + len > fcall->iounit)
|
|
|
|
break;
|
|
|
|
fcall->count += len;
|
2006-05-01 21:39:26 +04:00
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-02-10 00:48:01 +03:00
|
|
|
}
|
|
|
|
break;
|
2006-03-23 11:54:20 +03:00
|
|
|
case FsDview:
|
2006-02-01 18:27:53 +03:00
|
|
|
/* jump to offset */
|
2006-04-10 12:58:21 +04:00
|
|
|
len = 0;
|
2006-04-03 00:53:56 +04:00
|
|
|
if(view.size) {
|
2006-05-01 21:39:26 +04:00
|
|
|
len = stat_of_name(&stat, "name", m->wqid, m->sel);
|
|
|
|
len += stat_of_name(&stat, "ctl", m->wqid, m->sel);
|
2006-04-03 00:53:56 +04:00
|
|
|
if(view.data[i1]->area.size)
|
2006-05-01 21:39:26 +04:00
|
|
|
len += stat_of_name(&stat, "sel", m->wqid, m->sel);
|
2006-04-03 00:53:56 +04:00
|
|
|
for(i = 0; i < view.data[i1]->area.size; i++) {
|
2006-03-22 15:02:41 +03:00
|
|
|
snprintf(buf, sizeof(buf), "%u", i);
|
2006-05-01 21:39:26 +04:00
|
|
|
len += stat_of_name(&stat, buf, m->wqid, m->sel);
|
2006-03-22 15:02:41 +03:00
|
|
|
if(len <= fcall->offset)
|
|
|
|
continue;
|
2006-02-01 18:27:53 +03:00
|
|
|
break;
|
2006-03-22 15:02:41 +03:00
|
|
|
}
|
|
|
|
/* offset found, proceeding */
|
2006-04-03 00:53:56 +04:00
|
|
|
for(; i < view.data[i1]->area.size; i++) {
|
2006-03-22 15:02:41 +03:00
|
|
|
snprintf(buf, sizeof(buf), "%u", i);
|
2006-05-01 21:39:26 +04:00
|
|
|
len = stat_of_name(&stat, buf, m->wqid, m->sel);
|
2006-03-22 15:02:41 +03:00
|
|
|
if(fcall->count + len > fcall->iounit)
|
|
|
|
break;
|
|
|
|
fcall->count += len;
|
2006-05-01 21:39:26 +04:00
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-03-22 15:02:41 +03:00
|
|
|
}
|
2006-02-01 18:27:53 +03:00
|
|
|
}
|
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsDarea:
|
2006-02-01 18:27:53 +03:00
|
|
|
/* jump to offset */
|
2006-05-01 21:39:26 +04:00
|
|
|
len = stat_of_name(&stat, "ctl", m->wqid, m->sel);
|
2006-03-27 09:46:12 +04:00
|
|
|
if(i2)
|
2006-05-01 21:39:26 +04:00
|
|
|
len += stat_of_name(&stat, "mode", m->wqid, m->sel);
|
2006-04-03 00:53:56 +04:00
|
|
|
if(view.data[i1]->area.data[i2]->frame.size)
|
2006-05-01 21:39:26 +04:00
|
|
|
len += stat_of_name(&stat, "sel", m->wqid, m->sel);
|
2006-04-03 00:53:56 +04:00
|
|
|
for(i = 0; i < view.data[i1]->area.data[i2]->frame.size; i++) {
|
2006-03-22 11:48:08 +03:00
|
|
|
snprintf(buf, sizeof(buf), "%u", i);
|
2006-05-01 21:39:26 +04:00
|
|
|
len += stat_of_name(&stat, buf, m->wqid, m->sel);
|
2006-02-03 20:11:22 +03:00
|
|
|
if(len <= fcall->offset)
|
2006-02-01 18:27:53 +03:00
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* offset found, proceeding */
|
2006-04-03 00:53:56 +04:00
|
|
|
for(; i < view.data[i1]->area.data[i2]->frame.size; i++) {
|
2006-03-22 11:48:08 +03:00
|
|
|
snprintf(buf, sizeof(buf), "%u", i);
|
2006-05-01 21:39:26 +04:00
|
|
|
len = stat_of_name(&stat, buf, m->wqid, m->sel);
|
2006-02-03 20:11:22 +03:00
|
|
|
if(fcall->count + len > fcall->iounit)
|
2006-01-30 21:43:32 +03:00
|
|
|
break;
|
2006-02-03 20:11:22 +03:00
|
|
|
fcall->count += len;
|
2006-05-01 21:39:26 +04:00
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFevent:
|
2006-02-12 02:49:38 +03:00
|
|
|
memcpy(&c->pending, fcall, sizeof(Fcall));
|
|
|
|
c->is_pending = 1;
|
2006-02-03 20:11:22 +03:00
|
|
|
return nil;
|
2006-01-30 21:43:32 +03:00
|
|
|
break;
|
2006-03-10 18:21:20 +03:00
|
|
|
case FsFkeys:
|
|
|
|
len = def.keys ? strlen(def.keys) : 0;
|
|
|
|
if(len <= fcall->offset) {
|
|
|
|
fcall->count = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fcall->count = len - fcall->offset;
|
|
|
|
if(fcall->count > fcall->iounit) {
|
|
|
|
memcpy(p, def.keys + fcall->offset, fcall->iounit);
|
|
|
|
fcall->count = fcall->iounit;
|
|
|
|
}
|
|
|
|
else if(fcall->count)
|
|
|
|
memcpy(p, def.keys + fcall->offset, fcall->count);
|
|
|
|
break;
|
2006-03-10 17:22:36 +03:00
|
|
|
case FsFrules:
|
|
|
|
len = def.rules ? strlen(def.rules) : 0;
|
|
|
|
if(len <= fcall->offset) {
|
|
|
|
fcall->count = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fcall->count = len - fcall->offset;
|
|
|
|
if(fcall->count > fcall->iounit) {
|
|
|
|
memcpy(p, def.rules + fcall->offset, fcall->iounit);
|
|
|
|
fcall->count = fcall->iounit;
|
|
|
|
}
|
|
|
|
else if(fcall->count)
|
|
|
|
memcpy(p, def.rules + fcall->offset, fcall->count);
|
|
|
|
break;
|
2006-04-13 19:41:58 +04:00
|
|
|
case FsFtags:
|
2006-05-01 21:39:26 +04:00
|
|
|
if(dir_type == FsDroot) {
|
2006-04-13 19:41:58 +04:00
|
|
|
len = 0;
|
|
|
|
/* jump to offset */
|
|
|
|
for(i = 0; i < view.size; i++) {
|
|
|
|
len += strlen(view.data[i]->name) + 1;
|
|
|
|
if(len <= fcall->offset)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* offset found, proceeding */
|
|
|
|
for(; i < view.size; i++) {
|
|
|
|
len = strlen(view.data[i]->name) + 1;
|
|
|
|
if(fcall->count + len > fcall->iounit)
|
|
|
|
break;
|
|
|
|
memcpy(p + fcall->count, view.data[i]->name, len - 1);
|
|
|
|
memcpy(p + fcall->count + len - 1, "\n", 1);
|
|
|
|
fcall->count += len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2006-01-30 21:43:32 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2006-02-10 17:59:30 +03:00
|
|
|
switch (type) {
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsDroot:
|
2006-05-01 21:39:26 +04:00
|
|
|
fcall->count = stat_of_name(&stat, "ctl", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "event", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "def", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "bar", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-04-12 16:14:34 +04:00
|
|
|
if(client.size) {
|
2006-05-01 21:39:26 +04:00
|
|
|
fcall->count += stat_of_name(&stat, "client", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-03-22 15:02:41 +03:00
|
|
|
}
|
2006-04-12 16:14:34 +04:00
|
|
|
if(view.size) {
|
2006-05-01 21:39:26 +04:00
|
|
|
fcall->count += stat_of_name(&stat, "tags", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "view", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-03-22 15:02:41 +03:00
|
|
|
}
|
2006-04-13 12:06:07 +04:00
|
|
|
for(i = 0; i < view.size; i++) {
|
2006-05-01 21:39:26 +04:00
|
|
|
len = stat_of_name(&stat, view.data[i]->name, m->wqid, m->sel);
|
2006-03-07 19:22:36 +03:00
|
|
|
if(fcall->count + len > fcall->iounit)
|
|
|
|
break;
|
|
|
|
fcall->count += len;
|
2006-05-01 21:39:26 +04:00
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-03-07 19:22:36 +03:00
|
|
|
}
|
|
|
|
break;
|
2006-04-13 12:06:07 +04:00
|
|
|
case FsDclients:
|
|
|
|
for(i = 0; i < client.size; i++) {
|
|
|
|
snprintf(buf, sizeof(buf), "%u", i);
|
2006-05-01 21:39:26 +04:00
|
|
|
len = stat_of_name(&stat, buf, m->wqid, m->sel);
|
2006-04-12 16:14:34 +04:00
|
|
|
if(fcall->count + len > fcall->iounit)
|
|
|
|
break;
|
|
|
|
fcall->count += len;
|
2006-05-01 21:39:26 +04:00
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-04-12 16:14:34 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FsDbars:
|
2006-04-13 18:52:33 +04:00
|
|
|
for(i = 0; i < bar.size; i++) {
|
2006-05-01 21:39:26 +04:00
|
|
|
len = stat_of_name(&stat, bar.data[i]->name, m->wqid, m->sel);
|
2006-02-10 00:48:01 +03:00
|
|
|
if(fcall->count + len > fcall->iounit)
|
|
|
|
break;
|
|
|
|
fcall->count += len;
|
2006-05-01 21:39:26 +04:00
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-02-10 00:48:01 +03:00
|
|
|
}
|
|
|
|
break;
|
2006-04-12 16:14:34 +04:00
|
|
|
case FsDbar:
|
2006-04-13 18:52:33 +04:00
|
|
|
if(i1 >= bar.size)
|
2006-02-10 00:48:01 +03:00
|
|
|
return Enofile;
|
2006-05-01 21:39:26 +04:00
|
|
|
fcall->count = stat_of_name(&stat, "colors", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "data", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-02-10 00:48:01 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsDdef:
|
2006-05-01 21:39:26 +04:00
|
|
|
fcall->count = stat_of_name(&stat, "border", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "selcolors", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "normcolors", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "font", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "keys", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "rules", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "grabmod", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "colmode", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "colwidth", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-02-01 18:27:53 +03:00
|
|
|
break;
|
2006-03-23 11:54:20 +03:00
|
|
|
case FsDview:
|
2006-04-03 00:53:56 +04:00
|
|
|
if(view.size) {
|
2006-05-01 21:39:26 +04:00
|
|
|
fcall->count = stat_of_name(&stat, "name", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "ctl", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-04-03 00:53:56 +04:00
|
|
|
if(view.data[i1]->area.size) {
|
2006-05-01 21:39:26 +04:00
|
|
|
fcall->count += stat_of_name(&stat, "sel", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-03-22 15:02:41 +03:00
|
|
|
}
|
2006-04-03 00:53:56 +04:00
|
|
|
for(i = 0; i < view.data[i1]->area.size; i++) {
|
2006-03-22 15:02:41 +03:00
|
|
|
snprintf(buf, sizeof(buf), "%u", i);
|
2006-05-01 21:39:26 +04:00
|
|
|
len = stat_of_name(&stat, buf, m->wqid, m->sel);
|
2006-03-22 15:02:41 +03:00
|
|
|
if(fcall->count + len > fcall->iounit)
|
|
|
|
break;
|
|
|
|
fcall->count += len;
|
2006-05-01 21:39:26 +04:00
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-03-22 15:02:41 +03:00
|
|
|
}
|
2006-02-01 18:27:53 +03:00
|
|
|
}
|
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsDarea:
|
2006-05-01 21:39:26 +04:00
|
|
|
fcall->count = stat_of_name(&stat, "ctl", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-03-22 11:48:08 +03:00
|
|
|
if(i2) {
|
2006-05-01 21:39:26 +04:00
|
|
|
fcall->count += stat_of_name(&stat, "mode", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-03-22 11:48:08 +03:00
|
|
|
}
|
2006-04-03 00:53:56 +04:00
|
|
|
if(view.data[i1]->area.data[i2]->frame.size) {
|
2006-05-01 21:39:26 +04:00
|
|
|
fcall->count += stat_of_name(&stat, "sel", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-03-22 11:48:08 +03:00
|
|
|
}
|
2006-04-03 00:53:56 +04:00
|
|
|
for(i = 0; i < view.data[i1]->area.data[i2]->frame.size; i++) {
|
2006-03-22 11:48:08 +03:00
|
|
|
snprintf(buf, sizeof(buf), "%u", i);
|
2006-05-01 21:39:26 +04:00
|
|
|
len = stat_of_name(&stat, buf, m->wqid, m->sel);
|
2006-02-03 20:11:22 +03:00
|
|
|
if(fcall->count + len > fcall->iounit)
|
2006-02-01 18:27:53 +03:00
|
|
|
break;
|
2006-02-03 20:11:22 +03:00
|
|
|
fcall->count += len;
|
2006-05-01 21:39:26 +04:00
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-02-01 18:27:53 +03:00
|
|
|
}
|
|
|
|
break;
|
2006-03-07 19:22:36 +03:00
|
|
|
case FsDGclient:
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsDclient:
|
2006-05-01 21:39:26 +04:00
|
|
|
fcall->count = stat_of_name(&stat, "class", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "name", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "index", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "tags", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "geom", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
|
|
|
fcall->count += stat_of_name(&stat, "ctl", m->wqid, m->sel);
|
|
|
|
p = ixp_pack_stat(p, &stat);
|
2006-01-30 21:43:32 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFctl:
|
2006-02-04 17:13:11 +03:00
|
|
|
return Enoperm;
|
2006-01-30 21:43:32 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFevent:
|
2006-02-12 02:49:38 +03:00
|
|
|
memcpy(&c->pending, fcall, sizeof(Fcall));
|
|
|
|
c->is_pending = 1;
|
2006-02-03 20:11:22 +03:00
|
|
|
return nil;
|
2006-01-30 21:43:32 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFborder:
|
2006-02-24 12:38:48 +03:00
|
|
|
snprintf(buf, sizeof(buf), "%u", def.border);
|
2006-02-03 20:11:22 +03:00
|
|
|
fcall->count = strlen(buf);
|
|
|
|
memcpy(p, buf, fcall->count);
|
2006-01-30 21:43:32 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFgeom:
|
2006-05-01 21:39:26 +04:00
|
|
|
if(dir_type == FsDclient) {
|
2006-04-03 00:53:56 +04:00
|
|
|
f = view.data[i1]->area.data[i2]->frame.data[i3];
|
2006-03-07 19:22:36 +03:00
|
|
|
snprintf(buf, sizeof(buf), "%d %d %d %d", f->rect.x, f->rect.y,
|
|
|
|
f->rect.width, f->rect.height);
|
|
|
|
}
|
|
|
|
else {
|
2006-04-03 00:53:56 +04:00
|
|
|
Client *c = client.data[i1];
|
2006-03-07 19:22:36 +03:00
|
|
|
snprintf(buf, sizeof(buf), "%d %d %d %d", c->rect.x, c->rect.y,
|
|
|
|
c->rect.width, c->rect.height);
|
|
|
|
}
|
2006-02-03 20:11:22 +03:00
|
|
|
fcall->count = strlen(buf);
|
|
|
|
memcpy(p, buf, fcall->count);
|
2006-02-02 15:20:07 +03:00
|
|
|
break;
|
2006-03-10 13:59:26 +03:00
|
|
|
case FsFclass:
|
2006-05-01 21:39:26 +04:00
|
|
|
if(dir_type == FsDclient) {
|
2006-04-03 00:53:56 +04:00
|
|
|
if((fcall->count = strlen(view.data[i1]->area.data[i2]->frame.data[i3]->client->classinst)))
|
|
|
|
memcpy(p, view.data[i1]->area.data[i2]->frame.data[i3]->client->classinst, fcall->count);
|
2006-03-10 13:59:26 +03:00
|
|
|
}
|
|
|
|
else {
|
2006-04-03 00:53:56 +04:00
|
|
|
if((fcall->count = strlen(client.data[i1]->classinst)))
|
|
|
|
memcpy(p, client.data[i1]->classinst, fcall->count);
|
2006-03-10 13:59:26 +03:00
|
|
|
}
|
|
|
|
break;
|
2006-04-26 10:59:55 +04:00
|
|
|
case FsFindex:
|
2006-05-01 21:39:26 +04:00
|
|
|
if(dir_type == FsDclient)
|
2006-04-26 10:59:55 +04:00
|
|
|
snprintf(buf, sizeof(buf), "%d",
|
|
|
|
idx_of_client_id(view.data[i1]->area.data[i2]->frame.data[i3]->client->id));
|
|
|
|
else
|
|
|
|
snprintf(buf, sizeof(buf), "%d", i1);
|
|
|
|
if((fcall->count = strlen(buf)))
|
|
|
|
memcpy(p, buf, fcall->count);
|
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFname:
|
2006-05-01 21:39:26 +04:00
|
|
|
if(dir_type == FsDclient) {
|
2006-04-03 00:53:56 +04:00
|
|
|
if((fcall->count = strlen(view.data[i1]->area.data[i2]->frame.data[i3]->client->name)))
|
|
|
|
memcpy(p, view.data[i1]->area.data[i2]->frame.data[i3]->client->name, fcall->count);
|
2006-03-07 19:22:36 +03:00
|
|
|
}
|
2006-05-01 21:39:26 +04:00
|
|
|
else if(dir_type == FsDview) {
|
2006-04-11 19:21:38 +04:00
|
|
|
if((fcall->count = strlen(view.data[i1]->name)))
|
|
|
|
memcpy(p, view.data[i1]->name, fcall->count);
|
|
|
|
}
|
2006-03-07 19:22:36 +03:00
|
|
|
else {
|
2006-04-03 00:53:56 +04:00
|
|
|
if((fcall->count = strlen(client.data[i1]->name)))
|
|
|
|
memcpy(p, client.data[i1]->name, fcall->count);
|
2006-03-07 19:22:36 +03:00
|
|
|
}
|
2006-01-30 21:43:32 +03:00
|
|
|
break;
|
2006-03-05 21:20:27 +03:00
|
|
|
case FsFtags:
|
2006-05-01 21:39:26 +04:00
|
|
|
switch(dir_type) {
|
2006-04-13 19:41:58 +04:00
|
|
|
case FsDclient:
|
|
|
|
{
|
|
|
|
Client *c = view.data[i1]->area.data[i2]->frame.data[i3]->client;
|
|
|
|
if((fcall->count = strlen(c->tags)))
|
|
|
|
memcpy(p, c->tags, fcall->count);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FsDGclient:
|
2006-04-06 13:31:54 +04:00
|
|
|
if((fcall->count = strlen(client.data[i1]->tags)))
|
|
|
|
memcpy(p, client.data[i1]->tags, fcall->count);
|
2006-04-13 19:41:58 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
for(i = 0; i < view.size; i++) {
|
|
|
|
len = strlen(view.data[i]->name) + 1;
|
|
|
|
if(fcall->count + len > fcall->iounit)
|
|
|
|
break;
|
|
|
|
memcpy(p + fcall->count, view.data[i]->name, len - 1);
|
|
|
|
memcpy(p + fcall->count + len - 1, "\n", 1);
|
|
|
|
fcall->count += len;
|
|
|
|
}
|
|
|
|
break;
|
2006-03-07 19:22:36 +03:00
|
|
|
}
|
2006-03-05 18:48:14 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFdata:
|
2006-04-13 18:52:33 +04:00
|
|
|
if(i1 >= bar.size)
|
2006-02-10 00:48:01 +03:00
|
|
|
return Enofile;
|
2006-04-13 18:52:33 +04:00
|
|
|
if((fcall->count = strlen(bar.data[i1]->data)))
|
|
|
|
memcpy(p, bar.data[i1]->data, fcall->count);
|
2006-02-10 00:48:01 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFcolors:
|
2006-04-13 18:52:33 +04:00
|
|
|
if(i1 >= bar.size)
|
2006-02-10 00:48:01 +03:00
|
|
|
return Enofile;
|
2006-04-13 18:52:33 +04:00
|
|
|
if((fcall->count = strlen(bar.data[i1]->colstr)))
|
|
|
|
memcpy(p, bar.data[i1]->colstr, fcall->count);
|
2006-02-10 00:48:01 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFselcolors:
|
2006-02-10 20:32:35 +03:00
|
|
|
if((fcall->count = strlen(def.selcolor)))
|
|
|
|
memcpy(p, def.selcolor, fcall->count);
|
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFnormcolors:
|
2006-02-10 20:32:35 +03:00
|
|
|
if((fcall->count = strlen(def.normcolor)))
|
|
|
|
memcpy(p, def.normcolor, fcall->count);
|
|
|
|
break;
|
2006-03-10 18:21:20 +03:00
|
|
|
case FsFkeys:
|
|
|
|
fcall->count = def.keys ? strlen(def.keys) : 0;
|
|
|
|
if(fcall->count > fcall->iounit) {
|
|
|
|
memcpy(p, def.keys, fcall->iounit);
|
|
|
|
fcall->count = fcall->iounit;
|
|
|
|
}
|
|
|
|
else if(fcall->count)
|
|
|
|
memcpy(p, def.keys, fcall->count);
|
|
|
|
break;
|
2006-03-10 16:39:46 +03:00
|
|
|
case FsFrules:
|
2006-03-10 17:22:36 +03:00
|
|
|
fcall->count = def.rules ? strlen(def.rules) : 0;
|
|
|
|
if(fcall->count > fcall->iounit) {
|
|
|
|
memcpy(p, def.rules, fcall->iounit);
|
|
|
|
fcall->count = fcall->iounit;
|
|
|
|
}
|
|
|
|
else if(fcall->count)
|
|
|
|
memcpy(p, def.rules, fcall->count);
|
2006-03-10 16:39:46 +03:00
|
|
|
break;
|
2006-04-12 13:08:31 +04:00
|
|
|
case FsFgrabmod:
|
|
|
|
if((fcall->count = strlen(def.grabmod)))
|
|
|
|
memcpy(p, def.grabmod, fcall->count);
|
|
|
|
break;
|
2006-04-14 14:45:53 +04:00
|
|
|
case FsFcolw:
|
|
|
|
snprintf(buf, sizeof(buf), "%d", def.colw);
|
|
|
|
if((fcall->count = strlen(buf)))
|
|
|
|
memcpy(p, buf, fcall->count);
|
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFfont:
|
2006-02-10 20:32:35 +03:00
|
|
|
if((fcall->count = strlen(def.font)))
|
|
|
|
memcpy(p, def.font, fcall->count);
|
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFmode:
|
2006-05-01 21:39:26 +04:00
|
|
|
if(dir_type == FsDarea) {
|
2006-04-14 14:03:44 +04:00
|
|
|
if(!i2)
|
|
|
|
return Enofile;
|
|
|
|
i = view.data[i1]->area.data[i2]->mode;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
i = def.colmode;
|
|
|
|
snprintf(buf, sizeof(buf), "%s", str_of_column_mode(i));
|
2006-02-28 18:23:05 +03:00
|
|
|
fcall->count = strlen(buf);
|
|
|
|
memcpy(p, buf, fcall->count);
|
2006-03-23 18:07:18 +03:00
|
|
|
break;
|
2006-01-30 21:43:32 +03:00
|
|
|
default:
|
2006-03-11 03:07:19 +03:00
|
|
|
return Enoperm;
|
2006-01-30 21:43:32 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-02-03 20:11:22 +03:00
|
|
|
fcall->id = RREAD;
|
|
|
|
ixp_server_respond_fcall(c, fcall);
|
2006-03-23 18:07:18 +03:00
|
|
|
return nil;
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
|
|
|
|
2006-02-03 20:11:22 +03:00
|
|
|
static char *
|
|
|
|
xstat(IXPConn *c, Fcall *fcall)
|
2006-01-30 21:43:32 +03:00
|
|
|
{
|
2006-03-23 18:07:18 +03:00
|
|
|
IXPMap *m = ixp_server_fid2map(c, fcall->fid);
|
2006-01-30 21:43:32 +03:00
|
|
|
char *name;
|
|
|
|
|
2006-03-23 18:07:18 +03:00
|
|
|
if(!m)
|
|
|
|
return Enofile;
|
2006-05-01 21:39:26 +04:00
|
|
|
if(!(name = name_of_qid(m->wqid, m->sel)))
|
|
|
|
return Enofile;
|
|
|
|
if(!stat_of_name(&fcall->stat, name, m->wqid, m->sel ? m->sel - 1 : 0))
|
2006-02-03 20:11:22 +03:00
|
|
|
return Enofile;
|
2006-03-23 18:07:18 +03:00
|
|
|
fcall->id = RSTAT;
|
2006-02-03 20:11:22 +03:00
|
|
|
ixp_server_respond_fcall(c, fcall);
|
2006-03-23 18:07:18 +03:00
|
|
|
return nil;
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
|
|
|
|
2006-02-03 20:11:22 +03:00
|
|
|
static char *
|
|
|
|
xwrite(IXPConn *c, Fcall *fcall)
|
2006-01-30 21:43:32 +03:00
|
|
|
{
|
2006-03-10 18:21:20 +03:00
|
|
|
char buf[256], *tmp;
|
2006-03-23 18:07:18 +03:00
|
|
|
IXPMap *m = ixp_server_fid2map(c, fcall->fid);
|
2006-03-11 22:58:08 +03:00
|
|
|
int i, i1 = 0, i2 = 0, i3 = 0;
|
2006-05-01 21:39:26 +04:00
|
|
|
unsigned char dir_type, type;
|
|
|
|
unsigned int len;
|
2006-03-05 03:55:45 +03:00
|
|
|
Frame *f;
|
2006-04-06 13:31:54 +04:00
|
|
|
Client *cl;
|
2006-01-30 21:43:32 +03:00
|
|
|
|
2006-03-23 18:07:18 +03:00
|
|
|
if(!m)
|
|
|
|
return Enofile;
|
2006-05-01 21:39:26 +04:00
|
|
|
unpack_qpath(m->wqid, m->sel, &type, &i1, &i2, &i3);
|
2006-02-10 17:59:30 +03:00
|
|
|
if((i1 == -1) || (i2 == -1) || (i3 == -1))
|
2006-02-03 20:11:22 +03:00
|
|
|
return Enofile;
|
2006-05-01 21:39:26 +04:00
|
|
|
dir_type = dir_of_qid(m->wqid, m->sel);
|
2006-01-30 21:43:32 +03:00
|
|
|
|
2006-03-07 19:22:36 +03:00
|
|
|
switch(type) {
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFctl:
|
2006-02-06 11:46:52 +03:00
|
|
|
if(fcall->count > sizeof(buf) - 1)
|
|
|
|
return Enocommand;
|
|
|
|
memcpy(buf, fcall->data, fcall->count);
|
|
|
|
buf[fcall->count] = 0;
|
2006-05-01 21:39:26 +04:00
|
|
|
switch(dir_type) {
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsDroot:
|
2006-02-06 11:46:52 +03:00
|
|
|
if(!strncmp(buf, "quit", 5))
|
2006-02-08 13:07:30 +03:00
|
|
|
srv.running = 0;
|
2006-04-13 12:06:07 +04:00
|
|
|
else if(!strncmp(buf, "view ", 5))
|
2006-04-28 23:37:38 +04:00
|
|
|
select_view(&buf[5]);
|
2006-04-12 16:28:05 +04:00
|
|
|
else
|
|
|
|
return Enocommand;
|
|
|
|
break;
|
2006-03-23 11:54:20 +03:00
|
|
|
case FsDview:
|
2006-02-19 18:21:01 +03:00
|
|
|
if(!strncmp(buf, "select ", 7))
|
2006-04-03 00:53:56 +04:00
|
|
|
if(view.size)
|
|
|
|
select_area(view.data[i1]->area.data[view.data[i1]->sel], &buf[7]);
|
2006-02-02 00:24:07 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsDarea:
|
2006-02-14 14:06:16 +03:00
|
|
|
if(!strncmp(buf, "select ", 7)) {
|
2006-05-21 21:21:37 +04:00
|
|
|
Area *a = view.data[i1]->area.data[i2];
|
|
|
|
if(a->frame.size)
|
|
|
|
select_client(a->frame.data[a->sel]->client, &buf[7]);
|
2006-02-14 14:06:16 +03:00
|
|
|
}
|
2006-02-02 00:24:07 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsDclient:
|
2006-04-03 00:53:56 +04:00
|
|
|
f = view.data[i1]->area.data[i2]->frame.data[i3];
|
2006-02-16 17:28:51 +03:00
|
|
|
if(!strncmp(buf, "kill", 5))
|
2006-03-05 03:55:45 +03:00
|
|
|
kill_client(f->client);
|
2006-05-21 21:21:37 +04:00
|
|
|
else if(!strncmp(buf, "newcol ", 7))
|
|
|
|
newcol_client(f->client, &buf[7]);
|
|
|
|
else if(!strncmp(buf, "move ", 5))
|
|
|
|
move_client(f->client, &buf[5]);
|
2006-02-02 00:24:07 +03:00
|
|
|
break;
|
2006-03-07 19:22:36 +03:00
|
|
|
case FsDGclient:
|
|
|
|
if(!strncmp(buf, "kill", 5))
|
2006-04-03 00:53:56 +04:00
|
|
|
kill_client(client.data[i1]);
|
2006-03-07 19:22:36 +03:00
|
|
|
break;
|
2006-02-02 00:24:07 +03:00
|
|
|
default:
|
2006-02-06 11:46:52 +03:00
|
|
|
break;
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFborder:
|
2006-02-03 20:11:22 +03:00
|
|
|
if(fcall->count > sizeof(buf))
|
2006-03-11 03:07:19 +03:00
|
|
|
return Ebadvalue;
|
2006-02-03 20:11:22 +03:00
|
|
|
memcpy(buf, fcall->data, fcall->count);
|
|
|
|
buf[fcall->count] = 0;
|
2006-02-02 00:24:07 +03:00
|
|
|
i = cext_strtonum(buf, 0, 0xffff, &err);
|
2006-02-03 20:11:22 +03:00
|
|
|
if(err)
|
2006-03-11 03:07:19 +03:00
|
|
|
return Ebadvalue;
|
2006-02-24 12:38:48 +03:00
|
|
|
def.border = i;
|
|
|
|
resize_all_clients();
|
2006-01-30 21:43:32 +03:00
|
|
|
break;
|
2006-03-05 21:20:27 +03:00
|
|
|
case FsFtags:
|
2006-05-01 21:39:26 +04:00
|
|
|
if(dir_type == FsDroot)
|
2006-03-11 03:07:19 +03:00
|
|
|
return Enoperm;
|
2006-03-24 17:17:50 +03:00
|
|
|
if(!fcall->count || (fcall->count > sizeof(buf)))
|
2006-03-11 03:07:19 +03:00
|
|
|
return Ebadvalue;
|
2006-03-09 18:41:11 +03:00
|
|
|
memcpy(buf, fcall->data, fcall->count);
|
|
|
|
buf[fcall->count] = 0;
|
2006-05-07 23:56:05 +04:00
|
|
|
cext_trim(buf, " \t");
|
2006-04-13 12:06:07 +04:00
|
|
|
if(!permit_tags(buf))
|
|
|
|
return Ebadvalue;
|
2006-05-01 21:39:26 +04:00
|
|
|
if(dir_type == FsDclient)
|
2006-04-06 13:31:54 +04:00
|
|
|
cl = view.data[i1]->area.data[i2]->frame.data[i3]->client;
|
2006-03-09 18:41:11 +03:00
|
|
|
else
|
2006-04-06 13:31:54 +04:00
|
|
|
cl = client.data[i1];
|
|
|
|
cext_strlcpy(cl->tags, buf, sizeof(cl->tags));
|
2006-04-11 12:16:01 +04:00
|
|
|
update_views();
|
2006-04-06 13:31:54 +04:00
|
|
|
draw_client(cl);
|
2006-03-05 18:48:14 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFgeom:
|
2006-02-16 17:28:51 +03:00
|
|
|
if(fcall->count > sizeof(buf))
|
2006-03-11 03:07:19 +03:00
|
|
|
return Ebadvalue;
|
2006-02-16 17:28:51 +03:00
|
|
|
memcpy(buf, fcall->data, fcall->count);
|
|
|
|
buf[fcall->count] = 0;
|
2006-05-01 21:39:26 +04:00
|
|
|
if(dir_type == FsDclient) {
|
2006-04-24 19:53:48 +04:00
|
|
|
XRectangle new;
|
2006-04-03 00:53:56 +04:00
|
|
|
f = view.data[i1]->area.data[i2]->frame.data[i3];
|
2006-04-24 19:53:48 +04:00
|
|
|
new = f->rect;
|
|
|
|
blitz_strtorect(&rect, &new, buf);
|
2006-03-15 18:00:39 +03:00
|
|
|
if(i2)
|
2006-04-24 19:53:48 +04:00
|
|
|
resize_column(f->client, &new, nil);
|
2006-03-15 18:00:39 +03:00
|
|
|
else
|
2006-04-24 19:53:48 +04:00
|
|
|
resize_client(f->client, &new, False);
|
2006-03-07 19:22:36 +03:00
|
|
|
}
|
2006-02-02 15:20:07 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFdata:
|
2006-03-10 17:22:36 +03:00
|
|
|
len = fcall->count;
|
2006-04-13 18:52:33 +04:00
|
|
|
if(len >= sizeof(bar.data[i1]->data))
|
|
|
|
len = sizeof(bar.data[i1]->data) - 1;
|
|
|
|
memcpy(bar.data[i1]->data, fcall->data, len);
|
|
|
|
bar.data[i1]->data[len] = 0;
|
2006-03-10 17:22:36 +03:00
|
|
|
draw_bar();
|
2006-02-10 00:48:01 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFcolors:
|
2006-04-13 18:52:33 +04:00
|
|
|
if((i1 >= bar.size) || (fcall->count != 23) || (fcall->data[0] != '#')
|
2006-03-23 18:07:18 +03:00
|
|
|
|| (fcall->data[8] != '#') || (fcall->data[16] != '#'))
|
2006-03-11 03:07:19 +03:00
|
|
|
return Ebadvalue;
|
2006-04-13 18:52:33 +04:00
|
|
|
memcpy(bar.data[i1]->colstr, fcall->data, fcall->count);
|
|
|
|
bar.data[i1]->colstr[fcall->count] = 0;
|
2006-04-23 22:00:47 +04:00
|
|
|
blitz_loadcolor(dpy, &bar.data[i1]->color, screen, bar.data[i1]->colstr);
|
2006-02-10 00:48:01 +03:00
|
|
|
draw_bar();
|
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFselcolors:
|
2006-03-23 18:07:18 +03:00
|
|
|
if((fcall->count != 23) || (fcall->data[0] != '#')
|
|
|
|
|| (fcall->data[8] != '#') || (fcall->data[16] != '#'))
|
2006-03-11 03:07:19 +03:00
|
|
|
return Ebadvalue;
|
2006-02-10 20:32:35 +03:00
|
|
|
memcpy(def.selcolor, fcall->data, fcall->count);
|
|
|
|
def.selcolor[fcall->count] = 0;
|
2006-04-23 22:00:47 +04:00
|
|
|
blitz_loadcolor(dpy, &def.sel, screen, def.selcolor);
|
2006-03-11 22:58:08 +03:00
|
|
|
draw_clients();
|
2006-02-10 20:32:35 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFnormcolors:
|
2006-03-23 18:07:18 +03:00
|
|
|
if((fcall->count != 23) || (fcall->data[0] != '#')
|
|
|
|
|| (fcall->data[8] != '#') || (fcall->data[16] != '#'))
|
2006-03-11 03:07:19 +03:00
|
|
|
return Ebadvalue;
|
2006-02-10 20:32:35 +03:00
|
|
|
memcpy(def.normcolor, fcall->data, fcall->count);
|
|
|
|
def.normcolor[fcall->count] = 0;
|
2006-04-23 22:00:47 +04:00
|
|
|
blitz_loadcolor(dpy, &def.norm, screen, def.normcolor);
|
2006-03-11 22:58:08 +03:00
|
|
|
draw_clients();
|
2006-02-10 20:32:35 +03:00
|
|
|
break;
|
2006-03-10 18:21:20 +03:00
|
|
|
case FsFkeys:
|
|
|
|
if(def.keyssz < fcall->offset + fcall->count + 1) {
|
|
|
|
def.keyssz = fcall->offset + fcall->count + 1;
|
|
|
|
tmp = cext_emallocz(def.keyssz);
|
|
|
|
len = def.keys ? strlen(def.keys) : 0;
|
|
|
|
if(len) {
|
|
|
|
memcpy(tmp, def.keys, len);
|
|
|
|
free(def.keys);
|
|
|
|
}
|
|
|
|
def.keys = tmp;
|
|
|
|
}
|
|
|
|
memcpy(def.keys + fcall->offset, fcall->data, fcall->count);
|
|
|
|
def.keys[fcall->offset + fcall->count] = 0;
|
|
|
|
break;
|
2006-03-10 16:39:46 +03:00
|
|
|
case FsFrules:
|
2006-03-10 18:21:20 +03:00
|
|
|
if(def.rulessz < fcall->offset + fcall->count + 1) {
|
|
|
|
def.rulessz = fcall->offset + fcall->count + 1;
|
|
|
|
tmp = cext_emallocz(def.rulessz);
|
|
|
|
len = def.rules ? strlen(def.rules) : 0;
|
|
|
|
if(len) {
|
|
|
|
memcpy(tmp, def.rules, len);
|
|
|
|
free(def.rules);
|
2006-03-10 17:22:36 +03:00
|
|
|
}
|
2006-03-10 18:21:20 +03:00
|
|
|
def.rules = tmp;
|
2006-03-10 16:39:46 +03:00
|
|
|
}
|
2006-03-10 18:21:20 +03:00
|
|
|
memcpy(def.rules + fcall->offset, fcall->data, fcall->count);
|
|
|
|
def.rules[fcall->offset + fcall->count] = 0;
|
2006-03-10 16:39:46 +03:00
|
|
|
break;
|
2006-04-12 13:08:31 +04:00
|
|
|
case FsFgrabmod:
|
|
|
|
{
|
|
|
|
unsigned long mod;
|
|
|
|
if(fcall->count > sizeof(buf))
|
|
|
|
return Ebadvalue;
|
|
|
|
memcpy(buf, fcall->data, fcall->count);
|
|
|
|
buf[fcall->count] = 0;
|
|
|
|
mod = mod_key_of_str(buf);
|
2006-04-13 09:30:44 +04:00
|
|
|
if((mod != Mod1Mask) && (mod != Mod2Mask) && (mod != Mod3Mask)
|
|
|
|
&& (mod != Mod4Mask) && (mod != Mod5Mask))
|
2006-04-12 13:08:31 +04:00
|
|
|
return Ebadvalue;
|
|
|
|
cext_strlcpy(def.grabmod, buf, sizeof(def.grabmod));
|
|
|
|
def.mod = mod;
|
|
|
|
if(view.size)
|
|
|
|
restack_view(view.data[sel]);
|
|
|
|
}
|
|
|
|
break;
|
2006-04-14 14:45:53 +04:00
|
|
|
case FsFcolw:
|
|
|
|
if(fcall->count > sizeof(buf))
|
|
|
|
return Ebadvalue;
|
|
|
|
memcpy(buf, fcall->data, fcall->count);
|
|
|
|
buf[fcall->count] = 0;
|
2006-04-14 14:47:10 +04:00
|
|
|
i = cext_strtonum(buf, 0, rect.width - MIN_COLWIDTH, &err);
|
|
|
|
if(err || (i && i < MIN_COLWIDTH))
|
2006-04-14 14:45:53 +04:00
|
|
|
return Ebadvalue;
|
|
|
|
def.colw = i;
|
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFfont:
|
2006-02-10 20:32:35 +03:00
|
|
|
if(def.font)
|
|
|
|
free(def.font);
|
|
|
|
def.font = cext_emallocz(fcall->count + 1);
|
|
|
|
memcpy(def.font, fcall->data, fcall->count);
|
2006-04-23 22:00:47 +04:00
|
|
|
blitz_loadfont(dpy, &blitzfont, def.font);
|
2006-04-12 12:44:07 +04:00
|
|
|
resize_bar();
|
2006-02-10 20:32:35 +03:00
|
|
|
break;
|
2006-03-05 16:16:48 +03:00
|
|
|
case FsFmode:
|
2006-03-12 12:51:12 +03:00
|
|
|
if(fcall->count > sizeof(buf))
|
|
|
|
return Ebadvalue;
|
2006-05-01 21:39:26 +04:00
|
|
|
if(dir_type == FsDarea && !i2)
|
2006-04-14 14:03:44 +04:00
|
|
|
return Enofile;
|
2006-03-05 02:11:08 +03:00
|
|
|
memcpy(buf, fcall->data, fcall->count);
|
|
|
|
buf[fcall->count] = 0;
|
2006-04-12 12:44:07 +04:00
|
|
|
if((i = column_mode_of_str(buf)) == -1)
|
2006-03-11 03:07:19 +03:00
|
|
|
return Ebadvalue;
|
2006-05-01 21:39:26 +04:00
|
|
|
if(dir_type == FsDarea) {
|
2006-04-14 14:03:44 +04:00
|
|
|
view.data[i1]->area.data[i2]->mode = i;
|
|
|
|
arrange_column(view.data[i1]->area.data[i2], True);
|
2006-05-10 15:57:09 +04:00
|
|
|
restack_view(view.data[i1]);
|
2006-04-28 14:37:19 +04:00
|
|
|
draw_clients();
|
2006-04-14 14:03:44 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
def.colmode = i;
|
2006-03-23 18:07:18 +03:00
|
|
|
break;
|
2006-03-12 12:51:12 +03:00
|
|
|
case FsFevent:
|
|
|
|
if(fcall->count > sizeof(buf))
|
|
|
|
return Ebadvalue;
|
2006-03-15 11:02:25 +03:00
|
|
|
if(fcall->count) {
|
|
|
|
memcpy(buf, fcall->data, fcall->count);
|
|
|
|
buf[fcall->count] = 0;
|
2006-03-23 20:08:55 +03:00
|
|
|
write_event(buf);
|
2006-03-15 11:02:25 +03:00
|
|
|
}
|
2006-03-12 12:51:12 +03:00
|
|
|
break;
|
2006-01-30 21:43:32 +03:00
|
|
|
default:
|
2006-03-11 03:07:19 +03:00
|
|
|
return Enoperm;
|
2006-01-30 21:43:32 +03:00
|
|
|
break;
|
|
|
|
}
|
2006-03-23 18:07:18 +03:00
|
|
|
fcall->id = RWRITE;
|
2006-02-03 20:11:22 +03:00
|
|
|
ixp_server_respond_fcall(c, fcall);
|
|
|
|
return nil;
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
|
|
|
|
2006-02-03 20:11:22 +03:00
|
|
|
static char *
|
|
|
|
xclunk(IXPConn *c, Fcall *fcall)
|
2006-01-30 21:43:32 +03:00
|
|
|
{
|
2006-03-23 18:07:18 +03:00
|
|
|
IXPMap *m = ixp_server_fid2map(c, fcall->fid);
|
2006-05-17 18:47:26 +04:00
|
|
|
unsigned char type;
|
2006-01-30 21:43:32 +03:00
|
|
|
|
2006-03-23 18:07:18 +03:00
|
|
|
if(!m)
|
|
|
|
return Enofile;
|
2006-05-17 18:47:26 +04:00
|
|
|
type = unpack_type(m->wqid[m->sel].path);
|
2006-03-26 20:21:12 +04:00
|
|
|
if(type == FsFkeys)
|
2006-03-23 18:07:18 +03:00
|
|
|
update_keys();
|
2006-03-26 20:21:12 +04:00
|
|
|
else if(type == FsFrules)
|
|
|
|
update_rules();
|
2006-04-13 17:35:10 +04:00
|
|
|
cext_vdetach(ixp_vector_of_maps(&c->map), m);
|
2006-03-23 18:07:18 +03:00
|
|
|
free(m);
|
|
|
|
fcall->id = RCLUNK;
|
2006-02-03 20:11:22 +03:00
|
|
|
ixp_server_respond_fcall(c, fcall);
|
2006-03-23 18:07:18 +03:00
|
|
|
return nil;
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-02-03 20:11:22 +03:00
|
|
|
do_fcall(IXPConn *c)
|
2006-01-30 21:43:32 +03:00
|
|
|
{
|
2006-02-03 20:11:22 +03:00
|
|
|
static Fcall fcall;
|
2006-03-23 18:07:18 +03:00
|
|
|
unsigned int msize;
|
2006-02-03 20:11:22 +03:00
|
|
|
char *errstr;
|
|
|
|
|
|
|
|
if((msize = ixp_server_receive_fcall(c, &fcall))) {
|
|
|
|
switch(fcall.id) {
|
|
|
|
case TVERSION: errstr = xversion(c, &fcall); break;
|
|
|
|
case TATTACH: errstr = xattach(c, &fcall); break;
|
|
|
|
case TWALK: errstr = xwalk(c, &fcall); break;
|
2006-02-12 03:49:33 +03:00
|
|
|
case TCREATE: errstr = xcreate(c, &fcall); break;
|
2006-02-03 20:11:22 +03:00
|
|
|
case TOPEN: errstr = xopen(c, &fcall); break;
|
2006-02-10 00:48:01 +03:00
|
|
|
case TREMOVE: errstr = xremove(c, &fcall); break;
|
2006-02-03 20:11:22 +03:00
|
|
|
case TREAD: errstr = xread(c, &fcall); break;
|
|
|
|
case TWRITE: errstr = xwrite(c, &fcall); break;
|
|
|
|
case TCLUNK: errstr = xclunk(c, &fcall); break;
|
|
|
|
case TSTAT: errstr = xstat(c, &fcall); break;
|
|
|
|
default: errstr = Enofunc; break;
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
2006-02-03 20:11:22 +03:00
|
|
|
if(errstr)
|
|
|
|
ixp_server_respond_error(c, &fcall, errstr);
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
2006-02-08 20:35:40 +03:00
|
|
|
check_x_event(nil);
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
|
|
|
|
2006-02-02 00:24:07 +03:00
|
|
|
void
|
2006-03-23 20:08:55 +03:00
|
|
|
write_event(char *event)
|
2006-01-30 21:43:32 +03:00
|
|
|
{
|
2006-03-23 20:08:55 +03:00
|
|
|
unsigned int i = 0;
|
2006-03-23 18:07:18 +03:00
|
|
|
|
2006-04-03 18:48:41 +04:00
|
|
|
for(i = 0; i < srv.conn.size; i++) {
|
|
|
|
IXPConn *c = srv.conn.data[i];
|
2006-02-12 02:49:38 +03:00
|
|
|
if(c->is_pending) {
|
|
|
|
/* pending reads on /event only, no qid checking */
|
|
|
|
IXPMap *m = ixp_server_fid2map(c, c->pending.fid);
|
2006-01-30 21:43:32 +03:00
|
|
|
if(!m) {
|
2006-03-22 21:54:27 +03:00
|
|
|
if(ixp_server_respond_error(c, &c->pending, Enofile))
|
2006-03-23 10:43:26 +03:00
|
|
|
return;
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
2006-05-01 21:39:26 +04:00
|
|
|
else if(unpack_type(m->wqid[m->sel].path) == FsFevent) {
|
2006-03-23 10:43:26 +03:00
|
|
|
/* pending reads on /event only, no qid checking */
|
2006-02-12 02:49:38 +03:00
|
|
|
c->pending.count = strlen(event);
|
2006-03-23 10:43:26 +03:00
|
|
|
memcpy(c->pending.data, event, c->pending.count);
|
2006-02-12 02:49:38 +03:00
|
|
|
c->pending.id = RREAD;
|
|
|
|
if(ixp_server_respond_fcall(c, &c->pending))
|
2006-03-23 10:43:26 +03:00
|
|
|
return;
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-02 00:24:07 +03:00
|
|
|
void
|
2006-02-03 20:11:22 +03:00
|
|
|
new_ixp_conn(IXPConn *c)
|
2006-01-30 21:43:32 +03:00
|
|
|
{
|
|
|
|
int fd = ixp_accept_sock(c->fd);
|
2006-03-23 18:07:18 +03:00
|
|
|
|
2006-02-03 20:11:22 +03:00
|
|
|
if(fd >= 0)
|
|
|
|
ixp_server_open_conn(c->srv, fd, do_fcall, ixp_server_close_conn);
|
2006-01-30 21:43:32 +03:00
|
|
|
}
|