php-src/ext/shmop
2002-01-17 19:58:53 +00:00
..
config.m4 - shmop_open has a new flag for read/write access, 'w' 2002-01-09 08:02:21 +00:00
CREDITS 2nd step towards auto-credits 2000-11-20 10:33:33 +00:00
Makefile.in @- Added the shmop extension. It allows more general ways of shared memory 2000-10-01 15:06:04 +00:00
php_shmop.h - shmop_open has a new flag for read/write access, 'w' 2002-01-09 08:02:21 +00:00
README - shmop_open has a new flag for read/write access, 'w' 2002-01-09 08:02:21 +00:00
setup.stub @- Added the shmop extension. It allows more general ways of shared memory 2000-10-01 15:06:04 +00:00
shmop.c Fixed shmop_read to append \0 to returned string in shmop_read to eliminate Zend warnings 2002-01-17 19:58:53 +00:00
shmop.dsp let ext\shmop build under win32 2001-08-07 13:33:27 +00:00

last update Jan 2, 2002 (hackie@prohost.org/ilia@prohost.org)

Shared Memory Operations Extension to PHP4

	While developing a search deamon we needed a php based front end
	to communicate the deamon via SHM. PHP already had a shared memory
	extention (sysvshm) written by Christian Cartus <cartus@atrior.de>,
	unfortunatly this extention was designed with PHP only in mind and
	offers high level features which are extremly bothersome for basic SHM
	we had in mind.  After spending a day trying to reverse engineer and figure
	out the format of sysvshm we decided that it would be much easier to
	add our own extention to php for simple SHM operations, we were right :)). 

the functions are:
	
int shmop_open(int key, string flags, int mode, int size)
	
	key 		- the key of/for the shared memory block
	flags 		- 4 flags are avalible 
				a for read only access (sets SHM_RDONLY)
				w for read & write access
				c create or open an existing segment (sets IPC_CREATE)
				n create a new segment and fail if one already exists under same name (sets IPC_CREATE|IPC_EXCL)
				(the n flag is mostly useful for security perpouses, so that you don't end up opening a faked segment 
				if someone guesses your key)
	mode		- acsess mode same as for a file (0644) for example
	size		- size of the block in bytes
	
	returns an indentifier
	

char shmop_read(int shmid, int start, int count)

	shmid		- shmid from which to read
	start		- offset from which to start reading
	count		- how many bytes to read
	
	returns the data read

int shmop_write(int shmid, string data, int offset)

	shmid		- shmid from which to read
	data		- string to put into shared memory
	offset		- offset in shm to write from
	
	returns bytes written
	
int shmop_size(int shmid)

	shmid 		- shmid for which to return the size
	
	returns the size in bytes of the shm segment
	
	
int shmop_delete(int shmid)

	marks the segment for deletion, the segment will be deleted when all processes mapping it will detach

	shmid		- shmid which to mark for deletion
	
	returns 1 if all ok, zero on failure
	
int shmop_close(int shmid)

	shmid 		- shmid which to close
	
	returns zero