Mercurial > core / lisp/lib/pod/client.lisp
changeset 698: |
96958d3eb5b0 |
parent: |
35a579313b80
|
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Fri, 04 Oct 2024 22:04:59 -0400 |
permissions: |
-rw-r--r-- |
description: |
fixes |
1 ;;; lib/pod/client.lisp --- Libpod API client 8 (defvar *podman-local-user-socket* (format nil "/var/run/user/~a/podman/podman.sock" (sb-posix:getuid))) 10 (defvar *libpod-api-version* "4.8.2") 13 (defclass libpod-unix-socket (local-socket) ()) 15 (defclass libpod-tcp-socket (inet-socket) ()) 18 (defclass libpod-client () 19 ((socket :initarg :socket 20 :initform (make-instance 'local-socket :type :stream) 21 :type (or local-socket null) 22 :accessor client-socket) 25 :accessor client-addr) 27 :initform *podman-local-user-socket* 28 :accessor client-peer))) 30 (defmethod make-load-form ((self libpod-client) &optional env) 31 (declare (ignore env)) 32 `(make-instance 'libpod-client :socket nil :addr ,(client-addr self) :peer ,(client-peer self))) 34 ;;; Net Client protocol 37 (defmethod socket-connect ((self libpod-client) &rest addr) 38 (socket-connect (client-socket self) (or addr (client-peer self)))) 40 (defmethod socket-close ((self libpod-client) &key (abort t)) 41 (socket-close (client-socket self) :abort abort)) 43 (defmethod socket-shutdown ((self libpod-client) &key (direction t)) 44 (socket-shutdown self :direction direction)) 46 (defmethod socket-send ((self libpod-client) buffer length 56 (socket-send (client-socket self) buffer length 58 :external-format external-format 67 (defmethod socket-receive ((self libpod-client) buffer length 72 (element-type 'character)) 73 (socket-receive (client-socket self) buffer length 74 :element-type element-type 80 (defmethod socket-listen ((self libpod-client) backlog) 81 (socket-listen (client-socket self) backlog)) 83 (defmethod socket-bind ((self libpod-client) &rest addr) 84 (socket-bind (client-socket self) (or addr (client-addr self)))) 86 (defmethod socket-accept ((self libpod-client)) 87 (socket-accept (client-socket self))) 89 (defmethod socket-make-stream ((self libpod-client) 91 (element-type 'character) 92 (external-format :default) 97 (socket-make-stream (client-socket self) 100 :element-type element-type 101 :external-format external-format 104 :auto-close auto-close 105 :serve-events serve-events)) 107 (defmacro with-libpod-client ((cvar &optional c) &body body) 108 `(let ((,cvar ,(or c (make-instance 'libpod-client)))) 109 (socket-connect ,cvar) 110 (unwind-protect (progn ,@body) 111 (socket-close ,cvar))))