📄 fv.info.c
字号:
changed = TRUE; } else newname[0] = 0; if ((num = fv_getuid((char *)panel_get_value(Item[OWNERNAME]))) == -1) fv_putmsg(TRUE, "Unknown owner", 0, 0); else if (num != Fstatus.st_uid) { /* Change owner... */ if (chown(Filename, num, -1) == -1) { fv_putmsg(TRUE, sys_errlist[errno], 0, 0); error = TRUE; } else changed = Fv_style & FV_DOWNER; } if ((num = fv_getgid((char *)panel_get_value(Item[GROUPNAME]))) == -1) fv_putmsg(TRUE, "Unknown group", 0, 0); else if (num != Fstatus.st_gid) { /* Change group... */ if (chown(Filename, -1, num) == -1) { fv_putmsg(TRUE, sys_errlist[errno], 0, 0); error = TRUE; } else changed = Fv_style & FV_DGROUP; } if (New_color && Color != New_color) fv_apply_color(New_color); if (!error) { if (changed) fv_display_folder(FV_BUILD_FOLDER);#ifdef OPENLOOK stay_up = (BOOLEAN)window_get(Fprops_frame, FRAME_PROPS_PUSHPIN_IN);#else# ifdef SV1 stay_up = Pinned;# endif#endif if (!stay_up) window_set(Fprops_frame, WIN_SHOW, FALSE, 0); }}/*ARGSUSED*/staticgeneric_toggle(item, value, event) Panel_item item; Event *event; /* unused */{ Toggles[(int)panel_get(item, PANEL_CLIENT_DATA)] = value;}statictoggletonum(){ int bit, i, l; l = 0; bit = S_IREAD; for (i = 0; i < MAXTOGGLES; i++) { if (Toggles[i]) l = l | bit; bit >>= 1; } return(l);}static char *addcommas(k) off_t k;{ static char buf[20]; int i, j; char *p, *q, tmp; j = i = 0; if (k < 10000) (void)sprintf(buf, "%d", k); else { while (k > 0) { j++; buf[i++] = '0' + (k%10); k = k/10; if (k > 0 && j == 3) { buf[i++] = ','; j = 0; } } /* Found string, now reverse in place */ buf[i] = 0; p = buf; q = buf+i-1; while (p < q) { tmp = *p; *p = *q; *q = tmp; p++; q--; } } return(buf);}static char *docmd(cmd, name, sbuf) char *cmd; char *name; struct stat *sbuf;{ FILE *fp; char buf1[MAXPATH], buf2[MAXPATH]; int ln; register char *n_p, *b_p; (void)strcpy(buf1, "/usr/bin/"); (void)strcat(buf1, cmd); for (b_p = buf1+strlen(buf1), n_p = name; *n_p;) { /* Check characters which may be misinterpreted by the * shell. */ if (*n_p == '*' || *n_p == '&' || *n_p == '?') { fv_putmsg(TRUE, Fv_message[MECHAR], (int)*n_p, 0); return(NULL); } if (*n_p == ' ') *b_p++ = '\\'; *b_p++ = *n_p++; } *b_p = NULL; fp = popen(buf1, "r"); if (fp == NULL) { fv_putmsg(TRUE, "not enough file descriptors", 0, 0); return(NULL); } buf2[0] = 0; while (fgets(buf1, sizeof(buf1), fp)) { (void)strcat(buf2, buf1); } (void)pclose(fp); if (sbuf) { /* Must be file cmd */ b_p = strchr(buf2, '\t'); if (b_p == NULL) return(Typename[(sbuf->st_mode & S_IFMT) >> 12]); while (*b_p == '\t') b_p++; if ((ln = strlen(b_p)) > 1) /* Is this necessary? */ b_p[ln-1] = 0; return(b_p); } b_p = strchr(buf2, '\t'); if (b_p) *b_p = NULL; return(buf2);}#include <pwd.h>#include <grp.h>#include <utmp.h>struct utmp utmp;#define NMAX (sizeof (utmp.ut_name))#undef MAXUID#define MAXUID 2048#define MINUID -2 /* for nfs */#define MAXGID 300static int Outrangeuid = EMPTY; /* Last uid received */static char Outrangename[NMAX+1]; /* Last name returned */static int Outrangegid = EMPTY; /* Last gid received */static char Outrangegroup[NMAX+1]; /* Last name returned */char *getname(uid) int uid;{ register struct passwd *pw; if (uid == Outrangeuid) return (Outrangename); if (uid < MINUID) return (NULL); pw = getpwuid(uid); if (pw == NULL) return (NULL); Outrangeuid = uid; (void)strncpy(Outrangename, pw->pw_name, NMAX); return (Outrangename);}char *getgroup(gid) int gid;{ register struct group *gr; if (gid >= 0 && gid == Outrangegid) return (Outrangegroup); if (gid < 0) return (NULL); gr = getgrgid(gid); if (gr == NULL) return (NULL); Outrangegid = gr->gr_gid; (void)strncpy(Outrangegroup, gr->gr_name, NMAX); return(Outrangegroup);}/* * Given a name like /usr/src/etc/foo.c returns the mntent * structure for the file system it lives in. */struct mntent *getmntpt(file) char *file;{ FILE *mntp; struct mntent *mnt, *mntsave; struct mntent *mntdup(); if ((mntp = setmntent(MOUNTED, "r")) == 0) return(NULL); /* Get the filesystem that's mounted at the lowest point in the * path. Malloc it. */ mntsave = NULL; while (mnt = getmntent(mntp)) { if (strcmp(mnt->mnt_type, MNTTYPE_IGNORE) == 0 || strcmp(mnt->mnt_type, MNTTYPE_SWAP) == 0) continue; if (prefix(mnt->mnt_dir, file)) { if (!mntsave || strlen(mntsave->mnt_dir) <= strlen(mnt->mnt_dir)) { if (mntsave) freemnt(mntsave); mntsave = mntdup(mnt); } } } (void) endmntent(mntp); return(mntsave ? mntsave : NULL);}staticstruct mntent *mntdup(mnt) register struct mntent *mnt;{ register struct mntent *new; char *xmalloc(); new = (struct mntent *)xmalloc(sizeof(*new)); new->mnt_fsname = xmalloc((unsigned)strlen(mnt->mnt_fsname) + 1); (void) strcpy(new->mnt_fsname, mnt->mnt_fsname); new->mnt_dir = xmalloc((unsigned)strlen(mnt->mnt_dir) + 1); (void) strcpy(new->mnt_dir, mnt->mnt_dir); new->mnt_type = xmalloc((unsigned)strlen(mnt->mnt_type) + 1); (void) strcpy(new->mnt_type, mnt->mnt_type); new->mnt_opts = xmalloc((unsigned)strlen(mnt->mnt_opts) + 1); (void) strcpy(new->mnt_opts, mnt->mnt_opts); new->mnt_freq = mnt->mnt_freq; new->mnt_passno = mnt->mnt_passno; return (new);}static char *xmalloc(size) unsigned int size;{ register char *ret; char *malloc(); if ((ret = fv_malloc(size)) == NULL) exit(1); return (ret);}staticfreemnt(mnt) struct mntent *mnt;{ free(mnt->mnt_fsname); free(mnt->mnt_dir); free(mnt->mnt_type); free(mnt->mnt_opts); free((char *)mnt);}/* is str1 a prefix of str2? */prefix(str1, str2) register char *str1, *str2;{ while (*str1 == *str2++) if (*str1++ == 0) return(1); return(!*str1);}#ifdef SV1static Menu Ok_menu;static voidok_button(item, event) Panel_item item; Event *event;{ if (event_is_down(event) && event_id(event) == MS_RIGHT) menu_show(Ok_menu, Fprops_panel, event, 0); else if (event_is_up(event) && event_id(event) == MS_LEFT) apply(); panel_default_handle_event(item, event);}#ifndef PROTOstatic Panel_item Pin_item;static voidpin_proc(item, event) Panel_item item; Event *event;{ if (event_is_up(event) && event_id(event) == MS_LEFT) { Pinned = !Pinned; panel_set(Pin_item, PANEL_LABEL_IMAGE, Pinned ? &Pin_in : &Pin_out, 0); } panel_default_handle_event(item, event);}#endifstaticmake_ok_button(){ Ok_menu = menu_create( MENU_ITEM, MENU_STRING, "Apply", MENU_NOTIFY_PROC, apply, 0, MENU_ITEM, MENU_STRING, "Reset", MENU_NOTIFY_PROC, reset, 0, 0); Ok_button = panel_create_item(Fprops_panel, MY_MENU(Ok_menu), MY_BUTTON_IMAGE(Fprops_panel, "OK"),#ifndef PROTO PANEL_EVENT_PROC, ok_button,#endif 0);#ifndef PROTO Pin_item = panel_create_item(Fprops_panel, PANEL_BUTTON, PANEL_LABEL_IMAGE, &Pin_out, PANEL_EVENT_PROC, pin_proc, 0);#endif}#endifstaticcreate_color_canvas() /* Hack for color choice */{ static Notify_value color_event(); static void color_repaint(); Rect *r; /* Sunview won't allow colors directly on panels, create color * canvas and place it on top of panel. It will have the * appearance of a color exclusive choice item. */ r = (Rect*)panel_get(Tag_item[COLOR], PANEL_ITEM_RECT); if ((Color_canvas = window_create(Fprops_frame, CANVAS, CANVAS_REPAINT_PROC, color_repaint,#ifndef SV1 WIN_CONSUME_EVENT, MS_LEFT,#endif WIN_WIDTH, 6*COLOR_WIDTH+2, WIN_HEIGHT, COLOR_HEIGHT+EXTRA, WIN_X, ATTR_COL(JUSTIFY_COL+1), WIN_Y, r->r_top, 0)) == NULL) { fv_putmsg(TRUE, Fv_message[MEWIN], 0, 0); return; } pw_setcmsname(canvas_pixwin(Color_canvas), "FVCOLORMAP"); pw_putcolormap(canvas_pixwin(Color_canvas), 0, CMS_FVCOLORMAPSIZE, Fv_red, Fv_green, Fv_blue);#ifdef SV1 Color_pw = canvas_pixwin(Color_canvas); notify_interpose_event_func(Color_canvas, color_event, NOTIFY_SAFE);#else Color_pw = (PAINTWIN)vu_get(Color_canvas, CANVAS_NTH_PAINT_WINDOW, 0); notify_interpose_event_func(Color_pw, color_event, NOTIFY_SAFE);#endif}static Notify_valuecolor_event(cnvs, evnt, arg, typ) /* Process color choice */ Canvas cnvs; Event *evnt; Notify_arg arg; Notify_event_type typ;{ if (event_is_up(evnt) && event_id(evnt) == MS_LEFT && Owner) { New_color = (event_x(evnt)/COLOR_WIDTH)+1;#ifdef SV1 pw_lock(Color_pw, (Rect *)window_get(Color_canvas, WIN_RECT));#endif draw_box(New_color);#ifdef SV1 pw_unlock(Color_pw);#endif } return(notify_next_event_func(cnvs, evnt, arg, typ));}staticdraw_box(color) SBYTE color;{ static SBYTE old_color = EMPTY; if (color==0) color = 1; else color--; if (old_color != EMPTY) { box(old_color*COLOR_WIDTH, PIX_CLR, 3); box(old_color*COLOR_WIDTH, PIX_SET, 1); } box(color*COLOR_WIDTH, PIX_SET, 3); old_color = color;}staticbox(x, op, width) int x; int op; int width;{ struct pr_brush br; br.width = width; pw_line(Color_pw, x, 0, x+COLOR_WIDTH, 0, &br, NULL, op); pw_line(Color_pw, x+COLOR_WIDTH, 0, x+COLOR_WIDTH, COLOR_HEIGHT-1, &br, NULL, op); pw_line(Color_pw, x+COLOR_WIDTH, COLOR_HEIGHT-1, x, COLOR_HEIGHT-1, &br, NULL, op); pw_line(Color_pw, x, COLOR_HEIGHT-1, x, 0, &br, NULL, op);}/*ARGSUSED*/static voidcolor_repaint(canvas, pw, rlist) Canvas canvas; PAINTWIN pw; Rectlist *rlist;{ int i; for (i = 1; i<7; i++) { box((i-1)*COLOR_WIDTH, PIX_SET, 1); pw_rop(pw, ((i-1)*COLOR_WIDTH)+3, 3, COLOR_WIDTH-5, COLOR_HEIGHT-6, PIX_SRC | PIX_COLOR(i), (Pixrect *)0, 0, 0); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -