forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
1.7 KiB
83 lines
1.7 KiB
<?php |
|
|
|
/* |
|
Linha de comando |
|
ipcs -> mostra blocos de memoria alocados |
|
ipcrm -m "shmid" -> remove o bloco de memória referenciado por shmid |
|
*/ |
|
|
|
function ShmGetId($file) { |
|
if (!file_exists($file)) { |
|
touch($file); |
|
} |
|
return ftok($file, 'R'); |
|
} |
|
|
|
function ShmOpen($key, $flags = SHM_ACESS_MODE, $mode = SHM_ACESS_PERMISSION, $size = SHM_SIZE) { |
|
$shmkey = shmop_open($key, $flags, $mode, $size); |
|
|
|
if (!$shmkey) { |
|
return false; |
|
} else { |
|
return $shmkey; |
|
} |
|
} |
|
|
|
function ShmWrite($shmkey, $data, $offset = 0) { |
|
$fsize = strlen($data); |
|
$shm_bytes_written = shmop_write($shmkey, $data, $offset); |
|
|
|
if ($shm_bytes_written != $fsize) { |
|
return false; |
|
} else { |
|
return $shm_bytes_written; |
|
} |
|
} |
|
|
|
function ShmRead($shmkey, $start, $count) { |
|
$my_string = shmop_read($shmkey, $start, $count); |
|
if (!$my_string) { |
|
return false; |
|
} else { |
|
return $my_string; |
|
} |
|
} |
|
|
|
function ShmWriteVar($shmkey, $data, $offset) { |
|
$fdata = serialize($fdata); |
|
$fsize = strlen($fdata); |
|
$shm_bytes_written = shmop_write($shmkey, $fdata, $offset); |
|
|
|
if ($shm_bytes_written != $fsize) { |
|
return false; |
|
} else { |
|
return $shm_bytes_written; |
|
} |
|
} |
|
|
|
function ShmReadVar($shmkey, $start, $count) { |
|
$my_string = shmop_read($shmkey, $start, $count); |
|
if (!$my_string) { |
|
return false; |
|
} else { |
|
return unserialize($my_string); |
|
} |
|
} |
|
|
|
function ShmDelete($shmkey) { |
|
if (!@shmop_delete($shmkey)) { |
|
return false; |
|
} else { |
|
return true; |
|
} |
|
} |
|
|
|
function ShmClose($shmkey) { |
|
return @shmop_close($shmkey); |
|
} |
|
|
|
function ShmExist($key) { |
|
return @shmop_open($key, 'a', 0, 0); |
|
} |
|
|
|
?>
|