From bug-request at octave dot org Mon Nov 28 09:44:45 2005 Subject: Re: Can I submit a ver.m and license.m? From: William Poetra Yoga Hadisoeseno To: bug at octave dot org Date: Mon, 28 Nov 2005 23:43:41 +0800 ------=_Part_10126_31641095.1133192621287 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 11/28/05, John W. Eaton wrote: > > What options are there? > Basically there are a few options for license.m: 1. For checking licenses which are "in use", for those which are "available", and for "checking out" a license. I don't really know what those might mean, but I'm returning "GPL v2" for Octave. 2. Depending on nargout, we might return a struct or just display a string. I think looking at the code / running it would explain everything ;) > If they are complete new functions, then there is no need to send a > diff, but you should say what scripts subdirectory you think they > belong in. It is still best to send them as a text/plain attachment > since that is easier to view directly without having to save to a file > first (at least in my mail reader). > OK, I'm sending them with a ".txt" extension so you would want to rename them first. if you like them, please put the GPL license for me ;) I think it should be in miscellaneous, because version.m is also there. -- William Poetra Yoga Hadisoeseno ------=_Part_10126_31641095.1133192621287 Content-Type: text/plain; name=license.m.txt; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="license.m.txt" ## -*- texinfo -*- ## at deftypefn {Function File} {} license ## at deftypefnx {Function File} {} license ("inuse") ## at deftypefnx {Function File} {@var{retval}} = license ("inuse") ## at deftypefnx {Function File} {@var{retval}} = license ("test", @var{feature}) ## at deftypefnx {Function File} {} license ("test", @var{feature}, @var{toggle}) ## at deftypefnx {Function File} {@var{retval}} = license ("checkout", @var{feature}) ## Display the license of Octave. ## ## at itemize ## ## at item ## at code{license} displays the license of Octave (GNU GPL v2). ## ## at item ## at code{license ("inuse")} also displays a list of products currently ## being used. ## ## at item ## at code{@var{retval} = license ("inuse")} returns a structure which has ## two fields: at code{feature} is the product name ("Octave") and ## at code{user} is the current username (only works on Unix systems; on ## Windows systems it contains "octave_user"). ## ## at item ## at code{@var{retval} = license ("test", @var{feature})} returns 1 if a ## license exists for the product identified by the string at var{feature} ## and 0 otherwise. at var{feature} is case insensitive and only the first ## 27 characters are checked. ## ## at item ## at code{license ("test", @var{feature}, @var{toggle})} enables or disables ## license testing for at var{feature}, depending on @var{toggle}, which ## can be one of: ## ## at table @samp ## at item "enable" ## Future tests for the specified license of at var{feature} are conducted ## as usual. ## at item "disable" ## Future tests for the specified license of at var{feature} return 0. ## at end table ## ## at item ## at code{@var{retval} = license ("checkout", @var{feature})} checks out ## a license for at var{feature}, returning 1 on success and 0 on failure. ## ## at end itemize ## ## at end deftypefn ## at seealso{ver, version} function retval = license (varargin) global __octave_licenses__ if (isempty (__octave_licenses__)) __octave_licenses__ = cell (); __octave_licenses__{1,1} = "Octave"; __octave_licenses__{1,2} = "GNU General Public License, Version 2"; __octave_licenses__{1,3} = true; if (exist ("OCTAVE_FORGE_VERSION")) __octave_licenses__{2,1} = "octave-forge"; __octave_licenses__{2,2} = ""; __octave_licenses__{2,3} = true; endif endif nout = nargout; nin = nargin; nr_licenses = rows (__octave_licenses__); if ((nout > 1) || (nin > 3)) error ("type `help license' for usage info"); endif if (nin == 0) if (nout == 0) found = false; for p = 1:nr_licenses if (strcmp (__octave_licenses__{p,1}, "Octave")) found = true; break; endif endfor if (found) disp (__octave_licenses__{p,2}); else disp ("unknown"); endif else usage ("license"); endif elseif (nin == 1) if (nout == 0) if (! strcmp (varargin{1}, "inuse")) usage ("license (\"inuse\")"); endif for p = 1:nr_licenses disp (__octave_licenses__{p,1}); endfor else if (! strcmp (varargin{1}, "inuse")) usage ("retval = license (\"inuse\")"); endif if (isunix) [t, username] = unix ("id -un"); if (t == 0) username = username(1:end-1); else username = "octave_user"; endif else username = "octave_user"; endif retval(1:nr_licenses) = struct ("feature", "", "user", ""); for p = 1:nr_licenses retval(p).feature = __octave_licenses__{p,1}; retval(p).user = username; endfor endif else feature = varargin{2}(1:(min ([(length (varargin{2})), 27]))); if (strcmp (varargin{1}, "test")) found = false; for p = 1:nr_licenses if (strcmpi (feature, __octave_licenses__{p,1})) found = true; break; endif endfor if (nin == 2) retval = found && __octave_licenses__{p,3}; else if (found) if (strcmp (varargin{3}, "enable")) __octave_licenses__{p,3} = true; elseif (strcmp (varargin{3}, "disable")) __octave_licenses__{p,3} = false; else error ("toggle must be either `enable' of `disable'"); endif else error (["feature `" feature "' not found"]); endif endif elseif (strcmp (varargin{1}, "checkout")) if (nin != 2) usage ("retval = license (\"checkout\", feature)"); endif found = false; for p = 1:nr_licenses if (strcmpi (feature, __octave_licenses__{p,1})) found = true; break; endif endfor retval = found && __octave_licenses__{p,3}; else error ("type `help license' for usage info"); endif endif endfunction ------=_Part_10126_31641095.1133192621287 Content-Type: text/plain; name=ver.m.txt; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ver.m.txt" ## -*- texinfo -*- ## at deftypefn {Function File} {} ver ## at code{ver} displays a header containing the current Octave version ## number, license string and operating system, followed by the version ## number for octave-forge, if installed. ## at end deftypefn ## at seealso{license, version} function ver () if (nargin > 0) usage ("ver"); endif octave_license = "GNU General Public License, Version 2"; uname = system ("uname -srvm")(1:end-1); vd = char( \ ["-------------------------------------------------------------------"], \ ["GNU Octave Version " version], \ ["GNU Octave License: " octave_license], \ ["Operating System: " uname], \ ["-------------------------------------------------------------------"]); if (exist ("OCTAVE_FORGE_VERSION")) vd = [vd; \ ["octave-forge " (num2str (OCTAVE_FORGE_VERSION))]]; endif disp (vd); endfunction ------=_Part_10126_31641095.1133192621287-- ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------