Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(15) |
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(53) |
Dec
(10) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(159) |
Feb
(63) |
Mar
(282) |
Apr
(185) |
May
(228) |
Jun
(404) |
Jul
(376) |
Aug
(260) |
Sep
(891) |
Oct
(302) |
Nov
(338) |
Dec
(430) |
2006 |
Jan
(502) |
Feb
(116) |
Mar
(76) |
Apr
(135) |
May
(52) |
Jun
(134) |
Jul
(252) |
Aug
(355) |
Sep
(71) |
Oct
(36) |
Nov
(10) |
Dec
(22) |
2007 |
Jan
(649) |
Feb
(644) |
Mar
(458) |
Apr
(317) |
May
(519) |
Jun
(196) |
Jul
(201) |
Aug
(139) |
Sep
(504) |
Oct
(491) |
Nov
(749) |
Dec
(702) |
2008 |
Jan
(306) |
Feb
(261) |
Mar
(154) |
Apr
(355) |
May
(296) |
Jun
(420) |
Jul
(509) |
Aug
(389) |
Sep
(211) |
Oct
(304) |
Nov
(159) |
Dec
(180) |
2009 |
Jan
(193) |
Feb
(290) |
Mar
(206) |
Apr
(253) |
May
(220) |
Jun
(372) |
Jul
(534) |
Aug
(400) |
Sep
(322) |
Oct
(242) |
Nov
(374) |
Dec
(360) |
2010 |
Jan
(419) |
Feb
(296) |
Mar
(477) |
Apr
(646) |
May
(554) |
Jun
(284) |
Jul
(211) |
Aug
(412) |
Sep
(493) |
Oct
(313) |
Nov
(286) |
Dec
(416) |
2011 |
Jan
(914) |
Feb
(714) |
Mar
(614) |
Apr
(397) |
May
(177) |
Jun
(640) |
Jul
(382) |
Aug
(778) |
Sep
(484) |
Oct
(370) |
Nov
(340) |
Dec
(464) |
2012 |
Jan
(982) |
Feb
(417) |
Mar
(278) |
Apr
(517) |
May
(424) |
Jun
(580) |
Jul
(358) |
Aug
(605) |
Sep
(257) |
Oct
(809) |
Nov
(519) |
Dec
(197) |
2013 |
Jan
(159) |
Feb
(229) |
Mar
(480) |
Apr
(282) |
May
(348) |
Jun
(283) |
Jul
(495) |
Aug
(960) |
Sep
(648) |
Oct
(381) |
Nov
(330) |
Dec
(522) |
2014 |
Jan
(393) |
Feb
(388) |
Mar
(305) |
Apr
(127) |
May
(593) |
Jun
(444) |
Jul
(508) |
Aug
(476) |
Sep
(595) |
Oct
(196) |
Nov
(310) |
Dec
(277) |
2015 |
Jan
(242) |
Feb
(207) |
Mar
(220) |
Apr
(263) |
May
(324) |
Jun
(380) |
Jul
(302) |
Aug
(344) |
Sep
(240) |
Oct
(177) |
Nov
(156) |
Dec
(82) |
2016 |
Jan
(191) |
Feb
(212) |
Mar
(331) |
Apr
(281) |
May
(215) |
Jun
(192) |
Jul
(308) |
Aug
(248) |
Sep
(178) |
Oct
(233) |
Nov
(60) |
Dec
(48) |
2017 |
Jan
(85) |
Feb
(34) |
Mar
(72) |
Apr
(138) |
May
(139) |
Jun
(72) |
Jul
(95) |
Aug
(143) |
Sep
(171) |
Oct
(32) |
Nov
(81) |
Dec
(95) |
2018 |
Jan
(99) |
Feb
(118) |
Mar
(79) |
Apr
(23) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
|
|
1
(23) |
2
(1) |
3
|
4
(1) |
5
(5) |
6
(10) |
7
(14) |
8
(4) |
9
|
10
(2) |
11
(8) |
12
(19) |
13
(25) |
14
(26) |
15
(23) |
16
(4) |
17
(1) |
18
(11) |
19
(14) |
20
(10) |
21
(12) |
22
(6) |
23
(6) |
24
(5) |
25
(40) |
26
(22) |
27
(18) |
28
(61) |
29
(4) |
30
(3) |
31
(4) |
|
|
|
|
|
|
From: <brlcad@us...> - 2011-07-16 10:44:14
|
Revision: 45522 http://brlcad.svn.sourceforge.net/brlcad/?rev=45522&view=rev Author: brlcad Date: 2011-07-16 10:44:08 +0000 (Sat, 16 Jul 2011) Log Message: ----------- don't need _bu_ prefix on HIDDEN funcs, use file prefix. Modified Paths: -------------- brlcad/trunk/src/libbu/file.c Modified: brlcad/trunk/src/libbu/file.c =================================================================== --- brlcad/trunk/src/libbu/file.c 2011-07-16 10:42:03 UTC (rev 45521) +++ brlcad/trunk/src/libbu/file.c 2011-07-16 10:44:08 UTC (rev 45522) @@ -1,4 +1,4 @@ -/* S T A T . C +/* F I L E . C * BRL-CAD * * Copyright (c) 2004-2011 United States Government as represented by @@ -136,7 +136,7 @@ * specified file. */ HIDDEN int -_bu_file_access(const char *path, int access_level) +file_access(const char *path, int access_level) { struct stat sb; int mask = 0; @@ -209,21 +209,21 @@ int bu_file_readable(const char *path) { - return _bu_file_access(path, R_OK); + return file_access(path, R_OK); } int bu_file_writable(const char *path) { - return _bu_file_access(path, W_OK); + return file_access(path, W_OK); } int bu_file_executable(const char *path) { - return _bu_file_access(path, X_OK); + return file_access(path, X_OK); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <brlcad@us...> - 2011-07-16 10:42:11
|
Revision: 45521 http://brlcad.svn.sourceforge.net/brlcad/?rev=45521&view=rev Author: brlcad Date: 2011-07-16 10:42:03 +0000 (Sat, 16 Jul 2011) Log Message: ----------- renamed stat.c to file.c in order to reflect the API supporting more than determining whether a file exists and stat-style permissions info. Modified Paths: -------------- brlcad/trunk/include/bu.h brlcad/trunk/src/libbu/CMakeLists.txt brlcad/trunk/src/libbu/Makefile.am Added Paths: ----------- brlcad/trunk/src/libbu/file.c Removed Paths: ------------- brlcad/trunk/src/libbu/stat.c Modified: brlcad/trunk/include/bu.h =================================================================== --- brlcad/trunk/include/bu.h 2011-07-16 04:00:43 UTC (rev 45520) +++ brlcad/trunk/include/bu.h 2011-07-16 10:42:03 UTC (rev 45521) @@ -2775,7 +2775,7 @@ /** @ingroup io */ /** @{ */ -/** @file libbu/stat.c +/** @file libbu/file.c * * Support routines for identifying properties of files and * directories such as whether they exist or are the same as another Modified: brlcad/trunk/src/libbu/CMakeLists.txt =================================================================== --- brlcad/trunk/src/libbu/CMakeLists.txt 2011-07-16 04:00:43 UTC (rev 45520) +++ brlcad/trunk/src/libbu/CMakeLists.txt 2011-07-16 10:42:03 UTC (rev 45521) @@ -26,6 +26,7 @@ endian.c fchmod.c fgets.c + file.c fnmatch.c fopen_uniq.c getcwd.c @@ -68,7 +69,6 @@ rb_walk.c semaphore.c simd.c - stat.c str.c tcl.c temp.c Modified: brlcad/trunk/src/libbu/Makefile.am =================================================================== --- brlcad/trunk/src/libbu/Makefile.am 2011-07-16 04:00:43 UTC (rev 45520) +++ brlcad/trunk/src/libbu/Makefile.am 2011-07-16 10:42:03 UTC (rev 45521) @@ -26,6 +26,7 @@ endian.c \ fchmod.c \ fgets.c \ + file.c \ fnmatch.c \ fopen_uniq.c \ getcwd.c \ @@ -68,7 +69,6 @@ rb_walk.c \ semaphore.c \ simd.c \ - stat.c \ str.c \ tcl.c \ temp.c \ Copied: brlcad/trunk/src/libbu/file.c (from rev 45436, brlcad/trunk/src/libbu/stat.c) =================================================================== --- brlcad/trunk/src/libbu/file.c (rev 0) +++ brlcad/trunk/src/libbu/file.c 2011-07-16 10:42:03 UTC (rev 45521) @@ -0,0 +1,238 @@ +/* S T A T . C + * BRL-CAD + * + * Copyright (c) 2004-2011 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ + +#include "common.h" + +#include <string.h> +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif +#ifdef HAVE_PWD_H +# include <pwd.h> +#endif +#ifdef HAVE_GRP_H +# include <grp.h> +#endif +#include "bio.h" + +#include "bu.h" + +#ifndef R_OK +# define R_OK 4 +#endif +#ifndef W_OK +# define W_OK 2 +#endif +#ifndef X_OK +# define X_OK 1 +#endif + + +int +bu_file_exists(const char *path) +{ + struct stat sbuf; + + if (UNLIKELY(bu_debug & BU_DEBUG_PATHS)) { + bu_log("Does [%s] exist? ", path); + } + + if (!path || path[0] == '\0') { + if (UNLIKELY(bu_debug & BU_DEBUG_PATHS)) { + bu_log("NO\n"); + } + /* FAIL */ + return 0; + } + + /* does it exist as a filesystem entity? */ + if (stat(path, &sbuf) == 0) { + if (UNLIKELY(bu_debug & BU_DEBUG_PATHS)) { + bu_log("YES\n"); + } + /* OK */ + return 1; + } + + if (UNLIKELY(bu_debug & BU_DEBUG_PATHS)) { + bu_log("NO\n"); + } + /* FAIL */ + return 0; +} + + +int +bu_same_file(const char *fn1, const char *fn2) +{ + struct stat sb1, sb2; + + if (UNLIKELY(!fn1 || !fn2)) { + return 0; + } + + if (UNLIKELY(fn1[0] == '\0' || fn2[0] == '\0')) { + return 0; + } + + if (!bu_file_exists(fn1) || !bu_file_exists(fn2)) { + return 0; + } + + if ((stat(fn1, &sb1) == 0) && + (stat(fn2, &sb2) == 0) && + (sb1.st_dev == sb2.st_dev) && + (sb1.st_ino == sb2.st_ino)) { + return 1; + } + + return 0; +} + + +int +bu_same_fd(int fd1, int fd2) +{ + struct stat sb1, sb2; + + if (UNLIKELY(fd1<0 || fd2<0)) { + return 0; + } + + /* ares files the same inode on same device? */ + if ((fstat(fd1, &sb1) == 0) && (fstat(fd2, &sb2) == 0) && (sb1.st_dev == sb2.st_dev) && (sb1.st_ino == sb2.st_ino)) { + return 1; + } + + return 0; +} + + +/** + * _ b u _ f i l e _ a c c e s s + * + * common guts to the file access functions that returns truthfully if + * the current user has the ability permission-wise to access the + * specified file. + */ +HIDDEN int +_bu_file_access(const char *path, int access_level) +{ + struct stat sb; + int mask = 0; + + /* 0 is root or Windows user */ + uid_t uid = 0; + + /* 0 is wheel or Windows group */ + gid_t gid = 0; + + int usr_mask = S_IRUSR | S_IWUSR | S_IXUSR; + int grp_mask = S_IRGRP | S_IWGRP | S_IXGRP; + int oth_mask = S_IROTH | S_IWOTH | S_IXOTH; + + if (UNLIKELY(!path || (path[0] == '\0'))) { + return 0; + } + + if (stat(path, &sb) == -1) { + return 0; + } + + if (access_level & R_OK) { + mask = S_IRUSR | S_IRGRP | S_IROTH; + } + if (access_level & W_OK) { + mask = S_IWUSR | S_IWGRP | S_IWOTH; + } + if (access_level & X_OK) { + mask = S_IXUSR | S_IXGRP | S_IXOTH; + } + +#ifdef HAVE_GETEUID + uid = geteuid(); +#endif +#ifdef HAVE_GETEGID + gid = getegid(); +#endif + + if ((uid_t)sb.st_uid == uid) { + /* we own it */ + return sb.st_mode & (mask & usr_mask); + } else if ((gid_t)sb.st_gid == gid) { + /* our primary group */ + return sb.st_mode & (mask & grp_mask); + } + + /* search group database to see if we're in the file's group */ +#if defined(HAVE_PWD_H) && defined (HAVE_GRP_H) + { + struct passwd *pwdb = getpwuid(uid); + if (pwdb && pwdb->pw_name) { + int i; + struct group *grdb = getgrgid(sb.st_gid); + for (i = 0; grdb && grdb->gr_mem[i]; i++) { + if (BU_STR_EQUAL(grdb->gr_mem[i], pwdb->pw_name)) { + /* one of our other groups */ + return sb.st_mode & (mask & grp_mask); + } + } + } + } +#endif + + /* check other */ + return sb.st_mode & (mask & oth_mask);; +} + + +int +bu_file_readable(const char *path) +{ + return _bu_file_access(path, R_OK); +} + + +int +bu_file_writable(const char *path) +{ + return _bu_file_access(path, W_OK); +} + + +int +bu_file_executable(const char *path) +{ + return _bu_file_access(path, X_OK); +} + + +/* + * Local Variables: + * mode: C + * tab-width: 8 + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Deleted: brlcad/trunk/src/libbu/stat.c =================================================================== --- brlcad/trunk/src/libbu/stat.c 2011-07-16 04:00:43 UTC (rev 45520) +++ brlcad/trunk/src/libbu/stat.c 2011-07-16 10:42:03 UTC (rev 45521) @@ -1,238 +0,0 @@ -/* S T A T . C - * BRL-CAD - * - * Copyright (c) 2004-2011 United States Government as represented by - * the U.S. Army Research Laboratory. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this file; see the file named COPYING for more - * information. - */ - -#include "common.h" - -#include <string.h> -#ifdef HAVE_SYS_TYPES_H -# include <sys/types.h> -#endif -#ifdef HAVE_SYS_STAT_H -# include <sys/stat.h> -#endif -#ifdef HAVE_PWD_H -# include <pwd.h> -#endif -#ifdef HAVE_GRP_H -# include <grp.h> -#endif -#include "bio.h" - -#include "bu.h" - -#ifndef R_OK -# define R_OK 4 -#endif -#ifndef W_OK -# define W_OK 2 -#endif -#ifndef X_OK -# define X_OK 1 -#endif - - -int -bu_file_exists(const char *path) -{ - struct stat sbuf; - - if (UNLIKELY(bu_debug & BU_DEBUG_PATHS)) { - bu_log("Does [%s] exist? ", path); - } - - if (!path || path[0] == '\0') { - if (UNLIKELY(bu_debug & BU_DEBUG_PATHS)) { - bu_log("NO\n"); - } - /* FAIL */ - return 0; - } - - /* does it exist as a filesystem entity? */ - if (stat(path, &sbuf) == 0) { - if (UNLIKELY(bu_debug & BU_DEBUG_PATHS)) { - bu_log("YES\n"); - } - /* OK */ - return 1; - } - - if (UNLIKELY(bu_debug & BU_DEBUG_PATHS)) { - bu_log("NO\n"); - } - /* FAIL */ - return 0; -} - - -int -bu_same_file(const char *fn1, const char *fn2) -{ - struct stat sb1, sb2; - - if (UNLIKELY(!fn1 || !fn2)) { - return 0; - } - - if (UNLIKELY(fn1[0] == '\0' || fn2[0] == '\0')) { - return 0; - } - - if (!bu_file_exists(fn1) || !bu_file_exists(fn2)) { - return 0; - } - - if ((stat(fn1, &sb1) == 0) && - (stat(fn2, &sb2) == 0) && - (sb1.st_dev == sb2.st_dev) && - (sb1.st_ino == sb2.st_ino)) { - return 1; - } - - return 0; -} - - -int -bu_same_fd(int fd1, int fd2) -{ - struct stat sb1, sb2; - - if (UNLIKELY(fd1<0 || fd2<0)) { - return 0; - } - - /* ares files the same inode on same device? */ - if ((fstat(fd1, &sb1) == 0) && (fstat(fd2, &sb2) == 0) && (sb1.st_dev == sb2.st_dev) && (sb1.st_ino == sb2.st_ino)) { - return 1; - } - - return 0; -} - - -/** - * _ b u _ f i l e _ a c c e s s - * - * common guts to the file access functions that returns truthfully if - * the current user has the ability permission-wise to access the - * specified file. - */ -HIDDEN int -_bu_file_access(const char *path, int access_level) -{ - struct stat sb; - int mask = 0; - - /* 0 is root or Windows user */ - uid_t uid = 0; - - /* 0 is wheel or Windows group */ - gid_t gid = 0; - - int usr_mask = S_IRUSR | S_IWUSR | S_IXUSR; - int grp_mask = S_IRGRP | S_IWGRP | S_IXGRP; - int oth_mask = S_IROTH | S_IWOTH | S_IXOTH; - - if (UNLIKELY(!path || (path[0] == '\0'))) { - return 0; - } - - if (stat(path, &sb) == -1) { - return 0; - } - - if (access_level & R_OK) { - mask = S_IRUSR | S_IRGRP | S_IROTH; - } - if (access_level & W_OK) { - mask = S_IWUSR | S_IWGRP | S_IWOTH; - } - if (access_level & X_OK) { - mask = S_IXUSR | S_IXGRP | S_IXOTH; - } - -#ifdef HAVE_GETEUID - uid = geteuid(); -#endif -#ifdef HAVE_GETEGID - gid = getegid(); -#endif - - if ((uid_t)sb.st_uid == uid) { - /* we own it */ - return sb.st_mode & (mask & usr_mask); - } else if ((gid_t)sb.st_gid == gid) { - /* our primary group */ - return sb.st_mode & (mask & grp_mask); - } - - /* search group database to see if we're in the file's group */ -#if defined(HAVE_PWD_H) && defined (HAVE_GRP_H) - { - struct passwd *pwdb = getpwuid(uid); - if (pwdb && pwdb->pw_name) { - int i; - struct group *grdb = getgrgid(sb.st_gid); - for (i = 0; grdb && grdb->gr_mem[i]; i++) { - if (BU_STR_EQUAL(grdb->gr_mem[i], pwdb->pw_name)) { - /* one of our other groups */ - return sb.st_mode & (mask & grp_mask); - } - } - } - } -#endif - - /* check other */ - return sb.st_mode & (mask & oth_mask);; -} - - -int -bu_file_readable(const char *path) -{ - return _bu_file_access(path, R_OK); -} - - -int -bu_file_writable(const char *path) -{ - return _bu_file_access(path, W_OK); -} - - -int -bu_file_executable(const char *path) -{ - return _bu_file_access(path, X_OK); -} - - -/* - * Local Variables: - * mode: C - * tab-width: 8 - * indent-tabs-mode: t - * c-file-style: "stroustrup" - * End: - * ex: shiftwidth=4 tabstop=8 - */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <brlcad@us...> - 2011-07-16 04:00:50
|
Revision: 45520 http://brlcad.svn.sourceforge.net/brlcad/?rev=45520&view=rev Author: brlcad Date: 2011-07-16 04:00:43 +0000 (Sat, 16 Jul 2011) Log Message: ----------- fix a variety of minor build issues that came up during compilation testing. thanks starseeker! Modified Paths: -------------- brlcad/trunk/src/libbu/fchmod.c Modified: brlcad/trunk/src/libbu/fchmod.c =================================================================== --- brlcad/trunk/src/libbu/fchmod.c 2011-07-16 01:59:56 UTC (rev 45519) +++ brlcad/trunk/src/libbu/fchmod.c 2011-07-16 04:00:43 UTC (rev 45520) @@ -77,10 +77,10 @@ if (GetMappedFileName (GetCurrentProcess(), pMem, pszFilename, MAXPATHLEN)) { /* Translate path with device name to drive letters. */ - TCHAR szTemp[BUFSIZE]; + TCHAR szTemp[MAXPATHLEN+1]; szTemp[0] = '\0'; - if (GetLogicalDriveStrings(BUFSIZE-1, szTemp)) { + if (GetLogicalDriveStrings(MAXPATHLEN, szTemp)) { TCHAR szName[MAXPATHLEN]; TCHAR szDrive[3] = TEXT(" :"); int bFound = 0; @@ -119,8 +119,12 @@ CloseHandle(hFileMap); } - wcstombs(filename, pszFilename, MAXPATHLEN); - bu_strlcpy(filepath, filename, MAXPATHLEN); + if (sizeof(TCHAR) == sizeof(wchar_t)) { + wcstombs(filename, pszFilename, MAXPATHLEN); + bu_strlcpy(filepath, filename, MAXPATHLEN); + } else { + bu_strlcpy(filepath, pszFilename, MAXPATHLEN); + } return(bSuccess); } #endif @@ -147,11 +151,11 @@ * it's rather unreliable. */ { - const char filepath[MAXPATHLEN+1]; + char filepath[MAXPATHLEN+1]; int fd = fileno(fp); HANDLE h = (HANDLE)_get_osfhandle(fd); - GetFileNameFromHandle(h, &filepath); - return chmod(filepath, (mode_t)pmode); + GetFileNameFromHandle(h, filepath); + return chmod(filepath, pmode); } #endif } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bhinesley@us...> - 2011-07-16 02:00:03
|
Revision: 45519 http://brlcad.svn.sourceforge.net/brlcad/?rev=45519&view=rev Author: bhinesley Date: 2011-07-16 01:59:56 +0000 (Sat, 16 Jul 2011) Log Message: ----------- Changed the way that commands are added/stored, to use an array of structs similar to other command lists in BRL-CAD; much better. Set up ged_edit so that it behaves like a wrapper when the command name is not a ged_edit subcommand. Otherwise, when the command name is a ged_edit subcommand, it behaves as if it were the only command available. The syntax for some of the subcommands is pretty intense, so I also implemented a help system that displays the expanded syntax. Ex: "edit help", "edit help rotate" "rotate help", etc. Modified Paths: -------------- brlcad/trunk/src/libged/edit.c Modified: brlcad/trunk/src/libged/edit.c =================================================================== --- brlcad/trunk/src/libged/edit.c 2011-07-15 23:03:41 UTC (rev 45518) +++ brlcad/trunk/src/libged/edit.c 2011-07-16 01:59:56 UTC (rev 45519) @@ -832,10 +832,16 @@ */ /* argument types */ +/*FIXME: some of these first few flags can probably go away, as the + * edit_cmd union makes them redundant. The edit_cmd union object in + * ged_edit may require one or two of them, to distinguish between + * target object arguments and reference arguments. This is because + * ged_edit does not use the structs inside edit_cmd, in order to + * remain agnostic of subcommands. */ #define EDIT_FROM 0x001 /* aka keypoint */ #define EDIT_CENTER 0x002 /* for rotate/scale */ -#define EDIT_TO 0x004 -#define EDIT_TARGET_OBJ 0x008 /* obj to operate on */ +#define EDIT_TO 0x004 +#define EDIT_TARGET_OBJ 0x008 /* obj to operate on */ /* argument "TO" type modifiers */ #define EDIT_REL_DIST 0x010 @@ -849,36 +855,54 @@ #define EDIT_NATURAL_ORIGIN 0x100 /* use natural origin of object instead of center */ #define EDIT_USE_TARGETS 0x200 /* for batch ops */ -enum edit_cmd_name { - /* alphabetize */ - EDIT_CMD_HELP, - EDIT_CMD_ROTATE, - EDIT_CMD_SCALE, - EDIT_CMD_TRANSLATE, - /* end alphabetize */ +struct edit_cmd_tab { + char *name; + char *opt_global; + char *usage; + char *help; + /*FIXME: add *function, and full syntax, aliases, etc */ +}; - EDIT_CMD_MAX, /* count of commands, size of char array */ - EDIT_CMD_UNKNOWN = EDIT_CMD_MAX +static const struct edit_cmd_tab edit_cmds[] = { + {"help", (char *)NULL, "[subcmd]", (char *)NULL}, +#define EDIT_CMD_HELP 0 /* idx of "help" in edit_cmds */ + {"rotate", "R", + "[-R] [AXIS] [CENTER] ANGLE OBJECT ...", + "[[-n] [-a | -r] {AXIS_TO_OBJECT | AXIS_TO_POS}]]\n" + "[[-n] -c {CENTER_OBJECT | CENTER_POS}]\n" + "[[-n] -O {ANGLE_ORIGIN_OBJECT| ANGLE_ORIGIN_POS}]\n" + "[[-n] -k {ANGLE_FROM_OBJECT | ANGLE_FROM_POS}]\n" + "[-n | -o] [-a | -r | -d]" + "{ANGLE_TO_OBJECT | ANGLE_TO_POS}} OBJECT ..." + }, + {"scale", (char *)NULL, + "[SCALE] [CENTER] FACTOR OBJECT ...", + "[[[-n] -k {SCALE_FROM_OBJECT | SCALE_FROM_POS}]\n" + "[-n] [-a | -r] {SCALE_TO_OBJECT | SCALE_TO_POS}]\n" + "[[-n] -c {CENTER_OBJECT | CENTER_POS}]\n" + "[[-n] -k {FACTOR_FROM_OBJECT | FACTOR_FROM_POS}]\n" + "[-n] [-a | -r] {FACTOR_TO_OBJECT | FACTOR_TO_POS}" + " OBJECT ..." + }, + {"translate", (char *)NULL, + "[FROM] TO OBJECT ...", + "[[-n] -k {FROM_OBJECT | FROM_POS}]\n" + "[-n] [-a | -r] {TO_OBJECT | TO_POS} OBJECT ..." + }, + {(char *)NULL, (char *)NULL, (char *)NULL, (char *)NULL} }; -static const char * const edit_cmd_names[EDIT_CMD_MAX] = { - /* alphabetize to keep in same order as enum edit_cmd_name */ - "help", - "rotate", - "scale", - "translate" -}; -/* argument structure of each command */ +/* arg groupings for each command */ union edit_cmd{ - enum edit_cmd_name name; + const struct edit_cmd_tab *cmd; struct { - enum edit_cmd_name padding_for_name; + const struct edit_cmd_tab *padding_for_cmd; struct edit_arg objects; } common; struct { - enum edit_cmd_name padding_for_name; + const struct edit_cmd_tab *padding_for_cmd; struct edit_arg objects; struct { struct edit_arg from; @@ -887,7 +911,7 @@ } translate; struct { - enum edit_cmd_name padding_for_name; + const struct edit_cmd_tab *padding_for_cmd; struct edit_arg objects; struct { struct edit_arg from; @@ -902,7 +926,7 @@ } rotate; struct { - enum edit_cmd_name padding_for_cmd; + const struct edit_cmd_tab *padding_for_cmd; struct edit_arg objects; struct { struct edit_arg from; @@ -1052,18 +1076,19 @@ #endif /** - * A command line interface to the edit commands. + * A command line interface to the edit commands. Will handle any + * new commands without modification. */ int ged_edit(struct ged *gedp, int argc, const char *argv[]) { const char * const cmd_name = argv[0]; - const char *subcmd_name; - static const char * const usage = "subcmd args"; + const char *subcmd_name = NULL; union edit_cmd subcmd; + static const char * const usage = "[subcommand] [args]"; int i; /* iterator */ - subcmd.name = EDIT_CMD_UNKNOWN; + subcmd.cmd = (const struct edit_cmd_tab *)NULL; GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); GED_CHECK_READ_ONLY(gedp, GED_ERROR); @@ -1072,39 +1097,131 @@ /* initialize result */ bu_vls_trunc(gedp->ged_result_str, 0); - /* must be wanting help */ - if (argc == 1) { - bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", cmd_name, usage); - return GED_HELP; + /* + * Validate command name + */ + +/* FIXME: usage/help messages for subcommands should contain the name + * of the 'parent' command when necessary: i.e.: 'edit translate' + * rather than just 'translate'. */ + + for (i = 0; edit_cmds[i].name; ++i) { + /* search for command name in the table */ + if (BU_STR_EQUAL(edit_cmds[i].name, cmd_name)) { + subcmd_name = cmd_name; /* saves a strcmp later */ + subcmd.cmd = &edit_cmds[i]; + /* match of cmd name takes precedence over match of subcmd + * name */ + break; + } + /* treat first arg as a cmd, and search for it in table */ + if (!subcmd_name && argc > 1 && + BU_STR_EQUAL(edit_cmds[i].name, argv[1])) { + subcmd_name = argv[1]; + subcmd.cmd = &edit_cmds[i]; + } } - subcmd_name = argv[1]; + if (subcmd_name == cmd_name) { /* ptr cmp */ + /* command name is serving as the subcommand */ + --argc; + ++argv; + } else if (subcmd.cmd) { + /* first arg is the subcommand */ + argc -= 2; + argv += 2; + } else { + /* no subcommand was found */ + int ret = GED_HELP; + + if (argc > 1) { + /* no arguments accepted without a subcommand */ + bu_vls_printf(gedp->ged_result_str, "unknown subcommand \"%s\"\n", + argv[1]); + ret = GED_ERROR; + } + + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s" + "\nAvailable subcommands: ", cmd_name, usage); + for (i = 0; edit_cmds[i].name; ++i) + bu_vls_printf(gedp->ged_result_str, "%s ", edit_cmds[i].name); + return ret; + } + /* - * validate subcommand name + * Subcommand help system */ - for (i = 0; i < EDIT_CMD_MAX; ++i) - if (BU_STR_EQUAL(edit_cmd_names[i], subcmd_name)) - break; + /* switch on idx of subcmd.cmd in edit_cmds[] */ + switch (subcmd.cmd - edit_cmds) { + case EDIT_CMD_HELP: + if (argc == 0) { + /* get generic help */ + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s\n", + subcmd.cmd->name, subcmd.cmd->usage); + bu_vls_printf(gedp->ged_result_str, "Available subcommands: "); + for (i = 0; edit_cmds[i].name; ++i) + bu_vls_printf(gedp->ged_result_str, "%s ", + edit_cmds[i].name); + return GED_HELP; + } else { + /* get (long) help on a specific command */ + for (i = 0; edit_cmds[i].name; ++i) + /* search for command name in the table */ + if (BU_STR_EQUAL(edit_cmds[i].name, argv[0])) + break; /* for loop */ - subcmd.name = (enum edit_cmd_name)i; - switch (subcmd.name) { - case EDIT_CMD_UNKNOWN: - bu_vls_printf(gedp->ged_result_str, "unknown subcommand: %s\n", - subcmd_name); - /* fall through */ - case EDIT_CMD_HELP: - bu_vls_printf(gedp->ged_result_str, "Available subcommands: "); - for (i = 0; i < EDIT_CMD_MAX; ++i) - bu_vls_printf(gedp->ged_result_str, "%s ", - edit_cmd_names[i]); - return (subcmd.name == EDIT_CMD_HELP ? GED_HELP : GED_ERROR); - default: /* quiet compiler */ - break; + if (!edit_cmds[i].name) { + bu_vls_printf(gedp->ged_result_str, + "unknown subcommand \"%s\"\n", + argv[0]); + bu_vls_printf(gedp->ged_result_str, + "Available subcommands: "); + for (i = 0; edit_cmds[i].name; ++i) + bu_vls_printf(gedp->ged_result_str, "%s ", + edit_cmds[i].name); + return GED_ERROR; + } + + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s\n\n%s %s", + edit_cmds[i].name, edit_cmds[i].usage, + edit_cmds[i].name, edit_cmds[i].help); + return GED_HELP; + } + default: + if (argc == 0) { + /* no args to subcommand; must want usage */ + bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", + subcmd.cmd->name, subcmd.cmd->usage); + return GED_HELP; + } + + /* Handle "subcmd help" (identical to "help subcmd"), + * but only if there are no more args. Wouldn't want to + * match an object named "help". This syntax is needed + * to access the help system when subcmd is an actual + * command */ + if (argc == 1 && + BU_STR_EQUAL(edit_cmds[EDIT_CMD_HELP].name, + argv[0])) { + bu_vls_printf(gedp->ged_result_str, + "Usage: %s %s\n\n%s %s", + subcmd.cmd->name, subcmd.cmd->usage, + subcmd.cmd->name, subcmd.cmd->help); + return GED_HELP; + } } - /* TODO: set subcmd_usage */ + /* + * Create a linked list of all arguments to the subcommand. + * + * The object of the game is to remain agnostic of argument + * structures for specific commands (i.e. inside the ged_cmd + * union). Therefore, we will simply chain all of the arguments + * together with edit_arg structs. + */ + /* * testing */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |