diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-01-28 09:41:29 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-01-28 09:41:29 -0800 |
commit | 7a68eb9981f302f874c9269d8d41a917dc581e02 (patch) | |
tree | 657dc057014c3c74a75fc80bf0dc31e0649c12df | |
parent | f1f2dba34fb47a171cc47ccfd50073472b1ed970 (diff) |
Adopt standard X.Org code style
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | constype.c | 172 |
1 files changed, 87 insertions, 85 deletions
@@ -47,7 +47,7 @@ style. static int wu_fbid(const char *devname, const char **fbname, int *fbtype); int -main (int argc, char **argv) +main(int argc, char **argv) { int fbtype = -1; const char *fbname, *dev; @@ -55,19 +55,21 @@ main (int argc, char **argv) int error; if (argc > 1 && argv[1][0] == '/') { - dev = argv[1]; - argc--; argv++; - } else - dev = "/dev/fb"; - error = wu_fbid(dev, &fbname, &fbtype ); - if (argc > 1 && strncmp (argv[1], "-num", strlen(argv[1])) == 0) - print_num = 1; - - printf ("%s", fbname ? fbname : "tty"); + dev = argv[1]; + argc--; + argv++; + } + else + dev = "/dev/fb"; + error = wu_fbid(dev, &fbname, &fbtype); + if (argc > 1 && strncmp(argv[1], "-num", strlen(argv[1])) == 0) + print_num = 1; + + printf("%s", fbname ? fbname : "tty"); if (print_num) { - printf (" %d", fbtype); + printf(" %d", fbtype); } - putchar ('\n'); + putchar('\n'); return error; } @@ -95,113 +97,113 @@ main (int argc, char **argv) #define XFBTYPE_LASTPLUSONE 22 /* decoding as of Release 3.4 : fbio.h 1.3 87/01/09 SMI */ - /* the convention for entries in this table is to translate the - * macros for frame buffer codes (in <sun/fbio.h>) to short names - * thus: - * FBTYPE_SUNxBW becomes bwx - * FBTYPE_SUNxCOLOR becomes cgx - * FBTYPE_SUNxGP becomes gpx - * FBTYPE_NOTSUN[1-9] becomes ns[A-J] - */ + /* the convention for entries in this table is to translate the + * macros for frame buffer codes (in <sun/fbio.h>) to short names + * thus: + * FBTYPE_SUNxBW becomes bwx + * FBTYPE_SUNxCOLOR becomes cgx + * FBTYPE_SUNxGP becomes gpx + * FBTYPE_NOTSUN[1-9] becomes ns[A-J] + */ static const char *decode_fb[] = { - "bw1", "cg1", - "bw2", "cg2", - "gp2", - "cg5", "cg3", - "cg8", "cg4", - "nsA", "nsB", "nsC", + "bw1", "cg1", + "bw2", "cg2", + "gp2", + "cg5", "cg3", + "cg8", "cg4", + "nsA", "nsB", "nsC", #ifdef FBTYPE_SUNFAST_COLOR - "gx/cg6", + "gx/cg6", #endif #ifdef FBTYPE_SUNROP_COLOR - "rop", + "rop", #endif #ifdef FBTYPE_SUNFB_VIDEO - "vid", + "vid", #endif #ifdef FBTYPE_SUNGIFB - "gifb", + "gifb", #endif #ifdef FBTYPE_SUNGPLAS - "plas", + "plas", #endif #ifdef FBTYPE_SUNGP3 - "gp3/cg12", + "gp3/cg12", #endif #ifdef FBTYPE_SUNGT - "gt", + "gt", #endif #ifdef FBTYPE_SUNLEO - "leo/zx", + "leo/zx", #endif #ifdef FBTYPE_MDICOLOR - "mdi/cg14", + "mdi/cg14", #endif - }; +}; static int -wu_fbid(const char* devname, const char** fbname, int* fbtype) +wu_fbid(const char *devname, const char **fbname, int *fbtype) { - struct fbgattr fbattr; - int fd, ioctl_ret; + struct fbgattr fbattr; + int fd, ioctl_ret; + #ifdef VIS_GETIDENTIFIER - int vistype; - static struct vis_identifier fbid; + int vistype; + static struct vis_identifier fbid; #endif - #ifdef sun # define DEV_OPEN_MODE O_RDONLY #else # define DEV_OPEN_MODE O_RDWR #endif - if ( (fd = open(devname, DEV_OPEN_MODE, 0)) == -1 ) { - fprintf(stderr, "unable to open %s: %s\n", - devname, strerror(errno)); - *fbname = "unable to open fb"; - return 2; - } + if ((fd = open(devname, DEV_OPEN_MODE, 0)) == -1) { + fprintf(stderr, "unable to open %s: %s\n", devname, strerror(errno)); + *fbname = "unable to open fb"; + return 2; + } #ifdef VIS_GETIDENTIFIER - if ((vistype = ioctl(fd, VIS_GETIDENTIFIER, &fbid)) >= 0) { - *fbname = fbid.name; - *fbtype = vistype; - close(fd); - return 0; - } + if ((vistype = ioctl(fd, VIS_GETIDENTIFIER, &fbid)) >= 0) { + *fbname = fbid.name; + *fbtype = vistype; + close(fd); + return 0; + } #endif - /* FBIOGATTR fails for early frame buffer types */ - if ((ioctl_ret = ioctl(fd,FBIOGATTR,&fbattr))<0) /*success=>0(false)*/ - ioctl_ret = ioctl(fd, FBIOGTYPE, &fbattr.fbtype); - close(fd); - if ( ioctl_ret == -1 ) { - fprintf(stderr, "FBIO ioctls failed on %s: %s\n", - devname, strerror(errno)); - *fbname = "ioctl on fb failed"; - return 2; - } - *fbtype = fbattr.fbtype.fb_type; - /* The binary is obsolete and needs to be re-compiled: - * the ioctl returned a value beyond what was possible - * when the program was compiled */ - if (fbattr.fbtype.fb_type>=FBTYPE_LASTPLUSONE) { - if (fbattr.fbtype.fb_type == XFBTYPE_TCX) { - *fbname = "tcx"; - return 0; - } else { - *fbname = "unk"; - return 1; - } - } - /* The source is obsolete. The table "decode_fb" does not - * have entries for some of the values returned by the ioctl. - * Compare <sun/fbio.h> to the entries in "decode_fb" */ - if ( decode_fb[fbattr.fbtype.fb_type] == NULL ) { + /* FBIOGATTR fails for early frame buffer types */ + if ((ioctl_ret = ioctl(fd, FBIOGATTR, &fbattr)) < 0) /* success=>0(false) */ + ioctl_ret = ioctl(fd, FBIOGTYPE, &fbattr.fbtype); + close(fd); + if (ioctl_ret == -1) { + fprintf(stderr, "FBIO ioctls failed on %s: %s\n", + devname, strerror(errno)); + *fbname = "ioctl on fb failed"; + return 2; + } + *fbtype = fbattr.fbtype.fb_type; + /* The binary is obsolete and needs to be re-compiled: + * the ioctl returned a value beyond what was possible + * when the program was compiled */ + if (fbattr.fbtype.fb_type >= FBTYPE_LASTPLUSONE) { + if (fbattr.fbtype.fb_type == XFBTYPE_TCX) { + *fbname = "tcx"; + return 0; + } + else { *fbname = "unk"; - return 1; - } - *fbname = decode_fb[fbattr.fbtype.fb_type]; - return 0; + return 1; + } + } + /* The source is obsolete. The table "decode_fb" does not + * have entries for some of the values returned by the ioctl. + * Compare <sun/fbio.h> to the entries in "decode_fb" */ + if (decode_fb[fbattr.fbtype.fb_type] == NULL) { + *fbname = "unk"; + return 1; + } + *fbname = decode_fb[fbattr.fbtype.fb_type]; + return 0; } |