LispObj * Lisp_XRaiseWindow(LispBuiltin *builtin) /* x-raise-window display window */ { Display *display; Window window; LispObj *odisplay, *owindow; owindow = ARGUMENT(1); odisplay = ARGUMENT(0); if (!CHECKO(odisplay, x11Display_t)) LispDestroy("%s: cannot convert %s to Display*", STRFUN(builtin), STROBJ(odisplay)); display = (Display*)(odisplay->data.opaque.data); if (!CHECKO(owindow, x11Window_t)) LispDestroy("%s: cannot convert %s to Window", STRFUN(builtin), STROBJ(owindow)); window = (Window)(owindow->data.opaque.data); XRaiseWindow(display, window); return (owindow); }
LispObj * Lisp_XDrawLine(LispBuiltin *builtin) /* x-draw-line display drawable gc x1 y1 x2 y2 */ { Display *display; Drawable drawable; GC gc; int x1, y1, x2, y2; LispObj *odisplay, *odrawable, *ogc, *ox1, *oy1, *ox2, *oy2; oy2 = ARGUMENT(6); ox2 = ARGUMENT(5); oy1 = ARGUMENT(4); ox1 = ARGUMENT(3); ogc = ARGUMENT(2); odrawable = ARGUMENT(1); odisplay = ARGUMENT(0); if (!CHECKO(odisplay, x11Display_t)) LispDestroy("%s: cannot convert %s to Display*", STRFUN(builtin), STROBJ(odisplay)); display = (Display*)(odisplay->data.opaque.data); /* XXX correct check when drawing to pixmaps implemented */ if (!CHECKO(odrawable, x11Window_t)) LispDestroy("%s: cannot convert %s to Drawable", STRFUN(builtin), STROBJ(odrawable)); drawable = (Drawable)(odrawable->data.opaque.data); if (!CHECKO(ogc, x11GC_t)) LispDestroy("%s: cannot convert %s to Display*", STRFUN(builtin), STROBJ(ogc)); gc = (GC)(ogc->data.opaque.data); CHECK_FIXNUM(ox1); x1 = FIXNUM_VALUE(ox1); CHECK_FIXNUM(oy1); y1 = FIXNUM_VALUE(oy1); CHECK_FIXNUM(ox2); x2 = FIXNUM_VALUE(ox2); CHECK_FIXNUM(oy2); y2 = FIXNUM_VALUE(oy2); XDrawLine(display, drawable, gc, x1, y1, x2, y2); return (odrawable); }
LispObj * Lisp_GetOutputStreamString(LispBuiltin *builtin) /* get-output-stream-string string-output-stream */ { int length; char *string; LispObj *string_output_stream, *result; string_output_stream = ARGUMENT(0); if (!STREAMP(string_output_stream) || string_output_stream->data.stream.type != LispStreamString || string_output_stream->data.stream.readable || !string_output_stream->data.stream.writable) LispDestroy("%s: %s is not an output string stream", STRFUN(builtin), STROBJ(string_output_stream)); string = LispGetSstring(SSTREAMP(string_output_stream), &length); result = LSTRING(string, length); /* reset string */ SSTREAMP(string_output_stream)->output = SSTREAMP(string_output_stream)->length = SSTREAMP(string_output_stream)->column = 0; return (result); }
LispObj * Lisp_XBell(LispBuiltin *builtin) /* x-bell &optional percent */ { Display *display; int percent; LispObj *odisplay, *opercent; opercent = ARGUMENT(1); odisplay = ARGUMENT(0); if (!CHECKO(odisplay, x11Display_t)) LispDestroy("%s: cannot convert %s to Display*", STRFUN(builtin), STROBJ(odisplay)); display = (Display*)(odisplay->data.opaque.data); if (opercent == UNSPEC) percent = 0; else { CHECK_FIXNUM(opercent); percent = FIXNUM_VALUE(opercent); } if (percent < -100 || percent > 100) LispDestroy("%s: percent value %d out of range -100 to 100", STRFUN(builtin), percent); XBell(display, percent); return (odisplay); }
LispObj * Lisp_PQgetlength(LispBuiltin *builtin) /* pq-getlength result tupple field-number */ { PGresult *res; int tuple, field, length; LispObj *result, *otupple, *field_number; field_number = ARGUMENT(2); otupple = ARGUMENT(1); result = ARGUMENT(0); if (!CHECKO(result, PGresult_t)) LispDestroy("%s: cannot convert %s to PGresult*", STRFUN(builtin), STROBJ(result)); res = (PGresult*)(result->data.opaque.data); CHECK_INDEX(otupple); tuple = FIXNUM_VALUE(otupple); CHECK_INDEX(field_number); field = FIXNUM_VALUE(field_number); length = PQgetlength(res, tuple, field); return (INTEGER(length)); }
LispObj * Lisp_PQfsize(LispBuiltin *builtin) /* pq-fsize result field-number */ { int size, field; PGresult *res; LispObj *result, *field_number; field_number = ARGUMENT(1); result = ARGUMENT(0); if (!CHECKO(result, PGresult_t)) LispDestroy("%s: cannot convert %s to PGresult*", STRFUN(builtin), STROBJ(result)); res = (PGresult*)(result->data.opaque.data); CHECK_INDEX(field_number); field = FIXNUM_VALUE(field_number); size = PQfsize(res, field); return (INTEGER(size)); }
LispObj * Lisp_PQfnumber(LispBuiltin *builtin) /* pq-fnumber result field-name */ { int number; int field; PGresult *res; LispObj *result, *field_name; field_name = ARGUMENT(1); result = ARGUMENT(0); if (!CHECKO(result, PGresult_t)) LispDestroy("%s: cannot convert %s to PGresult*", STRFUN(builtin), STROBJ(result)); res = (PGresult*)(result->data.opaque.data); CHECK_STRING(field_name); number = PQfnumber(res, THESTR(field_name)); return (INTEGER(number)); }
LispObj * Lisp_PQfname(LispBuiltin *builtin) /* pq-fname result field-number */ { char *string; int field; PGresult *res; LispObj *result, *field_number; field_number = ARGUMENT(1); result = ARGUMENT(0); if (!CHECKO(result, PGresult_t)) LispDestroy("%s: cannot convert %s to PGresult*", STRFUN(builtin), STROBJ(result)); res = (PGresult*)(result->data.opaque.data); CHECK_INDEX(field_number); field = FIXNUM_VALUE(field_number); string = PQfname(res, field); return (string ? STRING(string) : NIL); }
LispObj * Lisp_XawCoerceToListReturnStruct(LispBuiltin *builtin) /* xaw-coerce-to-list-return-struct opaque */ { LispObj *result, *code, *ocod = COD; XawListReturnStruct *retlist; LispObj *opaque; opaque = ARGUMENT(0); if (!CHECKO(opaque, xawListReturnStruct_t)) LispDestroy("%s: cannot convert %s to XawListReturnStruct", STRFUN(builtin), STROBJ(opaque)); retlist = (XawListReturnStruct*)(opaque->data.opaque.data); GCDisable(); code = CONS(ATOM("MAKE-XAW-LIST-RETURN-STRUCT"), CONS(KEYWORD("STRING"), CONS(STRING(retlist->string), CONS(KEYWORD("INDEX"), CONS(INTEGER(retlist->list_index), NIL))))); COD = CONS(code, COD); GCEnable(); result = EVAL(code); COD = ocod; return (result); }
LispObj * Lisp_XawTextSetInsertionPoint(LispBuiltin *builtin) /* xaw-text-set-insertion-point widget position */ { Widget widget; XawTextPosition position; LispObj *owidget, *oposition; oposition = ARGUMENT(1); owidget = ARGUMENT(0); if (!CHECKO(owidget, xawWidget_t)) LispDestroy("%s: cannot convert %s to Widget", STRFUN(builtin), STROBJ(owidget)); widget = (Widget)(owidget->data.opaque.data); CHECK_INDEX(oposition); position = (XawTextPosition)FIXNUM_VALUE(oposition); XawTextSetInsertionPoint(widget, position); return (oposition); }
LispObj * Lisp_DeleteFile(LispBuiltin *builtin) /* delete-file filename */ { GC_ENTER(); LispObj *filename; filename = ARGUMENT(0); if (STRINGP(filename)) { filename = APPLY1(Oparse_namestring, filename); GC_PROTECT(filename); } else if (STREAMP(filename)) { if (filename->data.stream.type != LispStreamFile) LispDestroy("%s: %s is not a FILE-STREAM", STRFUN(builtin), STROBJ(filename)); filename = filename->data.stream.pathname; } else { CHECK_PATHNAME(filename); } GC_LEAVE(); return (LispUnlink(THESTR(CAR(filename->data.pathname))) ? NIL : T); }
LispObj * Lisp_XawTextSearch(LispBuiltin *builtin) /* xaw-text-search widget direction text */ { Widget widget; XawTextScanDirection direction; XawTextBlock block; LispObj *owidget, *odirection, *otext; otext = ARGUMENT(2); odirection = ARGUMENT(1); owidget = ARGUMENT(0); if (!CHECKO(owidget, xawWidget_t)) LispDestroy("%s: cannot convert %s to Widget", STRFUN(builtin), STROBJ(owidget)); widget = (Widget)(owidget->data.opaque.data); CHECK_INDEX(odirection); direction = (XawTextPosition)FIXNUM_VALUE(odirection); if (direction != XawsdLeft && direction != XawsdRight) LispDestroy("%s: %d does not fit in XawTextScanDirection", STRFUN(builtin), direction); CHECK_STRING(otext); block.firstPos = 0; block.ptr = THESTR(otext); block.length = strlen(block.ptr); block.format = FMT8BIT; return (FIXNUM(XawTextSearch(widget, direction, &block))); }
LispObj * Lisp_XawListHighlight(LispBuiltin *builtin) /* xaw-list-highlight widget index */ { Widget widget; int position; LispObj *owidget, *oindex; oindex = ARGUMENT(1); owidget = ARGUMENT(0); if (!CHECKO(owidget, xawWidget_t)) LispDestroy("%s: cannot convert %s to Widget", STRFUN(builtin), STROBJ(owidget)); widget = (Widget)(owidget->data.opaque.data); CHECK_INDEX(oindex); position = FIXNUM_VALUE(oindex); XawListHighlight(widget, position); return (oindex); }
/* Helper function, primarily for use with the xt module */ LispObj * Lisp_PipeBroken(LispBuiltin *builtin) /* pipe-broken pipe-stream */ { int pid, status, retval; LispObj *result = NIL; LispObj *pipe_stream; pipe_stream = ARGUMENT(0); if (!STREAMP(pipe_stream) || pipe_stream->data.stream.type != LispStreamPipe) LispDestroy("%s: %s is not a pipe stream", STRFUN(builtin), STROBJ(pipe_stream)); if ((pid = PIDPSTREAMP(pipe_stream)) > 0) { retval = waitpid(pid, &status, WNOHANG | WUNTRACED); if (retval == pid || (retval == -1 && errno == ECHILD)) result = T; } return (result); }
LispObj * Lisp_XDefaultGC(LispBuiltin *builtin) /* x-default-gc display &optional screen */ { Display *display; int screen; LispObj *odisplay, *oscreen; oscreen = ARGUMENT(1); odisplay = ARGUMENT(0); if (!CHECKO(odisplay, x11Display_t)) LispDestroy("%s: cannot convert %s to Display*", STRFUN(builtin), STROBJ(odisplay)); display = (Display*)(odisplay->data.opaque.data); if (oscreen == UNSPEC) screen = DefaultScreen(display); else { CHECK_FIXNUM(oscreen); screen = FIXNUM_VALUE(oscreen); } if (screen >= ScreenCount(display)) LispDestroy("%s: screen index %d too large, %d screens available", STRFUN(builtin), screen, ScreenCount(display)); return (OPAQUE(DefaultGC(display, screen), x11GC_t)); }
LispObj * Lisp_XawScrollbarSetThumb(LispBuiltin *builtin) /* xaw-scrollbar-set-thumb widget top &optional shown */ { Widget widget; double top, shown; LispObj *owidget, *otop, *oshown; oshown = ARGUMENT(2); otop = ARGUMENT(1); owidget = ARGUMENT(0); if (!CHECKO(owidget, xawWidget_t)) LispDestroy("%s: cannot convert %s to Widget", STRFUN(builtin), STROBJ(owidget)); widget = (Widget)(owidget->data.opaque.data); CHECK_DFLOAT(otop); top = DFLOAT_VALUE(otop); if (oshown == UNSPEC) shown = 1.0; else { CHECK_DFLOAT(oshown); shown = DFLOAT_VALUE(oshown); } XawScrollbarSetThumb(widget, top, shown); return (oshown == UNSPEC ? DFLOAT(shown) : oshown); }
LispObj * Lisp_RenameFile(LispBuiltin *builtin) /* rename-file filename new-name */ { int code; GC_ENTER(); char *from, *to; LispObj *old_truename, *new_truename; LispObj *filename, *new_name; new_name = ARGUMENT(1); filename = ARGUMENT(0); if (STRINGP(filename)) { filename = APPLY1(Oparse_namestring, filename); GC_PROTECT(filename); } else if (STREAMP(filename)) { if (filename->data.stream.type != LispStreamFile) LispDestroy("%s: %s is not a FILE-STREAM", STRFUN(builtin), STROBJ(filename)); filename = filename->data.stream.pathname; } else { CHECK_PATHNAME(filename); } old_truename = APPLY1(Otruename, filename); GC_PROTECT(old_truename); if (STRINGP(new_name)) { new_name = APPLY3(Oparse_namestring, new_name, NIL, filename); GC_PROTECT(new_name); } else { CHECK_PATHNAME(new_name); } from = THESTR(CAR(filename->data.pathname)); to = THESTR(CAR(new_name->data.pathname)); code = LispRename(from, to); if (code) LispDestroy("%s: rename(%s, %s): %s", STRFUN(builtin), from, to, strerror(errno)); GC_LEAVE(); new_truename = APPLY1(Otruename, new_name); RETURN_COUNT = 2; RETURN(0) = old_truename; RETURN(1) = new_truename; return (new_name); }
/* Helper function, primarily for use with the xt module */ LispObj * Lisp_PipeErrorDescriptor(LispBuiltin *builtin) /* pipe-error-descriptor pipe-stream */ { LispObj *pipe_stream; pipe_stream = ARGUMENT(0); if (!STREAMP(pipe_stream) || pipe_stream->data.stream.type != LispStreamPipe) LispDestroy("%s: %s is not a pipe stream", STRFUN(builtin), STROBJ(pipe_stream)); if (!EPSTREAMP(pipe_stream)) LispDestroy("%s: pipe %s is closed", STRFUN(builtin), STROBJ(pipe_stream)); return (INTEGER(LispFileno(EPSTREAMP(pipe_stream)))); }
/* Helper function, primarily for use with the xt module */ LispObj * Lisp_PipeInputDescriptor(LispBuiltin *builtin) /* pipe-input-descriptor pipe-stream */ { LispObj *pipe_stream; pipe_stream = ARGUMENT(0); if (!STREAMP(pipe_stream) || pipe_stream->data.stream.type != LispStreamPipe) LispDestroy("%s: %s is not a pipe stream", STRFUN(builtin), STROBJ(pipe_stream)); if (!IPSTREAMP(pipe_stream)) LispDestroy("%s: pipe %s is unreadable", STRFUN(builtin), STROBJ(pipe_stream)); return (INTEGER(LispFileno(IPSTREAMP(pipe_stream)))); }
static LispObj * LispFindPackageOrDie(LispBuiltin *builtin, LispObj *name) { LispObj *package; package = LispFindPackage(name); if (package == NIL) LispDestroy("%s: package %s is not available", STRFUN(builtin), STROBJ(name)); return (package); }
LispObj * Lisp_XWhitePixelOfScreen(LispBuiltin *builtin) /* x-white-pixel-of-screen screen */ { LispObj *screen; screen = ARGUMENT(0); if (!CHECKO(screen, x11Screen_t)) LispDestroy("%s: cannot convert %s to Screen*", STRFUN(builtin), STROBJ(screen)); return (INTEGER(WhitePixelOfScreen((Screen*)(screen->data.opaque.data)))); }
LispObj * Lisp_XawTextGetInsertionPoint(LispBuiltin *builtin) /* xaw-text-get-insertion-point widget */ { LispObj *owidget; owidget = ARGUMENT(0); if (!CHECKO(owidget, xawWidget_t)) LispDestroy("%s: cannot convert %s to Widget", STRFUN(builtin), STROBJ(owidget)); return (FIXNUM(XawTextGetInsertionPoint((Widget)(owidget->data.opaque.data)))); }
LispObj * Lisp_XawTextLastPosition(LispBuiltin *builtin) /* xaw-text-last-position widget */ { LispObj *owidget; owidget = ARGUMENT(0); if (!CHECKO(owidget, xawWidget_t)) LispDestroy("%s: cannot convert %s to Widget", STRFUN(builtin), STROBJ(owidget)); return (FIXNUM(XawTextLastPosition((Widget)(owidget->data.opaque.data)))); }
LispObj * Lisp_XHeightOfScreen(LispBuiltin *builtin) /* x-height-of-screen screen */ { LispObj *screen; screen = ARGUMENT(0); if (!CHECKO(screen, x11Screen_t)) LispDestroy("%s: cannot convert %s to Screen*", STRFUN(builtin), STROBJ(screen)); return (FIXNUM(HeightOfScreen((Screen*)(screen->data.opaque.data)))); }
LispObj * Lisp_XDefaultScreen(LispBuiltin *builtin) /* x-default-screen display */ { LispObj *display; display = ARGUMENT(0); if (!CHECKO(display, x11Display_t)) LispDestroy("%s: cannot convert %s to Display*", STRFUN(builtin), STROBJ(display)); return (INTEGER(DefaultScreen((Display*)(display->data.opaque.data)))); }
/* Helper function, so that it is not required to redirect error output */ LispObj * Lisp_PipeErrorStream(LispBuiltin *builtin) /* pipe-error-stream pipe-stream */ { LispObj *pipe_stream; pipe_stream = ARGUMENT(0); if (!STREAMP(pipe_stream) || pipe_stream->data.stream.type != LispStreamPipe) LispDestroy("%s: %s is not a pipe stream", STRFUN(builtin), STROBJ(pipe_stream)); return (pipe_stream->data.stream.source.program->errorp); }
LispObj * Lisp_XawTextGetSource(LispBuiltin *builtin) /* xaw-text-get-source widget */ { LispObj *owidget; owidget = ARGUMENT(0); if (!CHECKO(owidget, xawWidget_t)) LispDestroy("%s: cannot convert %s to Widget", STRFUN(builtin), STROBJ(owidget)); return (OPAQUE(XawTextGetSource((Widget)(owidget->data.opaque.data)), xawWidget_t)); }
LispObj * LispFindPackage(LispObj *name) { char *string = NULL; if (PACKAGEP(name)) return (name); if (SYMBOLP(name)) string = ATOMID(name)->value; else if (STRINGP(name)) string = THESTR(name); else LispDestroy("FIND-PACKAGE: %s is not a string or symbol", STROBJ(name)); return (LispFindPackageFromString(string)); }
LispObj * Lisp_XDefaultRootWindow(LispBuiltin *builtin) /* x-default-root-window display */ { LispObj *display; display = ARGUMENT(0); if (!CHECKO(display, x11Display_t)) LispDestroy("%s: cannot convert %s to Display*", STRFUN(builtin), STROBJ(display)); return (OPAQUE(DefaultRootWindow((Display*)(display->data.opaque.data)), x11Window_t)); }
LispObj * Lisp_XDefaultGCOfScreen(LispBuiltin *builtin) /* x-default-gc-of-screen screen */ { LispObj *screen; screen = ARGUMENT(0); if (!CHECKO(screen, x11Screen_t)) LispDestroy("%s: cannot convert %s to Screen*", STRFUN(builtin), STROBJ(screen)); return (OPAQUE(DefaultGCOfScreen((Screen*)(screen->data.opaque.data)), x11GC_t)); }