comments
stringlengths 1
16.6k
|
---|
Additionally, the level you choose for a message will be automatically added with the key 'lvl', and so
will the current timestamp with key 't'.
You may supply any additional context as a set of key/value pairs to the logging function. log15 allows
you to favor terseness, ordering, and speed over safety. This is a reasonable tradeoff for
logging functions. You don't need to explicitly state keys/values, log15 understands that they alternate
in the variadic argument list:
log.Warn("size out of bounds", "low", lowBound, "high", highBound, "val", val)
If you really do favor your type-safety, you may choose to pass a log.Ctx instead:
log.Warn("size out of bounds", log.Ctx{"low": lowBound, "high": highBound, "val": val})
Context loggers
Frequently, you want to add context to a logger so that you can track actions associated with it. An http
request is a good example. You can easily create new loggers that have context that is automatically included
with each log line:
requestlogger := log.New("path", r.URL.Path)
// later
requestlogger.Debug("db txn commit", "duration", txnTimer.Finish())
This will output a log line that includes the path context that is attached to the logger:
lvl=dbug t=2014-05-02T16:07:23-0700 path=/repo/12/add_hook msg="db txn commit" duration=0.12
Handlers
The Handler interface defines where log lines are printed to and how they are formated. Handler is a
single interface that is inspired by net/http's handler interface:
type Handler interface {
Log(r *Record) error
}
Handlers can filter records, format them, or dispatch to multiple other Handlers.
This package implements a number of Handlers for common logging patterns that are
easily composed to create flexible, custom logging structures.
Here's an example handler that prints logfmt output to Stdout:
handler := log.StreamHandler(os.Stdout, log.LogfmtFormat())
Here's an example handler that def |
attached to the logger:
lvl=dbug t=2014-05-02T16:07:23-0700 path=/repo/12/add_hook msg="db txn commit" duration=0.12
Handlers
The Handler interface defines where log lines are printed to and how they are formated. Handler is a
single interface that is inspired by net/http's handler interface:
type Handler interface {
Log(r *Record) error
}
Handlers can filter records, format them, or dispatch to multiple other Handlers.
This package implements a number of Handlers for common logging patterns that are
easily composed to create flexible, custom logging structures.
Here's an example handler that prints logfmt output to Stdout:
handler := log.StreamHandler(os.Stdout, log.LogfmtFormat())
Here's an example handler that defers to two other handlers. One handler only prints records
from the rpc package in logfmt to standard out. The other prints records at Error level
or above in JSON formatted output to the file /var/log/service.json
handler := log.MultiHandler(
log.LvlFilterHandler(log.LvlError, log.Must.FileHandler("/var/log/service.json", log.JsonFormat())),
log.MatchFilterHandler("pkg", "app/rpc" log.StdoutHandler())
)
Logging File Names and Line Numbers
This package implements three Handlers that add debugging information to the
context, CallerFileHandler, CallerFuncHandler and CallerStackHandler. Here's
an example that adds the source file and line number of each logging call to
the context.
h := log.CallerFileHandler(log.StdoutHandler)
log.Root().SetHandler(h)
...
log.Error("open file", "err", err)
This will output a line that looks like:
lvl=eror t=2014-05-02T16:07:23-0700 msg="open file" err="file not found" caller=data.go:42
Here's an example that logs the call stack rather than just the call site.
h := log.CallerStackHandler("% |
app/rpc" log.StdoutHandler())
)
Logging File Names and Line Numbers
This package implements three Handlers that add debugging information to the
context, CallerFileHandler, CallerFuncHandler and CallerStackHandler. Here's
an example that adds the source file and line number of each logging call to
the context.
h := log.CallerFileHandler(log.StdoutHandler)
log.Root().SetHandler(h)
...
log.Error("open file", "err", err)
This will output a line that looks like:
lvl=eror t=2014-05-02T16:07:23-0700 msg="open file" err="file not found" caller=data.go:42
Here's an example that logs the call stack rather than just the call site.
h := log.CallerStackHandler("%+v", log.StdoutHandler)
log.Root().SetHandler(h)
...
log.Error("open file", "err", err)
This will output a line that looks like:
lvl=eror t=2014-05-02T16:07:23-0700 msg="open file" err="file not found" stack="[pkg/data.go:42 pkg/cmd/main.go]"
The "%+v" format instructs the handler to include the path of the source file
relative to the compile time GOPATH. The github.com/go-stack/stack package
documents the full list of formatting verbs and modifiers available.
Custom Handlers
The Handler interface is so simple that it's also trivial to write your own. Let's create an
example handler which tries to write to one handler, but if that fails it falls back to
writing to another handler and includes the error that it encountered when trying to write
to the primary. This might be useful when trying to log over a network socket, but if that
fails you want to log those records to a file on disk.
type BackupHandler struct {
Primary Handler
Secondary Handler
}
func (h *BackupHandler) Log (r *Record) error {
err := h.Primary.Log(r)
if err!= nil |
main.go]"
The "%+v" format instructs the handler to include the path of the source file
relative to the compile time GOPATH. The github.com/go-stack/stack package
documents the full list of formatting verbs and modifiers available.
Custom Handlers
The Handler interface is so simple that it's also trivial to write your own. Let's create an
example handler which tries to write to one handler, but if that fails it falls back to
writing to another handler and includes the error that it encountered when trying to write
to the primary. This might be useful when trying to log over a network socket, but if that
fails you want to log those records to a file on disk.
type BackupHandler struct {
Primary Handler
Secondary Handler
}
func (h *BackupHandler) Log (r *Record) error {
err := h.Primary.Log(r)
if err!= nil {
r.Ctx = append(ctx, "primary_err", err)
return h.Secondary.Log(r)
}
return nil
}
This pattern is so useful that a generic version that handles an arbitrary number of Handlers
is included as part of this library called FailoverHandler.
Logging Expensive Operations
Sometimes, you want to log values that are extremely expensive to compute, but you don't want to pay
the price of computing them if you haven't turned up your logging level to a high level of detail.
This package provides a simple type to annotate a logging operation that you want to be evaluated
lazily, just when it is about to be logged, so that it would not be evaluated if an upstream Handler
filters it out. Just wrap any function which takes no arguments with the log.Lazy type. For example:
func factorRSAKey() (factors []int) {
// return the factors of a very large number
}
log.Debug("factors", log.Lazy{factorRSAKey})
If this message is not logged for any reason (like logging at the Error level), then
factorRSAKey is never evaluated.
Dynamic context values
The same log.Lazy mechanism can be used to attach context to a logger which you want to be
evaluated when the message is logged, but not when the logger is created. For example, let |
computing them if you haven't turned up your logging level to a high level of detail.
This package provides a simple type to annotate a logging operation that you want to be evaluated
lazily, just when it is about to be logged, so that it would not be evaluated if an upstream Handler
filters it out. Just wrap any function which takes no arguments with the log.Lazy type. For example:
func factorRSAKey() (factors []int) {
// return the factors of a very large number
}
log.Debug("factors", log.Lazy{factorRSAKey})
If this message is not logged for any reason (like logging at the Error level), then
factorRSAKey is never evaluated.
Dynamic context values
The same log.Lazy mechanism can be used to attach context to a logger which you want to be
evaluated when the message is logged, but not when the logger is created. For example, let's imagine
a game where you have Player objects:
type Player struct {
name string
alive bool
log.Logger
}
You always want to log a player's name and whether they're alive or dead, so when you create the player
object, you might do:
p := &Player{name: name, alive: true}
p.Logger = log.New("name", p.name, "alive", p.alive)
Only now, even after a player has died, the logger will still report they are alive because the logging
context is evaluated when the logger was created. By using the Lazy wrapper, we can defer the evaluation
of whether the player is alive or not to each log message, so that the log records will reflect the player's
current state no matter when the log message is written:
p := &Player{name: name, alive: true}
isAlive := func() bool { return p.alive }
player.Logger = log.New("name", p.name, "alive", log.Lazy{isAlive})
Terminal Format
If log15 detects that stdout is a terminal, it will configure the default
handler for it (which is log.StdoutHandler) to use TerminalFormat. This format
logs records nicely for your terminal, including color-coded output based
on log level.
Error Handling
Becasuse |
, even after a player has died, the logger will still report they are alive because the logging
context is evaluated when the logger was created. By using the Lazy wrapper, we can defer the evaluation
of whether the player is alive or not to each log message, so that the log records will reflect the player's
current state no matter when the log message is written:
p := &Player{name: name, alive: true}
isAlive := func() bool { return p.alive }
player.Logger = log.New("name", p.name, "alive", log.Lazy{isAlive})
Terminal Format
If log15 detects that stdout is a terminal, it will configure the default
handler for it (which is log.StdoutHandler) to use TerminalFormat. This format
logs records nicely for your terminal, including color-coded output based
on log level.
Error Handling
Becasuse log15 allows you to step around the type system, there are a few ways you can specify
invalid arguments to the logging functions. You could, for example, wrap something that is not
a zero-argument function with log.Lazy or pass a context key that is not a string. Since logging libraries
are typically the mechanism by which errors are reported, it would be onerous for the logging functions
to return errors. Instead, log15 handles errors by making these guarantees to you:
- Any log record containing an error will still be printed with the error explained to you as part of the log record.
- Any log record containing an error will include the context key LOG15_ERROR, enabling you to easily
(and if you like, automatically) detect if any of your logging calls are passing bad values.
Understanding this, you might wonder why the Handler interface can return an error value in its Log method. Handlers
are encouraged to return errors only if they fail to write their log records out to an external source like if the
syslog daemon is not responding. This allows the construction of useful handlers which cope with those failures
like the FailoverHandler.
Library Use
log15 is intended to be useful for library authors as a way to provide configurable logging to
users of their library. Best practice for use in a library is to always disable all output for your logger
by default |
you:
- Any log record containing an error will still be printed with the error explained to you as part of the log record.
- Any log record containing an error will include the context key LOG15_ERROR, enabling you to easily
(and if you like, automatically) detect if any of your logging calls are passing bad values.
Understanding this, you might wonder why the Handler interface can return an error value in its Log method. Handlers
are encouraged to return errors only if they fail to write their log records out to an external source like if the
syslog daemon is not responding. This allows the construction of useful handlers which cope with those failures
like the FailoverHandler.
Library Use
log15 is intended to be useful for library authors as a way to provide configurable logging to
users of their library. Best practice for use in a library is to always disable all output for your logger
by default and to provide a public Logger instance that consumers of your library can configure. Like so:
package yourlib
import "github.com/inconshreveable/log15"
var Log = log.New()
func init() {
Log.SetHandler(log.DiscardHandler())
}
Users of your library may then enable it if they like:
import "github.com/inconshreveable/log15"
import "example.com/yourlib"
func main() {
handler := // custom handler setup
yourlib.Log.SetHandler(handler)
}
Best practices attaching logger context
The ability to attach context to a logger is a powerful one. Where should you do it and why?
I favor embedding a Logger directly into any persistent object in my application and adding
unique, tracing context keys to it. For instance, imagine I am writing a web browser:
type Tab struct {
url string
render *RenderingContext
//...
Logger
}
func NewTab(url string) *Tab {
return &Tab {
//...
url: url,
Logger: log.New("url", url),
}
}
When a new tab is created, I assign a logger to it with the url of
the tab as context so it can easily be traced through the logs.
Now, whenever we perform |
"example.com/yourlib"
func main() {
handler := // custom handler setup
yourlib.Log.SetHandler(handler)
}
Best practices attaching logger context
The ability to attach context to a logger is a powerful one. Where should you do it and why?
I favor embedding a Logger directly into any persistent object in my application and adding
unique, tracing context keys to it. For instance, imagine I am writing a web browser:
type Tab struct {
url string
render *RenderingContext
//...
Logger
}
func NewTab(url string) *Tab {
return &Tab {
//...
url: url,
Logger: log.New("url", url),
}
}
When a new tab is created, I assign a logger to it with the url of
the tab as context so it can easily be traced through the logs.
Now, whenever we perform any operation with the tab, we'll log with its
embedded logger and it will include the tab title automatically:
tab.Debug("moved position", "idx", tab.idx)
There's only one problem. What if the tab url changes? We could
use log.Lazy to make sure the current url is always written, but that
would mean that we couldn't trace a tab's full lifetime through our
logs after the user navigate to a new URL.
Instead, think about what values to attach to your loggers the
same way you think about what to use as a key in a SQL database schema.
If it's possible to use a natural key that is unique for the lifetime of the
object, do so. But otherwise, log15's ext package has a handy RandId
function to let you generate what you might call "surrogate keys"
They're just random hex identifiers to use for tracing. Back to our
Tab example, we would prefer to set up our Logger like so:
import logext "github.com/inconshreveable/log15/ext"
t := &Tab {
//...
url: url,
}
t.Logger = log.New("id", logext.RandId(8), "url", log.Lazy{t.getUrl})
return t
Now we'll have a unique traceable identifier even across |
Instead, think about what values to attach to your loggers the
same way you think about what to use as a key in a SQL database schema.
If it's possible to use a natural key that is unique for the lifetime of the
object, do so. But otherwise, log15's ext package has a handy RandId
function to let you generate what you might call "surrogate keys"
They're just random hex identifiers to use for tracing. Back to our
Tab example, we would prefer to set up our Logger like so:
import logext "github.com/inconshreveable/log15/ext"
t := &Tab {
//...
url: url,
}
t.Logger = log.New("id", logext.RandId(8), "url", log.Lazy{t.getUrl})
return t
Now we'll have a unique traceable identifier even across loading new urls, but
we'll still be able to see the tab's current url in the log messages.
Must
For all Handler functions which can return an error, there is a version of that
function which will return no error but panics on failure. They are all available
on the Must object. For example:
log.Must.FileHandler("/path", log.JsonFormat)
log.Must.NetHandler("tcp", ":1234", log.JsonFormat)
Inspiration and Credit
All of the following excellent projects inspired the design of this library:
code.google.com/p/log4go
github.com/op/go-logging
github.com/technoweenie/grohl
github.com/Sirupsen/logrus
github.com/kr/logfmt
github.com/spacemonkeygo/spacelog
golang's stdlib, notably io and net/http
The Name
https://xkcd.com/927/
*/ |
", log.JsonFormat)
Inspiration and Credit
All of the following excellent projects inspired the design of this library:
code.google.com/p/log4go
github.com/op/go-logging
github.com/technoweenie/grohl
github.com/Sirupsen/logrus
github.com/kr/logfmt
github.com/spacemonkeygo/spacelog
golang's stdlib, notably io and net/http
The Name
https://xkcd.com/927/
*/ |
/******************************************************************************
* $Id: shpadd.c,v 1.18 2016-12-05 12:44:05 erouault Exp $
*
* Project: Shapelib
* Purpose: Sample application for adding a shape to a shapefile.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 1999, Frank Warmerdam
*
* This software is available under the following "MIT Style" license,
* or at the option of the licensee under the LGPL (see COPYING). This
* option is discussed in more detail in shapelib.html.
*
* --
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* $Log: shpadd.c,v $
* Revision 1.18 2016-12-05 12:44:05 erouault
* * Major overhaul of Makefile build system to use autoconf/automake.
*
* * Warning fixes in contrib/
*
* Revision 1.17 2016-12-04 15: |
AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* $Log: shpadd.c,v $
* Revision 1.18 2016-12-05 12:44:05 erouault
* * Major overhaul of Makefile build system to use autoconf/automake.
*
* * Warning fixes in contrib/
*
* Revision 1.17 2016-12-04 15:30:15 erouault
* * shpopen.c, dbfopen.c, shptree.c, shapefil.h: resync with
* GDAL Shapefile driver. Mostly cleanups. SHPObject and DBFInfo
* structures extended with new members. New functions:
* DBFSetLastModifiedDate, SHPOpenLLEx, SHPRestoreSHX,
* SHPSetFastModeReadObject
*
* * sbnsearch.c: new file to implement original ESRI.sbn spatial
* index reading. (no write support). New functions:
* SBNOpenDiskTree, SBNCloseDiskTree, SBNSearchDiskTree,
* SBNSearchDiskTreeInteger, SBNSearchFreeIds
*
* * Makefile, makefile.vc, CMakeLists.txt, shapelib.def: updates
* with new file and symbols.
*
* * commit: helper script to cvs commit
*
* Revision 1.16 2010-06-21 20:41:52 fwarmerdam
* reformat white space
*
* Revision 1.15 2007-12-30 16:57:32 fwarmerdam
* add support for z and m
*
* Revision |
* sbnsearch.c: new file to implement original ESRI.sbn spatial
* index reading. (no write support). New functions:
* SBNOpenDiskTree, SBNCloseDiskTree, SBNSearchDiskTree,
* SBNSearchDiskTreeInteger, SBNSearchFreeIds
*
* * Makefile, makefile.vc, CMakeLists.txt, shapelib.def: updates
* with new file and symbols.
*
* * commit: helper script to cvs commit
*
* Revision 1.16 2010-06-21 20:41:52 fwarmerdam
* reformat white space
*
* Revision 1.15 2007-12-30 16:57:32 fwarmerdam
* add support for z and m
*
* Revision 1.14 2004/09/26 20:09:35 fwarmerdam
* avoid rcsid warnings
*
* Revision 1.13 2002/01/15 14:36:07 warmerda
* updated email address
*
* Revision 1.12 2001/05/31 19:35:29 warmerda
* added support for writing null shapes
*
* Revision 1.11 2000/07/07 13:39:45 warmerda
* removed unused variables, and added system include files
*
* Revision 1.10 2000/05/24 15:09:22 warmerda
* Added logic to graw vertex lists of needed.
*
* Revision 1.9 1999/11/05 14:12:04 warmerda
* updated license terms
*
* Revision 1.8 1998/12/03 16:36:26 warmerda
* Use r+b rather than rb+ for binary access.
*
* Revision |
:35:29 warmerda
* added support for writing null shapes
*
* Revision 1.11 2000/07/07 13:39:45 warmerda
* removed unused variables, and added system include files
*
* Revision 1.10 2000/05/24 15:09:22 warmerda
* Added logic to graw vertex lists of needed.
*
* Revision 1.9 1999/11/05 14:12:04 warmerda
* updated license terms
*
* Revision 1.8 1998/12/03 16:36:26 warmerda
* Use r+b rather than rb+ for binary access.
*
* Revision 1.7 1998/11/09 20:57:04 warmerda
* Fixed SHPGetInfo() call.
*
* Revision 1.6 1998/11/09 20:19:16 warmerda
* Changed to use SHPObject based API.
*
* Revision 1.5 1997/03/06 14:05:02 warmerda
* fixed typo.
*
* Revision 1.4 1997/03/06 14:01:16 warmerda
* added memory allocation checking, and free()s.
*
* Revision 1.3 1995/10/21 03:14:37 warmerda
* Changed to use binary file access
*
* Revision 1.2 1995/08/04 03:18:01 warmerda
* Added header.
*
*/ |
6 14:05:02 warmerda
* fixed typo.
*
* Revision 1.4 1997/03/06 14:01:16 warmerda
* added memory allocation checking, and free()s.
*
* Revision 1.3 1995/10/21 03:14:37 warmerda
* Changed to use binary file access
*
* Revision 1.2 1995/08/04 03:18:01 warmerda
* Added header.
*
*/ |
/******************************************************************************
* $Id: shpopen.c,v 1.75 2016-12-05 12:44:05 erouault Exp $
*
* Project: Shapelib
* Purpose: Implementation of core Shapefile read/write functions.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 1999, 2001, Frank Warmerdam
* Copyright (c) 2011-2013, Even Rouault <even dot rouault at mines-paris dot org>
*
* This software is available under the following "MIT Style" license,
* or at the option of the licensee under the LGPL (see COPYING). This
* option is discussed in more detail in shapelib.html.
*
* --
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* $Log: shpopen.c,v $
* Revision 1.75 2016-12-05 12:44:05 erouault
* * Major overhaul of Makefile build system to use auto |
to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* $Log: shpopen.c,v $
* Revision 1.75 2016-12-05 12:44:05 erouault
* * Major overhaul of Makefile build system to use autoconf/automake.
*
* * Warning fixes in contrib/
*
* Revision 1.74 2016-12-04 15:30:15 erouault
* * shpopen.c, dbfopen.c, shptree.c, shapefil.h: resync with
* GDAL Shapefile driver. Mostly cleanups. SHPObject and DBFInfo
* structures extended with new members. New functions:
* DBFSetLastModifiedDate, SHPOpenLLEx, SHPRestoreSHX,
* SHPSetFastModeReadObject
*
* * sbnsearch.c: new file to implement original ESRI.sbn spatial
* index reading. (no write support). New functions:
* SBNOpenDiskTree, SBNCloseDiskTree, SBNSearchDiskTree,
* SBNSearchDiskTreeInteger, SBNSearchFreeIds
*
* * Makefile, makefile.vc, CMakeLists.txt, shapelib.def: updates
* with new file and symbols.
*
* * commit: helper script to cvs commit
*
* Revision 1.73 2012-01-24 22:33:01 fwarmerdam
* fix memory leak on failure to open.shp (gdal |
extended with new members. New functions:
* DBFSetLastModifiedDate, SHPOpenLLEx, SHPRestoreSHX,
* SHPSetFastModeReadObject
*
* * sbnsearch.c: new file to implement original ESRI.sbn spatial
* index reading. (no write support). New functions:
* SBNOpenDiskTree, SBNCloseDiskTree, SBNSearchDiskTree,
* SBNSearchDiskTreeInteger, SBNSearchFreeIds
*
* * Makefile, makefile.vc, CMakeLists.txt, shapelib.def: updates
* with new file and symbols.
*
* * commit: helper script to cvs commit
*
* Revision 1.73 2012-01-24 22:33:01 fwarmerdam
* fix memory leak on failure to open.shp (gdal #4410)
*
* Revision 1.72 2011-12-11 22:45:28 fwarmerdam
* fix failure return from SHPOpenLL.
*
* Revision 1.71 2011-09-15 03:33:58 fwarmerdam
* fix missing cast (#2344)
*
* Revision 1.70 2011-07-24 05:59:25 fwarmerdam
* minimize use of CPLError in favor of SAHooks.Error()
*
* Revision 1.69 2011-07-24 03:24:22 fwarmerdam
* fix memory leaks in error cases creating shapefiles (#2061)
*
* Revision 1.68 2010-08-27 23:42:52 fwarmerdam
* add SHPAPI_CALL attribute in code
*
* Revision 1.67 2010-07-01 08:15:48 fwarmerdam
* do not error out on an object with zero vertices
*
* Revision |
* Revision 1.70 2011-07-24 05:59:25 fwarmerdam
* minimize use of CPLError in favor of SAHooks.Error()
*
* Revision 1.69 2011-07-24 03:24:22 fwarmerdam
* fix memory leaks in error cases creating shapefiles (#2061)
*
* Revision 1.68 2010-08-27 23:42:52 fwarmerdam
* add SHPAPI_CALL attribute in code
*
* Revision 1.67 2010-07-01 08:15:48 fwarmerdam
* do not error out on an object with zero vertices
*
* Revision 1.66 2010-07-01 07:58:57 fwarmerdam
* minor cleanup of error handling
*
* Revision 1.65 2010-07-01 07:27:13 fwarmerdam
* white space formatting adjustments
*
* Revision 1.64 2010-01-28 11:34:34 fwarmerdam
* handle the shape file length limits more gracefully (#3236)
*
* Revision 1.63 2010-01-28 04:04:40 fwarmerdam
* improve numerical accuracy of SHPRewind() algs (gdal #3363)
*
* Revision 1.62 2010-01-17 05:34:13 fwarmerdam
* Remove asserts on x/y being null (#2148).
*
* Revision 1.61 2010-01-16 05:07:42 fwarmerdam
* allow 0/nulls in shpcreateobject (#2148)
*
* Revision 1 |
11:34:34 fwarmerdam
* handle the shape file length limits more gracefully (#3236)
*
* Revision 1.63 2010-01-28 04:04:40 fwarmerdam
* improve numerical accuracy of SHPRewind() algs (gdal #3363)
*
* Revision 1.62 2010-01-17 05:34:13 fwarmerdam
* Remove asserts on x/y being null (#2148).
*
* Revision 1.61 2010-01-16 05:07:42 fwarmerdam
* allow 0/nulls in shpcreateobject (#2148)
*
* Revision 1.60 2009-09-17 20:50:02 bram
* on Win32, define snprintf as alias to _snprintf
*
* Revision 1.59 2008-03-14 05:25:31 fwarmerdam
* Correct crash on buggy geometries (gdal #2218)
*
* Revision 1.58 2008/01/08 23:28:26 bram
* on line 2095, use a float instead of a double to avoid a compiler warning
*
* Revision 1.57 2007/12/06 07:00:25 fwarmerdam
* dbfopen now using SAHooks for fileio
*
* Revision 1.56 2007/12/04 20:37:56 fwarmerdam
* preliminary implementation of hooks api for io and errors
*
* Revision 1.55 2007/11/21 22:39:56 fwarmerdam
* close shx file in readonly mode (GDAL #1956)
*
* Revision |
58 2008/01/08 23:28:26 bram
* on line 2095, use a float instead of a double to avoid a compiler warning
*
* Revision 1.57 2007/12/06 07:00:25 fwarmerdam
* dbfopen now using SAHooks for fileio
*
* Revision 1.56 2007/12/04 20:37:56 fwarmerdam
* preliminary implementation of hooks api for io and errors
*
* Revision 1.55 2007/11/21 22:39:56 fwarmerdam
* close shx file in readonly mode (GDAL #1956)
*
* Revision 1.54 2007/11/15 00:12:47 mloskot
* Backported recent changes from GDAL (Ticket #1415) to Shapelib.
*
* Revision 1.53 2007/11/14 22:31:08 fwarmerdam
* checks after mallocs to detect for corrupted/voluntary broken shapefiles.
* http://trac.osgeo.org/gdal/ticket/1991
*
* Revision 1.52 2007/06/21 15:58:33 fwarmerdam
* fix for SHPRewindObject when rings touch at one vertex (gdal #976)
*
* Revision 1.51 2006/09/04 15:24:01 fwarmerdam
* Fixed up log message for 1.49.
*
* Revision 1.50 2006/09/04 15:21:39 fwarmerdam
* fix of last fix
*
* Revision 1.49 2006/09/04 15:21:0 |
ary broken shapefiles.
* http://trac.osgeo.org/gdal/ticket/1991
*
* Revision 1.52 2007/06/21 15:58:33 fwarmerdam
* fix for SHPRewindObject when rings touch at one vertex (gdal #976)
*
* Revision 1.51 2006/09/04 15:24:01 fwarmerdam
* Fixed up log message for 1.49.
*
* Revision 1.50 2006/09/04 15:21:39 fwarmerdam
* fix of last fix
*
* Revision 1.49 2006/09/04 15:21:00 fwarmerdam
* MLoskot: Added stronger test of Shapefile reading failures, e.g. truncated
* files. The problem was discovered by Tim Sutton and reported here
* https://svn.qgis.org/trac/ticket/200
*
* Revision 1.48 2006/01/26 15:07:32 fwarmerdam
* add bMeasureIsUsed flag from Craig Bruce: Bug 1249
*
* Revision 1.47 2006/01/04 20:07:23 fwarmerdam
* In SHPWriteObject() make sure that the record length is updated
* when rewriting an existing record.
*
* Revision 1.46 2005/02/11 17:17:46 fwarmerdam
* added panPartStart[0] validation
*
* Revision 1.45 2004/09/26 20:09:48 fwarmerdam
* const correctness changes
*
* Revision 1.44 2003/12/29 00:18:39 fwarmerdam
|
bMeasureIsUsed flag from Craig Bruce: Bug 1249
*
* Revision 1.47 2006/01/04 20:07:23 fwarmerdam
* In SHPWriteObject() make sure that the record length is updated
* when rewriting an existing record.
*
* Revision 1.46 2005/02/11 17:17:46 fwarmerdam
* added panPartStart[0] validation
*
* Revision 1.45 2004/09/26 20:09:48 fwarmerdam
* const correctness changes
*
* Revision 1.44 2003/12/29 00:18:39 fwarmerdam
* added error checking for failed IO and optional CPL error reporting
*
* Revision 1.43 2003/12/01 16:20:08 warmerda
* be careful of zero vertex shapes
*
* Revision 1.42 2003/12/01 14:58:27 warmerda
* added degenerate object check in SHPRewindObject()
*
* Revision 1.41 2003/07/08 15:22:43 warmerda
* avoid warning
*
* Revision 1.40 2003/04/21 18:30:37 warmerda
* added header write/update public methods
*
* Revision 1.39 2002/08/26 06:46:56 warmerda
* avoid c++ comments
*
* Revision 1.38 2002/05/07 16:43:39 warmerda
* Removed debugging printf.
*
* Revision 1.37 2002/04/10 17:35:22 warmerda
* |
indObject()
*
* Revision 1.41 2003/07/08 15:22:43 warmerda
* avoid warning
*
* Revision 1.40 2003/04/21 18:30:37 warmerda
* added header write/update public methods
*
* Revision 1.39 2002/08/26 06:46:56 warmerda
* avoid c++ comments
*
* Revision 1.38 2002/05/07 16:43:39 warmerda
* Removed debugging printf.
*
* Revision 1.37 2002/04/10 17:35:22 warmerda
* fixed bug in ring reversal code
*
* Revision 1.36 2002/04/10 16:59:54 warmerda
* added SHPRewindObject
*
* Revision 1.35 2001/12/07 15:10:44 warmerda
* fix if.shx fails to open
*
* Revision 1.34 2001/11/01 16:29:55 warmerda
* move pabyRec into SHPInfo for thread safety
*
* Revision 1.33 2001/07/03 12:18:15 warmerda
* Improved cleanup if SHX not found, provided by Riccardo Cohen.
*
* Revision 1.32 2001/06/22 01:58:07 warmerda
* be more careful about establishing initial bounds in face of NULL shapes
*
* Revision 1.31 2001/05/31 19:35:29 warmerda
* added support for writing null shapes
*
* Revision 1.30 2001/ |
.34 2001/11/01 16:29:55 warmerda
* move pabyRec into SHPInfo for thread safety
*
* Revision 1.33 2001/07/03 12:18:15 warmerda
* Improved cleanup if SHX not found, provided by Riccardo Cohen.
*
* Revision 1.32 2001/06/22 01:58:07 warmerda
* be more careful about establishing initial bounds in face of NULL shapes
*
* Revision 1.31 2001/05/31 19:35:29 warmerda
* added support for writing null shapes
*
* Revision 1.30 2001/05/28 12:46:29 warmerda
* Add some checking on reasonableness of record count when opening.
*
* Revision 1.29 2001/05/23 13:36:52 warmerda
* added use of SHPAPI_CALL
*
* Revision 1.28 2001/02/06 22:25:06 warmerda
* fixed memory leaks when SHPOpen() fails
*
* Revision 1.27 2000/07/18 15:21:33 warmerda
* added better enforcement of -1 for append in SHPWriteObject
*
* Revision 1.26 2000/02/16 16:03:51 warmerda
* added null shape support
*
* Revision 1.25 1999/12/15 13:47:07 warmerda
* Fixed record size settings in.shp file (was 4 words too long)
* Added stdlib.h.
*
* Revision 1.24 1999/11/05 14:12 |
22:25:06 warmerda
* fixed memory leaks when SHPOpen() fails
*
* Revision 1.27 2000/07/18 15:21:33 warmerda
* added better enforcement of -1 for append in SHPWriteObject
*
* Revision 1.26 2000/02/16 16:03:51 warmerda
* added null shape support
*
* Revision 1.25 1999/12/15 13:47:07 warmerda
* Fixed record size settings in.shp file (was 4 words too long)
* Added stdlib.h.
*
* Revision 1.24 1999/11/05 14:12:04 warmerda
* updated license terms
*
* Revision 1.23 1999/07/27 00:53:46 warmerda
* added support for rewriting shapes
*
* Revision 1.22 1999/06/11 19:19:11 warmerda
* Cleanup pabyRec static buffer on SHPClose().
*
* Revision 1.21 1999/06/02 14:57:56 kshih
* Remove unused variables
*
* Revision 1.20 1999/04/19 21:04:17 warmerda
* Fixed syntax error.
*
* Revision 1.19 1999/04/19 21:01:57 warmerda
* Force access string to binary in SHPOpen().
*
* Revision 1.18 1999/04/01 18:48:07 warmerda
* Try upper case extensions if lower case doesn't work.
*
* Revision 1.17 1998/12/31 15:29 |
().
*
* Revision 1.21 1999/06/02 14:57:56 kshih
* Remove unused variables
*
* Revision 1.20 1999/04/19 21:04:17 warmerda
* Fixed syntax error.
*
* Revision 1.19 1999/04/19 21:01:57 warmerda
* Force access string to binary in SHPOpen().
*
* Revision 1.18 1999/04/01 18:48:07 warmerda
* Try upper case extensions if lower case doesn't work.
*
* Revision 1.17 1998/12/31 15:29:39 warmerda
* Disable writing measure values to multipatch objects if
* DISABLE_MULTIPATCH_MEASURE is defined.
*
* Revision 1.16 1998/12/16 05:14:33 warmerda
* Added support to write MULTIPATCH. Fixed reading Z coordinate of
* MULTIPATCH. Fixed record size written for all feature types.
*
* Revision 1.15 1998/12/03 16:35:29 warmerda
* r+b is proper binary access string, not rb+.
*
* Revision 1.14 1998/12/03 15:47:56 warmerda
* Fixed setting of nVertices in SHPCreateObject().
*
* Revision 1.13 1998/12/03 15:33:54 warmerda
* Made SHPCalculateExtents() separately callable.
*
* Revision 1.12 1998/11/11 20:01:50 warmerda
* Fixed bug writing ArcM/Z, and PolygonM/Z for big endian machines.
*
* Revision 1.11 |
.15 1998/12/03 16:35:29 warmerda
* r+b is proper binary access string, not rb+.
*
* Revision 1.14 1998/12/03 15:47:56 warmerda
* Fixed setting of nVertices in SHPCreateObject().
*
* Revision 1.13 1998/12/03 15:33:54 warmerda
* Made SHPCalculateExtents() separately callable.
*
* Revision 1.12 1998/11/11 20:01:50 warmerda
* Fixed bug writing ArcM/Z, and PolygonM/Z for big endian machines.
*
* Revision 1.11 1998/11/09 20:56:44 warmerda
* Fixed up handling of file wide bounds.
*
* Revision 1.10 1998/11/09 20:18:51 warmerda
* Converted to support 3D shapefiles, and use of SHPObject.
*
* Revision 1.9 1998/02/24 15:09:05 warmerda
* Fixed memory leak.
*
* Revision 1.8 1997/12/04 15:40:29 warmerda
* Fixed byte swapping of record number, and record length fields in the
*.shp file.
*
* Revision 1.7 1995/10/21 03:15:58 warmerda
* Added support for binary file access, the magic cookie 9997
* and tried to improve the int32 selection logic for 16bit systems.
*
* Revision 1.6 1995/09/04 04:19:41 warmerda
* Added fix for file bounds.
*
* Revision 1.5 |
/02/24 15:09:05 warmerda
* Fixed memory leak.
*
* Revision 1.8 1997/12/04 15:40:29 warmerda
* Fixed byte swapping of record number, and record length fields in the
*.shp file.
*
* Revision 1.7 1995/10/21 03:15:58 warmerda
* Added support for binary file access, the magic cookie 9997
* and tried to improve the int32 selection logic for 16bit systems.
*
* Revision 1.6 1995/09/04 04:19:41 warmerda
* Added fix for file bounds.
*
* Revision 1.5 1995/08/25 15:16:44 warmerda
* Fixed a couple of problems with big endian systems... one with bounds
* and the other with multipart polygons.
*
* Revision 1.4 1995/08/24 18:10:17 warmerda
* Switch to use SfRealloc() to avoid problems with pre-ANSI realloc()
* functions (such as on the Sun).
*
* Revision 1.3 1995/08/23 02:23:15 warmerda
* Added support for reading bounds, and fixed up problems in setting the
* file wide bounds.
*
* Revision 1.2 1995/08/04 03:16:57 warmerda
* Added header.
*
*/ |
* functions (such as on the Sun).
*
* Revision 1.3 1995/08/23 02:23:15 warmerda
* Added support for reading bounds, and fixed up problems in setting the
* file wide bounds.
*
* Revision 1.2 1995/08/04 03:16:57 warmerda
* Added header.
*
*/ |
/******************************************************************************
* $Id: shpdump.c,v 1.19 2016-12-05 12:44:05 erouault Exp $
*
* Project: Shapelib
* Purpose: Sample application for dumping contents of a shapefile to
* the terminal in human readable form.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 1999, Frank Warmerdam
*
* This software is available under the following "MIT Style" license,
* or at the option of the licensee under the LGPL (see COPYING). This
* option is discussed in more detail in shapelib.html.
*
* --
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* $Log: shpdump.c,v $
* Revision 1.19 2016-12-05 12:44:05 erouault
* * Major overhaul of Makefile build system to use autoconf/automake.
*
* * Warning fixes in contrib/
*
* Revision 1.18 2011 |
.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* $Log: shpdump.c,v $
* Revision 1.19 2016-12-05 12:44:05 erouault
* * Major overhaul of Makefile build system to use autoconf/automake.
*
* * Warning fixes in contrib/
*
* Revision 1.18 2011-07-24 03:05:14 fwarmerdam
* use %.15g for formatting coordiantes in shpdump
*
* Revision 1.17 2010-07-01 07:33:04 fwarmerdam
* do not crash in shpdump if null object returned
*
* Revision 1.16 2010-07-01 07:27:13 fwarmerdam
* white space formatting adjustments
*
* Revision 1.15 2006-01-26 15:07:32 fwarmerdam
* add bMeasureIsUsed flag from Craig Bruce: Bug 1249
*
* Revision 1.14 2005/02/11 17:17:46 fwarmerdam
* added panPartStart[0] validation
*
* Revision 1.13 2004/09/26 20:09:35 fwarmerdam
* avoid rcsid warnings
*
* Revision 1.12 2004/01/27 18:05:35 |
07-01 07:27:13 fwarmerdam
* white space formatting adjustments
*
* Revision 1.15 2006-01-26 15:07:32 fwarmerdam
* add bMeasureIsUsed flag from Craig Bruce: Bug 1249
*
* Revision 1.14 2005/02/11 17:17:46 fwarmerdam
* added panPartStart[0] validation
*
* Revision 1.13 2004/09/26 20:09:35 fwarmerdam
* avoid rcsid warnings
*
* Revision 1.12 2004/01/27 18:05:35 fwarmerdam
* Added the -ho (header only) switch.
*
* Revision 1.11 2004/01/09 16:39:49 fwarmerdam
* include standard include files
*
* Revision 1.10 2002/04/10 16:59:29 warmerda
* added -validate switch
*
* Revision 1.9 2002/01/15 14:36:07 warmerda
* updated email address
*
* Revision 1.8 2000/07/07 13:39:45 warmerda
* removed unused variables, and added system include files
*
* Revision 1.7 1999/11/05 14:12:04 warmerda
* updated license terms
*
* Revision 1.6 1998/12/03 15:48:48 warmerda
* Added report of shapefile type, and total number of shapes.
*
* Revision 1.5 1998/11/09 20:57:36 warmerda
* |
* Revision 1.9 2002/01/15 14:36:07 warmerda
* updated email address
*
* Revision 1.8 2000/07/07 13:39:45 warmerda
* removed unused variables, and added system include files
*
* Revision 1.7 1999/11/05 14:12:04 warmerda
* updated license terms
*
* Revision 1.6 1998/12/03 15:48:48 warmerda
* Added report of shapefile type, and total number of shapes.
*
* Revision 1.5 1998/11/09 20:57:36 warmerda
* use SHPObject.
*
* Revision 1.4 1995/10/21 03:14:49 warmerda
* Changed to use binary file access.
*
* Revision 1.3 1995/08/23 02:25:25 warmerda
* Added support for bounds.
*
* Revision 1.2 1995/08/04 03:18:11 warmerda
* Added header.
*
*/ |
5/08/04 03:18:11 warmerda
* Added header.
*
*/ |
/******************************************************************************
* $Id: dbfopen.c,v 1.92 2016-12-05 18:44:08 erouault Exp $
*
* Project: Shapelib
* Purpose: Implementation of.dbf access API documented in dbf_api.html.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 1999, Frank Warmerdam
* Copyright (c) 2012-2013, Even Rouault <even dot rouault at mines-paris dot org>
*
* This software is available under the following "MIT Style" license,
* or at the option of the licensee under the LGPL (see COPYING). This
* option is discussed in more detail in shapelib.html.
*
* --
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* $Log: dbfopen.c,v $
* Revision 1.92 2016-12-05 18:44:08 erouault
* * dbfopen.c, shapefil.h: write DBF end |
following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* $Log: dbfopen.c,v $
* Revision 1.92 2016-12-05 18:44:08 erouault
* * dbfopen.c, shapefil.h: write DBF end-of-file character 0x1A by default.
* This behaviour can be controlled with the DBFSetWriteEndOfFileChar()
* function.
*
* Revision 1.91 2016-12-05 12:44:05 erouault
* * Major overhaul of Makefile build system to use autoconf/automake.
*
* * Warning fixes in contrib/
*
* Revision 1.90 2016-12-04 15:30:15 erouault
* * shpopen.c, dbfopen.c, shptree.c, shapefil.h: resync with
* GDAL Shapefile driver. Mostly cleanups. SHPObject and DBFInfo
* structures extended with new members. New functions:
* DBFSetLastModifiedDate, SHPOpenLLEx, SHPRestoreSHX,
* SHPSetFastModeReadObject
*
* * sbnsearch.c: new file to implement original ESRI.sbn spatial
* index reading. (no write support). New functions:
* SBNOpenDiskTree, SBNCloseDiskTree, SBNSearchDiskTree,
* SBNSearchDiskTreeInteger, SBNSearchFreeIds
*
* * Makefile, makefile.vc, |
* Revision 1.90 2016-12-04 15:30:15 erouault
* * shpopen.c, dbfopen.c, shptree.c, shapefil.h: resync with
* GDAL Shapefile driver. Mostly cleanups. SHPObject and DBFInfo
* structures extended with new members. New functions:
* DBFSetLastModifiedDate, SHPOpenLLEx, SHPRestoreSHX,
* SHPSetFastModeReadObject
*
* * sbnsearch.c: new file to implement original ESRI.sbn spatial
* index reading. (no write support). New functions:
* SBNOpenDiskTree, SBNCloseDiskTree, SBNSearchDiskTree,
* SBNSearchDiskTreeInteger, SBNSearchFreeIds
*
* * Makefile, makefile.vc, CMakeLists.txt, shapelib.def: updates
* with new file and symbols.
*
* * commit: helper script to cvs commit
*
* Revision 1.89 2011-07-24 05:59:25 fwarmerdam
* minimize use of CPLError in favor of SAHooks.Error()
*
* Revision 1.88 2011-05-13 17:35:17 fwarmerdam
* added DBFReorderFields() and DBFAlterFields() functions (from Even)
*
* Revision 1.87 2011-05-07 22:41:02 fwarmerdam
* ensure pending record is flushed when adding a native field (GDAL #4073)
*
* Revision 1.86 2011-04-17 15:15:29 fwarmerdam
* Removed unused variable.
*
* Revision 1.85 2010-12-06 16:09:34 fwarmerdam
* fix buffer read overrun fetching code page (bug 2276)
*
* Revision 1.84 |
-05-13 17:35:17 fwarmerdam
* added DBFReorderFields() and DBFAlterFields() functions (from Even)
*
* Revision 1.87 2011-05-07 22:41:02 fwarmerdam
* ensure pending record is flushed when adding a native field (GDAL #4073)
*
* Revision 1.86 2011-04-17 15:15:29 fwarmerdam
* Removed unused variable.
*
* Revision 1.85 2010-12-06 16:09:34 fwarmerdam
* fix buffer read overrun fetching code page (bug 2276)
*
* Revision 1.84 2009-10-29 19:59:48 fwarmerdam
* avoid crash on truncated header (gdal #3093)
*
* Revision 1.83 2008/11/12 14:28:15 fwarmerdam
* DBFCreateField() now works on files with records
*
* Revision 1.82 2008/11/11 17:47:09 fwarmerdam
* added DBFDeleteField() function
*
* Revision 1.81 2008/01/03 17:48:13 bram
* in DBFCreate, use default code page LDID/87 (= 0x57, ANSI)
* instead of LDID/3. This seems to be the same as what ESRI
* would be doing by default.
*
* Revision 1.80 2007/12/30 14:36:39 fwarmerdam
* avoid syntax issue with last comment.
*
* Revision 1.79 2007/12/30 14:35:48 fwarmerdam
* Avoid |
008/11/11 17:47:09 fwarmerdam
* added DBFDeleteField() function
*
* Revision 1.81 2008/01/03 17:48:13 bram
* in DBFCreate, use default code page LDID/87 (= 0x57, ANSI)
* instead of LDID/3. This seems to be the same as what ESRI
* would be doing by default.
*
* Revision 1.80 2007/12/30 14:36:39 fwarmerdam
* avoid syntax issue with last comment.
*
* Revision 1.79 2007/12/30 14:35:48 fwarmerdam
* Avoid char* / unsigned char* warnings.
*
* Revision 1.78 2007/12/18 18:28:07 bram
* - create hook for client specific atof (bugzilla ticket 1615)
* - check for NULL handle before closing cpCPG file, and close after reading.
*
* Revision 1.77 2007/12/15 20:25:21 bram
* dbfopen.c now reads the Code Page information from the DBF file, and exports
* this information as a string through the DBFGetCodePage function. This is
* either the number from the LDID header field ("LDID/<number>") or as the
* content of an accompanying.CPG file. When creating a DBF file, the code can
* be set using DBFCreateEx.
*
* Revision 1.76 2007/12/12 22:21:32 bram
* DBFClose: check for NULL psDBF handle before trying to close it.
*
* Revision 1.75 2007/12/06 13:58:19 fwarmerdam
* make sure file offset calculations are done in |
20:25:21 bram
* dbfopen.c now reads the Code Page information from the DBF file, and exports
* this information as a string through the DBFGetCodePage function. This is
* either the number from the LDID header field ("LDID/<number>") or as the
* content of an accompanying.CPG file. When creating a DBF file, the code can
* be set using DBFCreateEx.
*
* Revision 1.76 2007/12/12 22:21:32 bram
* DBFClose: check for NULL psDBF handle before trying to close it.
*
* Revision 1.75 2007/12/06 13:58:19 fwarmerdam
* make sure file offset calculations are done in as SAOffset
*
* Revision 1.74 2007/12/06 07:00:25 fwarmerdam
* dbfopen now using SAHooks for fileio
*
* Revision 1.73 2007/09/03 19:48:11 fwarmerdam
* move DBFReadAttribute() static dDoubleField into dbfinfo
*
* Revision 1.72 2007/09/03 19:34:06 fwarmerdam
* Avoid use of static tuple buffer in DBFReadTuple()
*
* Revision 1.71 2006/06/22 14:37:18 fwarmerdam
* avoid memory leak if dbfopen fread fails
*
* Revision 1.70 2006/06/17 17:47:05 fwarmerdam
* use calloc() for dbfinfo in DBFCreate
*
* Revision 1.69 2006/06/17 15:34:32 fwarmerdam
* disallow creating fields wider than 255
*
* Revision 1. |
info
*
* Revision 1.72 2007/09/03 19:34:06 fwarmerdam
* Avoid use of static tuple buffer in DBFReadTuple()
*
* Revision 1.71 2006/06/22 14:37:18 fwarmerdam
* avoid memory leak if dbfopen fread fails
*
* Revision 1.70 2006/06/17 17:47:05 fwarmerdam
* use calloc() for dbfinfo in DBFCreate
*
* Revision 1.69 2006/06/17 15:34:32 fwarmerdam
* disallow creating fields wider than 255
*
* Revision 1.68 2006/06/17 15:12:40 fwarmerdam
* Fixed C++ style comments.
*
* Revision 1.67 2006/06/17 00:24:53 fwarmerdam
* Don't treat non-zero decimals values as high order byte for length
* for strings. It causes serious corruption for some files.
* http://bugzilla.remotesensing.org/show_bug.cgi?id=1202
*
* Revision 1.66 2006/03/29 18:26:20 fwarmerdam
* fixed bug with size of pachfieldtype in dbfcloneempty
*
* Revision 1.65 2006/02/15 01:14:30 fwarmerdam
* added DBFAddNativeFieldType
*
* Revision 1.64 2006/02/09 00:29:04 fwarmerdam
* Changed to put spaces into string fields that are NULL as
* per http://bugzilla.maptools.org/show_bug.cgi?id=316.
*
* Revision 1.6 |
.
* http://bugzilla.remotesensing.org/show_bug.cgi?id=1202
*
* Revision 1.66 2006/03/29 18:26:20 fwarmerdam
* fixed bug with size of pachfieldtype in dbfcloneempty
*
* Revision 1.65 2006/02/15 01:14:30 fwarmerdam
* added DBFAddNativeFieldType
*
* Revision 1.64 2006/02/09 00:29:04 fwarmerdam
* Changed to put spaces into string fields that are NULL as
* per http://bugzilla.maptools.org/show_bug.cgi?id=316.
*
* Revision 1.63 2006/01/25 15:35:43 fwarmerdam
* check success on DBFFlushRecord
*
* Revision 1.62 2006/01/10 16:28:03 fwarmerdam
* Fixed typo in CPLError.
*
* Revision 1.61 2006/01/10 16:26:29 fwarmerdam
* Push loading record buffer into DBFLoadRecord.
* Implement CPL error reporting if USE_CPL defined.
*
* Revision 1.60 2006/01/05 01:27:27 fwarmerdam
* added dbf deletion mark/fetch
*
* Revision 1.59 2005/03/14 15:20:28 fwarmerdam
* Fixed last change.
*
* Revision 1.58 2005/03/14 15:18:54 fwarmerdam
* Treat very wide fields with no decimals as double. This is
* more than 32bit integer fields.
*
* Revision 1.57 20 |
16:26:29 fwarmerdam
* Push loading record buffer into DBFLoadRecord.
* Implement CPL error reporting if USE_CPL defined.
*
* Revision 1.60 2006/01/05 01:27:27 fwarmerdam
* added dbf deletion mark/fetch
*
* Revision 1.59 2005/03/14 15:20:28 fwarmerdam
* Fixed last change.
*
* Revision 1.58 2005/03/14 15:18:54 fwarmerdam
* Treat very wide fields with no decimals as double. This is
* more than 32bit integer fields.
*
* Revision 1.57 2005/02/10 20:16:54 fwarmerdam
* Make the pszStringField buffer for DBFReadAttribute() static char [256]
* as per bug 306.
*
* Revision 1.56 2005/02/10 20:07:56 fwarmerdam
* Fixed bug 305 in DBFCloneEmpty() - header length problem.
*
* Revision 1.55 2004/09/26 20:23:46 fwarmerdam
* avoid warnings with rcsid and signed/unsigned stuff
*
* Revision 1.54 2004/09/15 16:26:10 fwarmerdam
* Treat all blank numeric fields as null too.
*/ |
() - header length problem.
*
* Revision 1.55 2004/09/26 20:23:46 fwarmerdam
* avoid warnings with rcsid and signed/unsigned stuff
*
* Revision 1.54 2004/09/15 16:26:10 fwarmerdam
* Treat all blank numeric fields as null too.
*/ |
/******************************************************************************
* $Id: shputils.c,v 1.11 2016-12-05 12:44:06 erouault Exp $
*
* Project: Shapelib
* Purpose:
* Altered "shpdump" and "dbfdump" to allow two files to be appended.
* Other Functions:
* Selecting from the DBF before the write occurs.
* Change the UNITS between Feet and Meters and Shift X,Y.
* Clip and Erase boundary. The program only passes thru the
* data once.
*
* Bill Miller North Carolina - Department of Transporation
* Feb. 1997 -- bmiller@dot.state.nc.us
* There was not a lot of time to debug hidden problems;
* And the code is not very well organized or documented.
* The clip/erase function was not well tested.
* Oct. 2000 -- bmiller@dot.state.nc.us
* Fixed the problem when select is using numbers
* larger than short integer. It now reads long integer.
* NOTE: DBF files created using windows NT will read as a string with
* a length of 381 characters. This is a bug in "dbfopen".
*
*
* Author: Bill Miller (bmiller@dot.state.nc.us)
*
******************************************************************************
* Copyright (c) 1999, Frank Warmerdam
*
* This software is available under the following "MIT Style" license,
* or at the option of the licensee under the LGPL (see COPYING). This
* option is discussed in more detail in shapelib.html.
*
* --
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software |
characters. This is a bug in "dbfopen".
*
*
* Author: Bill Miller (bmiller@dot.state.nc.us)
*
******************************************************************************
* Copyright (c) 1999, Frank Warmerdam
*
* This software is available under the following "MIT Style" license,
* or at the option of the licensee under the LGPL (see COPYING). This
* option is discussed in more detail in shapelib.html.
*
* --
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* $Log: shputils.c,v $
* Revision 1.11 2016-12-05 12:44:06 erouault
* * Major overhaul of Makefile build system to use autoconf/automake.
*
* * Warning fixes in contrib/
*
* Revision 1.10 2007-12-13 19:59:23 fwarmerdam
* reindent code, avoid some warnings.
*
* Revision 1.9 2004/01/14 14:56:00 fwar |
DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* $Log: shputils.c,v $
* Revision 1.11 2016-12-05 12:44:06 erouault
* * Major overhaul of Makefile build system to use autoconf/automake.
*
* * Warning fixes in contrib/
*
* Revision 1.10 2007-12-13 19:59:23 fwarmerdam
* reindent code, avoid some warnings.
*
* Revision 1.9 2004/01/14 14:56:00 fwarmerdam
* Some cleanlyness improvements.
*
* Revision 1.8 2004/01/14 14:40:22 fwarmerdam
* Fixed exit() call to include code.
*
* Revision 1.7 2003/02/25 17:20:22 warmerda
* Set psCShape to NULL after SHPDestroyObject() to avoid multi-frees of
* the same memory... as submitted by Fred Fox.
*
* Revision 1.6 2001/08/28 13:57:14 warmerda
* fixed DBFAddField return value check
*
* Revision 1.5 2000/11/02 13:52:48 warmerda
* major upgrade from Bill Miller
*
* Revision 1.4 1999/11/05 14:12:05 warmerda
* updated license terms
*
* Revision 1.3 1998/12/03 15:47:39 warmerda
* Did a bunch of rewriting to make it work with the V1.2 API.
*
* |
() to avoid multi-frees of
* the same memory... as submitted by Fred Fox.
*
* Revision 1.6 2001/08/28 13:57:14 warmerda
* fixed DBFAddField return value check
*
* Revision 1.5 2000/11/02 13:52:48 warmerda
* major upgrade from Bill Miller
*
* Revision 1.4 1999/11/05 14:12:05 warmerda
* updated license terms
*
* Revision 1.3 1998/12/03 15:47:39 warmerda
* Did a bunch of rewriting to make it work with the V1.2 API.
*
* Revision 1.2 1998/06/18 01:19:49 warmerda
* Made C++ compilable.
*
* Revision 1.1 1997/05/27 20:40:27 warmerda
* Initial revision
*/ |
/******************************************************************************
* Copyright (c) 1999, Carl Anderson
*
* This code is based in part on the earlier work of Frank Warmerdam
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* requires shapelib 1.2
* gcc shpproj shpopen.o dbfopen.o -lm -lproj -o shpproj
*
* this may require linking with the PROJ4 projection library available from
*
* http://www.remotesensing.org/proj
*
* use -DPROJ4 to compile in Projection support
*
* $Log: shpgeo.c,v $
* Revision 1.15 2016-12-06 21:13:33 erouault
* * configure.ac: change soname to 2:1:0 to be in sync with Debian soname.
* http://bugzilla.maptools.org/show_bug.cgi?id=2628
* Patch by Bas Couwenberg
*
* * contrib/doc/Shape_PointInPoly_README.txt, contrib/shpgeo.c: typo fixes.
* http://bugzilla.maptools.org |
lproj -o shpproj
*
* this may require linking with the PROJ4 projection library available from
*
* http://www.remotesensing.org/proj
*
* use -DPROJ4 to compile in Projection support
*
* $Log: shpgeo.c,v $
* Revision 1.15 2016-12-06 21:13:33 erouault
* * configure.ac: change soname to 2:1:0 to be in sync with Debian soname.
* http://bugzilla.maptools.org/show_bug.cgi?id=2628
* Patch by Bas Couwenberg
*
* * contrib/doc/Shape_PointInPoly_README.txt, contrib/shpgeo.c: typo fixes.
* http://bugzilla.maptools.org/show_bug.cgi?id=2629
* Patch by Bas Couwenberg
*
* * web/*: use a local.css file to avoid a privacy breach issue reported
* by the lintian QA tool.
* http://bugzilla.maptools.org/show_bug.cgi?id=2630
* Patch by Bas Couwenberg
*
*
* Contributed by Sandro Mani: https://github.com/manisandro/shapelib/tree/autotools
*
* Revision 1.14 2016-12-05 12:44:07 erouault
* * Major overhaul of Makefile build system to use autoconf/automake.
*
* * Warning fixes in contrib/
*
* Revision 1.13 2011-07-24 03:17:46 fwarmerdam
* include string.h and stdlib.h where needed in contrib (#2146)
*
* Revision 1.12 2007-09-03 23:17:46 fwarmerdam
* fix SHPDimension() function
*
* Revision 1.11 2006/11 |
://github.com/manisandro/shapelib/tree/autotools
*
* Revision 1.14 2016-12-05 12:44:07 erouault
* * Major overhaul of Makefile build system to use autoconf/automake.
*
* * Warning fixes in contrib/
*
* Revision 1.13 2011-07-24 03:17:46 fwarmerdam
* include string.h and stdlib.h where needed in contrib (#2146)
*
* Revision 1.12 2007-09-03 23:17:46 fwarmerdam
* fix SHPDimension() function
*
* Revision 1.11 2006/11/06 20:45:58 fwarmerdam
* Fixed SHPProject.
*
* Revision 1.10 2006/11/06 20:44:58 fwarmerdam
* SHPProject() uses pj_transform now
*
* Revision 1.9 2006/01/25 15:33:50 fwarmerdam
* fixed ppsC assignment maptools bug 1263
*
* Revision 1.8 2002/01/15 14:36:56 warmerda
* upgrade to use proj_api.h
*
* Revision 1.7 2002/01/11 15:22:04 warmerda
* fix many warnings. Lots of this code is cruft.
*
* Revision 1.6 2001/08/30 13:42:31 warmerda
* avoid use of auto initialization of PT for VC++
*
* Revision 1.5 2000/04/26 13:24:06 warmerda
* made projUV handling safer
* |
fwarmerdam
* fixed ppsC assignment maptools bug 1263
*
* Revision 1.8 2002/01/15 14:36:56 warmerda
* upgrade to use proj_api.h
*
* Revision 1.7 2002/01/11 15:22:04 warmerda
* fix many warnings. Lots of this code is cruft.
*
* Revision 1.6 2001/08/30 13:42:31 warmerda
* avoid use of auto initialization of PT for VC++
*
* Revision 1.5 2000/04/26 13:24:06 warmerda
* made projUV handling safer
*
* Revision 1.4 2000/04/26 13:17:15 warmerda
* check if projUV or UV
*
* Revision 1.3 2000/03/17 14:15:16 warmerda
* Don't try to use system nan.h... doesn't always exist.
*
* Revision 1.2 1999/05/26 02:56:31 candrsn
* updates to shpdxf, dbfinfo, port from Shapelib 1.1.5 of dbfcat and shpinfo
*
*/ |
999/05/26 02:56:31 candrsn
* updates to shpdxf, dbfinfo, port from Shapelib 1.1.5 of dbfcat and shpinfo
*
*/ |
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_prog_java.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PROG_JAVA
#
# DESCRIPTION
#
# Here is a summary of the main macros:
#
# AX_PROG_JAVAC: finds a Java compiler.
#
# AX_PROG_JAVA: finds a Java virtual machine.
#
# AX_CHECK_CLASS: finds if we have the given class (beware of CLASSPATH!).
#
# AX_CHECK_RQRD_CLASS: finds if we have the given class and stops
# otherwise.
#
# AX_TRY_COMPILE_JAVA: attempt to compile user given source.
#
# AX_TRY_RUN_JAVA: attempt to compile and run user given source.
#
# AX_JAVA_OPTIONS: adds Java configure options.
#
# AX_PROG_JAVA tests an existing Java virtual machine. It uses the
# environment variable JAVA then tests in sequence various common Java
# virtual machines. For political reasons, it starts with the free ones.
# You *must* call [AX_PROG_JAVAC] before.
#
# If you want to force a specific VM:
#
# - at the configure.in level, set JAVA=yourvm before calling AX_PROG_JAVA
#
# (but after AC_INIT)
#
# - at the configure level, setenv JAVA
#
# You can use the JAVA variable in your Makefile.in, with @JAVA@.
#
# *Warning*: its success or failure can depend on a proper setting of the
# CLASSPATH env. variable.
#
# TODO: allow to exclude virtual machines (rationale: most Java programs
# cannot run with some VM like kaffe).
#
# Note: This is part of the set of autoconf M4 macros for Java programs.
# It is VERY IMPORTANT that you download the whole set, some macros depend
# on other. Unfortunately, the autoconf archive does not support the
# concept of set of macros, |
#
# - at the configure.in level, set JAVA=yourvm before calling AX_PROG_JAVA
#
# (but after AC_INIT)
#
# - at the configure level, setenv JAVA
#
# You can use the JAVA variable in your Makefile.in, with @JAVA@.
#
# *Warning*: its success or failure can depend on a proper setting of the
# CLASSPATH env. variable.
#
# TODO: allow to exclude virtual machines (rationale: most Java programs
# cannot run with some VM like kaffe).
#
# Note: This is part of the set of autoconf M4 macros for Java programs.
# It is VERY IMPORTANT that you download the whole set, some macros depend
# on other. Unfortunately, the autoconf archive does not support the
# concept of set of macros, so I had to break it for submission.
#
# A Web page, with a link to the latest CVS snapshot is at
# <http://www.internatif.org/bortzmeyer/autoconf-Java/>.
#
# This is a sample configure.in Process this file with autoconf to produce
# a configure script.
#
# AC_INIT(UnTag.java)
#
# dnl Checks for programs.
# AC_CHECK_CLASSPATH
# AX_PROG_JAVAC
# AX_PROG_JAVA
#
# dnl Checks for classes
# AX_CHECK_RQRD_CLASS(org.xml.sax.Parser)
# AX_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver)
#
# AC_OUTPUT(Makefile)
#
# LICENSE
#
# Copyright (c) 2008 Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version |
dnl Checks for programs.
# AC_CHECK_CLASSPATH
# AX_PROG_JAVAC
# AX_PROG_JAVA
#
# dnl Checks for classes
# AX_CHECK_RQRD_CLASS(org.xml.sax.Parser)
# AX_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver)
#
# AC_OUTPUT(Makefile)
#
# LICENSE
#
# Copyright (c) 2008 Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program 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 General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 10
|
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 10
|
/**
* jGrowl 1.2.10
*
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* Written by Stan Lemon <stosh1985@gmail.com>
* Last updated: 2013.02.14
*
* jGrowl is a jQuery plugin implementing unobtrusive userland notifications. These
* notifications function similarly to the Growl Framework available for
* Mac OS X (http://growl.info).
*
* To Do:
* - Move library settings to containers and allow them to be changed per container
*
* Changes in 1.2.10
* - Fix beforeClose to be called in click event
*
* Changes in 1.2.9
* - Fixed BC break in jQuery 2.0 beta
*
* Changes in 1.2.8
* - Fixes for jQuery 1.9 and the MSIE6 check, note that with jQuery 2.0 support
* jGrowl intends to drop support for IE6 altogether
*
* Changes in 1.2.6
* - Fixed js error when a notification is opening and closing at the same time
*
* Changes in 1.2.5
* - Changed wrapper jGrowl's options usage to "o" instead of $.jGrowl.defaults
* - Added themeState option to control 'highlight' or 'error' for jQuery UI
* - Ammended some CSS to provide default positioning for nested usage.
* - Changed some CSS to be prefixed with jGrowl- to prevent namespacing issues
* - Added two new options - openDuration and closeDuration to allow
* better control of notification open and close speeds, respectively
* Patch contributed by Jesse Vincet.
* - Added afterOpen callback. Patch contributed by Russel Branca.
*
* Changes in 1.2.4
* - Fixed IE bug with the close-all button
* - Fixed IE bug with the filter CSS attribute (special thanks to gotwic)
* - Update |
at the same time
*
* Changes in 1.2.5
* - Changed wrapper jGrowl's options usage to "o" instead of $.jGrowl.defaults
* - Added themeState option to control 'highlight' or 'error' for jQuery UI
* - Ammended some CSS to provide default positioning for nested usage.
* - Changed some CSS to be prefixed with jGrowl- to prevent namespacing issues
* - Added two new options - openDuration and closeDuration to allow
* better control of notification open and close speeds, respectively
* Patch contributed by Jesse Vincet.
* - Added afterOpen callback. Patch contributed by Russel Branca.
*
* Changes in 1.2.4
* - Fixed IE bug with the close-all button
* - Fixed IE bug with the filter CSS attribute (special thanks to gotwic)
* - Update IE opacity CSS
* - Changed font sizes to use "em", and only set the base style
*
* Changes in 1.2.3
* - The callbacks no longer use the container as context, instead they use the actual notification
* - The callbacks now receive the container as a parameter after the options parameter
* - beforeOpen and beforeClose now check the return value, if it's false - the notification does
* not continue. The open callback will also halt execution if it returns false.
* - Fixed bug where containers would get confused
* - Expanded the pause functionality to pause an entire container.
*
* Changes in 1.2.2
* - Notification can now be theme rolled for jQuery UI, special thanks to Jeff Chan!
*
* Changes in 1.2.1
* - Fixed instance where the interval would fire the close method multiple times.
* - Added CSS to hide from print media
* - Fixed issue with closer button when div { position: relative } is set
* - Fixed leaking issue with multiple containers. Special thanks to Matthew Hanlon!
*
* Changes in 1.2.0
* - Added message pooling to limit the number of messages appearing at a given time.
* - Closing a notification is now bound to the notification object and triggered by the close button.
*
* Changes in 1. |
also halt execution if it returns false.
* - Fixed bug where containers would get confused
* - Expanded the pause functionality to pause an entire container.
*
* Changes in 1.2.2
* - Notification can now be theme rolled for jQuery UI, special thanks to Jeff Chan!
*
* Changes in 1.2.1
* - Fixed instance where the interval would fire the close method multiple times.
* - Added CSS to hide from print media
* - Fixed issue with closer button when div { position: relative } is set
* - Fixed leaking issue with multiple containers. Special thanks to Matthew Hanlon!
*
* Changes in 1.2.0
* - Added message pooling to limit the number of messages appearing at a given time.
* - Closing a notification is now bound to the notification object and triggered by the close button.
*
* Changes in 1.1.2
* - Added iPhone styled example
* - Fixed possible IE7 bug when determining if the ie6 class shoudl be applied.
* - Added template for the close button, so that it's content could be customized.
*
* Changes in 1.1.1
* - Fixed CSS styling bug for ie6 caused by a mispelling
* - Changes height restriction on default notifications to min-height
* - Added skinned examples using a variety of images
* - Added the ability to customize the content of the [close all] box
* - Added jTweet, an example of using jGrowl + Twitter
*
* Changes in 1.1.0
* - Multiple container and instances.
* - Standard $.jGrowl() now wraps $.fn.jGrowl() by first establishing a generic jGrowl container.
* - Instance methods of a jGrowl container can be called by $.fn.jGrowl(methodName)
* - Added glue preferenced, which allows notifications to be inserted before or after nodes in the container
* - Added new log callback which is called before anything is done for the notification
* - Corner's attribute are now applied on an individual notification basis.
*
* Changes in 1.0.4
* - Various CSS fixes so that jGrowl renders correctly in IE6.
*
* Changes in |
variety of images
* - Added the ability to customize the content of the [close all] box
* - Added jTweet, an example of using jGrowl + Twitter
*
* Changes in 1.1.0
* - Multiple container and instances.
* - Standard $.jGrowl() now wraps $.fn.jGrowl() by first establishing a generic jGrowl container.
* - Instance methods of a jGrowl container can be called by $.fn.jGrowl(methodName)
* - Added glue preferenced, which allows notifications to be inserted before or after nodes in the container
* - Added new log callback which is called before anything is done for the notification
* - Corner's attribute are now applied on an individual notification basis.
*
* Changes in 1.0.4
* - Various CSS fixes so that jGrowl renders correctly in IE6.
*
* Changes in 1.0.3
* - Fixed bug with options persisting across notifications
* - Fixed theme application bug
* - Simplified some selectors and manipulations.
* - Added beforeOpen and beforeClose callbacks
* - Reorganized some lines of code to be more readable
* - Removed unnecessary this.defaults context
* - If corners plugin is present, it's now customizable.
* - Customizable open animation.
* - Customizable close animation.
* - Customizable animation easing.
* - Added customizable positioning (top-left, top-right, bottom-left, bottom-right, center)
*
* Changes in 1.0.2
* - All CSS styling is now external.
* - Added a theme parameter which specifies a secondary class for styling, such
* that notifications can be customized in appearance on a per message basis.
* - Notification life span is now customizable on a per message basis.
* - Added the ability to disable the global closer, enabled by default.
* - Added callbacks for when a notification is opened or closed.
* - Added callback for the global closer.
* - Customizable animation speed.
* - jGrowl now set itself up and tears itself down.
*
* Changes in 1.0.1:
* - Removed dependency on metadata plugin in favor of.data()
* - Namespaced all |
- Customizable animation easing.
* - Added customizable positioning (top-left, top-right, bottom-left, bottom-right, center)
*
* Changes in 1.0.2
* - All CSS styling is now external.
* - Added a theme parameter which specifies a secondary class for styling, such
* that notifications can be customized in appearance on a per message basis.
* - Notification life span is now customizable on a per message basis.
* - Added the ability to disable the global closer, enabled by default.
* - Added callbacks for when a notification is opened or closed.
* - Added callback for the global closer.
* - Customizable animation speed.
* - jGrowl now set itself up and tears itself down.
*
* Changes in 1.0.1:
* - Removed dependency on metadata plugin in favor of.data()
* - Namespaced all events
*/ |
/*! \file gpio.h
*
* The <code>gpio.lib</code> library provides functions for using the CC2511's pins
* as general purpose inputs or outputs (GPIO). Every pin on the CC2511 that has a
* name starting with <i>P</i> can be configured as a <i>digital input</i> or <i>digital output</i>.
*
* The functions in this library allow for simpler programmatic approaches to working
* with digital I/O since you no longer have to deal with a multitude of pin-specific
* registers.
*
* \section ports Ports
*
* The pins on the CC2511 are divided into three ports: Port 0 (P0), Port 1 (P1),
* and Port 2 (P2). Every pin's name is prefixed by the name of the port it is on.
* For example, P0_3 starts with "P0" so it is a pin on Port 0.
*
* On the Wixel, none of the pins on Port 0 and Port 1 are tied to any on-board
* hardware so they completely free to be used as GPIO.
*
* When the Wixel starts up, all the pins on Port 0 and Port 1 will be inputs with
* internal pull-up resistors enabled <i>except</i> P1_0 and P1_1, which do not have
* internal pull-up or pull-down resistors
*
* This library supports Port 2, but all of the Wixel's Port 2 pins are handled by the
* functions declared in board.h so you should not need to manipulate them with this
* library.
*
* \section pinparam The pinNumber parameter
*
* Most of the functions in this library take a pin number as their first
* argument. These numbers are computed by multiplying the first digit in the
* pin name by ten and adding it to the second digit, as shown in the table below.
*
* <table>
* <caption>CC2511 Pins</caption>
* <tr><th>Pin</th><th>pinNumber parameter</th></tr>
* |
up resistors enabled <i>except</i> P1_0 and P1_1, which do not have
* internal pull-up or pull-down resistors
*
* This library supports Port 2, but all of the Wixel's Port 2 pins are handled by the
* functions declared in board.h so you should not need to manipulate them with this
* library.
*
* \section pinparam The pinNumber parameter
*
* Most of the functions in this library take a pin number as their first
* argument. These numbers are computed by multiplying the first digit in the
* pin name by ten and adding it to the second digit, as shown in the table below.
*
* <table>
* <caption>CC2511 Pins</caption>
* <tr><th>Pin</th><th>pinNumber parameter</th></tr>
* <tr><td>P0_0</td><td>0</td></tr>
* <tr><td>P0_1</td><td>1</td></tr>
* <tr><td>P0_2</td><td>2</td></tr>
* <tr><td>P0_3</td><td>3</td></tr>
* <tr><td>P0_4</td><td>4</td></tr>
* <tr><td>P0_5</td><td>5</td></tr>
* <tr><td>P1_0</td><td>10</td></tr>
* <tr><td>P1_1</td><td>11</td></tr>
* <tr><td>P1_2</td><td>12</td></tr>
* <tr><td>P1_3</td><td>13</td></tr>
* <tr><td>P1_4</td><td>14</td></tr>
* <tr><td>P1_5</td><td>15</td></tr>
* <tr><td>P1_6</td><td>16</td></tr>
* <tr><td>P1 |
td>4</td></tr>
* <tr><td>P0_5</td><td>5</td></tr>
* <tr><td>P1_0</td><td>10</td></tr>
* <tr><td>P1_1</td><td>11</td></tr>
* <tr><td>P1_2</td><td>12</td></tr>
* <tr><td>P1_3</td><td>13</td></tr>
* <tr><td>P1_4</td><td>14</td></tr>
* <tr><td>P1_5</td><td>15</td></tr>
* <tr><td>P1_6</td><td>16</td></tr>
* <tr><td>P1_7</td><td>17</td></tr>
* <tr><td>P2_0</td><td>20</td></tr>
* <tr><td>P2_1</td><td>21</td></tr>
* <tr><td>P2_2</td><td>22</td></tr>
* <tr><td>P2_3</td><td>23</td></tr>
* <tr><td>P2_4</td><td>24\footnote</td></tr>
* </table>
*
* \section interrupts Interrupts
*
* All the functions in this library are declared as reentrant, which means it is
* safe to call them in your main loop and also in your interrupt service routines
* (ISRs).
* However, if you are using these functions in an ISR, you should make sure that you
* have no code in your main loop that does a non-atomic read-modify-write operation
* on any of the I/O registers that are changed in the interrupt.
* The risk is that the interrupt could fire after while the read-modify-write
* operation is in progress, after the register has been read but before it has been
* written. Then when the register is written by the main loop, the |
3</td></tr>
* <tr><td>P2_4</td><td>24\footnote</td></tr>
* </table>
*
* \section interrupts Interrupts
*
* All the functions in this library are declared as reentrant, which means it is
* safe to call them in your main loop and also in your interrupt service routines
* (ISRs).
* However, if you are using these functions in an ISR, you should make sure that you
* have no code in your main loop that does a non-atomic read-modify-write operation
* on any of the I/O registers that are changed in the interrupt.
* The risk is that the interrupt could fire after while the read-modify-write
* operation is in progress, after the register has been read but before it has been
* written. Then when the register is written by the main loop, the change made by
* the ISR will be unintentionally lost.
*
* For example, it would be bad if you called <code>setDigitalOutput(10, 1)</code>
* in an interrupt and in your main loop you had some code like:
\code
P1DIR = (P1DIR & MASK) | VALUE;
\endcode
*
* It is OK to have code like <code>P1DIR |= VALUE;</code> in your main loop because
* that compiles to a single instruction, so it should be atomic.
*
* \section overhead Overhead
*
* Calling the functions in this library will be slower than manipulating the I/O
* registers yourself, but the overhead should be roughly the same for each pin.
*
* This library (git revision 4de9ee1f) was tested with
* SDCC 3.0.0 (#6037) and it was found that an I/O line could be toggled once
* every 3.2 microseconds by calling setDigitalOutput() several times in a row.
*
* \section caveats Caveats
*
* To use your digital I/O pins correctly, there are several things you should be aware of:
* - <b>Maximum voltage ratings:</b> Be sure to not expose your input pins to vol |
|= VALUE;</code> in your main loop because
* that compiles to a single instruction, so it should be atomic.
*
* \section overhead Overhead
*
* Calling the functions in this library will be slower than manipulating the I/O
* registers yourself, but the overhead should be roughly the same for each pin.
*
* This library (git revision 4de9ee1f) was tested with
* SDCC 3.0.0 (#6037) and it was found that an I/O line could be toggled once
* every 3.2 microseconds by calling setDigitalOutput() several times in a row.
*
* \section caveats Caveats
*
* To use your digital I/O pins correctly, there are several things you should be aware of:
* - <b>Maximum voltage ratings:</b> Be sure to not expose your input pins to voltages
* outside their allowed range. The voltage should not go below 0 V (GND) and should
* not exceed VDD (typically 3.3 V). This means that you can not connect an input
* on the CC2511 directly to an output from a 5V system if the output ever drives
* high (5 V). You can use a voltage divider circuit, level-shifter, or diode to
* overcome this limitation.
* - <b>Drawing too much current from an output pin:</b> Be sure you do not attempt
* to draw too much current from your output pin; it may break.
* The amount of current that can be supplied by the CC2511's I/O pins is not
* well-documented by the manufacturer. According to
* <a href="http://e2e.ti.com/support/low_power_rf/f/155/p/31555/319919.aspx">this forum post by a TI Employee</a>,
* regular I/O pins are designed to be able to source 4 mA while P1_0 and P1_1 are designed for 20 mA.
* You can use a transistor to overcome |
diode to
* overcome this limitation.
* - <b>Drawing too much current from an output pin:</b> Be sure you do not attempt
* to draw too much current from your output pin; it may break.
* The amount of current that can be supplied by the CC2511's I/O pins is not
* well-documented by the manufacturer. According to
* <a href="http://e2e.ti.com/support/low_power_rf/f/155/p/31555/319919.aspx">this forum post by a TI Employee</a>,
* regular I/O pins are designed to be able to source 4 mA while P1_0 and P1_1 are designed for 20 mA.
* You can use a transistor to overcome this limitation.
* - <b>Shorts</b>: Be sure that you do not connect a high output pin directly to a
* low output pin or to another high output pin that is driving to a different voltage.
* - <b>Peripheral functions</b>: Many of the pins on the CC2511 can be configured to
* be used by a peripheral by setting the right bit in the P0SEL, P1SEL, or P2SEL
* register. When a pin is being used by a peripheral, the functions in this
* library may not work. For example, if you have enabled USART1 in Alternate
* Location 1, then you can not control the output value of P1_6 using these
* functions because P1_6 serves as the serial transmit (TX) line.
*/ |
2SEL
* register. When a pin is being used by a peripheral, the functions in this
* library may not work. For example, if you have enabled USART1 in Alternate
* Location 1, then you can not control the output value of P1_6 using these
* functions because P1_6 serves as the serial transmit (TX) line.
*/ |
/*! \file servo.h
* The <code>servo.lib</code> library provides the ability to control up to 6
* RC servos by generating digital pulses directly from your Wixel without the
* need for a separate servo controller.
*
* This library uses Timer 1, so it will conflict with any other
* library that uses Timer 1.
*
* With the exception of servosStop(), the functions in this library are
* non-blocking. Pulses are generated in the background by Timer 1 and its
* interrupt service routine (ISR).
*
* This library uses hardware PWM from Timer 1 to generate the servo pulses,
* so it can only generate servo pulses on the following pins:
*
* - P0_2
* - P0_3
* - P0_4
* - P1_0
* - P1_1
* - P1_2
*
* The period of the servo signals generated by this library is approximately
* 19.11 ms (0x70000 clock cycles).
* The allowed pulse widths range from one 24th of a microsecond to 2500
* microseconds, and the resolution available is one 24th of a microsecond.
*
* For example code that uses this library, please see the <code>example_servo_sequence</code>
* app in the Wixel SDK's <code>apps</code> directory.
*
* \section wiring Wiring servos
*
* To control servos from your Wixel, you will need to wire them properly.
*
* Most standard radio control servos have three wires, each a different color.
* Usually, they are either black, red, and white, or they are brown, red, and orange/yellow:
* - brown or black = ground (GND, battery negative terminal)
* - red = servo power (Vservo, battery positive terminal)
* - orange, yellow, white, or blue = servo control signal line
*
* The ground and power wires of the servo will need to be connected to a power
* supply that provides a voltage the servo can tolerate and which provides
* enough current for |
the <code>example_servo_sequence</code>
* app in the Wixel SDK's <code>apps</code> directory.
*
* \section wiring Wiring servos
*
* To control servos from your Wixel, you will need to wire them properly.
*
* Most standard radio control servos have three wires, each a different color.
* Usually, they are either black, red, and white, or they are brown, red, and orange/yellow:
* - brown or black = ground (GND, battery negative terminal)
* - red = servo power (Vservo, battery positive terminal)
* - orange, yellow, white, or blue = servo control signal line
*
* The ground and power wires of the servo will need to be connected to a power
* supply that provides a voltage the servo can tolerate and which provides
* enough current for the servo.
*
* The ground wire of the servo also needs to be connected to one of the Wixel's
* GND pins.
* If you are powering the Wixel from the same power supply as the servos,
* then you have already made this connection.
*
* The signal wire of the servo needs to connect to an I/O pin of the
* Wixel that will be outputting servo pulses.
* These pins are specified by the parameters to servosStart().
*
* \section more More information about servos
*
* For more information about servos and how to control them, we
* recommend reading this series of blog posts by Pololu president Jan Malasek:
*
* -# <a href="http://www.pololu.com/blog/11/introduction-to-an-introduction-to-servos">Introduction to an introduction to servos</a>
* -# <a href="http://www.pololu.com/blog/12/introduction-to-servos">Introduction to servos</a>
* -# <a href="http://www.pololu.com/blog/13/gettin-all-up-in-your-servos">Gettin' all up in your servos</a>
* -# <a href=" |
specified by the parameters to servosStart().
*
* \section more More information about servos
*
* For more information about servos and how to control them, we
* recommend reading this series of blog posts by Pololu president Jan Malasek:
*
* -# <a href="http://www.pololu.com/blog/11/introduction-to-an-introduction-to-servos">Introduction to an introduction to servos</a>
* -# <a href="http://www.pololu.com/blog/12/introduction-to-servos">Introduction to servos</a>
* -# <a href="http://www.pololu.com/blog/13/gettin-all-up-in-your-servos">Gettin' all up in your servos</a>
* -# <a href="http://www.pololu.com/blog/15/servo-servo-motor-servomotor-definitely-not-server">Servo, servo motor, servomotor (definitely not server)</a>
* -# <a href="http://www.pololu.com/blog/16/electrical-characteristics-of-servos-and-introduction-to-the-servo-control-interface">
* Electrical characteristics of servos and introduction to the servo control interface</a>
* -# <a href="http://www.pololu.com/blog/17/servo-control-interface-in-detail">Servo control interface in detail</a>
* -# <a href="http://www.pololu.com/blog/18/simple-hardware-approach-to-controlling-a-servo">Simple hardware approach to controlling a servo</a>
* -# <a href="http://www.pololu.com/blog/19/simple-microcontroller-approach-to-controlling-a-servo">Simple microcontroller approach to controlling a servo</a>
* -# <a href="http://www.pololu.com/blog/20/advanced-hobby-servo-control-pulse-generation-using-hardware-pwm"> |
Electrical characteristics of servos and introduction to the servo control interface</a>
* -# <a href="http://www.pololu.com/blog/17/servo-control-interface-in-detail">Servo control interface in detail</a>
* -# <a href="http://www.pololu.com/blog/18/simple-hardware-approach-to-controlling-a-servo">Simple hardware approach to controlling a servo</a>
* -# <a href="http://www.pololu.com/blog/19/simple-microcontroller-approach-to-controlling-a-servo">Simple microcontroller approach to controlling a servo</a>
* -# <a href="http://www.pololu.com/blog/20/advanced-hobby-servo-control-pulse-generation-using-hardware-pwm">Advanced hobby servo control pulse generation using hardware PWM</a>
* -# <a href="http://www.pololu.com/blog/21/advanced-hobby-servo-control-using-only-a-timer-and-interrupts">Advanced hobby servo control using only a timer and interrupts</a>
* -# <a href="http://www.pololu.com/blog/22/rc-servo-speed-control">RC servo speed control</a>
* -# <a href="http://www.pololu.com/blog/24/continuous-rotation-servos-and-multi-turn-servos">Continuous-rotation servos and multi-turn servos</a>
*/ |
-control">RC servo speed control</a>
* -# <a href="http://www.pololu.com/blog/24/continuous-rotation-servos-and-multi-turn-servos">Continuous-rotation servos and multi-turn servos</a>
*/ |
/** \mainpage Wixel SDK Documentation
The Pololu Wixel Software Development Kit (SDK) contains code and Makefiles
that will help you create your own applications for the
<a href="http://www.pololu.com/catalog/product/1336">Pololu Wixel</a>.
The Wixel is a general-purpose programmable module featuring a 2.4 GHz radio
and USB.
The Wixel is based on the
<a href="http://www.ti.com/product/CC2511">CC2511F32</a>
microcontroller from Texas Instruments, which has an integrated radio transceiver,
32 KB of flash memory, 4 KB of RAM, and a full-speed USB interface.
\section starting Getting Started
To load apps onto the Wixel, you will need to have
the Wixel's drivers and software installed on your system.
See the <i>Getting Started</i> section of the
<a href="http://www.pololu.com/docs/0J46">Pololu Wixel User's Guide</a>.
To develop your own apps or modify existing ones using the Wixel SDK,
you will need to have a copy of the Wixel SDK,
<a href="http://sdcc.sourceforge.net/">SDCC</a> version 3.0.0 or later,
and you will need to have certain GNU utililties available on your path:
cat, cp, echo, grep, make, mv, rm, and sed.
For Windows users, we recommend that you install all of these components
by downloading the <b>Wixel Development Bundle</b>, available from the
<a href="http://www.pololu.com/docs/0J46">Pololu Wixel User's Guide</a>.
Please see the <i>Writing Your Own Wixel App</i>
section of the
<a href="http://www.pololu.com/docs/0J46">Pololu Wixel User's Guide</a>
for step-by-step instructions for getting started with the Wixel SDK.
\section sdk Downloading the |
cc.sourceforge.net/">SDCC</a> version 3.0.0 or later,
and you will need to have certain GNU utililties available on your path:
cat, cp, echo, grep, make, mv, rm, and sed.
For Windows users, we recommend that you install all of these components
by downloading the <b>Wixel Development Bundle</b>, available from the
<a href="http://www.pololu.com/docs/0J46">Pololu Wixel User's Guide</a>.
Please see the <i>Writing Your Own Wixel App</i>
section of the
<a href="http://www.pololu.com/docs/0J46">Pololu Wixel User's Guide</a>
for step-by-step instructions for getting started with the Wixel SDK.
\section sdk Downloading the Wixel SDK itself
The Wixel SDK is available as a
<a href="http://github.com/pololu/wixel-sdk">git repository hosted on github</a>.
You can get the latest version by installing <a href="http://git-scm.com/">git</a>
and running:
<pre>
git clone -o pololu git://github.com/pololu/wixel-sdk.git
</pre>
If you need help, see github's instructions on how to
<a href="http://help.github.com/set-up-git-redirect">Set Up Git</a>.
For Windows users, we also recommend installing
<a href="http://code.google.com/p/tortoisegit/">TortoiseGit</a>
because it provides a good graphical user interface for git.
You can also download the
<a href="https://github.com/pololu/wixel-sdk/zipball/latest">latest version of the Wixel SDK</a>
from github.
\section building_app Building and Loading Apps
Open a command-line terminal, navigate to the top level directory
of the SDK, and type "make". This will build all of the apps in
the apps folder and all of the libraries that they depend on.
|
</pre>
If you need help, see github's instructions on how to
<a href="http://help.github.com/set-up-git-redirect">Set Up Git</a>.
For Windows users, we also recommend installing
<a href="http://code.google.com/p/tortoisegit/">TortoiseGit</a>
because it provides a good graphical user interface for git.
You can also download the
<a href="https://github.com/pololu/wixel-sdk/zipball/latest">latest version of the Wixel SDK</a>
from github.
\section building_app Building and Loading Apps
Open a command-line terminal, navigate to the top level directory
of the SDK, and type "make". This will build all of the apps in
the apps folder and all of the libraries that they depend on.
To load an app onto all the Wixels connected to the computer,
type "make load_APPNAME" where APPNAME is the name of your app's
folder in the apps directory.
To open your app in the Wixel Configuration Utility,
type "make open_APPNAME".
Running any of the commands above will rebuild your app if it
is out of date.
\section creating_app Creating Your Own App
To create your own app, simply copy one of the existing folders in the
<code>apps</code> directory and change its name.
You do not need to modify the Makefile;
the Makefile will automatically detect the new app as long as it is in
the <code>apps</code> folder.
If your app doesn't use the default set of libraries defined in
<code>libraries/libs.mk</code>, you can specify which libraries
your app uses by creating a file called
<code>options.mk</code> in your
app directory and defining a GNU Make variable in it called <code>APP_LIBS</code>
that contains a list of the file names of the libraries your app uses, separated
by spaces. See <code>apps/test_board/options.mk</code> for an example.
\endcode
\section sdk_docs Documentation of Wixel SDK Libraries
The <a href |
app, simply copy one of the existing folders in the
<code>apps</code> directory and change its name.
You do not need to modify the Makefile;
the Makefile will automatically detect the new app as long as it is in
the <code>apps</code> folder.
If your app doesn't use the default set of libraries defined in
<code>libraries/libs.mk</code>, you can specify which libraries
your app uses by creating a file called
<code>options.mk</code> in your
app directory and defining a GNU Make variable in it called <code>APP_LIBS</code>
that contains a list of the file names of the libraries your app uses, separated
by spaces. See <code>apps/test_board/options.mk</code> for an example.
\endcode
\section sdk_docs Documentation of Wixel SDK Libraries
The <a href="./group__libraries.html">Libraries</a> page contains an overview
of all the libraries available in this SDK.
The <a href="./files.html">File List</a> page links to the documentation
for all the library functions, grouped by header file.
This documentation is auto-generated from the.h
files in the SDK.
The <a href="./globals.html">Globals</a> page contains an index of all
the global functions variables, typedefs, and defines in this SDK.
To generate this documentation yourself, type "make docs"
(requires <a href="http://www.doxygen.org/">Doxygen</a>).
\section other_docs Other Documentation
Documentation for the Wixel itself is available in the
<a href="http://www.pololu.com/docs/0J46">Pololu Wixel User's Guide</a> provided by Pololu.
The user's guide contains schematic diagrams, pinout diagrams, documentation for the
apps, example wiring, and more.
Documentation for the CC2511F32 (the microcontroller on the Wixel) is available in the
<a href="http://www.ti.com/product/CC2511">CC2511F32 datasheet</a>
provided by Texas Instruments |
variables, typedefs, and defines in this SDK.
To generate this documentation yourself, type "make docs"
(requires <a href="http://www.doxygen.org/">Doxygen</a>).
\section other_docs Other Documentation
Documentation for the Wixel itself is available in the
<a href="http://www.pololu.com/docs/0J46">Pololu Wixel User's Guide</a> provided by Pololu.
The user's guide contains schematic diagrams, pinout diagrams, documentation for the
apps, example wiring, and more.
Documentation for the CC2511F32 (the microcontroller on the Wixel) is available in the
<a href="http://www.ti.com/product/CC2511">CC2511F32 datasheet</a>
provided by Texas Instruments.
The datasheet provides detailed technical information about the hardware peripherals and
how to control them, as well as electrical specifications, and more.
Texas Instruments also provides many app notes and design notes on the
<a href="http://www.ti.com/product/CC2511">CC2511 page</a>.
Documentation for SDCC is available on the <a href="http://sdcc.sourceforge.net/">SDCC website</a>.
\section make_exception Make Interrupt/Exception Error
You might get the following error message from make in Windows:
<pre>
make: Interrupt/Exception caught (code = 0xc00000fd, addr = 0x425073)
</pre>
If you get this error, please run "make -v" at a Command Prompt and make
sure that you are running <a href="https://github.com/pololu/make">GNU Make 3.82-pololu1</a> or later.
This version of make is included in the latest <b>Wixel Development Bundle</b>,
available from the <a href="http://www.pololu.com/docs/0J46">Pololu Wixel User's Guide</a>.
If the output from "make -v" shows |
SDCC website</a>.
\section make_exception Make Interrupt/Exception Error
You might get the following error message from make in Windows:
<pre>
make: Interrupt/Exception caught (code = 0xc00000fd, addr = 0x425073)
</pre>
If you get this error, please run "make -v" at a Command Prompt and make
sure that you are running <a href="https://github.com/pololu/make">GNU Make 3.82-pololu1</a> or later.
This version of make is included in the latest <b>Wixel Development Bundle</b>,
available from the <a href="http://www.pololu.com/docs/0J46">Pololu Wixel User's Guide</a>.
If the output from "make -v" shows some other version of make even after
installing the Wixel Development Bundle, then you should remove that other version
of make from your PATH or reorder your PATH so that version 3.82-pololu1 (or later)
is used.
You can edit your PATH environment variable from the Control Panel.
See the <a href="https://github.com/pololu/make/wiki">pololu/make wiki on github</a>
for more information on this problem.
\section help Getting Help
If you have a problem or question, feel free to ask us on the
<a href="http://forum.pololu.com/viewforum.php?f=30">Pololu Forum</a>.
**/ |
more information on this problem.
\section help Getting Help
If you have a problem or question, feel free to ask us on the
<a href="http://forum.pololu.com/viewforum.php?f=30">Pololu Forum</a>.
**/ |
#define PAUSE 0
#define C0 16.35
#define Db0 17.32
#define D0 18.35
#define Eb0 19.45
#define E0 20.60
#define F0 21.83
#define Gb0 23.12
#define G0 24.50
#define Ab0 25.96
#define LA0 27.50
#define Bb0 29.14
#define B0 30.87
#define C1 32.70
#define Db1 34.65
#define D1 36.71
#define Eb1 38.89
#define E1 41.20
#define F1 43.65
#define Gb1 46.25
#define G1 49.00
#define Ab1 51.91
#define LA1 55.00
#define Bb1 58.27
#define B1 61.74
#define C2 65.41
#define Db2 69.30
#define D2 73.42
#define Eb2 77.78
#define E2 82.41
#define F2 87.31
#define Gb2 92.50
#define G2 98.00
#define Ab2 103.83
#define LA2 110.00
#define Bb2 116.54
#define B2 123.47
#define C3 130.81
#define Db3 138.59
#define D3 146.83
#define Eb3 155.56
#define E3 164.81
#define F3 174.61
#define Gb3 185. |
#define D2 73.42
#define Eb2 77.78
#define E2 82.41
#define F2 87.31
#define Gb2 92.50
#define G2 98.00
#define Ab2 103.83
#define LA2 110.00
#define Bb2 116.54
#define B2 123.47
#define C3 130.81
#define Db3 138.59
#define D3 146.83
#define Eb3 155.56
#define E3 164.81
#define F3 174.61
#define Gb3 185.00
#define G3 196.00
#define Ab3 207.65
#define LA3 220.00
#define Bb3 233.08
#define B3 246.94
#define C4 261.63
#define Db4 277.18
#define D4 293.66
#define Eb4 311.13
#define E4 329.63
#define F4 349.23
#define Gb4 369.99
#define G4 392.00
#define Ab4 415.30
#define LA4 440.00
#define Bb4 466.16
#define B4 493.88
#define C5 523.25
#define Db5 554.37
#define D5 587.33
#define Eb5 622.25
#define E5 659.26
#define F5 698.46
#define Gb5 739.99
#define G |
#define Eb4 311.13
#define E4 329.63
#define F4 349.23
#define Gb4 369.99
#define G4 392.00
#define Ab4 415.30
#define LA4 440.00
#define Bb4 466.16
#define B4 493.88
#define C5 523.25
#define Db5 554.37
#define D5 587.33
#define Eb5 622.25
#define E5 659.26
#define F5 698.46
#define Gb5 739.99
#define G5 783.99
#define Ab5 830.61
#define LA5 880.00
#define Bb5 932.33
#define B5 987.77
#define C6 1046.50
#define Db6 1108.73
#define D6 1174.66
#define Eb6 1244.51
#define E6 1318.51
#define F6 1396.91
#define Gb6 1479.98
#define G6 1567.98
#define Ab6 1661.22
#define LA6 1760.00
#define Bb6 1864.66
#define B6 1975.53
#define C7 2093.00
#define Db7 2217.46
#define D7 2349.32
#define Eb7 2489.02
#define E7 2637.02
#define F7 2793.83
#define Gb |
b6 1244.51
#define E6 1318.51
#define F6 1396.91
#define Gb6 1479.98
#define G6 1567.98
#define Ab6 1661.22
#define LA6 1760.00
#define Bb6 1864.66
#define B6 1975.53
#define C7 2093.00
#define Db7 2217.46
#define D7 2349.32
#define Eb7 2489.02
#define E7 2637.02
#define F7 2793.83
#define Gb7 2959.96
#define G7 3135.96
#define Ab7 3322.44
#define LA7 3520.01
#define Bb7 3729.31
#define B7 3951.07
#define C8 4186.01
#define Db8 4434.92
#define D8 4698.64
|
2
#define D8 4698.64
|
/**
\page basicconcepts Overview and basic concepts
The data sets
involved in some modern applications are too large to fit in the main
memory of even the most powerful computers and must therefore reside
on disk. Thus communication between internal and external memory, and
not actual computation time, often becomes the bottleneck in the
computation. This is due to the huge difference in access time of fast
internal memory and slower external memory such as disks. While
typical access time of main memory is measured in nanoseconds, a
typical access time of a disk is on the order of
milliseconds. So roughly speaking there is a
factor of a million difference in the access time of internal and
external memory.
The goal of theoretical work in the area of <em>external memory (EM)
algorithms</em> (also called <em>I/O algorithms</em> or <em>out-of-core
algorithms</em>) is to eliminate or minimize the I/O bottleneck through
better algorithm design. In order to cope with the high cost of
accessing data, efficient EM algorithms exploit locality in their
design. They access a large \em block of \em B contiguous data
elements at a time and perform the necessary algorithmic steps on the
elements in the block while in the high-speed memory. The speedup can
be considerable. See the surveys by Vitter [<a href="#vitteriosurvey" id="backlink1">1</a>] and Arge
[<a href="#argehandbook" id="backlink2">2</a>] for other results, including I/O-efficient algorithms for
various geometric and graph problems.
The objectives of the TPIE project include the following:
- <em>Abstract away the details of how I/O is performed</em> so that
programmers need only deal with a simple high level interface.
- <em>Provide a collection of I/O-optimal paradigms</em> for large
scale computation that are efficient not only in theory, but also in
practice.
- <em>Be flexible</em>, allowing programmers to specify the
functional details of computation taking place within the supported
paradigms. This will allow a wide variety of algorithms to be
implemented within the |
Vitter [<a href="#vitteriosurvey" id="backlink1">1</a>] and Arge
[<a href="#argehandbook" id="backlink2">2</a>] for other results, including I/O-efficient algorithms for
various geometric and graph problems.
The objectives of the TPIE project include the following:
- <em>Abstract away the details of how I/O is performed</em> so that
programmers need only deal with a simple high level interface.
- <em>Provide a collection of I/O-optimal paradigms</em> for large
scale computation that are efficient not only in theory, but also in
practice.
- <em>Be flexible</em>, allowing programmers to specify the
functional details of computation taking place within the supported
paradigms. This will allow a wide variety of algorithms to be
implemented within the system.
- <em>Be portable</em> across a variety hardware platforms.
- <em>Be extensible</em>, so that new features can be easily added
later.
\section basicconcepts Basic concepts
TPIE is written in the C++ language, and this manual assumes that
the reader is familiar with C++.
Familiarity with the theoretical results on I/O-efficient algorithms
is not necessary in order to use TPIE. However, this manual may be easier to
follow with some general
background information such as how a theoretically optimal external
merge sort algorithm works. Some of the basic concepts
required for understanding the discussion of I/O issues and external
memory algorithms in this manual are outlined below.
Roughly speaking there is a factor of a million difference in the
access time of internal and external memory. In order to cope with
the high cost of accessing externally-stored data, efficient EM
algorithms exploit locality in their design. They access a large
\em block of \em B contiguous data elements at a time and perform
the necessary algorithmic steps on the elements in the block while it
is in the high-speed memory. The speedup can be considerable.
The performance of an EM algorithm on a given set of data is affected
directly by how much internal memory is available for its use. We use |
PIE. However, this manual may be easier to
follow with some general
background information such as how a theoretically optimal external
merge sort algorithm works. Some of the basic concepts
required for understanding the discussion of I/O issues and external
memory algorithms in this manual are outlined below.
Roughly speaking there is a factor of a million difference in the
access time of internal and external memory. In order to cope with
the high cost of accessing externally-stored data, efficient EM
algorithms exploit locality in their design. They access a large
\em block of \em B contiguous data elements at a time and perform
the necessary algorithmic steps on the elements in the block while it
is in the high-speed memory. The speedup can be considerable.
The performance of an EM algorithm on a given set of data is affected
directly by how much internal memory is available for its use. We use
\em M to denote the number of application data elements that fit into
the internal memory available to the algorithm, and \em m = \em M / \em B denotes
the number of blocks that fit into the available internal memory. Such
a block is more precisely called a <em>logical block</em> because it
may be a different size (usually larger) than either the physical
block size or the system block size. We will reserve the term
<em>physical block</em> size to mean the block size used by a disk
controller to communicate with a physical disk, and the <em>system
block</em> size will be the size of block used within the operating
system for I/O operations on disk devices. In EM algorithms we will
assume that the logical block size is a multiple of the system block
size.
TPIE is implemented as a set of templated classes and functions in
C++, and employs an object-oriented abstraction to EM computation.
TPIE provides C++ templates of various optimal EM computation
\em patterns or \em paradigms. Examples of such paradigms are
the EM algorithms for merge sorting, distribution sweeping, time
forward processing, etc. In a TPIE
program, the application programmer provides application-specific
details of the specific computation paradigm used, such as C++
object definitions |
<em>physical block</em> size to mean the block size used by a disk
controller to communicate with a physical disk, and the <em>system
block</em> size will be the size of block used within the operating
system for I/O operations on disk devices. In EM algorithms we will
assume that the logical block size is a multiple of the system block
size.
TPIE is implemented as a set of templated classes and functions in
C++, and employs an object-oriented abstraction to EM computation.
TPIE provides C++ templates of various optimal EM computation
\em patterns or \em paradigms. Examples of such paradigms are
the EM algorithms for merge sorting, distribution sweeping, time
forward processing, etc. In a TPIE
program, the application programmer provides application-specific
details of the specific computation paradigm used, such as C++
object definitions of the application data records, and code for
application-specific sub-computations at critical points in the
computation pattern, but TPIE provides the application-independent
parts of the pattern.
The definition of an application data element (or record) is provided
by the user as a class definition. Such a class definition is
typically used as a template parameter in a TPIE code fragment (e.g. a
templated function).
\section stream Streams
In TPIE, a \em stream is an ordered collection of
objects of a particular type, stored in external memory, and accessed
in sequential order. Streams can be thought of as fundamental TPIE
objects which map volatile, typed application data elements in
internal memory to persistent, untyped data elements in external
memory, and vice-versa. See \ref tpie::file_stream.
Streams are read and written like files in
Unix and support a number of primitive file-like operations such as
\c read(), \c write(), \c truncate(), etc.
TPIE also supports the concept of a \em substream, see \ref tpie::file, which
permits a contiguous subset of the elements in a stream to
accessed sequentially.
Various paradigms of external memory computation are supported.
TPIE reduces the
programming effort required to perform an |
\section stream Streams
In TPIE, a \em stream is an ordered collection of
objects of a particular type, stored in external memory, and accessed
in sequential order. Streams can be thought of as fundamental TPIE
objects which map volatile, typed application data elements in
internal memory to persistent, untyped data elements in external
memory, and vice-versa. See \ref tpie::file_stream.
Streams are read and written like files in
Unix and support a number of primitive file-like operations such as
\c read(), \c write(), \c truncate(), etc.
TPIE also supports the concept of a \em substream, see \ref tpie::file, which
permits a contiguous subset of the elements in a stream to
accessed sequentially.
Various paradigms of external memory computation are supported.
TPIE reduces the
programming effort required to perform an external sort, merge, etc.,
by providing the high level flow of control within each paradigm, and
therefore structuring this part of the computation so that it will be
I/O efficient. The programmer is left with the task of providing what
amount to event handlers, specifying the application-specific
details of the computation. For instance in sorting, the programmer
defines a stream of input data, a comparison operator (the event handler
for the task of comparing two application data elements), and an
output stream for the results. See also \ref tpie::sort.
Creating a stream of objects in TPIE is very much like creating any
other object in C++. The only difference is that the data placed in
the stream is stored in external memory (on disk).
\section introreferences References
<a href="#backlink1">^</a> <span id="vitteriosurvey">1: J. S. Vitter: External Memory Algorithms and Data Structures: Dealing with MASSIVE Data, ACM Computing Surveys (2001)</span>
<a href="#backlink2">^</a> <span id="argehandbook">2: L. Arge: External Memory Data Structures, from Handbook of Massive Data Sets (2002)</span>
<!--
@article{vitter:iosurvey,
|
application data elements), and an
output stream for the results. See also \ref tpie::sort.
Creating a stream of objects in TPIE is very much like creating any
other object in C++. The only difference is that the data placed in
the stream is stored in external memory (on disk).
\section introreferences References
<a href="#backlink1">^</a> <span id="vitteriosurvey">1: J. S. Vitter: External Memory Algorithms and Data Structures: Dealing with MASSIVE Data, ACM Computing Surveys (2001)</span>
<a href="#backlink2">^</a> <span id="argehandbook">2: L. Arge: External Memory Data Structures, from Handbook of Massive Data Sets (2002)</span>
<!--
@article{vitter:iosurvey,
author = {J. S. Vitter},
title = {External Memory Algorithms and Data Structures:
Dealing with {MASSIVE} Data},
journal = survey,
volume = 33,
number = 2,
year = {2001},
pages = {209--271}
}
@incollection{arge:handbook,
author = {L. Arge},
title = {External Memory Data Structures},
booktitle = {Handbook of Massive Data Sets},
editor = {J. Abello and P. M. Pardalos and M. G. C. Resende},
publisher = {Kluwer Academic Publishers},
pages = {313-358},
year = 2002
}
-->
*/ |
title = {External Memory Data Structures},
booktitle = {Handbook of Massive Data Sets},
editor = {J. Abello and P. M. Pardalos and M. G. C. Resende},
publisher = {Kluwer Academic Publishers},
pages = {313-358},
year = 2002
}
-->
*/ |
/**
\page pipelining Pipelining
\section sec_pipeintro Pipelining concepts
Some algorithms can be expressed in terms of stream sweeps. For instance, the
Graham sweep algorithm for computing the convex hull of a set of points will
sweep through the input points from left to right, maintaining the upper convex
hull and the lower convex hull in a stack of points. Thus, the algorithm
consists of four components: reading the input, sorting by x-coordinate,
computing the upper and lower hull, and reporting the convex polygon.
The pipelining framework is used to implement such so-called streaming
algorithms that process streams of items in this manner. The programmer implements
the specialized components needed for the algorithm (computing the upper and
lower hull, for instance), and stitches them together with built-ins such as
reading, sorting and writing.
In this way, we may test each component individually and reuse them in multiple
contexts. Without the TPIE pipelining framework, streaming algorithms are often
implemented as monolithic classes with multiple interdependent methods that do
not facilitate individual development and testing. Using virtual polymorphism
may enable unit testing of components, but the virtual method speed penalty
paid per item per operation is too high a price to pay in our case.
What we want instead is a kind of compile-time polymorphism: Implementations of
operations that use C++ generic programming to let the programmer mix and match
at code time, but have the methods inlined and fused together at compile time.
Without an underlying framework, this kind of architecture will lead to a lot
of typedefs that are overly verbose and somewhat unmaintainable.
The pipelining framework provides compile-time polymorphism along with high
maintainability, high testability and low verbosity.
\section sec_node Nodes
In TPIE pipelining, a <em>node</em> is any object that implements
\c tpie::pipelining::node.
A node processes items of a stream in some fashion,
typically by implementing a \c push() method which processes an item
and pushes to a <em>destination</em> node.
The node can implement a \c begin() and/or an \ |
orphism: Implementations of
operations that use C++ generic programming to let the programmer mix and match
at code time, but have the methods inlined and fused together at compile time.
Without an underlying framework, this kind of architecture will lead to a lot
of typedefs that are overly verbose and somewhat unmaintainable.
The pipelining framework provides compile-time polymorphism along with high
maintainability, high testability and low verbosity.
\section sec_node Nodes
In TPIE pipelining, a <em>node</em> is any object that implements
\c tpie::pipelining::node.
A node processes items of a stream in some fashion,
typically by implementing a \c push() method which processes an item
and pushes to a <em>destination</em> node.
The node can implement a \c begin() and/or an \c end() method
to perform some initialization or finalization.
The framework guarantees that \c begin() and \c end() are called in an order
such that the destination of the node is ready to accept items via \c push()
when \c begin() and \c end() are called.
<img src="pipelining_sequence.png" />
Since the framework computes the topological order of the nodes
of the actor graph (that is, using the actor edges as in the above two figures)
and the framework requires that the actor graph is acyclic,
the nodes may call \c push(), \c pull() and \c can_pull() in both \c begin()
and \c end() even when push and pull nodes are mixed together.
In code, a pipelining node implementation may look like the following.
\code
namespace tp = tpie::pipelining;
template <typename dest_t>
class hello_world_type : public tp::node {
public:
hello_world_type(dest_t dest): dest(std::move(dest)) {}
void push(const size_t & item) {
if ((item % 2) == 0)
dest.push(item/2);
else
dest.push(3*item+1);
|
, using the actor edges as in the above two figures)
and the framework requires that the actor graph is acyclic,
the nodes may call \c push(), \c pull() and \c can_pull() in both \c begin()
and \c end() even when push and pull nodes are mixed together.
In code, a pipelining node implementation may look like the following.
\code
namespace tp = tpie::pipelining;
template <typename dest_t>
class hello_world_type : public tp::node {
public:
hello_world_type(dest_t dest): dest(std::move(dest)) {}
void push(const size_t & item) {
if ((item % 2) == 0)
dest.push(item/2);
else
dest.push(3*item+1);
}
private:
dest_t dest;
};
typedef tp::pipe_middle<tp::factory<hello_world_type> > hello_world;
\endcode
A node implementation may supply the following extra information to the framework
which is otherwise inferred in the ordinary case.
<table>
<tr>
<th colspan="6" align="center">\ref tpie::pipelining::node_parameters</th>
</tr>
<tr>
<td colspan="3" align="center">Memory</td>
<td colspan="2" align="center">Name</td>
<td colspan="1" align="center">Progress</td>
</tr>
<tr>
<td align="left">Minimum
\c memory_size_type</td>
<td align="left">Maximum
\c memory_size_type</td>
<td align="left">Priority
\c double</td>
<td align="left">Name
\c std::string</td>
<td align="left">Priority
\c int</td>
<td align="left">Total steps
\c stream_size_type</td>
</tr>
</table>
If the node needs to allocate a buffer in \c begin() which is deallocated in \c end(),
it can |
</tr>
<tr>
<td colspan="3" align="center">Memory</td>
<td colspan="2" align="center">Name</td>
<td colspan="1" align="center">Progress</td>
</tr>
<tr>
<td align="left">Minimum
\c memory_size_type</td>
<td align="left">Maximum
\c memory_size_type</td>
<td align="left">Priority
\c double</td>
<td align="left">Name
\c std::string</td>
<td align="left">Priority
\c int</td>
<td align="left">Total steps
\c stream_size_type</td>
</tr>
</table>
If the node needs to allocate a buffer in \c begin() which is deallocated in \c end(),
it can specify the size of this buffer in bytes using a call to \c set_minimum_memory()
in the constructor, in \c prepare() or in \c propagate().
If the node can benefit from a larger buffer, it should set a positive memory priority
for itself using a call to \c set_memory_fraction().
If there is a limit to the amount of memory it can use,
it should declare this limit using \c set_maximum_memory().
By default, the minimum memory is zero bytes, and the memory priority is zero,
meaning the node is assigned its minimum memory.
The default maximum memory is infinity.
If the node has multiple pull sources and/or push destinations,
these must be specified using \c add_push_destination and \c add_pull_source
in the constructor.
In \c propagate(), \c begin() and \c end(), the node may access the amount of memory
assigned to it using \c get_available_memory().
For debugging, each node object has a \em name, which defaults to a pretty
version of the name provided by \c typeid(*this).name().
The name can be set by a call to \c set_name() in the constructor.
If the node has multiple overloads of the \c push() method,
it must declare a primary \c item_type as a |
By default, the minimum memory is zero bytes, and the memory priority is zero,
meaning the node is assigned its minimum memory.
The default maximum memory is infinity.
If the node has multiple pull sources and/or push destinations,
these must be specified using \c add_push_destination and \c add_pull_source
in the constructor.
In \c propagate(), \c begin() and \c end(), the node may access the amount of memory
assigned to it using \c get_available_memory().
For debugging, each node object has a \em name, which defaults to a pretty
version of the name provided by \c typeid(*this).name().
The name can be set by a call to \c set_name() in the constructor.
If the node has multiple overloads of the \c push() method,
it must declare a primary \c item_type as a public member typedef.
Otherwise, the framework uses metaprogramming to discover the type accepted
by \c push().
Here, we restate the above implementation with all the defaults spelled out:
\code
namespace tp = tpie::pipelining;
template <typename dest_t>
class hello_world_type : public tp::node {
public:
typedef size_t item_type;
hello_world_type(dest_t dest)
: dest(std::move(dest))
{
// The default name is the class name, capitalized,
// with underscores replaced by spaces,
// removing a trailing "_type" or "_t".
set_name("Hello world");
// If we have just one push destination or pull source,
// this is inferred by the framework if we do not specify any.
add_push_destination(dest);
}
virtual void prepare() override {
set_minimum_memory((tpie::memory_size_type) 0);
//set_maximum_memory((tpie::memory_size_type) infinity);
set_memory_fraction((double) 0.0);
}
virtual void propagate() override {
// optionally access get_available_memory
}
|
_type(dest_t dest)
: dest(std::move(dest))
{
// The default name is the class name, capitalized,
// with underscores replaced by spaces,
// removing a trailing "_type" or "_t".
set_name("Hello world");
// If we have just one push destination or pull source,
// this is inferred by the framework if we do not specify any.
add_push_destination(dest);
}
virtual void prepare() override {
set_minimum_memory((tpie::memory_size_type) 0);
//set_maximum_memory((tpie::memory_size_type) infinity);
set_memory_fraction((double) 0.0);
}
virtual void propagate() override {
// optionally access get_available_memory
}
virtual void begin() override {
// allocate buffer of size get_available_memory
}
void push(const size_t & item) {
if ((item % 2) == 0) {
dest.push(item/2);
} else {
dest.push(3*item+1);
}
}
virtual void end() override {
// deallocate buffer
}
private:
dest_t dest;
};
typedef tp::pipe_middle<tp::factory<hello_world_type> > hello_world;
\endcode
\section sec_pull Pull nodes
In some applications it might be easier to express the operation
in terms of pulling items from a source and returning a processed item.
This is the style used by STL iterators, and it is the style preferred
by STXXL, another framework which implements pipelining.
In this case, a TPIE pipelining node should implement the two methods
\c pull() and \c can_pull().
Again, the framework ensures that it is permitted to call
\c pull() and \c can_pull() in \c begin() and \c end().
<img src="pipelining_sequence_pull.png" />
The implementation details of pull nodes are similar to |